semaphore related work. ServerWindow has a few methods guarded by a semaphore. Same for WinBorder.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8061 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
8491b62602
commit
c233705d66
@ -251,6 +251,8 @@ DisplayDriver* Desktop::GetDisplayDriver() const
|
||||
|
||||
void Desktop::AddWinBorder(WinBorder* winBorder)
|
||||
{
|
||||
desktop->fGeneralLock.Lock();
|
||||
|
||||
if(fWinBorderList.HasItem(winBorder))
|
||||
return;
|
||||
|
||||
@ -269,14 +271,14 @@ void Desktop::AddWinBorder(WinBorder* winBorder)
|
||||
fLayerLock.Lock();
|
||||
fWinBorderList.AddItem(winBorder);
|
||||
fLayerLock.Unlock();
|
||||
|
||||
// TODO: remove those 2? I vote for: YES! still... have to think...
|
||||
// SetFrontWinBorder(fActiveRootLayer->ActiveWorkspace()->FrontLayer());
|
||||
// SetFocusWinBorder(fActiveRootLayer->ActiveWorkspace()->FocusLayer());
|
||||
|
||||
desktop->fGeneralLock.Unlock();
|
||||
}
|
||||
|
||||
void Desktop::RemoveWinBorder(WinBorder* winBorder)
|
||||
{
|
||||
desktop->fGeneralLock.Lock();
|
||||
|
||||
if(winBorder->fLevel == B_SYSTEM_LAST)
|
||||
{
|
||||
for(int32 i=0; i<fRootLayerList.CountItems(); i++)
|
||||
@ -285,15 +287,11 @@ void Desktop::RemoveWinBorder(WinBorder* winBorder)
|
||||
else
|
||||
winBorder->GetRootLayer()->RemoveWinBorder(winBorder);
|
||||
|
||||
// TODO: remove those 4? I vote for: YES! still... have to think...
|
||||
// if (winBorder == fFrontWinBorder)
|
||||
// SetFrontWinBorder(fActiveRootLayer->ActiveWorkspace()->FrontLayer());
|
||||
// if (winBorder == fFocusWinBorder)
|
||||
// SetFocusWinBorder(fActiveRootLayer->ActiveWorkspace()->FocusLayer());
|
||||
|
||||
fLayerLock.Lock();
|
||||
fWinBorderList.RemoveItem(winBorder);
|
||||
fLayerLock.Unlock();
|
||||
|
||||
desktop->fGeneralLock.Unlock();
|
||||
}
|
||||
|
||||
bool Desktop::HasWinBorder(WinBorder* winBorder)
|
||||
@ -364,6 +362,7 @@ WinBorder* Desktop::FocusWinBorder(void) const
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::MouseEventHandler(PortMessage *msg)
|
||||
{
|
||||
// TODO: locking mechanism needs SERIOUS rethought!!!!
|
||||
switch(msg->Code())
|
||||
{
|
||||
case B_MOUSE_DOWN:
|
||||
@ -398,13 +397,15 @@ void Desktop::MouseEventHandler(PortMessage *msg)
|
||||
{
|
||||
fGeneralLock.Lock();
|
||||
rl->fMainLock.Lock();
|
||||
target->Window()->Lock();
|
||||
|
||||
ws->SearchAndSetNewFront(target);
|
||||
ws->SetFocusLayer(target);
|
||||
|
||||
fMouseTarget = target;
|
||||
target->MouseDown(msg);
|
||||
|
||||
|
||||
target->Window()->Unlock();
|
||||
rl->fMainLock.Unlock();
|
||||
fGeneralLock.Unlock();
|
||||
}
|
||||
@ -420,7 +421,10 @@ void Desktop::MouseEventHandler(PortMessage *msg)
|
||||
|
||||
if (fMouseTarget)
|
||||
{
|
||||
fMouseTarget->Window()->Lock();
|
||||
fMouseTarget->MouseUp(msg);
|
||||
fMouseTarget->Window()->Unlock();
|
||||
|
||||
fMouseTarget = NULL;
|
||||
}
|
||||
else
|
||||
@ -438,8 +442,11 @@ void Desktop::MouseEventHandler(PortMessage *msg)
|
||||
msg->Rewind();
|
||||
|
||||
WinBorder *target = ActiveRootLayer()->ActiveWorkspace()->SearchWinBorder(pt);
|
||||
if(target)
|
||||
if(target){
|
||||
target->Window()->Lock();
|
||||
target->MouseUp(msg);
|
||||
target->Window()->Unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// printf("MOUSE UP: at (%f, %f)\n", pt.x, pt.y);
|
||||
@ -469,14 +476,21 @@ void Desktop::MouseEventHandler(PortMessage *msg)
|
||||
{
|
||||
fActiveScreen->DDriver()->HideCursor();
|
||||
fActiveScreen->DDriver()->MoveCursorTo(x,y);
|
||||
|
||||
fMouseTarget->Window()->Lock();
|
||||
fMouseTarget->MouseMoved(msg);
|
||||
fMouseTarget->Window()->Unlock();
|
||||
|
||||
fActiveScreen->DDriver()->ShowCursor();
|
||||
}
|
||||
else
|
||||
{
|
||||
WinBorder *target = ActiveRootLayer()->ActiveWorkspace()->SearchWinBorder(BPoint(x,y));
|
||||
if(target)
|
||||
if(target){
|
||||
target->Window()->Lock();
|
||||
target->MouseMoved(msg);
|
||||
target->Window()->Unlock();
|
||||
}
|
||||
|
||||
fActiveScreen->DDriver()->MoveCursorTo(x,y);
|
||||
}
|
||||
|
@ -124,9 +124,10 @@ ServerApp::~ServerApp(void)
|
||||
STRACE(("*ServerApp %s:~ServerApp()\n",fSignature.String()));
|
||||
int32 i;
|
||||
|
||||
WindowBroadcast(AS_QUIT_APP);
|
||||
// WindowBroadcast(AS_QUIT_APP);
|
||||
|
||||
// wait for our ServerWindow threads
|
||||
// TODO: wait for our ServerWindow threads.
|
||||
/*
|
||||
bool ready=true;
|
||||
desktop->fLayerLock.Lock();
|
||||
do{
|
||||
@ -154,7 +155,7 @@ ServerApp::~ServerApp(void)
|
||||
}
|
||||
} while(!ready);
|
||||
desktop->fLayerLock.Unlock();
|
||||
|
||||
*/
|
||||
/*
|
||||
ServerWindow *tempwin;
|
||||
for(i=0;i<fSWindowList->CountItems();i++)
|
||||
@ -267,6 +268,7 @@ void ServerApp::PostMessage(int32 code, size_t size, int8 *buffer)
|
||||
\brief Send a simple message to all of the ServerApp's ServerWindows
|
||||
\param msg The message code to broadcast
|
||||
*/
|
||||
/*
|
||||
void ServerApp::WindowBroadcast(int32 code)
|
||||
{
|
||||
desktop->fLayerLock.Lock();
|
||||
@ -275,11 +277,13 @@ void ServerApp::WindowBroadcast(int32 code)
|
||||
{
|
||||
ServerWindow *sw = ((WinBorder*)desktop->fWinBorderList.ItemAt(i))->Window();
|
||||
BMessage msg(code);
|
||||
sw->Lock();
|
||||
sw->SendMessageToClient(&msg);
|
||||
sw->Unlock();
|
||||
}
|
||||
desktop->fLayerLock.Unlock();
|
||||
}
|
||||
|
||||
*/
|
||||
/*!
|
||||
\brief Send a message to the ServerApp's BApplication
|
||||
\param msg The message to send
|
||||
@ -365,7 +369,13 @@ int32 ServerApp::MonitorApp(void *data)
|
||||
{
|
||||
BMessage pleaseQuit(B_QUIT_REQUESTED);
|
||||
app->SendMessageToClient(&pleaseQuit);
|
||||
app->WindowBroadcast(AS_QUIT_APP);
|
||||
// TODO: I do not understand why we nee this? delete.
|
||||
// When BApplications receives B_QUIT_REQUESTED, it asks its BWindow(s) if it can
|
||||
// safely quit. If all respond with 'true' then, each one that 'agrees' will send
|
||||
// a AS_DELETE_WINDOW message to the server couterpart thread (ServerWindow). Curently,
|
||||
// it always quits on this message.
|
||||
// DW, I left this text here for you to see it. After you read, please remove it. Thanks.
|
||||
// app->WindowBroadcast(AS_QUIT_APP);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
bool PingTarget(void);
|
||||
|
||||
void PostMessage(int32 code, size_t size=0,int8 *buffer=NULL);
|
||||
void WindowBroadcast(int32 code);
|
||||
/* void WindowBroadcast(int32 code); */
|
||||
|
||||
void SendMessageToClient( const BMessage* msg ) const;
|
||||
void SetAppCursor(void);
|
||||
|
@ -194,13 +194,11 @@ void ServerWindow::Init(void)
|
||||
resume_thread(fMonitorThreadID);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
//!Tears down all connections with the user application, kills the monitoring thread.
|
||||
//!Tears down all connections the main app_server objects, and deletes some internals.
|
||||
ServerWindow::~ServerWindow(void)
|
||||
{
|
||||
STRACE(("*ServerWindow (%s):~ServerWindow()\n",fTitle.String()));
|
||||
|
||||
desktop->fGeneralLock.Lock();
|
||||
|
||||
desktop->RemoveWinBorder(fWinBorder);
|
||||
STRACE(("SW(%s) Successfully removed from the desktop\n", fTitle.String()));
|
||||
|
||||
@ -220,8 +218,7 @@ ServerWindow::~ServerWindow(void)
|
||||
|
||||
if (fTopLayer)
|
||||
delete fTopLayer;
|
||||
|
||||
desktop->fGeneralLock.Unlock();
|
||||
|
||||
STRACE(("#ServerWindow(%s) will exit NOW!!!\n", fTitle.String()));
|
||||
}
|
||||
//5700 - fara servo , fara cas
|
||||
@ -2229,27 +2226,16 @@ int32 ServerWindow::MonitorWin(void *data)
|
||||
|
||||
switch(code)
|
||||
{
|
||||
case AS_DELETE_WINDOW:
|
||||
case AS_CLIENT_DEAD:
|
||||
{
|
||||
// this means the client has been killed
|
||||
STRACE(("ServerWindow %s received 'AS_CLIENT_DEAD' message code\n",win->Title()));
|
||||
STRACE(("ServerWindow %s received 'AS_CLIENT_DEAD/AS_DELETE_WINDOW' message code\n",win->Title()));
|
||||
quitting = true;
|
||||
// TODO: this is not that simple. Desktop Class should delete a window.
|
||||
// something like: Desktop::DeleteWindow(thisWindow).
|
||||
// ServerWindow's destructor takes care of pulling this object off the desktop.
|
||||
delete win;
|
||||
break;
|
||||
}
|
||||
// TODO: This message is never received.... why?
|
||||
/* case AS_QUIT_APP:
|
||||
{
|
||||
// We receive this _only_ when the server is shutting down. The app_server
|
||||
// is not asking the app to quit - it's *telling* it to quit because
|
||||
// in just a short time, the server itself is going to disappear.
|
||||
|
||||
BMessage msg(_QUIT_);
|
||||
win->SendMessageToClient(&msg);
|
||||
}
|
||||
*/
|
||||
case B_QUIT_REQUESTED:
|
||||
{
|
||||
STRACE(("ServerWindow %s received Quit request\n",win->Title()));
|
||||
|
@ -134,6 +134,9 @@ void WinBorder::RebuildFullRegion(void)
|
||||
|
||||
void WinBorder::MouseDown(PortMessage *msg)
|
||||
{
|
||||
if (!(Window()->IsLocked()))
|
||||
debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseDown()\n");
|
||||
|
||||
// this is important to determine how much we should resize or move the Layer(WinBorder)(window)
|
||||
|
||||
// user clicked on WinBorder's visible region, which is in fact decorator's.
|
||||
@ -245,6 +248,9 @@ void WinBorder::MouseDown(PortMessage *msg)
|
||||
|
||||
void WinBorder::MouseMoved(PortMessage *msg)
|
||||
{
|
||||
if (!(Window()->IsLocked()))
|
||||
debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseMoved()\n");
|
||||
|
||||
BPoint pt;
|
||||
int64 dummy;
|
||||
int32 buttons;
|
||||
@ -298,6 +304,9 @@ void WinBorder::MouseMoved(PortMessage *msg)
|
||||
|
||||
void WinBorder::MouseUp(PortMessage *msg)
|
||||
{
|
||||
if (!(Window()->IsLocked()))
|
||||
debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseUp()\n");
|
||||
|
||||
if (fIsMoving)
|
||||
{
|
||||
fIsMoving = false;
|
||||
@ -377,7 +386,7 @@ void WinBorder::MoveBy(float x, float y)
|
||||
STRACE(("WinBorder(%s)::MoveBy()\n", GetName()));
|
||||
if(fDecorator)
|
||||
fDecorator->MoveBy(x,y);
|
||||
// TODO: Repair! :-))
|
||||
|
||||
Layer::MoveBy(x,y);
|
||||
}
|
||||
|
||||
@ -386,7 +395,7 @@ void WinBorder::ResizeBy(float x, float y)
|
||||
STRACE(("WinBorder(%s)::ResizeBy()\n", GetName()));
|
||||
if(fDecorator)
|
||||
fDecorator->ResizeBy(x,y);
|
||||
// TODO: Repair! :-))
|
||||
|
||||
Layer::ResizeBy(x,y);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user