Window now talks nice-nice to app_server

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2903 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2003-03-12 18:02:37 +00:00
parent 71c040584c
commit ea4ea97733
+90 -95
View File
@@ -53,17 +53,21 @@ BWindow::BWindow(BRect frame,
{ {
Lock(); Lock();
fFrame = frame; fFrame = frame;
SetTitle(title);
decompose_type(type,&fLook,&fFeel); decompose_type(type,&fLook,&fFeel);
SetFlags(flags);
SetWorkspaces(workspace);
// MESSAGING STUFF - Adapted from DarkWyrms proto6 code if(title)
// Names changed to match <Window.h> {
fTitle=new char[strlen(title)];
strcpy(fTitle,title);
}
else
fTitle=NULL;
fFlags=flags;
// Create a port on which to listen to messages // Create a port on which to listen to messages
receive_port=create_port(50,"msgport"); receive_port=create_port(50,"msgport");
if(receive_port==B_BAD_VALUE || receive_port==B_NO_MORE_PORTS) if(receive_port==B_BAD_VALUE || receive_port==B_NO_MORE_PORTS)
printf("BWindow: Couldn't create message port\n"); printf("BWindow: Couldn't create message port\n");
// Notify app that we exist // Notify app that we exist
BWindow *win=this; BWindow *win=this;
@@ -72,52 +76,46 @@ BWindow::BWindow(BRect frame,
serverlink->Attach(&win,sizeof(BWindow*)); serverlink->Attach(&win,sizeof(BWindow*));
serverlink->Flush(); serverlink->Flush();
fUnused1 = true; // Haven't been Show()n yet. Show() must UnLock(). fShowLevel=0; // Hidden to start with.
// Knew I'd find a use for fUnused1 :)
fShowLevel = 0; // Hidden to start with.
// We create our serverlink utilizing our application's server port // We create our serverlink utilizing our application's server port
// because the server's ServerApp will handle window creation // because the server's ServerApp will handle window creation
serverlink->SetPort(be_app->fServerTo); serverlink->SetPort(be_app->fServerTo);
// make sure that the server port is valid. It will == B_NAME_NOT_FOUND if the // make sure that the server port is valid. It will == B_NAME_NOT_FOUND if the
// OBApplication couldn't find the server // OBApplication couldn't find the server
if(be_app->fServerTo!=B_NAME_NOT_FOUND) if(be_app->fServerTo!=B_NAME_NOT_FOUND)
{ {
// Notify server of window's existence // Notify server of window's existence
serverlink->SetOpCode(AS_CREATE_WINDOW); serverlink->SetOpCode(AS_CREATE_WINDOW);
serverlink->Attach(fFrame); serverlink->Attach(fFrame);
serverlink->Attach((int32)fLook); serverlink->Attach((int32)fLook);
serverlink->Attach((int32)fFeel); serverlink->Attach((int32)fFeel);
serverlink->Attach((int32)flags); serverlink->Attach((int32)flags);
serverlink->Attach(&receive_port,sizeof(port_id)); serverlink->Attach(&receive_port,sizeof(port_id));
serverlink->Attach((int32)workspace); serverlink->Attach((int32)workspace);
serverlink->Attach(fTitle,sizeof(fTitle)); if(fTitle)
serverlink->Attach(fTitle,sizeof(fTitle));
else
serverlink->Attach(0L);
// Send and wait for ServerWindow port. Necessary here so we can respond to // Send and wait for ServerWindow port. Necessary here so we can respond to
// messages as soon as Show() is called. // messages as soon as Show() is called.
PortLink::ReplyData replydata;
serverlink->FlushWithReply(&replydata);
send_port=*((port_id*)replydata.buffer);
serverlink->SetPort(send_port);
int32 replycode; top_view=new BView(frame.OffsetToCopy(0,0),"top_view",B_FOLLOW_ALL, B_WILL_DRAW);
status_t replystat; top_view->owner=this;
ssize_t replysize; top_view->top_level_view=true;
int8 *replybuffer; fFocus = top_view; // top view gets the focus by default
replybuffer=serverlink->FlushWithReply(&replycode,&replystat,&replysize);
send_port=*((port_id*)replybuffer);
serverlink->SetPort(send_port);
delete replybuffer;
serverlink->Flush();
top_view=new BView(frame.OffsetToCopy(0,0),"top_view",B_FOLLOW_ALL, B_WILL_DRAW); }
top_view->owner=this; else
top_view->top_level_view=true; {
fFocus = top_view; // top view gets the focus by default // We've got some serious problems. uh-oh...
}
}
else
{
// Not sure what to do here
}
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
@@ -130,18 +128,21 @@ BWindow::BWindow(BRect frame,
{ {
Lock(); Lock();
fFrame = frame; fFrame = frame;
SetTitle(title); if(title)
SetLook(look); {
SetFeel(feel); fTitle=new char[strlen(title)];
SetFlags(flags); strcpy(fTitle,title);
SetWorkspaces(workspace); }
else
fTitle=NULL;
fFlags=flags;
fLook=look;
fFeel=feel;
// MESSAGING STUFF - Adapted from DarkWyrms proto6 code
// Names changed to match <Window.h>
// Create a port on which to listen to messages // Create a port on which to listen to messages
receive_port=create_port(50,"msgport"); receive_port=create_port(50,"msgport");
if(receive_port==B_BAD_VALUE || receive_port==B_NO_MORE_PORTS) if(receive_port==B_BAD_VALUE || receive_port==B_NO_MORE_PORTS)
printf("BWindow: Couldn't create message port\n"); printf("BWindow: Couldn't create message port\n");
// Notify app that we exist // Notify app that we exist
BWindow *win=this; BWindow *win=this;
@@ -150,52 +151,46 @@ BWindow::BWindow(BRect frame,
serverlink->Attach(&win,sizeof(BWindow*)); serverlink->Attach(&win,sizeof(BWindow*));
serverlink->Flush(); serverlink->Flush();
fUnused1 = true; // Haven't been Show()n yet. Show() must UnLock(). fShowLevel = 0; // Hidden to start with.
// Knew I'd find a use for fUnused1 :)
fShowLevel = 0; // Hidden to start with.
// We create our serverlink utilizing our application's server port // We create our serverlink utilizing our application's server port
// because the server's ServerApp will handle window creation // because the server's ServerApp will handle window creation
serverlink->SetPort(be_app->fServerTo); serverlink->SetPort(be_app->fServerTo);
// make sure that the server port is valid. It will == B_NAME_NOT_FOUND if the // make sure that the server port is valid. It will == B_NAME_NOT_FOUND if the
// OBApplication couldn't find the server // OBApplication couldn't find the server
if(be_app->fServerTo!=B_NAME_NOT_FOUND) if(be_app->fServerTo!=B_NAME_NOT_FOUND)
{ {
// Notify server of window's existence // Notify server of window's existence
serverlink->SetOpCode(AS_CREATE_WINDOW); serverlink->SetOpCode(AS_CREATE_WINDOW);
serverlink->Attach(fFrame); serverlink->Attach(fFrame);
serverlink->Attach((int32)fLook); serverlink->Attach((int32)fLook);
serverlink->Attach((int32)fFeel); serverlink->Attach((int32)fFeel);
serverlink->Attach((int32)flags); serverlink->Attach((int32)flags);
serverlink->Attach(&receive_port,sizeof(port_id)); serverlink->Attach(&receive_port,sizeof(port_id));
serverlink->Attach((int32)workspace); serverlink->Attach((int32)workspace);
serverlink->Attach(fTitle,sizeof(fTitle)); if(fTitle)
serverlink->Attach(fTitle,sizeof(fTitle));
else
serverlink->Attach(0L);
// Send and wait for ServerWindow port. Necessary here so we can respond to // Send and wait for ServerWindow port. Necessary here so we can respond to
// messages as soon as Show() is called. // messages as soon as Show() is called.
PortLink::ReplyData replydata;
serverlink->FlushWithReply(&replydata);
send_port=*((port_id*)replydata.buffer);
serverlink->SetPort(send_port);
int32 replycode; top_view=new BView(frame.OffsetToCopy(0,0),"top_view",B_FOLLOW_ALL, B_WILL_DRAW);
status_t replystat; top_view->owner=this;
ssize_t replysize; top_view->top_level_view=true;
int8 *replybuffer; fFocus = top_view; // top view gets the focus by default
replybuffer=serverlink->FlushWithReply(&replycode,&replystat,&replysize);
send_port=*((port_id*)replybuffer);
serverlink->SetPort(send_port);
delete replybuffer;
serverlink->Flush();
top_view=new BView(frame.OffsetToCopy(0,0),"top_view",B_FOLLOW_ALL, B_WILL_DRAW); }
top_view->owner=this; else
top_view->top_level_view=true; {
fFocus = top_view; // top view gets the focus by default // We've got some serious problems. uh-oh...
}
}
else
{
// Not sure what to do here
}
} }
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------