From 49de2e8b4f75b2188dc36cc3e78df86f91c1c0f3 Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Sun, 22 Aug 2004 22:33:57 +0000 Subject: [PATCH] server no longer turn into a zombie if closed with an app running ServerApp now supports workspace activation along with client notification git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8623 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/server/AppServer.cpp | 4 +- src/servers/app/server/RootLayer.cpp | 24 ++++++ src/servers/app/server/ServerApp.cpp | 107 ++++++--------------------- src/servers/app/server/ServerApp.h | 3 +- src/servers/app/server/Workspace.h | 1 + 5 files changed, 52 insertions(+), 87 deletions(-) diff --git a/src/servers/app/server/AppServer.cpp b/src/servers/app/server/AppServer.cpp index 136caf8fe4..bf4bca5035 100644 --- a/src/servers/app/server/AppServer.cpp +++ b/src/servers/app/server/AppServer.cpp @@ -49,7 +49,7 @@ #include "Desktop.h" //#define DEBUG_KEYHANDLING -//#define DEBUG_SERVER +#define DEBUG_SERVER #ifdef DEBUG_KEYHANDLING # include @@ -785,7 +785,7 @@ void AppServer::Broadcast(int32 code) app=(ServerApp*)fAppList->ItemAt(i); if(!app) { printf("PANIC in AppServer::Broadcast()\n"); continue; } - app->PostMessage(code, sizeof(int32), (int8*)&code); + app->PostMessage(code); } release_sem(fAppListLock); } diff --git a/src/servers/app/server/RootLayer.cpp b/src/servers/app/server/RootLayer.cpp index 6aa01a87f8..151bcc40ca 100644 --- a/src/servers/app/server/RootLayer.cpp +++ b/src/servers/app/server/RootLayer.cpp @@ -620,7 +620,31 @@ void RootLayer::SetActiveWorkspace(Workspace *ws) if (fActiveWorkspace == ws || !ws) return; + int32 index; + WinBorder *winborder; + + // Notify windows in current workspace of change + if(fActiveWorkspace) + { + index=fWorkspaceList.IndexOf(fActiveWorkspace); + winborder=fActiveWorkspace->GoToTopItem(); + while(winborder) + { + winborder->Window()->WorkspaceActivated(index,false); + winborder=(WinBorder*)winborder->fLowerSibling; + } + } + fActiveWorkspace = ws; + + // Notify windows in new workspace of change + index=fWorkspaceList.IndexOf(fActiveWorkspace); + winborder=fActiveWorkspace->GoToTopItem(); + while(winborder) + { + winborder->Window()->WorkspaceActivated(index,true); + winborder=(WinBorder*)winborder->fLowerSibling; + } } int32 RootLayer::ActiveWorkspaceIndex() const{ diff --git a/src/servers/app/server/ServerApp.cpp b/src/servers/app/server/ServerApp.cpp index 2523db7d63..c840676cc3 100644 --- a/src/servers/app/server/ServerApp.cpp +++ b/src/servers/app/server/ServerApp.cpp @@ -42,7 +42,9 @@ #include "Desktop.h" #include "DisplayDriver.h" #include "FontServer.h" +#include "RootLayer.h" #include "ServerApp.h" +#include "ServerScreen.h" #include "ServerWindow.h" #include "ServerCursor.h" #include "ServerBitmap.h" @@ -120,50 +122,6 @@ ServerApp::~ServerApp(void) STRACE(("*ServerApp %s:~ServerApp()\n",fSignature.String())); int32 i; -// WindowBroadcast(AS_QUIT_APP); - -// TODO: wait for our ServerWindow threads. -/* - bool ready=true; - desktop->fLayerLock.Lock(); - do{ - ready = true; - - int32 count = desktop->fWinBorderList.CountItems(); - for( int32 i = 0; i < count; i++) - { - ServerWindow *sw = ((WinBorder*)desktop->fWinBorderList.ItemAt(i))->Window(); - if (ClientTeamID() == sw->ClientTeamID()) - { - thread_id tid = sw->ThreadID(); - status_t temp; - - desktop->fLayerLock.Unlock(); - - printf("waiting for thread %s\n", sw->Title()); - wait_for_thread(tid, &temp); - - desktop->fLayerLock.Lock(); - - ready = false; - break; - } - } - } while(!ready); - desktop->fLayerLock.Unlock(); -*/ -/* - ServerWindow *tempwin; - for(i=0;iCountItems();i++) - { - tempwin=(ServerWindow*)fSWindowList->ItemAt(i); - if(tempwin) - delete tempwin; - } - fSWindowList->MakeEmpty(); - delete fSWindowList; -*/ - ServerBitmap *tempbmp; for(i=0;iCountItems();i++) { @@ -199,7 +157,6 @@ ServerApp::~ServerApp(void) thread_info info; if(get_thread_info(fMonitorThreadID,&info)==B_OK) kill_thread(fMonitorThreadID); - } /*! @@ -255,31 +212,13 @@ bool ServerApp::PingTarget(void) \brief Send a message to the ServerApp with no attachments \param code ID code of the message to post */ -void ServerApp::PostMessage(int32 code, size_t size, int8 *buffer) +void ServerApp::PostMessage(int32 code) { - write_port(fMessagePort,code, buffer, size); + BPortLink link(fMessagePort); + link.StartMessage(code); + link.Flush(); } -/*! - \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(); - int32 count=desktop->fWinBorderList.CountItems(); - for(int32 i=0; ifWinBorderList.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 @@ -366,11 +305,6 @@ int32 ServerApp::MonitorApp(void *data) break; } - // TODO: Fix - // Using this case is a hack. The ServerApp is receiving a message with a '0' code after - // it sends the quit message on server shutdown and I can't find what's sending it. This - // must be found and fixed! - case 0: case B_QUIT_REQUESTED: { STRACE(("ServerApp %s: B_QUIT_REQUESTED\n",app->fSignature.String())); @@ -519,9 +453,6 @@ void ServerApp::_DispatchMessage(int32 code, BPortLink& msg) msg.Read(&looperPort); msg.ReadString(&title); - //TODO: deprecate - just use sendPort -// msg.Read(&replyport); - STRACE(("ServerApp %s: Got 'New Window' message, trying to do smething...\n",fSignature.String())); // ServerWindow constructor will reply with port_id of a newly created port @@ -662,30 +593,40 @@ void ServerApp::_DispatchMessage(int32 code, BPortLink& msg) // 1) int32 workspace # // 2) uint32 screen mode // 3) bool make default - int32 workspace; + int32 index; uint32 mode; bool stick; - msg.Read(&workspace); + msg.Read(&index); msg.Read(&mode); msg.Read(&stick); - //TODO: Resolve - //SetSpace(workspace,mode,ActiveScreen(),stick); - + RootLayer *root=desktop->ActiveRootLayer(); + Workspace *workspace=root->WorkspaceAt(index); + + if(!workspace) + { + // apparently out of range or something, so we do nothing. :) + break; + } + + // TODO: Add mode-setting code to Workspace class + //workspace->SetMode(mode,stick); break; } case AS_ACTIVATE_WORKSPACE: { STRACE(("ServerApp %s: Activate Workspace\n",fSignature.String())); + // Attached data // 1) int32 workspace index // Error-checking is done in ActivateWorkspace, so this is a safe call int32 workspace; msg.Read(&workspace); - - //TODO: Resolve - //SetWorkspace(workspace); + + RootLayer *root=desktop->ActiveRootLayer(); + if(root) + root->SetActiveWorkspaceByIndex(workspace); break; } diff --git a/src/servers/app/server/ServerApp.h b/src/servers/app/server/ServerApp.h index 6751edbbff..3a8130c68a 100644 --- a/src/servers/app/server/ServerApp.h +++ b/src/servers/app/server/ServerApp.h @@ -66,8 +66,7 @@ public: void Activate(bool value); bool PingTarget(void); - void PostMessage(int32 code, size_t size=0,int8 *buffer=NULL); -/* void WindowBroadcast(int32 code); */ + void PostMessage(int32 code); void SendMessageToClient( const BMessage* msg ) const; void SetAppCursor(void); diff --git a/src/servers/app/server/Workspace.h b/src/servers/app/server/Workspace.h index 4f388bade3..648981500a 100644 --- a/src/servers/app/server/Workspace.h +++ b/src/servers/app/server/Workspace.h @@ -90,6 +90,7 @@ public: void SearchAndSetNewFocus(WinBorder *preferred); void BringToFrontANormalWindow(WinBorder *layer); + private: void InsertItem(ListData *item, ListData *before);