Modified to utilize member PortLink instead of creating new ones

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2891 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2003-03-12 01:21:54 +00:00
parent 6e4a70109a
commit 0d97724c61
+36 -42
View File
@@ -21,6 +21,7 @@
//
// File Name: Window.cpp
// Author: John Hedditch ([email protected])
// DarkWyrm <[email protected]>
// Description: BWindow is the base class for all windows (graphic areas
// displayed on-screen).
// Needs serverlink and msglink PortLink variables declared, but not sure whether
@@ -66,11 +67,10 @@ BWindow::BWindow(BRect frame,
// Notify app that we exist
BWindow *win=this;
PortLink *link=new PortLink(be_app->fServerFrom);
link->SetOpCode(AS_CREATE_WINDOW);
link->Attach(&win,sizeof(BWindow*));
link->Flush();
delete link;
serverlink=new PortLink(be_app->fServerFrom);
serverlink->SetOpCode(AS_CREATE_WINDOW);
serverlink->Attach(&win,sizeof(BWindow*));
serverlink->Flush();
fUnused1 = true; // Haven't been Show()n yet. Show() must UnLock().
// Knew I'd find a use for fUnused1 :)
@@ -79,21 +79,21 @@ BWindow::BWindow(BRect frame,
// We create our serverlink utilizing our application's server port
// because the server's ServerApp will handle window creation
link=new PortLink(be_app->fServerTo);
serverlink->SetPort(be_app->fServerTo);
// make sure that the server port is valid. It will == B_NAME_NOT_FOUND if the
// OBApplication couldn't find the server
if(be_app->fServerTo!=B_NAME_NOT_FOUND)
{
// Notify server of window's existence
link->SetOpCode(AS_CREATE_WINDOW);
link->Attach(fFrame);
link->Attach((int32)fLook);
link->Attach((int32)fFeel);
link->Attach((int32)flags);
link->Attach(&receive_port,sizeof(port_id));
link->Attach((int32)workspace);
link->Attach(fTitle,sizeof(fTitle));
serverlink->SetOpCode(AS_CREATE_WINDOW);
serverlink->Attach(fFrame);
serverlink->Attach((int32)fLook);
serverlink->Attach((int32)fFeel);
serverlink->Attach((int32)flags);
serverlink->Attach(&receive_port,sizeof(port_id));
serverlink->Attach((int32)workspace);
serverlink->Attach(fTitle,sizeof(fTitle));
// Send and wait for ServerWindow port. Necessary here so we can respond to
// messages as soon as Show() is called.
@@ -102,12 +102,11 @@ BWindow::BWindow(BRect frame,
status_t replystat;
ssize_t replysize;
int8 *replybuffer;
replybuffer=link->FlushWithReply(&replycode,&replystat,&replysize);
replybuffer=serverlink->FlushWithReply(&replycode,&replystat,&replysize);
send_port=*((port_id*)replybuffer);
link->SetPort(send_port);
serverlink->SetPort(send_port);
delete replybuffer;
link->Flush();
delete link;
serverlink->Flush();
top_view=new BView(frame.OffsetToCopy(0,0),"top_view",B_FOLLOW_ALL, B_WILL_DRAW);
top_view->owner=this;
@@ -146,11 +145,10 @@ BWindow::BWindow(BRect frame,
// Notify app that we exist
BWindow *win=this;
PortLink *link=new PortLink(be_app->fServerFrom);
link->SetOpCode(AS_CREATE_WINDOW);
link->Attach(&win,sizeof(BWindow*));
link->Flush();
delete link;
serverlink=new PortLink(be_app->fServerFrom);
serverlink->SetOpCode(AS_CREATE_WINDOW);
serverlink->Attach(&win,sizeof(BWindow*));
serverlink->Flush();
fUnused1 = true; // Haven't been Show()n yet. Show() must UnLock().
// Knew I'd find a use for fUnused1 :)
@@ -159,21 +157,21 @@ BWindow::BWindow(BRect frame,
// We create our serverlink utilizing our application's server port
// because the server's ServerApp will handle window creation
link=new PortLink(be_app->fServerTo);
serverlink->SetPort(be_app->fServerTo);
// make sure that the server port is valid. It will == B_NAME_NOT_FOUND if the
// OBApplication couldn't find the server
if(be_app->fServerTo!=B_NAME_NOT_FOUND)
{
// Notify server of window's existence
link->SetOpCode(AS_CREATE_WINDOW);
link->Attach(fFrame);
link->Attach((int32)fLook);
link->Attach((int32)fFeel);
link->Attach((int32)flags);
link->Attach(&receive_port,sizeof(port_id));
link->Attach((int32)workspace);
link->Attach(fTitle,sizeof(fTitle));
serverlink->SetOpCode(AS_CREATE_WINDOW);
serverlink->Attach(fFrame);
serverlink->Attach((int32)fLook);
serverlink->Attach((int32)fFeel);
serverlink->Attach((int32)flags);
serverlink->Attach(&receive_port,sizeof(port_id));
serverlink->Attach((int32)workspace);
serverlink->Attach(fTitle,sizeof(fTitle));
// Send and wait for ServerWindow port. Necessary here so we can respond to
// messages as soon as Show() is called.
@@ -182,12 +180,11 @@ BWindow::BWindow(BRect frame,
status_t replystat;
ssize_t replysize;
int8 *replybuffer;
replybuffer=link->FlushWithReply(&replycode,&replystat,&replysize);
replybuffer=serverlink->FlushWithReply(&replycode,&replystat,&replysize);
send_port=*((port_id*)replybuffer);
link->SetPort(send_port);
serverlink->SetPort(send_port);
delete replybuffer;
link->Flush();
delete link;
serverlink->Flush();
top_view=new BView(frame.OffsetToCopy(0,0),"top_view",B_FOLLOW_ALL, B_WILL_DRAW);
top_view->owner=this;
@@ -226,12 +223,13 @@ BWindow::Quit()
link->Flush();
delete link;
// Server will need to be notified of window destruction
PortLink *serverlink=new PortLink(be_app->fServerTo);
serverlink->SetOpCode(AS_DELETE_WINDOW);
// serverlink->Attach(&ID,sizeof(int32)); XXX What is ID???
/* MAYBE */ serverlink->Attach(&win,sizeof(BWindow *));
/* MAYBE */
serverlink->Attach(&win,sizeof(BWindow *));
serverlink->Flush();
delete serverlink;
// Quit our looper and delete our self :)
Quit();
@@ -592,10 +590,8 @@ BWindow::Show()
if(fShowLevel>0) // Transition between hidden and unhidden
{
// Notify App_server that it should show the window
PortLink *serverlink= new PortLink(be_app->fServerTo);
serverlink->SetOpCode(AS_SHOW_WINDOW);
serverlink->Flush();
delete serverlink;
}
}
//--------------------------------------------------------------------------------
@@ -607,10 +603,8 @@ BWindow::Hide()
if(fShowLevel==0) // Transition between unhidden and hidden
{
// Notify App_server that it should hide this window
PortLink *serverlink= new PortLink(be_app->fServerTo);
serverlink->SetOpCode(AS_HIDE_WINDOW);
serverlink->Flush();
delete serverlink;
}
}
//--------------------------------------------------------------------------------