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:
+95
-100
@@ -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));
|
||||||
// Send and wait for ServerWindow port. Necessary here so we can respond to
|
else
|
||||||
// messages as soon as Show() is called.
|
serverlink->Attach(0L);
|
||||||
|
|
||||||
int32 replycode;
|
// Send and wait for ServerWindow port. Necessary here so we can respond to
|
||||||
status_t replystat;
|
// messages as soon as Show() is called.
|
||||||
ssize_t replysize;
|
PortLink::ReplyData replydata;
|
||||||
int8 *replybuffer;
|
serverlink->FlushWithReply(&replydata);
|
||||||
replybuffer=serverlink->FlushWithReply(&replycode,&replystat,&replysize);
|
send_port=*((port_id*)replydata.buffer);
|
||||||
send_port=*((port_id*)replybuffer);
|
serverlink->SetPort(send_port);
|
||||||
serverlink->SetPort(send_port);
|
|
||||||
delete replybuffer;
|
top_view=new BView(frame.OffsetToCopy(0,0),"top_view",B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
serverlink->Flush();
|
top_view->owner=this;
|
||||||
|
top_view->top_level_view=true;
|
||||||
top_view=new BView(frame.OffsetToCopy(0,0),"top_view",B_FOLLOW_ALL, B_WILL_DRAW);
|
fFocus = top_view; // top view gets the focus by default
|
||||||
top_view->owner=this;
|
|
||||||
top_view->top_level_view=true;
|
}
|
||||||
fFocus = top_view; // top view gets the focus by default
|
else
|
||||||
|
{
|
||||||
}
|
// 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;
|
||||||
int32 replycode;
|
serverlink->FlushWithReply(&replydata);
|
||||||
status_t replystat;
|
send_port=*((port_id*)replydata.buffer);
|
||||||
ssize_t replysize;
|
serverlink->SetPort(send_port);
|
||||||
int8 *replybuffer;
|
|
||||||
replybuffer=serverlink->FlushWithReply(&replycode,&replystat,&replysize);
|
top_view=new BView(frame.OffsetToCopy(0,0),"top_view",B_FOLLOW_ALL, B_WILL_DRAW);
|
||||||
send_port=*((port_id*)replybuffer);
|
top_view->owner=this;
|
||||||
serverlink->SetPort(send_port);
|
top_view->top_level_view=true;
|
||||||
delete replybuffer;
|
fFocus = top_view; // top view gets the focus by default
|
||||||
serverlink->Flush();
|
|
||||||
|
}
|
||||||
top_view=new BView(frame.OffsetToCopy(0,0),"top_view",B_FOLLOW_ALL, B_WILL_DRAW);
|
else
|
||||||
top_view->owner=this;
|
{
|
||||||
top_view->top_level_view=true;
|
// We've got some serious problems. uh-oh...
|
||||||
fFocus = top_view; // top view gets the focus by default
|
}
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Not sure what to do here
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//--------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user