From 158c46331a33e30da89f8f427740aff92735ef00 Mon Sep 17 00:00:00 2001 From: Adi Oanca Date: Tue, 13 Jan 2004 00:56:36 +0000 Subject: [PATCH] new desktop management code git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6057 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/server/AppServer.cpp | 279 ++++++----- src/servers/app/server/AppServer.h | 69 +-- src/servers/app/server/Desktop.cpp | 465 ++++++++++--------- src/servers/app/server/Desktop.h | 156 +++---- src/servers/app/server/Layer.cpp | 163 +++---- src/servers/app/server/Layer.h | 190 ++++---- src/servers/app/server/RootLayer.cpp | 128 +++++- src/servers/app/server/RootLayer.h | 104 +++-- src/servers/app/server/ServerApp.cpp | 208 +++++---- src/servers/app/server/ServerApp.h | 87 ++-- src/servers/app/server/ServerWindow.cpp | 586 ++++++++++++------------ src/servers/app/server/ServerWindow.h | 170 +++---- src/servers/app/server/WinBorder.cpp | 43 +- src/servers/app/server/WinBorder.h | 29 +- 14 files changed, 1387 insertions(+), 1290 deletions(-) diff --git a/src/servers/app/server/AppServer.cpp b/src/servers/app/server/AppServer.cpp index a3287fa663..3a512969c7 100644 --- a/src/servers/app/server/AppServer.cpp +++ b/src/servers/app/server/AppServer.cpp @@ -38,7 +38,6 @@ #include #include "AppServer.h" #include "ColorSet.h" -#include "Desktop.h" #include "DisplayDriver.h" #include "ServerApp.h" #include "ServerCursor.h" @@ -50,6 +49,7 @@ #include "CursorManager.h" #include "Utils.h" #include "FontServer.h" +#include "Desktop.h" //#define DEBUG_KEYHANDLING #ifdef DEBUG_KEYHANDLING @@ -60,6 +60,8 @@ #endif // Globals +Desktop* desktop; + //! Used to access the app_server from new_decorator AppServer *app_server=NULL; @@ -81,14 +83,14 @@ AppServer::AppServer(void) : BApplication (SERVER_SIGNATURE) AppServer::AppServer(void) #endif { - _mouseport=create_port(200,SERVER_INPUT_PORT); - _messageport=create_port(200,SERVER_PORT_NAME); + _mouseport = create_port(200,SERVER_INPUT_PORT); + _messageport = create_port(200,SERVER_PORT_NAME); - _applist=new BList(0); - _quitting_server=false; - _exit_poller=false; - _ssindex=1; - make_decorator=NULL; + _applist = new BList(0); + _quitting_server= false; + _exit_poller = false; + _ssindex = 1; + make_decorator = NULL; // Create the font server and scan the proper directories. fontserver=new FontServer; @@ -123,40 +125,36 @@ AppServer::AppServer(void) InitDecorators(); // Set up the Desktop - desktop=new Desktop(); + desktop = new Desktop(); + desktop->Init(); // Create the cursor manager. Object declared in CursorManager.cpp - cursormanager=new CursorManager(); + cursormanager = new CursorManager(); cursormanager->SetCursor(B_CURSOR_DEFAULT); // Create the bitmap allocator. Object declared in BitmapManager.cpp - bitmapmanager=new BitmapManager(); + bitmapmanager = new BitmapManager(); // This is necessary to mediate access between the Poller and app_server threads - _active_lock=create_sem(1,"app_server_active_sem"); + _active_lock = create_sem(1,"app_server_active_sem"); // This locker is for app_server and Picasso to vy for control of the ServerApp list - _applist_lock=create_sem(1,"app_server_applist_sem"); + _applist_lock = create_sem(1,"app_server_applist_sem"); // This locker is to mediate access to the make_decorator pointer - _decor_lock=create_sem(1,"app_server_decor_sem"); + _decor_lock = create_sem(1,"app_server_decor_sem"); - // Get the driver first - Poller thread utilizes the thing - _driver=desktop->GetGfxDriver(); - // Spawn our input-polling thread - _poller_id=spawn_thread(PollerThread, "Poller", B_NORMAL_PRIORITY, this); + _poller_id = spawn_thread(PollerThread, "Poller", B_NORMAL_PRIORITY, this); if (_poller_id >= 0) resume_thread(_poller_id); // Spawn our thread-monitoring thread - _picasso_id = spawn_thread(PicassoThread,"Picasso", B_NORMAL_PRIORITY, this); + _picasso_id = spawn_thread(PicassoThread,"Picasso", B_NORMAL_PRIORITY, this); if (_picasso_id >= 0) resume_thread(_picasso_id); - _active_app=-1; - _p_active_app=NULL; - decorator_name="Default"; + decorator_name = "Default"; } /*! @@ -183,6 +181,8 @@ AppServer::~AppServer(void) delete bitmapmanager; delete cursormanager; + delete desktop; + // If these threads are still running, kill them - after this, if exit_poller // is deleted, who knows what will happen... These things will just return an // error and fail if the threads have already exited. @@ -192,8 +192,6 @@ AppServer::~AppServer(void) delete fontserver; make_decorator=NULL; - delete desktop; - desktop=NULL; } /*! @@ -204,10 +202,10 @@ AppServer::~AppServer(void) int32 AppServer::PollerThread(void *data) { // This thread handles nothing but input messages for mouse and keyboard - AppServer *appserver=(AppServer*)data; - PortQueue mousequeue(appserver->_mouseport); - PortMessage *msg; - + AppServer *appserver = (AppServer*)data; + PortQueue mousequeue(appserver->_mouseport); + PortMessage *msg; + for(;;) { if(!mousequeue.MessagesWaiting()) @@ -215,10 +213,10 @@ int32 AppServer::PollerThread(void *data) else mousequeue.GetMessagesFromPort(false); - msg=mousequeue.GetMessageFromQueue(); + msg = mousequeue.GetMessageFromQueue(); if(!msg) continue; - + switch(msg->Code()) { // We don't need to do anything with these two, so just pass them @@ -227,44 +225,18 @@ int32 AppServer::PollerThread(void *data) case B_MOUSE_DOWN: case B_MOUSE_UP: case B_MOUSE_WHEEL_CHANGED: - { - if(!msg->Buffer()) - break; - ServerWindow::HandleMouseEvent(msg); - break; - } - - // Process the cursor and then pass it on case B_MOUSE_MOVED: - { - // Attached data: - // 1) int64 - time of mouse click - // 2) float - x coordinate of mouse click - // 3) float - y coordinate of mouse click - // 4) int32 - buttons down - - int64 dummy; - float tempx=0,tempy=0; - - msg->Read(&dummy); - msg->Read(&tempx); - msg->Read(&tempy); - msg->Rewind(); - - if(appserver->_driver) - { - appserver->_driver->MoveCursorTo(tempx,tempy); - ServerWindow::HandleMouseEvent(msg); - } + desktop->MouseEventHandler(msg); break; - } + case B_KEY_DOWN: case B_KEY_UP: case B_UNMAPPED_KEY_DOWN: case B_UNMAPPED_KEY_UP: case B_MODIFIERS_CHANGED: - appserver->HandleKeyMessage(msg->Code(),(int8*)msg->Buffer()); + desktop->KeyboardEventHandler(msg); break; + default: printf("Server::Poller received unexpected code %lx\n",msg->Code()); break; @@ -285,15 +257,15 @@ int32 AppServer::PollerThread(void *data) */ int32 AppServer::PicassoThread(void *data) { - int32 i; - AppServer *appserver=(AppServer*)data; - ServerApp *app; + int32 i; + AppServer *appserver = (AppServer*)data; + ServerApp *app; for(;;) { acquire_sem(appserver->_applist_lock); - for(i=0;i_applist->CountItems(); i++) + for(i = 0; i < appserver->_applist->CountItems(); i++) { - app=(ServerApp*)appserver->_applist->ItemAt(i); + app = (ServerApp*)appserver->_applist->ItemAt(i); if(!app) { printf("PANIC: NULL app in app list\n"); @@ -328,13 +300,13 @@ thread_id AppServer::Run(void) //! Main message-monitoring loop for the regular message port - no input messages! void AppServer::MainLoop(void) { - PortMessage pmsg; + PortMessage pmsg; for(;;) { - if(pmsg.ReadFromPort(_messageport)==B_OK) + if(pmsg.ReadFromPort(_messageport) == B_OK) { - if(pmsg.Protocol()==B_QUIT_REQUESTED) + if(pmsg.Protocol() == B_QUIT_REQUESTED) pmsg.SetCode(B_QUIT_REQUESTED); switch(pmsg.Code()) @@ -364,13 +336,10 @@ void AppServer::MainLoop(void) if(pmsg.Code()==AS_DELETE_APP || (pmsg.Protocol()==B_QUIT_REQUESTED && DISPLAYDRIVER!=HWDRIVER)) { - if(_quitting_server==true && _applist->CountItems()==0) + if(_quitting_server == true && _applist->CountItems() == 0) break; } } - // Make sure our polling thread has exited - if(find_thread("Poller")!=B_NAME_NOT_FOUND) - kill_thread(_poller_id); } /*! @@ -392,16 +361,16 @@ bool AppServer::LoadDecorator(const char *path) // internal one if(!path) { - make_decorator=NULL; + make_decorator = NULL; return true; } - create_decorator *pcreatefunc=NULL; - status_t stat; - image_id addon; + create_decorator *pcreatefunc = NULL; + status_t stat; + image_id addon; - addon=load_add_on(path); - if(addon<0) + addon = load_add_on(path); + if(addon < 0) return false; // As of now, we do nothing with decorator versions, but the possibility exists @@ -410,19 +379,18 @@ bool AppServer::LoadDecorator(const char *path) // go here. // Get the instantiation function - stat=get_image_symbol(addon, "instantiate_decorator", B_SYMBOL_TYPE_TEXT, (void**)&pcreatefunc); - if(stat!=B_OK) - { + stat = get_image_symbol(addon, "instantiate_decorator", B_SYMBOL_TYPE_TEXT, (void**)&pcreatefunc); + if(stat != B_OK){ unload_add_on(addon); return false; } - BPath temppath(path); - decorator_name=temppath.Leaf(); + BPath temppath(path); + decorator_name = temppath.Leaf(); acquire_sem(_decor_lock); - make_decorator=pcreatefunc; - _decorator_id=addon; + make_decorator = pcreatefunc; + _decorator_id = addon; release_sem(_decor_lock); return true; } @@ -477,17 +445,23 @@ void AppServer::DispatchMessage(PortMessage *msg) // Attached data: // 1) port_id - receiver port of a regular app - // 2) int32 - handler token of the regular app - // 2) char * - signature of the regular app - // 3) port_id - port to reply to + // 2) port_id - client looper port - for send messages to the client + // 2) team_id - app's team ID + // 3) int32 - handler token of the regular app + // 4) char * - signature of the regular app + // 5) port_id - port to reply to // Find the necessary data - port_id reply_port; - port_id app_port; - int32 htoken; - char *app_signature; + team_id clientTeamID; + port_id clientLooperPort; + port_id reply_port; + port_id app_port; + int32 htoken; + char* app_signature; - msg->Read(&app_port); + msg->Read(&app_port); + msg->Read(&clientLooperPort); + msg->Read(&clientTeamID); msg->Read(&htoken); msg->ReadString(&app_signature); msg->Read(&reply_port); @@ -495,22 +469,21 @@ void AppServer::DispatchMessage(PortMessage *msg) // Create the ServerApp subthread for this app acquire_sem(_applist_lock); - port_id r=create_port(DEFAULT_MONITOR_PORT_SIZE,app_signature); - if(r==B_NO_MORE_PORTS || r==B_BAD_VALUE) + port_id r = create_port(DEFAULT_MONITOR_PORT_SIZE, app_signature); + if(r == B_NO_MORE_PORTS || r == B_BAD_VALUE) { release_sem(_applist_lock); printf("No more ports left. Time to crash. Have a nice day! :)\n"); break; } - ServerApp *newapp=new ServerApp(app_port,r,htoken,app_signature); + ServerApp *newapp; + newapp = new ServerApp(app_port, r, clientLooperPort, clientTeamID, htoken, app_signature); + + // add the new ServerApp to the known list of ServerApps _applist->AddItem(newapp); release_sem(_applist_lock); - acquire_sem(_active_lock); - _p_active_app=newapp; - _active_app=_applist->CountItems()-1; - PortLink replylink(reply_port); replylink.SetOpCode(AS_SET_SERVER_PORT); replylink.Attach(newapp->_receiver); @@ -518,10 +491,7 @@ void AppServer::DispatchMessage(PortMessage *msg) // This is necessary because PortLink::ReadString allocates memory delete app_signature; - - release_sem(_active_lock); - - newapp->Run(); + break; } case AS_DELETE_APP: @@ -532,47 +502,32 @@ void AppServer::DispatchMessage(PortMessage *msg) // Attached Data: // 1) thread_id - thread ID of the ServerApp to be deleted - int32 i, appnum=_applist->CountItems(); - ServerApp *srvapp; - thread_id srvapp_id; + int32 i, + appnum = _applist->CountItems(); + ServerApp *srvapp; + + thread_id srvapp_id; msg->Read(&srvapp_id); - + + acquire_sem(_applist_lock); + // Run through the list of apps and nuke the proper one - for(i=0;iItemAt(i); + srvapp = (ServerApp *)_applist->ItemAt(i); - if(srvapp!=NULL && srvapp->_monitor_thread==srvapp_id) + if(srvapp != NULL && srvapp->_monitor_thread == srvapp_id) { - acquire_sem(_applist_lock); - srvapp=(ServerApp *)_applist->RemoveItem(i); - if(srvapp) - { + srvapp = (ServerApp *)_applist->RemoveItem(i); + if(srvapp){ delete srvapp; - srvapp=NULL; + srvapp = NULL; } - release_sem(_applist_lock); - acquire_sem(_active_lock); - - if(_applist->CountItems()==0) - { - // active==-1 signifies that no other apps are running - NOT good - _active_app=-1; - } - else - { - // we actually still have apps running, so make a new one active - if(_active_app>0) - _active_app--; - else - _active_app=0; - } - _p_active_app=(_active_app>-1)?(ServerApp*)_applist->ItemAt(_active_app):NULL; - release_sem(_active_lock); break; // jump out of our for() loop } - } + + release_sem(_applist_lock); break; } case AS_UPDATED_CLIENT_FONTLIST: @@ -723,14 +678,34 @@ void AppServer::DispatchMessage(PortMessage *msg) // We've been asked to quit, so (for now) broadcast to all // test apps to quit. This situation will occur only when the server // is compiled as a regular Be application. - if(DISPLAYDRIVER==HWDRIVER) + if(DISPLAYDRIVER == HWDRIVER) break; Broadcast(AS_QUIT_APP); - // So when we delete the last ServerApp, we can exit the server - _quitting_server=true; - _exit_poller=true; + // we have to wait until *all* threads have finished! + ServerApp *app = NULL; + status_t rv; + acquire_sem(_applist_lock); + for(int32 i = 0; i < _applist->CountItems(); i++) + { + app = (ServerApp*)_applist->ItemAt(i); + if(!app) + { printf("PANIC in AppServer::Broadcast()\n"); continue; } + + wait_for_thread(app->_monitor_thread, &rv); + } + release_sem(_applist_lock); + + // When we delete the last ServerApp, we can exit the server + _quitting_server = true; + _exit_poller = true; + // also wait for picasso thread + wait_for_thread(_picasso_id, &rv); + // poller thread is stuck reading messages from its input port + // so, there is no cleaner way to make it quit, other than killing it! + kill_thread(_poller_id); + // we are now clear to exit break; } case AS_SET_SYSCURSOR_DEFAULTS: @@ -752,15 +727,14 @@ void AppServer::DispatchMessage(PortMessage *msg) */ void AppServer::Broadcast(int32 code) { - int32 i; - ServerApp *app; + ServerApp *app = NULL; acquire_sem(_applist_lock); - for(i=0;i<_applist->CountItems(); i++) + for(int32 i = 0; i < _applist->CountItems(); i++) { - app=(ServerApp*)_applist->ItemAt(i); + app = (ServerApp*)_applist->ItemAt(i); if(!app) - continue; + { printf("PANIC in AppServer::Broadcast()\n"); continue; } app->PostMessage(code, sizeof(int32), (int8*)&code); } release_sem(_applist_lock); @@ -824,7 +798,7 @@ void AppServer::HandleKeyMessage(int32 code, int8 *buffer) if(modifiers & B_CONTROL_KEY) { STRACE(("Set Workspace %ld\n",scancode-1)); - desktop->SetWorkspace(scancode-2); +//TODO: change SetWorkspace(scancode-2); break; } @@ -878,7 +852,7 @@ void AppServer::HandleKeyMessage(int32 code, int8 *buffer) if(modifiers & (B_LEFT_SHIFT_KEY | B_LEFT_CONTROL_KEY)) { STRACE(("Set Workspace %ld\n",scancode-1)); - desktop->SetWorkspace(scancode-2); +//TODO: resolve SetWorkspace(scancode-2); break; } } @@ -1080,11 +1054,13 @@ Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel int32 wflags, DisplayDriver *ddriver) { Decorator *dec=NULL; - if(!app_server->make_decorator) +// Temporary solution! + dec=new DefaultDecorator(rect,wlook,wfeel,wflags); +/* if(!app_server->make_decorator) dec=new DefaultDecorator(rect,wlook,wfeel,wflags); else dec=app_server->make_decorator(rect,wlook,wfeel,wflags); - +*/ gui_colorset.Lock(); dec->SetDriver(ddriver); dec->SetColors(gui_colorset); @@ -1101,15 +1077,18 @@ Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel \param argv String array of the command-line arguments \return -1 if the app_server is already running, 0 if everything's OK. */ - int main( int argc, char** argv ) { // There can be only one.... if(find_port(SERVER_PORT_NAME)!=B_NAME_NOT_FOUND) return -1; - app_server=new AppServer(); +// why on the heap? +/* app_server=new AppServer(); app_server->Run(); delete app_server; +*/ + AppServer app_server; + app_server.Run(); return 0; } diff --git a/src/servers/app/server/AppServer.h b/src/servers/app/server/AppServer.h index 60ea5679ed..8e17ab8ad8 100644 --- a/src/servers/app/server/AppServer.h +++ b/src/servers/app/server/AppServer.h @@ -34,37 +34,52 @@ class AppServer : public BApplication #endif { public: - AppServer(void); - ~AppServer(void); - static int32 PollerThread(void *data); - static int32 PicassoThread(void *data); - thread_id Run(void); - void MainLoop(void); - bool LoadDecorator(const char *path); - void InitDecorators(void); - void DispatchMessage(PortMessage *msg); - void Broadcast(int32 code); - void HandleKeyMessage(int32 code, int8 *buffer); - ServerApp *FindApp(const char *sig); + AppServer(void); + ~AppServer(void); + + static int32 PollerThread(void *data); + static int32 PicassoThread(void *data); + thread_id Run(void); + void MainLoop(void); + + bool LoadDecorator(const char *path); + void InitDecorators(void); + + void DispatchMessage(PortMessage *msg); + void Broadcast(int32 code); + // TODO: remove shortly! + void HandleKeyMessage(int32 code, int8 *buffer); + + ServerApp* FindApp(const char *sig); + private: - friend Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel, - int32 wflags, DisplayDriver *ddriver); + friend Decorator* new_decorator(BRect rect, const char *title, + int32 wlook, int32 wfeel, + int32 wflags, DisplayDriver *ddriver); - create_decorator *make_decorator; // global function pointer + create_decorator *make_decorator; // global function pointer - port_id _messageport,_mouseport; - image_id _decorator_id; - BString decorator_name; - bool _quitting_server; - BList *_applist; - int32 _active_app; - ServerApp *_p_active_app; - thread_id _poller_id, _picasso_id; + port_id _messageport, + _mouseport; - sem_id _active_lock, _applist_lock, _decor_lock; - bool _exit_poller; - DisplayDriver *_driver; - int32 _ssindex; + image_id _decorator_id; + + BString decorator_name; + + bool _quitting_server, + _exit_poller; + + BList *_applist; + thread_id _poller_id, + _picasso_id; + + sem_id _active_lock, + _applist_lock, + _decor_lock; + + DisplayDriver *_driver; + + int32 _ssindex; }; Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel, diff --git a/src/servers/app/server/Desktop.cpp b/src/servers/app/server/Desktop.cpp index ae0689b79d..43cfbe2cef 100644 --- a/src/servers/app/server/Desktop.cpp +++ b/src/servers/app/server/Desktop.cpp @@ -1,8 +1,10 @@ -#include "Desktop.h" - +#include +#include #include + +#include "Desktop.h" #include "RootLayer.h" -#include "ServerScreen.h" +#include "Screen.h" #include "Layer.h" #include "PortMessage.h" #include "DisplayDriver.h" @@ -12,72 +14,66 @@ #include "Workspace.h" #include "Globals.h" #include "ServerWindow.h" -#include "ServerConfig.h" -#include -#include +//#define REAL_MODE -Desktop *desktop=NULL; +Desktop::Desktop(void){ +// desktop = this; -Desktop::Desktop(void) -{ fDragMessage = NULL; fActiveRootLayer = NULL; fFrontWinBorder = NULL; fFocusWinBorder = NULL; - fActiveScreen = NULL; - Init(); + fCursorScreen = NULL; } - -Desktop::~Desktop(void) -{ +//--------------------------------------------------------------------------- +Desktop::~Desktop(void){ +//printf("~Desktop()\n"); if (fDragMessage) delete fDragMessage; - void *ptr; - for(int32 i=0; (ptr=fRootLayerList.ItemAt(i)); i++) + void *ptr; + for(int32 i=0; (ptr=fRootLayerList.ItemAt(i)); i++){ delete (RootLayer*)ptr; + } - for(int32 i=0; (ptr=fScreenList.ItemAt(i)); i++) + for(int32 i=0; (ptr=fScreenList.ItemAt(i)); i++){ delete (Screen*)ptr; + } - for(int32 i=0; (ptr=fWinBorderList.ItemAt(i)); i++) + for(int32 i=0; (ptr=fWinBorderList.ItemAt(i)); i++){ delete (WinBorder*)ptr; + } } - -void Desktop::Init(void) -{ +//--------------------------------------------------------------------------- +void Desktop::Init(void){ DisplayDriver *driver = NULL; - int32 driverCount = 0; - bool initDrivers = true; + int32 driverCount = 0; + bool initDrivers = true; - while(initDrivers) - { - #ifdef TEST_MODE - driver = new ViewDriver(); - #else - - // If we're using the AccelerantDriver for rendering, eventually we will loop through - // drivers until one can't initialize in order to support multiple monitors. For now, - // we'll just load one and be done with it. - driver = new AccelerantDriver(); - #endif - - if(driver->Initialize()) - { + while(initDrivers){ + +#ifdef REAL_MODE + // If we're using the AccelerantDriver for rendering, eventually we will loop through + // drivers until one can't initialize in order to support multiple monitors. For now, + // we'll just load one and be done with it. + driver = new AccelerantDriver(); +#else + driver = new ViewDriver(); +#endif + + if(driver->Initialize()){ driverCount++; - - Screen *sc = new Screen(driver, BPoint(640, 480), B_RGB32, driverCount); - - // TODO: be careful, it may fail to initialize! - Monitor may not support 640x480 + + Screen *sc = new Screen(driver, BPoint(640, 480), B_RGB32, driverCount); +// TODO: be careful, it may fail to initialize! - Monitor may not support 640x480 fScreenList.AddItem(sc); - - // TODO: remove this when you have a real Driver. - if (driverCount == 2) + +// TODO: remove this when you have a real Driver. + if (driverCount == 1)//2) initDrivers = false; } - else - { + else{ driver->Shutdown(); delete driver; driver = NULL; @@ -85,89 +81,77 @@ void Desktop::Init(void) } } - if (driverCount < 1) + if (driverCount < 1){ delete this; + } InitMode(); - + SetActiveRootLayerByIndex(0); } - -void Desktop::InitMode(void) -{ - // this is init mode for n-SS. - for (int32 i=0; iSetScreens(screens, 1, 1); fRootLayerList.AddItem(rl); } } -// Methods for multiple monitors. -Screen* Desktop::ScreenAt(int32 index) const -{ + // Methods for multiple monitors. +//--------------------------------------------------------------------------- +Screen* Desktop::ScreenAt(int32 index) const{ Screen *sc; - sc = static_cast(fScreenList.ItemAt(index)); + sc = static_cast(fScreenList.ItemAt(index)); return sc; } - -int32 Desktop::ScreenCount(void) const -{ +//--------------------------------------------------------------------------- +int32 Desktop::ScreenCount() const{ return fScreenList.CountItems(); } - -void Desktop::SetActiveScreen(int32 index) -{ - if(index<0 || index>fScreenList.CountItems()-1) - return; - - // TODO: Once we get multiple monitor support going officially, we'll likely - // need to do something with the cursor here. - - fActiveScreen=(Screen*)fScreenList.ItemAt(index); +//--------------------------------------------------------------------------- +Screen* Desktop::CursorScreen() const{ + return fCursorScreen; } - -void Desktop::SetActiveRootLayerByIndex(int32 listIndex) -{ +//--------------------------------------------------------------------------- +void Desktop::SetActiveRootLayerByIndex(int32 listIndex){ RootLayer *rl; - rl = RootLayerAt(listIndex); + rl = RootLayerAt(listIndex); if (rl) SetActiveRootLayer(rl); } - -void Desktop::SetActiveRootLayer(RootLayer* rl) -{ +//--------------------------------------------------------------------------- +void Desktop::SetActiveRootLayer(RootLayer* rl){ if (fActiveRootLayer == rl) return; fActiveRootLayer = rl; - // also set he new front and focus + // also set he new front and focus SetFrontWinBorder(fActiveRootLayer->ActiveWorkspace()->FrontLayer()); SetFocusWinBorder(fActiveRootLayer->ActiveWorkspace()->FocusLayer()); - // TODO: other tasks required when this happens. I don't know them now. - // Rebuild & Invalidate - // hide the mouse in the old ActiveRootLayer - // show the mouse in new ActiveRootLayer +// TODO: other tasks required when this happens. I don't know them now. +// Rebuild & Invalidate +// hide the mouse in the old ActiveRootLayer +// show the mouse in new ActiveRootLayer } - -RootLayer* Desktop::ActiveRootLayer(void) const -{ +//--------------------------------------------------------------------------- +RootLayer* Desktop::ActiveRootLayer() const{ return fActiveRootLayer; } - -int32 Desktop::ActiveRootLayerIndex(void) const -{ +//--------------------------------------------------------------------------- +int32 Desktop::ActiveRootLayerIndex() const{ int32 rootLayerCount = CountRootLayers(); for(int32 i=0; i(fRootLayerList.ItemAt(index)); + rl = static_cast(fRootLayerList.ItemAt(index)); return rl; } - -int32 Desktop::CountRootLayers(void) const{ +//--------------------------------------------------------------------------- +int32 Desktop::CountRootLayers() const{ return fRootLayerList.CountItems(); } -// Methods for layer(WinBorder) manipulation. - -void Desktop::AddWinBorder(WinBorder* winBorder) -{ +DisplayDriver* Desktop::GetDisplayDriver() const{ + return ScreenAt(0)->DDriver(); +} + // Methods for layer(WinBorder) manipulation. +//--------------------------------------------------------------------------- +void Desktop::AddWinBorder(WinBorder* winBorder){ if(fWinBorderList.HasItem(winBorder)) return; - // special case for Tracker background window. - if (winBorder->GetServerFeel() == B_SYSTEM_LAST) - { - // it's added in all RottLayers - for(int32 i=0; i_level == B_SYSTEM_LAST){ + // it's added in all RottLayers + for(int32 i=0; iAddWinBorder(winBorder); } } - else - { // other windows are added to the current RootLayer only. + else ActiveRootLayer()->AddWinBorder(winBorder); - } - - // add that pointer to user winboder list so that we can keep track of them. + + // add that pointer to user winboder list so that we can keep track of them. + fLayerLock.Lock(); fWinBorderList.AddItem(winBorder); + fLayerLock.Unlock(); SetFrontWinBorder(fActiveRootLayer->ActiveWorkspace()->FrontLayer()); SetFocusWinBorder(fActiveRootLayer->ActiveWorkspace()->FocusLayer()); } - -void Desktop::RemoveWinBorder(WinBorder* winBorder) -{ - if(winBorder->GetServerFeel() == B_SYSTEM_LAST) +//--------------------------------------------------------------------------- +void Desktop::RemoveWinBorder(WinBorder* winBorder){ + if(winBorder->_level == B_SYSTEM_LAST){ for(int32 i=0; iRemoveWinBorder(winBorder); - else + } + else{ winBorder->GetRootLayer()->RemoveWinBorder(winBorder); + } if (winBorder == fFrontWinBorder) SetFrontWinBorder(fActiveRootLayer->ActiveWorkspace()->FrontLayer()); - if (winBorder == fFocusWinBorder) SetFocusWinBorder(fActiveRootLayer->ActiveWorkspace()->FocusLayer()); + fLayerLock.Lock(); fWinBorderList.RemoveItem(winBorder); + fLayerLock.Unlock(); } - -bool Desktop::HasWinBorder(WinBorder* winBorder) -{ +//--------------------------------------------------------------------------- +bool Desktop::HasWinBorder(WinBorder* winBorder){ return fWinBorderList.HasItem(winBorder); } - -void Desktop::SetFrontWinBorder(WinBorder* winBorder) -{ - // TODO: implement +//--------------------------------------------------------------------------- +void Desktop::SetFrontWinBorder(WinBorder* winBorder){ fFrontWinBorder = winBorder; +// TODO: implement } +//--------------------------------------------------------------------------- +void Desktop::SetFocusWinBorder(WinBorder* winBorder){ + if (fFocusWinBorder == winBorder && (winBorder && !winBorder->IsHidden())) + return; -void Desktop::SetFocusWinBorder(WinBorder* winBorder) -{ - // TODO: implement - fFocusWinBorder = winBorder; + // NOTE: we assume both, the old and new focus layer are in the active workspace + WinBorder *newFocus = NULL; + + if(fFocusWinBorder){ + fFocusWinBorder->SetFocus(false); + } + + if(winBorder){ + newFocus = winBorder->GetRootLayer()->ActiveWorkspace()->SetFocusLayer(winBorder); + newFocus->SetFocus(true); + } + + fFocusWinBorder = newFocus; } - -WinBorder* Desktop::FrontWinBorder(void) const -{ +//--------------------------------------------------------------------------- +WinBorder* Desktop::FrontWinBorder(void) const{ return fActiveRootLayer->ActiveWorkspace()->FrontLayer(); +// return fFrontWinBorder; +} +//--------------------------------------------------------------------------- +WinBorder* Desktop::FocusWinBorder(void) const{ +// return fActiveRootLayer->ActiveWorkspace()->FocusLayer(); + return fFocusWinBorder; } -WinBorder* Desktop::FocusWinBorder(void) const -{ - return fActiveRootLayer->ActiveWorkspace()->FocusLayer(); + // Input related methods +//--------------------------------------------------------------------------- +void Desktop::MouseEventHandler(PortMessage *msg){ + switch(msg->Code()){ + case B_MOUSE_DOWN:{ + // Attached data: + // 1) int64 - time of mouse click + // 2) float - x coordinate of mouse click + // 3) float - y coordinate of mouse click + // 4) int32 - modifier keys down + // 5) int32 - buttons down + // 6) int32 - clicks + + BPoint pt; + int64 dummy; + msg->Read(&dummy); + msg->Read(&pt.x); + msg->Read(&pt.y); + + printf("MOUSE DOWN: at (%f, %f)\n", pt.x, pt.y); + + WinBorder *target; + RootLayer *rl; + Workspace *ws; + rl = ActiveRootLayer(); + ws = rl->ActiveWorkspace(); + target = ws->SearchLayerUnderPoint(pt); + if (target){ + printf("\t '%s' was selected.\n", target->GetName()); + fGeneralLock.Lock(); + rl->fMainLock.Lock(); + + + ws->SetFrontLayer(target); + SetFocusWinBorder(target); +// TODO: improve! + rl->Invalidate(rl->Bounds()); + + + rl->fMainLock.Unlock(); + fGeneralLock.Unlock(); + } + + break; + } + case B_MOUSE_UP:{ + // Attached data: + // 1) int64 - time of mouse click + // 2) float - x coordinate of mouse click + // 3) float - y coordinate of mouse click + // 4) int32 - modifier keys down + + BPoint pt; + int64 dummy; + msg->Read(&dummy); + msg->Read(&pt.x); + msg->Read(&pt.y); + + printf("MOUSE UP: at (%f, %f)\n", pt.x, pt.y); + + break; + } + case B_MOUSE_MOVED:{ + // Attached data: + // 1) int64 - time of mouse click + // 2) float - x coordinate of mouse click + // 3) float - y coordinate of mouse click + // 4) int32 - buttons down + + break; + } + case B_MOUSE_WHEEL_CHANGED:{ + break; + } + default:{ + printf("\nDesktop::MouseEventHandler(): WARNING: unknown message\n\n"); + } + } } - -// Input related methods - -void Desktop::MouseEventHandler(PortMessage *msg) -{ +//--------------------------------------------------------------------------- +void Desktop::KeyboardEventHandler(PortMessage *msg){ } - -void Desktop::KeyboardEventHandler(PortMessage *msg) -{ -} - -void Desktop::SetDragMessage(BMessage* msg) -{ - if (fDragMessage) - { +//--------------------------------------------------------------------------- +void Desktop::SetDragMessage(BMessage* msg){ + if (fDragMessage){ delete fDragMessage; fDragMessage = NULL; } @@ -282,86 +349,71 @@ void Desktop::SetDragMessage(BMessage* msg) if (msg) fDragMessage = new BMessage(*msg); } - -BMessage* Desktop::DragMessage(void) const -{ +//--------------------------------------------------------------------------- +BMessage* Desktop::DragMessage(void) const{ return fDragMessage; } // Methods for various desktop stuff handled by the server -void Desktop::SetScrollBarInfo(const scroll_bar_info &info) -{ +//--------------------------------------------------------------------------- +void Desktop::SetScrollBarInfo(const scroll_bar_info &info){ fScrollBarInfo = info; } - -scroll_bar_info Desktop::ScrollBarInfo(void) const -{ +//--------------------------------------------------------------------------- +scroll_bar_info Desktop::ScrollBarInfo(void) const{ return fScrollBarInfo; } - -void Desktop::SetMenuInfo(const menu_info &info) -{ +//--------------------------------------------------------------------------- +void Desktop::SetMenuInfo(const menu_info &info){ fMenuInfo = info; } - -menu_info Desktop::MenuInfo(void) const -{ +//--------------------------------------------------------------------------- +menu_info Desktop::MenuInfo(void) const{ return fMenuInfo; } - -void Desktop::UseFFMouse(const bool &useffm) -{ +//--------------------------------------------------------------------------- +void Desktop::UseFFMouse(const bool &useffm){ fFFMouseMode = useffm; } - -bool Desktop::FFMouseInUse(void) const -{ +//--------------------------------------------------------------------------- +bool Desktop::FFMouseInUse(void) const{ return fFFMouseMode; } - -void Desktop::SetFFMouseMode(const mode_mouse &value) -{ +//--------------------------------------------------------------------------- +void Desktop::SetFFMouseMode(const mode_mouse &value){ fMouseMode = value; } - -mode_mouse Desktop::FFMouseMode(void) const -{ +//--------------------------------------------------------------------------- +mode_mouse Desktop::FFMouseMode(void) const{ return fMouseMode; } - -bool Desktop::ReadWorkspaceData(void) -{ - // TODO: implement +//--------------------------------------------------------------------------- +bool Desktop::ReadWorkspaceData(void){ +// TODO: implement return true; } - -void Desktop::SaveWorkspaceData(void) -{ - // TODO: implement +//--------------------------------------------------------------------------- +void Desktop::SaveWorkspaceData(void){ +// TODO: implement } - -void Desktop::RemoveSubsetWindow(WinBorder* wb) -{ +//--------------------------------------------------------------------------- +void Desktop::RemoveSubsetWindow(WinBorder* wb){ WinBorder *winBorder = NULL; int32 count = fWinBorderList.CountItems(); - - for(int32 i=0; i < count; i++) - { + for(int32 i=0; i < count; i++){ winBorder = static_cast(fWinBorderList.ItemAt(i)); - if (winBorder->GetServerFeel() == B_NORMAL_FEEL) - winBorder->Window()->GetFMWList()->RemoveItem(wb); + if (winBorder->_level == B_NORMAL_FEEL) + winBorder->Window()->fWinFMWList.RemoveItem(wb); } RootLayer *rl = winBorder->GetRootLayer(); int32 countWKs = rl->WorkspaceCount(); - for (int32 i=0; i < countWKs; i++) - { + for (int32 i=0; i < countWKs; i++){ rl->WorkspaceAt(i+1)->RemoveLayerPtr(wb); } } - -void Desktop::PrintToStream(void) -{ +//--------------------------------------------------------------------------- +void Desktop::PrintToStream(){ printf("RootLayer List:\n=======\n"); for(int32 i=0; iGetName()); @@ -369,7 +421,7 @@ void Desktop::PrintToStream(void) printf("-------\n"); } printf("=======\nActive RootLayer: %s\n", fActiveRootLayer? fActiveRootLayer->GetName(): "NULL"); -// printf("Active WinBorder: %s\n", fActiveWinBorder? fActiveWinBorder->Name(void): "NULL"); +// printf("Active WinBorder: %s\n", fActiveWinBorder? fActiveWinBorder->Name(): "NULL"); printf("Screen List:\n"); for(int32 i=0; i=fRootLayerList.CountItems()) return; @@ -392,13 +443,3 @@ void Desktop::PrintVisibleInRootLayerNo(int32 no) wb->PrintToStream(); } } - -DisplayDriver *Desktop::GetGfxDriver(void) -{ - return fActiveScreen->GetDriver(); -} - -void Desktop::SetWorkspace(int32 index) -{ - fActiveRootLayer->SetActiveWorkspaceByIndex(index); -} diff --git a/src/servers/app/server/Desktop.h b/src/servers/app/server/Desktop.h index 78ce9e93f2..97ffa956aa 100644 --- a/src/servers/app/server/Desktop.h +++ b/src/servers/app/server/Desktop.h @@ -6,101 +6,97 @@ #include #include -class DisplayDriver; class RootLayer; class Screen; class Layer; class BMessage; class PortMessage; class WinBorder; +class DisplayDriver; class Desktop { public: - // startup methods - Desktop(void); - ~Desktop(void); - void Init(void); + // startup methods + Desktop(void); + ~Desktop(void); + void Init(void); + void InitMode(void); // 1-BigScreen or n-SmallScreens - // 1-BigScreen or n-SmallScreens - void InitMode(void); - - // Methods for multiple monitors. - Screen *ScreenAt(int32 index) const; - int32 ScreenCount(void) const; - Screen *ActiveScreen(void) const { return fActiveScreen; } - void SetActiveScreen(int32 index); - - void SetActiveRootLayerByIndex(int32 listIndex); - void SetActiveRootLayer(RootLayer* rl); - RootLayer* RootLayerAt(int32 index); - RootLayer* ActiveRootLayer(void) const; - int32 ActiveRootLayerIndex(void) const; - int32 CountRootLayers(void) const; + // Methods for multiple monitors. + Screen* ScreenAt(int32 index) const; + int32 ScreenCount() const; + Screen* CursorScreen() const; - // Stuff for easy access - DisplayDriver *GetGfxDriver(void); - void SetWorkspace(int32 index); - - // Methods for layer(WinBorder) manipulation. - void AddWinBorder(WinBorder* winBorder); - void RemoveWinBorder(WinBorder* winBorder); - bool HasWinBorder(WinBorder* winBorder); - void SetFrontWinBorder(WinBorder* winBorder); - void SetFocusWinBorder(WinBorder* winBorder); - WinBorder* FrontWinBorder(void) const; - WinBorder* FocusWinBorder(void) const; - - // Input related methods - void MouseEventHandler(PortMessage *msg); - void KeyboardEventHandler(PortMessage *msg); - - void SetDragMessage(BMessage* msg); - BMessage* DragMessage(void) const; - - // Methods for various desktop stuff handled by the server - void SetScrollBarInfo(const scroll_bar_info &info); - scroll_bar_info ScrollBarInfo(void) const; - - void SetMenuInfo(const menu_info &info); - menu_info MenuInfo(void) const; - - - void UseFFMouse(const bool &useffm); - bool FFMouseInUse(void) const; - void SetFFMouseMode(const mode_mouse &value); - mode_mouse FFMouseMode(void) const; - - bool ReadWorkspaceData(void); - void SaveWorkspaceData(void); - - // Debugging methods - void PrintToStream(void); - void PrintVisibleInRootLayerNo(int32 no); - - // "Private" to app_server :-) - means they should not be used very much - void RemoveSubsetWindow(WinBorder* wb); + void SetActiveRootLayerByIndex(int32 listIndex); + void SetActiveRootLayer(RootLayer* rl); + RootLayer* RootLayerAt(int32 index); + RootLayer* ActiveRootLayer() const; + int32 ActiveRootLayerIndex() const; + int32 CountRootLayers() const; + DisplayDriver* GetDisplayDriver() const; + + // Methods for layer(WinBorder) manipulation. + void AddWinBorder(WinBorder* winBorder); + void RemoveWinBorder(WinBorder* winBorder); + bool HasWinBorder(WinBorder* winBorder); + void SetFrontWinBorder(WinBorder* winBorder); + void SetFocusWinBorder(WinBorder* winBorder); + WinBorder* FrontWinBorder(void) const; + WinBorder* FocusWinBorder(void) const; + + // Input related methods + void MouseEventHandler(PortMessage *msg); + void KeyboardEventHandler(PortMessage *msg); + + void SetDragMessage(BMessage* msg); + BMessage* DragMessage(void) const; + + // Methods for various desktop stuff handled by the server + void SetScrollBarInfo(const scroll_bar_info &info); + scroll_bar_info ScrollBarInfo(void) const; + + void SetMenuInfo(const menu_info &info); + menu_info MenuInfo(void) const; + + + void UseFFMouse(const bool &useffm); + bool FFMouseInUse(void) const; + void SetFFMouseMode(const mode_mouse &value); + mode_mouse FFMouseMode(void) const; + + bool ReadWorkspaceData(void); + void SaveWorkspaceData(void); + +// Debugging methods + void PrintToStream(); + void PrintVisibleInRootLayerNo(int32 no); + +// "Private" to app_server :-) - means they should not be used very much + void RemoveSubsetWindow(WinBorder* wb); + BLocker fGeneralLock; + BLocker fLayerLock; + BList fWinBorderList; private: - BLocker fLayerLock; - BList fWinBorderList; - - BMessage *fDragMessage; - - BList fRootLayerList; - RootLayer* fActiveRootLayer; - WinBorder* fFrontWinBorder; - WinBorder* fFocusWinBorder; - - BList fScreenList; - - scroll_bar_info fScrollBarInfo; - menu_info fMenuInfo; - mode_mouse fMouseMode; - bool fFFMouseMode; - Screen *fActiveScreen; + + BMessage *fDragMessage; + + BList fRootLayerList; + RootLayer* fActiveRootLayer; + WinBorder* fFrontWinBorder; + WinBorder* fFocusWinBorder; + + BList fScreenList; + int32 fScreenMode; // '1' or 'n' Screen(s). Not sure it's needed though. + Screen* fCursorScreen; + + scroll_bar_info fScrollBarInfo; + menu_info fMenuInfo; + mode_mouse fMouseMode; + bool fFFMouseMode; }; extern Desktop* desktop; -#endif // _DESKTOP_H_ +#endif _DESKTOP_H_ diff --git a/src/servers/app/server/Layer.cpp b/src/servers/app/server/Layer.cpp index b6c0c425a8..43a76315cc 100644 --- a/src/servers/app/server/Layer.cpp +++ b/src/servers/app/server/Layer.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include "Layer.h" @@ -39,7 +40,6 @@ #include "ServerCursor.h" #include "CursorManager.h" #include "TokenHandler.h" -#include "RectUtils.h" #include "RootLayer.h" #include "DisplayDriver.h" #include "Desktop.h" @@ -81,6 +81,7 @@ Layer::Layer(BRect frame, const char *name, int32 token, uint32 resize, _lowersibling = NULL; _topchild = NULL; _bottomchild = NULL; + fRootLayer = NULL; /* NOW all regions (_visible, _fullVisible, _full) are empty */ @@ -95,9 +96,8 @@ Layer::Layer(BRect frame, const char *name, int32 token, uint32 resize, _serverwin = win; _cursor = NULL; clipToPicture = NULL; - - //TODO: Fix -// fDriver = GetGfxDriver(ActiveScreen()); +// TODO: modify! + fDriver = desktop->GetDisplayDriver(); } //! Destructor frees all allocated heap space @@ -127,13 +127,20 @@ Layer::~Layer(void) \param before Add the child in front of this layer \param rebuild Flag to fully rebuild all visibility regions */ -void Layer::AddChild(Layer *layer, Layer *before) +void Layer::AddChild(Layer *layer, RootLayer *rootLayer) { if( layer->_parent != NULL ) { printf("ERROR: AddChild(): Layer already has a _parent\n"); return; } + if (layer->GetRootLayer()){ + printf("Error: Layer already belongs to a RootLayer!\n"); + return; + } + + layer->fRootLayer = rootLayer; + // attach layer to the tree structure layer->_parent = this; if( _bottomchild ){ @@ -164,24 +171,6 @@ void Layer::AddChild(Layer *layer, Layer *before) } } -/*! - \brief Used in the new Desktop Management code -*/ -void Layer::AddChild(Layer *layer, RootLayer *rootLayer) -{ - // TODO: Document - - if (layer->GetRootLayer()) - { - printf("Error: Layer already belongs to a RootLayer!\n"); - return; - } - - layer->fRootLayer = rootLayer; - - fLayerList.AddItem(layer); -} - /*! \brief Removes a layer from the child stack \param layer The layer to remove @@ -193,13 +182,13 @@ void Layer::RemoveChild(Layer *layer) printf("ERROR: RemoveChild(): Layer doesn't have a _parent\n"); return; } - - if (!(fLayerList.HasItem(layer))) - { - printf("Error: Layer is not a child of this RootLayer!\n"); + if( layer->_parent != this ){ + printf("ERROR: RemoveChild(): Layer is not a child of this layer\n"); return; } + fRootLayer = NULL; + // cache some things. The rebuilding/redrawing process will need those. Layer* cachedUpperSibling = layer->_uppersibling; @@ -236,9 +225,6 @@ void Layer::RemoveChild(Layer *layer) DoInvalidate( BRegion(invalidRect), cachedUpperSibling ); } } - - fRootLayer = NULL; - fLayerList.RemoveItem(layer); } /*! @@ -255,35 +241,23 @@ void Layer::RemoveSelf() _parent->RemoveChild(this); } -/*! - \brief Used in the new Desktop Management code -*/ -bool Layer::HasChild(Layer* layer) const -{ - return fLayerList.HasItem(layer); -} - -/*! - \brief Used in the new Desktop Management code -*/ -void Layer::SetRootLayer(RootLayer* rl) -{ - fRootLayer = rl; +bool Layer::HasChild(Layer* layer) const{ + for(Layer *lay = VirtualTopChild(); lay; lay = lay->VirtualLowerSibling()){ + if(lay == layer) + return true; + } + return false; } /*! \brief Finds the first child at a given point. \param pt Point to look for a child - \param recursive Flag to look for the bottom-most child \return non-NULL if found, NULL if not Find out which child gets hit if we click at a certain spot. Returns NULL if there are no _visible children or if the click does not hit a child layer - If recursive==true, then it will continue to call until it reaches a layer - which has no children, i.e. a layer that is at the top of its 'branch' in - the layer tree */ -Layer* Layer::GetLayerAt(const BPoint &pt) +Layer* Layer::LayerAt(const BPoint &pt) { if (_visible.Contains(pt)){ return this; @@ -292,7 +266,7 @@ Layer* Layer::GetLayerAt(const BPoint &pt) if (_fullVisible.Contains(pt)){ Layer *lay = NULL; for ( Layer* child = _bottomchild; child != NULL; child = child->_uppersibling ){ - if ( (lay = child->GetLayerAt( pt )) ) + if ( (lay = child->LayerAt( pt )) ) return lay; } } @@ -421,7 +395,15 @@ void Layer::MouseTransit(uint32 transit) void Layer::DoInvalidate(const BRegion ®, Layer *start){ //TODO: REMOVE this! For Test purposes only! +printf("**********Layer::DoInvalidate()\n"); + if (GetRootLayer()) + GetRootLayer()->Draw(GetRootLayer()->Bounds()); + else{ + if(dynamic_cast(this)) + Draw(Bounds()); + } return; +//---------------- if (_hidden || !(_fullVisible.Intersects(reg.Frame())) ){ printf("SERVER: WARNING: Layer(%s)::DoInvalidate() 1 \n\n", _name->String()); @@ -586,6 +568,12 @@ void Layer::Show(void) _hidden = false; +//TODO: *****!*!*!*!*!*!*!**!***REMOVE this! For Test purposes only! +printf("**********Layer::Show()\n"); + DoInvalidate(BRegion(Bounds()), NULL); + return; +//---------------- + // rebuild layer visible region based on its parent's and those supplied by user if (_parent){ _parent->RebuildChildRegions( _full.Frame(), this ); @@ -608,6 +596,12 @@ void Layer::Hide(void) _hidden = true; +//TODO: *****!*!*!*!*!*!*!**!***REMOVE this! For Test purposes only! +printf("**********Layer::Hide()\n"); + DoInvalidate(BRegion(Bounds()), NULL); + return; +//---------------- + if (_fullVisible.CountRects() > 0){ BRegion cachedFullVisible = _fullVisible; @@ -1034,7 +1028,12 @@ void Layer::RebuildRegions( const BRect& r ) } void Layer::RebuildFullRegion( ){ - _full.Set( ConvertToTop( _frame ) ); +// TODO: temporary patch? + if (_parent && dynamic_cast(_parent) ){ + } + else{ + _full.Set( ConvertToTop( _frame ) ); + } LayerData *ld; @@ -1255,59 +1254,15 @@ BRect Layer::ConvertFromTop(BRect rect) return(rect); } -/*! - \brief Makes the layer the backmost layer belonging to its parent - - This function will do nothing if the Layer has no parent or no siblings. Region - rebuilding is not performed. -*/ -void Layer::MakeTopChild(void) -{ - // Handle redundant and pointless cases - if(!_parent || (!_uppersibling && !_lowersibling) || _parent->_topchild==this) - return; - - // Pull ourselves out of the layer tree - if(_uppersibling) - _uppersibling->_lowersibling=_lowersibling; - - if(_lowersibling) - _lowersibling->_uppersibling=_uppersibling; - - // Set this layer's upper/lower sib pointers to appropriate values - _uppersibling=NULL; - _lowersibling=_parent->_topchild; - - // move former top child down a layer - _lowersibling->_uppersibling=this; - _parent->_topchild=this; +RootLayer* Layer::GetRootLayer() const{ + return fRootLayer; } -/*! - \brief Makes the layer the frontmost layer belonging to its parent - - This function will do nothing if the Layer has no parent or no siblings. Region - rebuilding is not performed. -*/ -void Layer::MakeBottomChild(void) -{ - // Handle redundant and pointless cases - if(!_parent || (!_uppersibling && !_lowersibling) || _parent->_bottomchild==this) - return; - - // Pull ourselves out of the layer tree - if(_uppersibling) - _uppersibling->_lowersibling=_lowersibling; - - if(_lowersibling) - _lowersibling->_uppersibling=_uppersibling; - - // Set this layer's upper/lower sib pointers to appropriate values - _uppersibling=_parent->_bottomchild; - _lowersibling=NULL; - - // move former bottom child up a layer - _uppersibling->_lowersibling=this; - _parent->_bottomchild=this; - +void Layer::SetRootLayer(RootLayer* rl){ + fRootLayer = rl; } + + +/* + @log +*/ diff --git a/src/servers/app/server/Layer.h b/src/servers/app/server/Layer.h index 23e86f0aa5..ead43f6383 100644 --- a/src/servers/app/server/Layer.h +++ b/src/servers/app/server/Layer.h @@ -44,6 +44,8 @@ class WinBorder; class Screen; class ServerCursor; class DisplayDriver; +class Desktop; +class Workspace; /*! \class Layer Layer.h @@ -56,105 +58,119 @@ class DisplayDriver; class Layer { public: - Layer(BRect frame, const char *name, int32 token, uint32 resize, uint32 flags, ServerWindow *win); - virtual ~Layer(void); - - void AddChild(Layer *child, Layer *before=NULL); - void AddChild(Layer *layer, RootLayer *rootLayer); - void RemoveChild(Layer *child); - void RemoveSelf(); - bool HasChild(Layer* layer) const; - uint32 CountChildren(void) const; - void MakeTopChild(void); - void MakeBottomChild(void); - Layer* FindLayer(const int32 token); - Layer* GetLayerAt(const BPoint &pt); - Layer* GetUpperSibling() const { return _uppersibling; } - Layer* GetLowerSibling() const { return _lowersibling; } - RootLayer *GetRootLayer() const { return fRootLayer; } - void SetRootLayer(RootLayer* rl); - - const char* GetName(void) const { return (_name)?_name->String():NULL; } - LayerData* GetLayerData(void) const { return _layerdata; } + Layer(BRect frame, const char *name, int32 token, uint32 resize, + uint32 flags, ServerWindow *win); + virtual ~Layer(void); - void SetLayerCursor(ServerCursor *csr); - ServerCursor *GetLayerCursor(void) const; - virtual void MouseTransit(uint32 transit); + void AddChild(Layer *child, RootLayer *rootLayer); + void RemoveChild(Layer *child); + void RemoveSelf(); + bool HasChild(Layer* layer) const; + RootLayer* GetRootLayer() const; + + uint32 CountChildren(void) const; + Layer* FindLayer(const int32 token); + Layer* LayerAt(const BPoint &pt); + + virtual Layer* TopLayer() const { return _topchild; } + virtual Layer* LowerSibling() const { return _lowersibling; } + virtual Layer* UpperSibling() const { return _uppersibling; } + virtual Layer* BottomLayer() const { return _bottomchild; } + + virtual Layer* VirtualTopChild() const{ return _topchild; } + virtual Layer* VirtualLowerSibling() const{ return _lowersibling; } + virtual Layer* VirtualUpperSibling() const{ return _uppersibling; } + virtual Layer* VirtualBottomChild() const{ return _bottomchild; } + + + const char* GetName(void) const { return (_name)?_name->String():NULL; } + LayerData* GetLayerData(void) const { return _layerdata; } - void Invalidate(const BRect &rect); - void Invalidate(const BRegion ®ion); - void DoInvalidate(const BRegion ®, Layer *start); - - virtual void RebuildRegions( const BRect& r ); - void RebuildChildRegions( const BRect &r, Layer* startFrom ); - void RebuildFullRegion(void); - void MoveRegionsBy(float x, float y); - void ResizeRegionsBy(float x, float y); - - void RequestClientUpdate(const BRect &rect); - void RequestDraw(const BRect &r); - virtual void Draw(const BRect &r); - - void Show(void); - void Hide(void); - bool IsHidden(void) const; - - BRect Bounds(void) const; - BRect Frame(void) const; - - virtual void MoveBy(float x, float y); - virtual void ResizeBy(float x, float y); - - BRect ConvertToParent(BRect rect); - BRegion ConvertToParent(BRegion *reg); - BRect ConvertFromParent(BRect rect); - BRegion ConvertFromParent(BRegion *reg); - BRegion ConvertToTop(BRegion *reg); - BRect ConvertToTop(BRect rect); - BRegion ConvertFromTop(BRegion *reg); - BRect ConvertFromTop(BRect rect); - - void PruneTree(void); - - void PrintToStream(void); - void PrintNode(void); - void PrintTree(); + void SetLayerCursor(ServerCursor *csr); + ServerCursor* GetLayerCursor(void) const; + virtual void MouseTransit(uint32 transit); + + void Invalidate(const BRect &rect); + void Invalidate(const BRegion ®ion); + void DoInvalidate(const BRegion ®, Layer *start); + + virtual void RebuildRegions( const BRect& r ); + void RebuildChildRegions( const BRect &r, Layer* startFrom ); + void RebuildFullRegion(void); + void MoveRegionsBy(float x, float y); + void ResizeRegionsBy(float x, float y); + void RequestClientUpdate(const BRect &rect); + void RequestDraw(const BRect &r); + virtual void Draw(const BRect &r); + + virtual void Show(void); + virtual void Hide(void); + bool IsHidden(void) const; + + BRect Bounds(void) const; + BRect Frame(void) const; + + virtual void MoveBy(float x, float y); + virtual void ResizeBy(float x, float y); + + BRect ConvertToParent(BRect rect); + BRegion ConvertToParent(BRegion *reg); + BRect ConvertFromParent(BRect rect); + BRegion ConvertFromParent(BRegion *reg); + BRegion ConvertToTop(BRegion *reg); + BRect ConvertToTop(BRect rect); + BRegion ConvertFromTop(BRegion *reg); + BRect ConvertFromTop(BRect rect); + + void PruneTree(void); + + void PrintToStream(void); + void PrintNode(void); + void PrintTree(); + + // server "private" - should not be used + void SetRootLayer(RootLayer* rl); protected: friend class RootLayer; friend class WinBorder; friend class Screen; friend class ServerWindow; + friend class Desktop; + friend class Workspace; - BRect _frame; - BPoint _boundsLeftTop; - Layer *_parent, - *_uppersibling, - *_lowersibling, - *_topchild, - *_bottomchild; - - BRegion _visible, - _fullVisible, - _full; + BRect _frame; + BPoint _boundsLeftTop; + Layer *_parent, + *_uppersibling, + *_lowersibling, + *_topchild, + *_bottomchild; - BRegion *clipToPicture; - bool clipToPictureInverse; + BRegion _visible, + _fullVisible, + _full; - ServerWindow *_serverwin; - BString *_name; - int32 _view_token; - int32 _level; - uint32 _flags; - uint32 _resize_mode; - bool _hidden; - bool _is_updating; - LayerData *_layerdata; - ServerCursor *_cursor; - DisplayDriver *fDriver; + BRegion *clipToPicture; + bool clipToPictureInverse; - RootLayer* fRootLayer; - BList fLayerList; + ServerWindow *_serverwin; + BString *_name; + int32 _view_token; + int32 _level; + uint32 _flags; + uint32 _resize_mode; + bool _hidden; + bool _is_updating; + LayerData *_layerdata; + ServerCursor *_cursor; + DisplayDriver* fDriver; + RootLayer* fRootLayer; }; #endif +/* + @log + * added a new member, BPoint _boundsLeftTop. Beside other uses, (DW don't forget!)it will be needed in redraw code. + * _flags is now declared as uint32 +*/ diff --git a/src/servers/app/server/RootLayer.cpp b/src/servers/app/server/RootLayer.cpp index 285c9ff4d2..7baacf2ecf 100644 --- a/src/servers/app/server/RootLayer.cpp +++ b/src/servers/app/server/RootLayer.cpp @@ -3,16 +3,19 @@ #include #include -#include "ServerApp.h" #include "Globals.h" #include "RootLayer.h" #include "Layer.h" #include "Workspace.h" -#include "ServerScreen.h" +#include "Screen.h" #include "WinBorder.h" #include "ServerWindow.h" +#include "ServerApp.h" #include "Desktop.h" #include "FMWList.h" +#include "DisplayDriver.h" + +//#define DISPLAYDRIVER_TEST_HACK //--------------------------------------------------------------------------- RootLayer::RootLayer(const char *layername, int32 workspaceCount, Desktop *desktop) @@ -34,7 +37,6 @@ RootLayer::RootLayer(const char *layername, int32 workspaceCount, Desktop *deskt } //--------------------------------------------------------------------------- RootLayer::~RootLayer(){ -//printf("~RootLayer( %s )\n", Name()); // RootLayer object just uses Screen objects, it is not allowed to delete them. } //--------------------------------------------------------------------------- @@ -42,8 +44,29 @@ void RootLayer::Draw(const BRect &r){ /* THIS method is here because of DisplayDriver testing! * It SHOULD BE REMOVED as soon as testing is done!!!! */ -/* +printf("*RootLayer(%s)::Draw(r)\n", GetName()); + // NOTE: (!!!) fMainLock MUST be locked when this method is called!!! + if (!fMainLock.IsLocked()) + printf("\n\n\tWARNING: fMainLock MUST be locked!!!\n\n"); + // NOTE: (!!!) desktop->fGeneralLock MUST be locked when this method is called!!! + if (!desktop->fGeneralLock.IsLocked()) + printf("\n\n\tWARNING: desktop->fGeneralLock MUST be locked!!!\n\n"); + + RGBColor c(51,102,152); + + fDriver->FillRect(Bounds(), c); + + Workspace *as = ActiveWorkspace(); + WinBorder *wb = NULL; + for (wb = as->GoToTopItem(); wb; wb = as->GoToLowerItem()){ +printf("requesting draw? %s from %s\n", wb->IsHidden()?"NO":"YES", wb->GetName()); + if (!(wb->IsHidden())) + wb->Draw(wb->Bounds()); + } + printf("#RootLayer(%s)::Draw(r) END\n", GetName()); +//--------REMOVE ABOVE-------------- #ifdef DISPLAYDRIVER_TEST_HACK + DisplayDriver *_driver = fDriver; int8 pattern[8]; int8 pattern2[8]; memset(pattern,255,8); @@ -104,7 +127,7 @@ void RootLayer::Draw(const BRect &r){ _driver->FillPolygon(polygon,6,polygonRect,_layerdata,pattern); // _driver->FillTriangle(triangle,triangleRect,_layerdata,pattern); #endif -*/ + } //--------------------------------------------------------------------------- void RootLayer::MoveBy(float x, float y){ @@ -146,11 +169,15 @@ void RootLayer::AddWinBorderToWorkspaces(WinBorder* winBorder, uint32 wks){ */ //--------------------------------------------------------------------------- void RootLayer::AddWinBorder(WinBorder* winBorder){ +printf("*RootLayer::AddWinBorder(%s)\n", winBorder->GetName()); +desktop->fGeneralLock.Lock(); +printf("*RootLayer::AddWinBorder(%s) - General lock acquired\n", winBorder->GetName()); +fMainLock.Lock(); +printf("*RootLayer::AddWinBorder(%s) - Main lock acquired\n", winBorder->GetName()); // add winBorder to the known list of WinBorders so we can keep track of it. AddChild(winBorder, this); - // add winBorder to the desired workspaces - switch(winBorder->Window()->GetFeel()){ + switch(winBorder->Window()->Feel()){ case B_MODAL_SUBSET_WINDOW_FEEL:{ /* this kind of window isn't added anywhere. It *will* be added to main window's subset when winBorder::AddToSubsetOf(main) @@ -160,7 +187,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder){ case B_MODAL_APP_WINDOW_FEEL:{ // add to ***app's*** list of Floating/Modal Windows. - winBorder->Window()->GetApp()->GetFMWList()->AddItem(winBorder); + winBorder->Window()->App()->fAppFMWList.AddItem(winBorder); // determine in witch workspaces to add this winBorder. uint32 wks = 0; @@ -169,9 +196,9 @@ void RootLayer::AddWinBorder(WinBorder* winBorder){ Workspace *ws = WorkspaceAt(i+1); for (WinBorder *wb = ws->GoToBottomItem(); wb!=NULL; wb = ws->GoToUpperItem()){ if ( !(wb->IsHidden()) && - winBorder->Window()->GetClientTeamID() == wb->Window()->GetClientTeamID()) + winBorder->Window()->ClientTeamID() == wb->Window()->ClientTeamID()) { - wks = wks | winBorder->Window()->GetWorkspaces(); + wks = wks | winBorder->Window()->Workspaces(); break; } } @@ -200,13 +227,13 @@ void RootLayer::AddWinBorder(WinBorder* winBorder){ case B_FLOATING_APP_WINDOW_FEEL:{ // add to ***app's*** list of Floating/Modal Windows. - winBorder->Window()->GetApp()->GetFMWList()->AddItem(winBorder); + winBorder->Window()->App()->fAppFMWList.AddItem(winBorder); for (int32 i=0; iFrontLayer(); - if(wb && wb->Window()->GetClientTeamID() == winBorder->Window()->GetClientTeamID() - && wb->Window()->GetFeel() == B_NORMAL_WINDOW_FEEL) + if(wb && wb->Window()->ClientTeamID() == winBorder->Window()->ClientTeamID() + && wb->Window()->Feel() == B_NORMAL_WINDOW_FEEL) { ws->AddLayerPtr(winBorder); } @@ -225,7 +252,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder){ case B_NORMAL_WINDOW_FEEL:{ // add this winBorder to the specified workspaces - AddWinBorderToWorkspaces(winBorder, winBorder->Window()->GetWorkspaces()); + AddWinBorderToWorkspaces(winBorder, winBorder->Window()->Workspaces()); break; } @@ -238,6 +265,11 @@ void RootLayer::AddWinBorder(WinBorder* winBorder){ default: break; } +fMainLock.Unlock(); +printf("*RootLayer::AddWinBorder(%s) - Main lock released\n", winBorder->GetName()); +desktop->fGeneralLock.Unlock(); +printf("*RootLayer::AddWinBorder(%s) - General lock released\n", winBorder->GetName()); +printf("#RootLayer::AddWinBorder(%s)\n", winBorder->GetName()); } /* This method does 3 things: * 1) Removes MODAL/SUBSET windows from system/app/window subset list. @@ -246,8 +278,9 @@ void RootLayer::AddWinBorder(WinBorder* winBorder){ */ //--------------------------------------------------------------------------- void RootLayer::RemoveWinBorder(WinBorder* winBorder){ - - int32 feel = winBorder->Window()->GetFeel(); +desktop->fGeneralLock.Lock(); +fMainLock.Lock(); + int32 feel = winBorder->Window()->Feel(); if(feel == B_MODAL_SUBSET_WINDOW_FEEL || feel == B_FLOATING_SUBSET_WINDOW_FEEL){ desktop->RemoveSubsetWindow(winBorder); } @@ -265,14 +298,17 @@ void RootLayer::RemoveWinBorder(WinBorder* winBorder){ WorkspaceAt(i+1)->RemoveLayerPtr(winBorder); } else{ // for B_NORMAL_WINDOW_FEEL - uint32 workspaces = winBorder->Window()->GetWorkspaces(); + uint32 workspaces = winBorder->Window()->Workspaces(); int32 count = WorkspaceCount(); for( int32 i=0; i < 32 && i < count; i++) - if( workspaces & (0x00000001 << i)) + if( workspaces & (0x00000001UL << i)){ WorkspaceAt(i+1)->RemoveLayerPtr(winBorder); + } } RemoveChild(winBorder); +fMainLock.Unlock(); +desktop->fGeneralLock.Unlock(); } //--------------------------------------------------------------------------- void RootLayer::ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces){ @@ -280,7 +316,7 @@ void RootLayer::ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces){ if(!winBorder->_level != B_NORMAL_FEEL) return; - uint32 oldWorkspaces = winBorder->Window()->GetWorkspaces(); + uint32 oldWorkspaces = winBorder->Window()->Workspaces(); for(int32 i=0; i < WorkspaceCount(); i++){ if ((oldWorkspaces & (0x00000001 << i)) && (newWorkspaces & (0x00000001 << i))){ // do nothing. @@ -294,6 +330,49 @@ void RootLayer::ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces){ } } //--------------------------------------------------------------------------- +bool RootLayer::SetFrontWinBorder(WinBorder* winBorder){ +// TODO: watch out for a NULL value +printf("*RootLayer::SetFrontWinBorder(%s)\n", winBorder? winBorder->GetName():"NULL"); +fMainLock.Lock(); +printf("*RootLayer::SetFrontWinBorder(%s) - main lock acquired\n", winBorder? winBorder->GetName():"NULL"); + if (!winBorder){ + ActiveWorkspace()->SetFrontLayer(NULL); + return true; + } + + uint32 workspaces = winBorder->Window()->Workspaces(); + int32 count = WorkspaceCount(); + int32 newWorkspace= 0; + + if (workspaces & (0x00000001UL << (ActiveWorkspaceIndex()-1)) ){ + newWorkspace = ActiveWorkspaceIndex(); + } + else{ + int32 i; + for( i = 0; i < 32 && i < count; i++) + if( workspaces & (0x00000001UL << i)){ + newWorkspace = i+1; + break; + } + + if (i == count || i == 32) + newWorkspace = ActiveWorkspaceIndex(); + } + + if(newWorkspace != ActiveWorkspaceIndex()){ + WorkspaceAt(newWorkspace)->SetFrontLayer(winBorder); + SetActiveWorkspaceByIndex(newWorkspace); + } + else{ + ActiveWorkspace()->SetFrontLayer(winBorder); + } + +fMainLock.Unlock(); +printf("*RootLayer::SetFrontWinBorder(%s) - main lock released\n", winBorder? winBorder->GetName():"NULL"); +printf("#RootLayer::SetFrontWinBorder(%s)\n", winBorder? winBorder->GetName():"NULL"); + return true; +} +//--------------------------------------------------------------------------- void RootLayer::SetScreens(Screen *screen[], int32 rows, int32 columns){ // NOTE: *All* Screens *MUST* have the same resolution. fScreenPtrList.MakeEmpty(); @@ -359,6 +438,7 @@ bool RootLayer::SetScreenResolution(int32 width, int32 height, uint32 colorspace } //--------------------------------------------------------------------------- void RootLayer::SetWorkspaceCount(const int32 count){ +printf("*RootLayer::SetWorkspaceCount(%ld)\n", count); if ((count < 1 && count > 32) || count == WorkspaceCount()) return; @@ -367,6 +447,8 @@ void RootLayer::SetWorkspaceCount(const int32 count){ BList newWSPtrList; void *workspacePtr; +fMainLock.Lock(); +printf("*RootLayer::SetWorkspaceCount(%ld) - main lock acquired\n", count); for(int i=0; i < count; i++){ workspacePtr = fWSPtrList.ItemAt(i); if (workspacePtr){ @@ -374,7 +456,7 @@ void RootLayer::SetWorkspaceCount(const int32 count){ } else{ Workspace *ws; - ws = new Workspace(fColorSpace, i+1, BGColor()); + ws = new Workspace(fColorSpace, i+1, BGColor(), this); newWSPtrList.AddItem(ws); } } @@ -393,12 +475,16 @@ void RootLayer::SetWorkspaceCount(const int32 count){ } fWSPtrList = newWSPtrList; + +fMainLock.Unlock(); +printf("*RootLayer::SetWorkspaceCount(%ld) - main lock released\n", count); if (exActiveWorkspaceIndex > count) SetActiveWorkspaceByIndex(count); // if true, this is the first time this method is called. if (exActiveWorkspaceIndex == -1) SetActiveWorkspaceByIndex(1); +printf("#RootLayer::SetWorkspaceCount(%ld)\n", count); } //--------------------------------------------------------------------------- int32 RootLayer::WorkspaceCount() const{ @@ -453,7 +539,7 @@ RGBColor RootLayer::BGColor(void) const{ } //--------------------------------------------------------------------------- void RootLayer::RemoveAppWindow(WinBorder *wb){ - wb->Window()->GetApp()->GetFMWList()->RemoveItem(wb); + wb->Window()->App()->fAppFMWList.RemoveItem(wb); int32 count = WorkspaceCount(); for(int32 i=0; i < count; i++){ diff --git a/src/servers/app/server/RootLayer.h b/src/servers/app/server/RootLayer.h index 7beca9285b..cc35302cda 100644 --- a/src/servers/app/server/RootLayer.h +++ b/src/servers/app/server/RootLayer.h @@ -29,6 +29,7 @@ #define _ROOTLAYER_H_ #include +#include #include "Layer.h" #include "FMWList.h" @@ -50,60 +51,63 @@ class Desktop; class RootLayer : public Layer { public: - RootLayer(const char *layername, int32 workspaceCount, Desktop *desktop); - virtual ~RootLayer(); - - virtual void Draw(const BRect &r); - virtual void MoveBy(float x, float y); - virtual void ResizeBy(float x, float y); + RootLayer(const char *layername, + int32 workspaceCount, Desktop *desktop); + virtual ~RootLayer(); - virtual Layer* VirtualTopChild() const; // - virtual Layer* VirtualLowerSibling() const; // ... for the active workspace - virtual Layer* VirtualUpperSibling() const; // - virtual Layer* VirtualBottomChild() const; // + virtual void Draw(const BRect &r); + virtual void MoveBy(float x, float y); + virtual void ResizeBy(float x, float y); + + virtual Layer* VirtualTopChild() const; // + virtual Layer* VirtualLowerSibling() const; // ... for the active workspace + virtual Layer* VirtualUpperSibling() const; // + virtual Layer* VirtualBottomChild() const; // - void AddWinBorder(WinBorder* winBorder); - void RemoveWinBorder(WinBorder* winBorder); - void ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces); - - void SetScreens(Screen *screen[], int32 rows, int32 columns); - Screen** Screens(); - bool SetScreenResolution(int32 width, int32 height, uint32 colorspace); - int32 ScreenRows() const { return fRows; } - int32 ScreenColumns() const { return fColumns; } - - void SetWorkspaceCount(const int32 count); - int32 WorkspaceCount(void) const; - Workspace* WorkspaceAt(const int32 index) const; - void SetActiveWorkspaceByIndex(const int32 index); - void SetActiveWorkspace(Workspace *ws); - int32 ActiveWorkspaceIndex(void) const; - Workspace* ActiveWorkspace(void) const; - - void SetBGColor(const RGBColor &col); - RGBColor BGColor(void) const; - - void AddWinBorderToWorkspaces(WinBorder* winBorder, uint32 wks); + void AddWinBorder(WinBorder* winBorder); + void RemoveWinBorder(WinBorder* winBorder); + void ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces); + bool SetFrontWinBorder(WinBorder* winBorder); + + void SetScreens(Screen *screen[], int32 rows, int32 columns); + Screen** Screens(); + bool SetScreenResolution(int32 width, int32 height, uint32 colorspace); + int32 ScreenRows() const { return fRows; } + int32 ScreenColumns() const { return fColumns; } + + void SetWorkspaceCount(const int32 count); + int32 WorkspaceCount(void) const; + Workspace* WorkspaceAt(const int32 index) const; + void SetActiveWorkspaceByIndex(const int32 index); + void SetActiveWorkspace(Workspace *ws); + int32 ActiveWorkspaceIndex(void) const; + Workspace* ActiveWorkspace(void) const; - // ------- debugging methods ------- - void PrintToStream(); - - // "Private" to app_server :-) - they should not be used - void RemoveAppWindow(WinBorder *wb); - - FMWList fMainFMWList; + void SetBGColor(const RGBColor &col); + RGBColor BGColor(void) const; + + void AddWinBorderToWorkspaces(WinBorder* winBorder, + uint32 wks); + +// ------- debugging methods ------- + void PrintToStream(); +// "Private" to app_server :-) - they should not be used + void RemoveAppWindow(WinBorder *wb); + + FMWList fMainFMWList; + BLocker fMainLock; private: - Desktop *fDesktop; - - BList fScreenPtrList; - int32 fRows; - int32 fColumns; - int32 fScreenXResolution; - int32 fScreenYResolution; - uint32 fColorSpace; - - BList fWSPtrList; - Workspace *fActiveWorkspace; + Desktop *fDesktop; + + BList fScreenPtrList; + int32 fRows; + int32 fColumns; + int32 fScreenXResolution; + int32 fScreenYResolution; + uint32 fColorSpace; + + BList fWSPtrList; + Workspace *fActiveWorkspace; }; #endif diff --git a/src/servers/app/server/ServerApp.cpp b/src/servers/app/server/ServerApp.cpp index 022c1c62e6..fa3a3099d7 100644 --- a/src/servers/app/server/ServerApp.cpp +++ b/src/servers/app/server/ServerApp.cpp @@ -54,7 +54,7 @@ #include "LayerData.h" #include "Utils.h" -//#define DEBUG_SERVERAPP +#define DEBUG_SERVERAPP #ifdef DEBUG_SERVERAPP # include @@ -70,8 +70,14 @@ \param _signature NULL-terminated string which contains the BApplication's MIME _signature. */ -ServerApp::ServerApp(port_id sendport, port_id rcvport, int32 handlerID, char *signature) +ServerApp::ServerApp(port_id sendport, port_id rcvport, port_id clientLooperPort, + team_id clientTeamID, int32 handlerID, char *signature) { + // it will be of *very* musch use in correct window order + fClientTeamID = clientTeamID; + // what to send a message to the client? Write a BMessage to this port. + fClientLooperPort = clientLooperPort; + // need to copy the _signature because the message buffer // owns the copy which we are passed as a parameter. _signature=(signature)?signature:"application/x-vnd.unregistered-application"; @@ -85,9 +91,7 @@ ServerApp::ServerApp(port_id sendport, port_id rcvport, int32 handlerID, char *s _applink->SetPort(_sender); // Gotta get the team ID so we can ping the application - port_info pinfo; - get_port_info(_sender,&pinfo); - _target_id=pinfo.team; + _target_id = clientTeamID; // _receiver is the port we receive messages from our BApplication _receiver=rcvport; @@ -102,11 +106,12 @@ ServerApp::ServerApp(port_id sendport, port_id rcvport, int32 handlerID, char *s _appcursor=(defaultc)?new ServerCursor(defaultc):NULL; _lock=create_sem(1,"ServerApp sem"); - // TODO: Fix +//TODO: resolve // _driver=GetGfxDriver(ActiveScreen()); - _cursorhidden=false; + Run(); + STRACE(("ServerApp %s:\n",_signature.String())); STRACE(("\tBApp port: %ld\n",_sender)); STRACE(("\tReceiver port: %ld\n",_receiver)); @@ -115,9 +120,35 @@ ServerApp::ServerApp(port_id sendport, port_id rcvport, int32 handlerID, char *s //! Does all necessary teardown for application ServerApp::~ServerApp(void) { - STRACE(("ServerApp %s:~ServerApp()\n",_signature.String())); + STRACE(("*ServerApp %s:~ServerApp()\n",_signature.String())); int32 i; - + + // 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;i<_winlist->CountItems();i++) { @@ -127,7 +158,7 @@ ServerApp::~ServerApp(void) } _winlist->MakeEmpty(); delete _winlist; - +*/ ServerBitmap *tempbmp; for(i=0;i<_bmplist->CountItems();i++) { @@ -153,13 +184,17 @@ ServerApp::~ServerApp(void) if(_appcursor) delete _appcursor; + + cursormanager->RemoveAppCursors(_signature.String()); + delete_sem(_lock); + + STRACE(("#ServerApp %s:~ServerApp()\n",_signature.String())); + // Kill the monitor thread if it exists thread_info info; if(get_thread_info(_monitor_thread,&info)==B_OK) kill_thread(_monitor_thread); - cursormanager->RemoveAppCursors(_signature.String()); - delete_sem(_lock); } /*! @@ -220,6 +255,21 @@ void ServerApp::PostMessage(int32 code, size_t size, int8 *buffer) write_port(_receiver,code, buffer, size); } +void ServerApp::SendMessageToClient(const BMessage* msg) const{ + ssize_t size; + char *buffer; + + size = msg->FlattenedSize(); + buffer = new char[size]; + if (msg->Flatten(buffer, size) == B_OK){ + write_port(fClientLooperPort, msg->what, buffer, size); + } + else + printf("PANIC: ServerApp: '%s': can't flatten message in 'SendMessageToClient()'\n", _signature.String()); + + delete buffer; +} + /*! \brief Sets the ServerApp's active status \param value The new status of the ServerApp. @@ -247,22 +297,23 @@ void ServerApp::SetAppCursor(void) \param data Pointer to the thread's ServerApp object \return Throwaway value - always 0 */ -int32 ServerApp::MonitorApp(void *data) + int32 ServerApp::MonitorApp(void *data) { // Message-dispatching loop for the ServerApp - ServerApp *app=(ServerApp *)data; - PortQueue msgqueue(app->_receiver); - PortMessage *msg; + ServerApp *app = (ServerApp *)data; + PortQueue msgqueue(app->_receiver); + PortMessage *msg; + bool quiting = false; - for(;;) + for( ; !quiting; ) { if(!msgqueue.MessagesWaiting()) msgqueue.GetMessagesFromPort(true); else msgqueue.GetMessagesFromPort(false); - msg=msgqueue.GetMessageFromQueue(); + msg = msgqueue.GetMessageFromQueue(); if(!msg) continue; @@ -271,6 +322,7 @@ int32 ServerApp::MonitorApp(void *data) case AS_QUIT_APP: { STRACE(("ServerApp %s:Server shutdown notification received\n",app->_signature.String())); +/* // If we are using the real, accelerated version of the // DisplayDriver, we do NOT want the user to be able shut down // the server. The results would NOT be pretty @@ -281,18 +333,13 @@ int32 ServerApp::MonitorApp(void *data) // ask all apps to quit. This is NOT the same as system // shutdown and will happen only in testing - // For now, it seems that we can't seem to try to play nice and tell - // an application to quit, so we'll just have to go postal. XD - -// BMessage *shutdown=new BMessage(_QUIT_); -// SendMessage(app->_sender,shutdown); - - // DIE! DIE! DIE! :P - port_info pi; - get_port_info(app->_sender,&pi); - kill_team(pi.team); - app->PostMessage(B_QUIT_REQUESTED); + BMessage pleaseQuit(_QUIT_); + app->SendMessageToClient(&pleaseQuit); } +* Adi: I do not agree here! I think this is a reminiscence(?) since the "old" days... +*/ + BMessage pleaseQuit(_QUIT_); + app->SendMessageToClient(&pleaseQuit); break; } @@ -300,15 +347,19 @@ int32 ServerApp::MonitorApp(void *data) { // Our BApplication sent us this message when it quit. // We need to ask the app_server to delete our monitor - port_id serverport=find_port(SERVER_PORT_NAME); - if(serverport==B_NAME_NOT_FOUND) - { + // ADI: No! This is a bad solution. A thead should continue its + // execution until its exit point, and this can *very* easily be done + quiting = true; + // see... no need to ask the main thread to kill us. + // still... it will delete this ServerApp object. + port_id serverport = find_port(SERVER_PORT_NAME); + if(serverport == B_NAME_NOT_FOUND){ printf("PANIC: ServerApp %s could not find the app_server port!\n",app->_signature.String()); break; } app->_applink->SetPort(serverport); app->_applink->SetOpCode(AS_DELETE_APP); - app->_applink->Attach(&app->_monitor_thread,sizeof(thread_id)); + app->_applink->Attach(&app->_monitor_thread, sizeof(thread_id)); app->_applink->Flush(); break; } @@ -321,10 +372,8 @@ int32 ServerApp::MonitorApp(void *data) } delete msg; - } // end for - - exit_thread(0); + // clean exit. return 0; } @@ -353,9 +402,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) } case AS_UPDATE_COLORS: { - // TODO: move message def to ServerProtocol.h to allow for - // complete build compatibility under R5 -/* ServerWindow *win; + ServerWindow *win; BMessage msg(_COLORS_UPDATED); for(int32 i=0; i<_winlist->CountItems(); i++) @@ -366,14 +413,11 @@ void ServerApp::_DispatchMessage(PortMessage *msg) win->SendMessageToClient(&msg); win->Unlock(); } -*/ break; - + break; } case AS_UPDATE_FONTS: { - // TODO: move message def to ServerProtocol.h to allow for - // complete build compatibility under R5 -/* ServerWindow *win; + ServerWindow *win; BMessage msg(_FONTS_UPDATED); for(int32 i=0; i<_winlist->CountItems(); i++) @@ -384,13 +428,11 @@ void ServerApp::_DispatchMessage(PortMessage *msg) win->SendMessageToClient(&msg); win->Unlock(); } -*/ break; + break; } case AS_UPDATE_DECORATOR: { - // TODO: move message def to ServerProtocol.h to allow for - // complete build compatibility under R5 -/* ServerWindow *win; + ServerWindow *win; for(int32 i=0; i<_winlist->CountItems(); i++) { @@ -399,7 +441,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) win->_winborder->UpdateDecorator(); win->Unlock(); } -*/ break; + break; } case AS_CREATE_WINDOW: { @@ -425,7 +467,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) port_id looperPort; port_id replyport; char *title; - + msg->Read(&frame); msg->Read((int32*)&look); msg->Read((int32*)&feel); @@ -441,41 +483,18 @@ void ServerApp::_DispatchMessage(PortMessage *msg) _signature.String())); // ServerWindow constructor will reply with port_id of a newly created port - ServerWindow *newwin = new ServerWindow(frame, title, - look, feel, flags, this, sendPort, looperPort, replyport, wkspaces, token); - - _winlist->AddItem(newwin); + new ServerWindow(frame, title, look, feel, flags, this, + sendPort, looperPort, replyport, wkspaces, token); + // ServerWindow constructor has added 'newwin' to the Desktop. + // We don't have to do anything here... - STRACE(("ServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n", + STRACE(("\nServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n", _signature.String(),title,frame.left,frame.top,frame.right,frame.bottom)); delete title; break; } - case AS_DELETE_WINDOW: - { - // Received from a ServerWindow when its window quits - - // Attached data: - // 1) uint32 ServerWindow ID token - ServerWindow *w; - uint32 winid; - msg->Read(&winid); - - for(int32 i=0;i<_winlist->CountItems();i++) - { - w=(ServerWindow*)_winlist->ItemAt(i); - if(w->_token==winid) - { - STRACE(("ServerApp %s: Deleting window %s\n",_signature.String(),w->GetTitle())); - _winlist->RemoveItem(w); - delete w; - break; - } - } - break; - } case AS_CREATE_BITMAP: { // Allocate a bitmap for an application @@ -601,8 +620,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) msg->Read(&workspace); msg->Read(&mode); msg->Read(&stick); - - // TODO: Fix +//TODO: Resolve // SetSpace(workspace,mode,ActiveScreen(),stick); break; @@ -615,8 +633,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) // Error-checking is done in ActivateWorkspace, so this is a safe call int32 workspace; msg->Read(&workspace); - - // TODO: Fix +//TODO: Resolve // SetWorkspace(workspace); break; } @@ -735,13 +752,15 @@ void ServerApp::_DispatchMessage(PortMessage *msg) { // Attached data: // 1) port_id reply port - synchronous message - scroll_bar_info sbi=desktop->ScrollBarInfo(); +//TODO: resolve +// scroll_bar_info sbi=GetScrollBarInfo(); port_id replyport; msg->Read(&replyport); PortLink link(replyport); - link.Attach(sbi); +//TODO: resolve +// link.Attach(sbi); link.Flush(); break; } @@ -751,7 +770,8 @@ void ServerApp::_DispatchMessage(PortMessage *msg) // 1) scroll_bar_info scroll bar info structure scroll_bar_info sbi; msg->Read(&sbi); - desktop->SetScrollBarInfo(sbi); +//TODO: resolve +// SetScrollBarInfo(sbi); break; } case AS_FOCUS_FOLLOWS_MOUSE: @@ -763,7 +783,8 @@ void ServerApp::_DispatchMessage(PortMessage *msg) msg->Read(&replyport); PortLink link(replyport); - link.Attach(desktop->FFMouseInUse()); +//TODO: resolve +// link.Attach(GetFFMouse()); link.Flush(); break; } @@ -773,7 +794,8 @@ void ServerApp::_DispatchMessage(PortMessage *msg) // 1) scroll_bar_info scroll bar info structure scroll_bar_info sbi; msg->Read(&sbi); - desktop->SetScrollBarInfo(sbi); +//TODO: resolve +// SetScrollBarInfo(sbi); break; } case AS_SET_MOUSE_MODE: @@ -782,20 +804,23 @@ void ServerApp::_DispatchMessage(PortMessage *msg) // 1) enum mode_mouse FFM mouse mode mode_mouse mmode; msg->Read(&mmode); - desktop->SetFFMouseMode(mmode); +//TODO: resolve +// SetFFMouseMode(mmode); break; } case AS_GET_MOUSE_MODE: { // Attached data: // 1) port_id reply port - synchronous message - mode_mouse mmode=desktop->FFMouseMode(); +//TODO: resolve +// mode_mouse mmode=GetFFMouseMode(); port_id replyport; msg->Read(&replyport); PortLink link(replyport); - link.Attach(mmode); +//TODO: resolve +// link.Attach(mmode); link.Flush(); break; } @@ -831,3 +856,6 @@ ServerBitmap *ServerApp::_FindBitmap(int32 token) return NULL; } +team_id ServerApp::ClientTeamID(){ + return fClientTeamID; +} diff --git a/src/servers/app/server/ServerApp.h b/src/servers/app/server/ServerApp.h index c094a6553b..02815ff281 100644 --- a/src/servers/app/server/ServerApp.h +++ b/src/servers/app/server/ServerApp.h @@ -29,7 +29,6 @@ #include #include -#include #include "FMWList.h" class AppServer; @@ -40,22 +39,6 @@ class BList; class DisplayDriver; class ServerCursor; - -/* -class ServerApp{ -public: - ServerApp(team_id clientTeamID){ - fClientTeamID = clientTeamID; - } - virtual ~ServerApp(){ } - team_id ClientTeamID(){ return fClientTeamID; } - - FMWList fAppFMWList; -private: - team_id fClientTeamID; -}; -*/ - /*! \class ServerApp ServerApp.h \brief Counterpart to BApplication within the app_server @@ -63,48 +46,60 @@ private: class ServerApp { public: - ServerApp(port_id sendport, port_id rcvport, int32 handlerID, char *signature); - ~ServerApp(void); + ServerApp(port_id sendport, port_id rcvport, port_id clientLooperPort, + team_id clientTeamID, int32 handlerID, char *signature); + virtual ~ServerApp(void); - bool Run(void); - static int32 MonitorApp(void *data); - void Lock(void); - void Unlock(void); - bool IsLocked(void); + bool Run(void); + static int32 MonitorApp(void *data); + void Lock(void); + void Unlock(void); + bool IsLocked(void); /*! \brief Determines whether the application is the active one \return true if active, false if not. */ - bool IsActive(void) const { return _isactive; } + bool IsActive(void) const { return _isactive; } - void Activate(bool value); - bool PingTarget(void); + void Activate(bool value); + bool PingTarget(void); - void PostMessage(int32 code, size_t size=0, int8 *buffer=NULL); + void PostMessage(int32 code, size_t size=0, + int8 *buffer=NULL); + void SendMessageToClient( const BMessage* msg ) const; - void SetAppCursor(void); - FMWList *GetFMWList(void) { return &fAppFMWList; } - + void SetAppCursor(void); + + team_id ClientTeamID(); + + FMWList fAppFMWList; protected: friend class AppServer; friend class ServerWindow; - void _DispatchMessage(PortMessage *msg); - ServerBitmap *_FindBitmap(int32 token); - port_id _sender,_receiver; - BString _signature; - thread_id _monitor_thread; - team_id _target_id; - PortLink *_applink; - BList *_winlist, *_bmplist, *_piclist; - DisplayDriver *_driver; - ServerCursor *_appcursor; - sem_id _lock; - bool _cursorhidden; - bool _isactive; - int32 _handlertoken; - FMWList fAppFMWList; + void _DispatchMessage(PortMessage *msg); + ServerBitmap* _FindBitmap(int32 token); + + port_id _sender, + _receiver, + fClientLooperPort; + + BString _signature; + thread_id _monitor_thread; + + team_id fClientTeamID; + + team_id _target_id; + PortLink* _applink; + BList *_winlist, + *_bmplist, + *_piclist; + ServerCursor* _appcursor; + sem_id _lock; + bool _cursorhidden; + bool _isactive; + int32 _handlertoken; }; #endif diff --git a/src/servers/app/server/ServerWindow.cpp b/src/servers/app/server/ServerWindow.cpp index 8488b90f44..400ad6fd30 100644 --- a/src/servers/app/server/ServerWindow.cpp +++ b/src/servers/app/server/ServerWindow.cpp @@ -41,14 +41,14 @@ #include "ServerProtocol.h" #include "WinBorder.h" #include "Desktop.h" -#include "Workspace.h" #include "TokenHandler.h" #include "Utils.h" #include "DisplayDriver.h" #include "ServerPicture.h" #include "CursorManager.h" +#include "Workspace.h" -//#define DEBUG_SERVERWINDOW +#define DEBUG_SERVERWINDOW //#define DEBUG_SERVERWINDOW_MOUSE //#define DEBUG_SERVERWINDOW_KEYBOARD @@ -122,6 +122,8 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook, uint32 wfeel, uint32 wflags, ServerApp *winapp, port_id winport, port_id looperPort, port_id replyport, uint32 index, int32 handlerID) { + STRACE(("ServerWindow(%s)::ServerWindow()\n",string? string: "NULL")); + _app = winapp; _title = new BString; if(string) _title->SetTo(string); @@ -131,18 +133,18 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook, _feel = wfeel; _handlertoken = handlerID; winLooperPort = looperPort; - _workspaces = index; + fWorkspaces = index; + fClientTeamID = winapp->ClientTeamID(); _workspace = NULL; _token = win_token_handler.GetToken(); // _sender is the port to which the app awaits messages from the server _sender = winport; - // _receiver is the port to which the app sends messages for the server _receiver = create_port(30,_title->String()); - - + + ses = new BSession(_receiver, _sender); // Send a reply to our window - it is expecting _receiver port. @@ -154,7 +156,6 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook, _winlink->Flush(); _winlink->SetPort(winport); - // Wait for top_view data and create ServerWindow's top most Layer int32 vToken; @@ -167,32 +168,29 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook, pmsg.ReadFromPort(_receiver); if(pmsg.Code() != AS_LAYER_CREATE_ROOT) debugger("SERVER ERROR: ServerWindow(xxx): NO top_view data received!\n"); - + pmsg.Read(&vToken); pmsg.Read(&vFrame); pmsg.Read(&vResizeMode); pmsg.Read(&vFlags); pmsg.ReadString(&vName); - - top_layer= new Layer(vFrame, vName, vToken, vResizeMode, vFlags, this); + + top_layer = new Layer(vFrame, vName, vToken, vResizeMode, vFlags, this); delete vName; - currentlayer = top_layer; + cl = top_layer; - // Create a WindoBorder object for our ServerWindow. _winborder = new WinBorder(_frame,_title->String(),wlook,wfeel,wflags,this); + // NOTE: this MUST be before the monitor thread is spawned! + desktop->AddWinBorder(_winborder); // Spawn our message-monitoring _monitorthread _monitorthread = spawn_thread(MonitorWin, _title->String(), B_NORMAL_PRIORITY, this); if(_monitorthread != B_NO_MORE_THREADS && _monitorthread != B_NO_MEMORY) resume_thread(_monitorthread); - - // Add window to desktop structure. - desktop->AddWinBorder(_winborder); - STRACE(("ServerWindow %s:\n",_title->String())); STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom)); STRACE(("\tPort: %ld\n",_receiver)); @@ -202,22 +200,31 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook, //!Tears down all connections with the user application, kills the monitoring thread. ServerWindow::~ServerWindow(void) { -STRACE(("ServerWindow %s:~ServerWindow()\n",_title->String())); +STRACE(("*ServerWindow %s:~ServerWindow()\n",_title->String())); + + desktop->fGeneralLock.Lock(); + desktop->RemoveWinBorder(_winborder); - - if(_applink) - { - delete _applink; - _applink=NULL; - delete _title; - delete _winlink; - delete _winborder; - - currentlayer = NULL; - if (top_layer) - delete top_layer; +printf("SW(%s) Successfuly removed from the desktop\n", _title->String()); + if(ses){ + delete ses; + ses = NULL; } - kill_thread(_monitorthread); + if (_winlink){ + delete _winlink; + _winlink = NULL; + } + if (_winborder){ + delete _winborder; + _winborder = NULL; + } + cl = NULL; + if (top_layer) + delete top_layer; + + desktop->fGeneralLock.Unlock(); +printf("#ServerWindow(%s) will exit NOW!!!\n", _title->String()); + delete _title; } /*! @@ -285,8 +292,26 @@ void ServerWindow::Show(void) STRACE(("ServerWindow %s: Show\n",_title->String())); if(_winborder) { + desktop->fGeneralLock.Lock(); _winborder->Show(); -// _winborder->SetFocus(true); + desktop->fGeneralLock.Unlock(); + + RootLayer *rl = _winborder->GetRootLayer(); + + desktop->fGeneralLock.Lock(); +printf("ServerWindow(%s)::Show() - General lock acquired\n", _winborder->GetName()); + rl->fMainLock.Lock(); +printf("ServerWindow(%s)::Show() - Main lock acquired\n", _winborder->GetName()); + int32 wksCount= rl->WorkspaceCount(); + for(int32 i = 0; i < wksCount; i++){ + if (fWorkspaces & (0x00000001UL << i)) + rl->WorkspaceAt(i+1)->SetFrontLayer(_winborder); + } + desktop->SetFocusWinBorder(_winborder); + rl->fMainLock.Unlock(); +printf("ServerWindow(%s)::Show() - Main lock released\n", _winborder->GetName()); + desktop->fGeneralLock.Unlock(); +printf("ServerWindow(%s)::Show() - General lock released\n", _winborder->GetName()); } } @@ -294,8 +319,27 @@ STRACE(("ServerWindow %s: Show\n",_title->String())); void ServerWindow::Hide(void) { STRACE(("ServerWindow %s: Hide\n",_title->String())); - if(_winborder) + if(_winborder){ + desktop->fGeneralLock.Lock(); _winborder->Hide(); + desktop->fGeneralLock.Unlock(); + + RootLayer *rl = _winborder->GetRootLayer(); + Workspace *ws = NULL; + + rl->fMainLock.Lock(); + int32 wksCount= rl->WorkspaceCount(); + for(int32 i = 0; i < wksCount; i++){ + ws = rl->WorkspaceAt(i+1); + if ( ws->FrontLayer() == _winborder){ + ws->SetFrontLayer(_winborder); + } + } + + if(desktop->FocusWinBorder() == _winborder) + desktop->SetFocusWinBorder(_winborder); + rl->fMainLock.Unlock(); + } } /* @@ -341,30 +385,6 @@ void ServerWindow::Zoom(){ // TODO: implement; } -void ServerWindow::SetLook(int32 look) -{ - // TODO: Finish - _look=look; -} - -void ServerWindow::SetFeel(int32 feel) -{ - // TODO: Finish - _feel=feel; -} - -void ServerWindow::SetFlags(int32 flags) -{ - // TODO: Finish - _flags=flags; -} - -void ServerWindow::SetWorkspaces(int32 workspaces) -{ - // TODO: Finish - _workspaces=workspaces; -} - /*! \brief Handles focus and redrawing when changing focus states @@ -502,9 +522,10 @@ bool ServerWindow::IsLocked(void) return _locker.IsLocked(); } -void ServerWindow::DispatchMessage(PortMessage msg) +void ServerWindow::DispatchMessage(int32 code) { - switch(msg.Code()) + PortMessage msg; + switch(code) { //--------- BView Messages ----------------- case AS_SET_CURRENT_LAYER: @@ -515,11 +536,11 @@ void ServerWindow::DispatchMessage(PortMessage msg) Layer *current = FindLayer(top_layer, token); if (current) - currentlayer = current; + cl = current; else // hope this NEVER happens! :-) debugger("Server PANIC: window cannot find Layer with ID\n"); - STRACE(("ServerWindow %s: Message AS_SET_CURRENT_LAYER: Layer name: %s\n", _title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_SET_CURRENT_LAYER: Layer name: %s\n", _title->String(), cl->_name->String())); break; } case AS_LAYER_CREATE: @@ -532,7 +553,7 @@ TODO: Figure out what Adi did here and convert to PortMessages // the area in which the new layer resides assuming that it is // visible. STRACE(("ServerWindow %s: AS_LAYER_CREATE...\n", _title->String())); - Layer *oldCL = currentlayer; + Layer *oldCL = cl; int32 token; BRect frame; @@ -557,7 +578,7 @@ TODO: Figure out what Adi did here and convert to PortMessages newLayer->_hidden = hidden; // we set Layer's attributes (BView's state) - currentlayer = newLayer; + cl = newLayer; int32 msgCode; msg.Read(&msgCode); // this is AS_LAYER_SET_FONT_STATE @@ -575,9 +596,9 @@ TODO: Figure out what Adi did here and convert to PortMessages DispatchMessage(msgCode); } - currentlayer = oldCL; + cl = oldCL; - STRACE(("DONE: ServerWindow %s: Message AS_CREATE_LAYER: Parent: %s, Child: %s\n", _title->String(), currentlayer->_name->String(), name)); + STRACE(("DONE: ServerWindow %s: Message AS_CREATE_LAYER: Parent: %s, Child: %s\n", _title->String(), cl->_name->String(), name)); */ break; } @@ -589,20 +610,20 @@ TODO: Figure out what Adi did here and convert to PortMessages // area assuming that the view was visible when removed STRACE(("SW %s: AS_LAYER_DELETE(self)...\n", _title->String())); Layer *parent; - parent = currentlayer->_parent; + parent = cl->_parent; // here we remove current layer from list. - currentlayer->RemoveSelf(); + cl->RemoveSelf(); // TODO: invalidate the region occupied by this view. // Should be done in Layer::RemoveChild() though! - currentlayer->PruneTree(); + cl->PruneTree(); parent->PrintTree(); - STRACE(("DONE: ServerWindow %s: Message AS_DELETE_LAYER: Parent: %s Layer: %s\n", _title->String(), parent->_name->String(), currentlayer->_name->String())); + STRACE(("DONE: ServerWindow %s: Message AS_DELETE_LAYER: Parent: %s Layer: %s\n", _title->String(), parent->_name->String(), cl->_name->String())); - delete currentlayer; + delete cl; - currentlayer = parent; + cl = parent; break; } case AS_LAYER_SET_STATE: @@ -613,53 +634,53 @@ TODO: Figure out what Adi did here and convert to PortMessages pattern patt; int32 clippRegRects; - msg.Read(&(currentlayer->_layerdata->penlocation)); - msg.Read(&(currentlayer->_layerdata->pensize)); + msg.Read(&(cl->_layerdata->penlocation)); + msg.Read(&(cl->_layerdata->pensize)); msg.Read(&highColor); msg.Read(&lowColor); msg.Read(&viewColor); msg.Read(&patt); - msg.Read((int8*)&(currentlayer->_layerdata->draw_mode)); - msg.Read(&(currentlayer->_layerdata->coordOrigin)); - msg.Read((int8*)&(currentlayer->_layerdata->lineJoin)); - msg.Read((int8*)&(currentlayer->_layerdata->lineCap)); - msg.Read(&(currentlayer->_layerdata->miterLimit)); - msg.Read((int8*)&(currentlayer->_layerdata->alphaSrcMode)); - msg.Read((int8*)&(currentlayer->_layerdata->alphaFncMode)); - msg.Read(&(currentlayer->_layerdata->scale)); - msg.Read(&(currentlayer->_layerdata->fontAliasing)); + msg.Read((int8*)&(cl->_layerdata->draw_mode)); + msg.Read(&(cl->_layerdata->coordOrigin)); + msg.Read((int8*)&(cl->_layerdata->lineJoin)); + msg.Read((int8*)&(cl->_layerdata->lineCap)); + msg.Read(&(cl->_layerdata->miterLimit)); + msg.Read((int8*)&(cl->_layerdata->alphaSrcMode)); + msg.Read((int8*)&(cl->_layerdata->alphaFncMode)); + msg.Read(&(cl->_layerdata->scale)); + msg.Read(&(cl->_layerdata->fontAliasing)); msg.Read(&clippRegRects); - currentlayer->_layerdata->patt.Set(*((uint64*)&patt)); - currentlayer->_layerdata->highcolor.SetColor(highColor); - currentlayer->_layerdata->lowcolor.SetColor(lowColor); - currentlayer->_layerdata->viewcolor.SetColor(viewColor); + cl->_layerdata->patt.Set(*((uint64*)&patt)); + cl->_layerdata->highcolor.SetColor(highColor); + cl->_layerdata->lowcolor.SetColor(lowColor); + cl->_layerdata->viewcolor.SetColor(viewColor); if(clippRegRects != 0){ - if(currentlayer->_layerdata->clippReg == NULL) - currentlayer->_layerdata->clippReg = new BRegion(); + if(cl->_layerdata->clippReg == NULL) + cl->_layerdata->clippReg = new BRegion(); else - currentlayer->_layerdata->clippReg->MakeEmpty(); + cl->_layerdata->clippReg->MakeEmpty(); BRect rect; for(int32 i = 0; i < clippRegRects; i++){ msg.Read(&rect); - currentlayer->_layerdata->clippReg->Include(rect); + cl->_layerdata->clippReg->Include(rect); } - currentlayer->RebuildFullRegion(); + cl->RebuildFullRegion(); } else{ - if (currentlayer->_layerdata->clippReg){ - delete currentlayer->_layerdata->clippReg; - currentlayer->_layerdata->clippReg = NULL; + if (cl->_layerdata->clippReg){ + delete cl->_layerdata->clippReg; + cl->_layerdata->clippReg = NULL; - currentlayer->RebuildFullRegion(); + cl->RebuildFullRegion(); } } - STRACE(("ServerWindow %s: Message AS_LAYER_SET_STATE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_STATE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_SET_FONT_STATE: @@ -673,52 +694,52 @@ TODO: Figure out what Adi did here and convert to PortMessages msg.Read((int32*)&fontID); // TODO: implement later. Currently there is no SetFamAndStyle(uint32) // in ServerFont class. DW, could you add one? - //currentlayer->_layerdata->font-> + //cl->_layerdata->font-> } if (mask & B_FONT_SIZE){ float size; msg.Read(&size); - currentlayer->_layerdata->font.SetSize(size); + cl->_layerdata->font.SetSize(size); } if (mask & B_FONT_SHEAR){ float shear; msg.Read(&shear); - currentlayer->_layerdata->font.SetShear(shear); + cl->_layerdata->font.SetShear(shear); } if (mask & B_FONT_ROTATION){ float rotation; msg.Read(&rotation); - currentlayer->_layerdata->font.SetRotation(rotation); + cl->_layerdata->font.SetRotation(rotation); } if (mask & B_FONT_SPACING){ uint8 spacing; msg.Read(&spacing); // uint8 - currentlayer->_layerdata->font.SetSpacing(spacing); + cl->_layerdata->font.SetSpacing(spacing); } if (mask & B_FONT_ENCODING){ uint8 encoding; msg.Read((int8*)&encoding); // uint8 - currentlayer->_layerdata->font.SetEncoding(encoding); + cl->_layerdata->font.SetEncoding(encoding); } if (mask & B_FONT_FACE){ uint16 face; msg.Read(&face); // uint16 - currentlayer->_layerdata->font.SetFace(face); + cl->_layerdata->font.SetFace(face); } if (mask & B_FONT_FLAGS){ uint32 flags; msg.Read(&flags); // uint32 - currentlayer->_layerdata->font.SetFlags(flags); + cl->_layerdata->font.SetFlags(flags); } - STRACE(("ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_GET_STATE: @@ -728,7 +749,7 @@ TODO: Figure out what Adi did here and convert to PortMessages rgb_color hc, lc, vc; // high, low and view colors uint64 patt; // current pattern as a uint64 - ld = currentlayer->_layerdata; // now we write fewer characters. :-) + ld = cl->_layerdata; // now we write fewer characters. :-) hc = ld->highcolor.GetColor32(); lc = ld->lowcolor.GetColor32(); vc = ld->viewcolor.GetColor32(); @@ -771,12 +792,12 @@ TODO: Figure out what Adi did here and convert to PortMessages _winlink->Attach(ld->clippReg->RectAt(i)); } - _winlink->Attach(currentlayer->_frame.left); - _winlink->Attach(currentlayer->_frame.top); - _winlink->Attach(currentlayer->_frame.OffsetToCopy(currentlayer->_boundsLeftTop)); + _winlink->Attach(cl->_frame.left); + _winlink->Attach(cl->_frame.top); + _winlink->Attach(cl->_frame.OffsetToCopy(cl->_boundsLeftTop)); _winlink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_STATE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_STATE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_MOVETO: @@ -786,9 +807,9 @@ TODO: Figure out what Adi did here and convert to PortMessages msg.Read(&x); msg.Read(&y); - currentlayer->MoveBy(x, y); + cl->MoveBy(x, y); - STRACE(("ServerWindow %s: Message AS_LAYER_MOVETO: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_MOVETO: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_RESIZETO: @@ -800,19 +821,19 @@ TODO: Figure out what Adi did here and convert to PortMessages /* TODO: check for minimum alowed. WinBorder should provide such * a method, based on its decorator. */ - currentlayer->ResizeBy(newWidth, newHeight); + cl->ResizeBy(newWidth, newHeight); - STRACE(("ServerWindow %s: Message AS_LAYER_RESIZETO: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_RESIZETO: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_GET_COORD: { - _winlink->Attach(currentlayer->_frame.left); - _winlink->Attach(currentlayer->_frame.top); - _winlink->Attach(currentlayer->_frame.OffsetToCopy(currentlayer->_boundsLeftTop)); + _winlink->Attach(cl->_frame.left); + _winlink->Attach(cl->_frame.top); + _winlink->Attach(cl->_frame.OffsetToCopy(cl->_boundsLeftTop)); _winlink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_SET_ORIGIN: @@ -822,24 +843,24 @@ TODO: Figure out what Adi did here and convert to PortMessages msg.Read(&x); msg.Read(&y); - currentlayer->_layerdata->coordOrigin.Set(x, y); + cl->_layerdata->coordOrigin.Set(x, y); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_ORIGIN: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_ORIGIN: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_GET_ORIGIN: { - _winlink->Attach(currentlayer->_layerdata->coordOrigin); + _winlink->Attach(cl->_layerdata->coordOrigin); _winlink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_RESIZE_MODE: { - msg.Read(&(currentlayer->_resize_mode)); + msg.Read(&(cl->_resize_mode)); - STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_MODE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_MODE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_CURSOR: @@ -850,28 +871,28 @@ TODO: Figure out what Adi did here and convert to PortMessages cursormanager->SetCursor(token); - STRACE(("ServerWindow %s: Message AS_LAYER_CURSOR: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_CURSOR: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_SET_FLAGS: { - msg.Read(&(currentlayer->_flags)); + msg.Read(&(cl->_flags)); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_FLAGS: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_FLAGS: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_HIDE: { - currentlayer->Hide(); + cl->Hide(); - STRACE(("ServerWindow %s: Message AS_LAYER_HIDE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_HIDE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_SHOW: { - currentlayer->Show(); + cl->Show(); - STRACE(("ServerWindow %s: Message AS_LAYER_SHOW: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SHOW: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_SET_LINE_MODE: @@ -884,61 +905,61 @@ TODO: Figure out what Adi did here and convert to PortMessages */ msg.Read(&lineCap); msg.Read(&lineJoin); - msg.Read(&(currentlayer->_layerdata->miterLimit)); + msg.Read(&(cl->_layerdata->miterLimit)); - currentlayer->_layerdata->lineCap = (cap_mode)lineCap; - currentlayer->_layerdata->lineJoin = (join_mode)lineJoin; + cl->_layerdata->lineCap = (cap_mode)lineCap; + cl->_layerdata->lineJoin = (join_mode)lineJoin; - STRACE(("ServerWindow %s: Message AS_LAYER_SET_LINE_MODE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_LINE_MODE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_GET_LINE_MODE: { - _winlink->Attach((int8)(currentlayer->_layerdata->lineCap)); - _winlink->Attach((int8)(currentlayer->_layerdata->lineJoin)); - _winlink->Attach(currentlayer->_layerdata->miterLimit); + _winlink->Attach((int8)(cl->_layerdata->lineCap)); + _winlink->Attach((int8)(cl->_layerdata->lineJoin)); + _winlink->Attach(cl->_layerdata->miterLimit); _winlink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_PUSH_STATE: { LayerData *ld = new LayerData(); - ld->prevState = currentlayer->_layerdata; - currentlayer->_layerdata = ld; + ld->prevState = cl->_layerdata; + cl->_layerdata = ld; - currentlayer->RebuildFullRegion(); + cl->RebuildFullRegion(); - STRACE(("ServerWindow %s: Message AS_LAYER_PUSH_STATE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_PUSH_STATE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_POP_STATE: { - if (!(currentlayer->_layerdata->prevState)) { - STRACE(("WARNING: SW(%s): User called BView(%s)::PopState(), but there is NO state on stack!\n", _title->String(), currentlayer->_name->String())); + if (!(cl->_layerdata->prevState)) { + STRACE(("WARNING: SW(%s): User called BView(%s)::PopState(), but there is NO state on stack!\n", _title->String(), cl->_name->String())); break; } - LayerData *ld = currentlayer->_layerdata; - currentlayer->_layerdata = currentlayer->_layerdata->prevState; + LayerData *ld = cl->_layerdata; + cl->_layerdata = cl->_layerdata->prevState; delete ld; - currentlayer->RebuildFullRegion(); + cl->RebuildFullRegion(); - STRACE(("ServerWindow %s: Message AS_LAYER_POP_STATE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_POP_STATE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_SET_SCALE: { - msg.Read(&(currentlayer->_layerdata->scale)); + msg.Read(&(cl->_layerdata->scale)); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_GET_SCALE: { - LayerData *ld = currentlayer->_layerdata; + LayerData *ld = cl->_layerdata; float scale = ld->scale; while((ld = ld->prevState)) @@ -947,7 +968,7 @@ TODO: Figure out what Adi did here and convert to PortMessages _winlink->Attach(scale); _winlink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_SET_PEN_LOC: @@ -957,32 +978,32 @@ TODO: Figure out what Adi did here and convert to PortMessages msg.Read(&x); msg.Read(&y); - currentlayer->_layerdata->penlocation.Set(x, y); + cl->_layerdata->penlocation.Set(x, y); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_LOC: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_LOC: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_GET_PEN_LOC: { - _winlink->Attach(currentlayer->_layerdata->penlocation); + _winlink->Attach(cl->_layerdata->penlocation); _winlink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_SET_PEN_SIZE: { - msg.Read(&(currentlayer->_layerdata->pensize)); + msg.Read(&(cl->_layerdata->pensize)); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_GET_PEN_SIZE: { - _winlink->Attach(currentlayer->_layerdata->pensize); + _winlink->Attach(cl->_layerdata->pensize); _winlink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_SET_HIGH_COLOR: @@ -991,9 +1012,9 @@ TODO: Figure out what Adi did here and convert to PortMessages msg.Read(&c); - currentlayer->_layerdata->highcolor.SetColor(c); + cl->_layerdata->highcolor.SetColor(c); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_HIGH_COLOR: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_HIGH_COLOR: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_SET_LOW_COLOR: @@ -1002,9 +1023,9 @@ TODO: Figure out what Adi did here and convert to PortMessages msg.Read(&c); - currentlayer->_layerdata->lowcolor.SetColor(c); + cl->_layerdata->lowcolor.SetColor(c); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_LOW_COLOR: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_LOW_COLOR: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_SET_VIEW_COLOR: @@ -1013,25 +1034,25 @@ TODO: Figure out what Adi did here and convert to PortMessages msg.Read(&c); - currentlayer->_layerdata->viewcolor.SetColor(c); + cl->_layerdata->viewcolor.SetColor(c); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_VIEW_COLOR: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_VIEW_COLOR: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_GET_COLORS: { rgb_color highColor, lowColor, viewColor; - highColor = currentlayer->_layerdata->highcolor.GetColor32(); - lowColor = currentlayer->_layerdata->lowcolor.GetColor32(); - viewColor = currentlayer->_layerdata->viewcolor.GetColor32(); + highColor = cl->_layerdata->highcolor.GetColor32(); + lowColor = cl->_layerdata->lowcolor.GetColor32(); + viewColor = cl->_layerdata->viewcolor.GetColor32(); _winlink->Attach(highColor); _winlink->Attach(lowColor); _winlink->Attach(viewColor); _winlink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_COLORS: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_COLORS: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_SET_BLEND_MODE: @@ -1041,19 +1062,19 @@ TODO: Figure out what Adi did here and convert to PortMessages msg.Read(&srcAlpha); msg.Read(&alphaFunc); - currentlayer->_layerdata->alphaSrcMode = (source_alpha)srcAlpha; - currentlayer->_layerdata->alphaFncMode = (alpha_function)alphaFunc; + cl->_layerdata->alphaSrcMode = (source_alpha)srcAlpha; + cl->_layerdata->alphaFncMode = (alpha_function)alphaFunc; - STRACE(("ServerWindow %s: Message AS_LAYER_SET_BLEND_MODE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_BLEND_MODE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_GET_BLEND_MODE: { - _winlink->Attach((int8)(currentlayer->_layerdata->alphaSrcMode)); - _winlink->Attach((int8)(currentlayer->_layerdata->alphaFncMode)); + _winlink->Attach((int8)(cl->_layerdata->alphaSrcMode)); + _winlink->Attach((int8)(cl->_layerdata->alphaFncMode)); _winlink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_SET_DRAW_MODE: @@ -1062,24 +1083,24 @@ TODO: Figure out what Adi did here and convert to PortMessages msg.Read(&drawingMode); - currentlayer->_layerdata->draw_mode = (drawing_mode)drawingMode; + cl->_layerdata->draw_mode = (drawing_mode)drawingMode; - STRACE(("ServerWindow %s: Message AS_LAYER_SET_DRAW_MODE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_DRAW_MODE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_GET_DRAW_MODE: { - _winlink->Attach((int8)(currentlayer->_layerdata->draw_mode)); + _winlink->Attach((int8)(cl->_layerdata->draw_mode)); _winlink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_PRINT_ALIASING: { - msg.Read(&(currentlayer->_layerdata->fontAliasing)); + msg.Read(&(cl->_layerdata->fontAliasing)); - STRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_CLIP_TO_PICTURE: @@ -1097,8 +1118,8 @@ TODO: Figure out what Adi did here and convert to PortMessages // if we had a picture to clip to, include the FULL visible region(if any) in the area to be redrawn // in other words: invalidate what ever is visible for this layer and his children. - if (currentlayer->clipToPicture && currentlayer->_fullVisible.CountRects() > 0){ - reg.Include(¤tlayer->_fullVisible); + if (cl->clipToPicture && cl->_fullVisible.CountRects() > 0){ + reg.Include(&cl->_fullVisible); redraw = true; } @@ -1106,12 +1127,12 @@ TODO: Figure out what Adi did here and convert to PortMessages ServerPicture *sp = NULL; int32 i = 0; for(;;){ - sp = static_cast(currentlayer->_serverwin->_app->_piclist->ItemAt(i++)); + sp = static_cast(cl->_serverwin->_app->_piclist->ItemAt(i++)); if (!sp) break; if(sp->GetToken() == pictureToken){ -// currentlayer->clipToPicture = sp; +// cl->clipToPicture = sp; // TODO: increase that picture's reference count.(~ allocate a picture) break; } @@ -1120,34 +1141,34 @@ TODO: Figure out what Adi did here and convert to PortMessages i = 0; // we have a new picture to clip to, so rebuild our full region - if(currentlayer->clipToPicture) { + if(cl->clipToPicture) { - currentlayer->clipToPictureInverse = false; + cl->clipToPictureInverse = false; - currentlayer->RebuildFullRegion(); + cl->RebuildFullRegion(); } // we need to rebuild the visible region, we may have a valid one. - if (currentlayer->_parent && !(currentlayer->_hidden)){ - currentlayer->_parent->RebuildChildRegions(currentlayer->_full.Frame(), currentlayer); + if (cl->_parent && !(cl->_hidden)){ + cl->_parent->RebuildChildRegions(cl->_full.Frame(), cl); } else{ // will this happen? Maybe... - currentlayer->RebuildRegions(currentlayer->_full.Frame()); + cl->RebuildRegions(cl->_full.Frame()); } // include our full visible region in the region to be redrawn - if (!(currentlayer->_hidden) && (currentlayer->_fullVisible.CountRects() > 0)){ - reg.Include(&(currentlayer->_fullVisible)); + if (!(cl->_hidden) && (cl->_fullVisible.CountRects() > 0)){ + reg.Include(&(cl->_fullVisible)); redraw = true; } // redraw if: we had OR if we NOW have a picture to clip to. if (redraw){ - currentlayer->Invalidate(reg); + cl->Invalidate(reg); } - STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_CLIP_TO_INVERSE_PICTURE: @@ -1163,12 +1184,12 @@ TODO: Figure out what Adi did here and convert to PortMessages int32 i = 0; for(;;){ - sp = static_cast(currentlayer->_serverwin->_app->_piclist->ItemAt(i++)); + sp = static_cast(cl->_serverwin->_app->_piclist->ItemAt(i++)); if (!sp) break; if(sp->GetToken() == pictureToken){ -// currentlayer->clipToPicture = sp; +// cl->clipToPicture = sp; // TODO: increase that picture's reference count.(~ allocate a picture) break; } @@ -1177,16 +1198,16 @@ TODO: Figure out what Adi did here and convert to PortMessages i = 0; // if a picture has been found... - if(currentlayer->clipToPicture) { + if(cl->clipToPicture) { - currentlayer->clipToPictureInverse = true; + cl->clipToPictureInverse = true; - currentlayer->RebuildFullRegion(); + cl->RebuildFullRegion(); - currentlayer->RequestDraw(currentlayer->clipToPicture->Frame()); + cl->RequestDraw(cl->clipToPicture->Frame()); } - STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_GET_CLIP_REGION: @@ -1196,8 +1217,8 @@ TODO: Figure out what Adi did here and convert to PortMessages LayerData *ld; int32 noOfRects; - ld = currentlayer->_layerdata; - reg = currentlayer->ConvertFromParent(&(currentlayer->_visible)); + ld = cl->_layerdata; + reg = cl->ConvertFromParent(&(cl->_visible)); if(ld->clippReg) reg.IntersectWith(ld->clippReg); @@ -1215,7 +1236,7 @@ TODO: Figure out what Adi did here and convert to PortMessages _winlink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_SET_CLIP_REGION: @@ -1224,23 +1245,23 @@ TODO: Figure out what Adi did here and convert to PortMessages int32 noOfRects; BRect r; - if(currentlayer->_layerdata->clippReg) - currentlayer->_layerdata->clippReg->MakeEmpty(); + if(cl->_layerdata->clippReg) + cl->_layerdata->clippReg->MakeEmpty(); else - currentlayer->_layerdata->clippReg = new BRegion(); + cl->_layerdata->clippReg = new BRegion(); msg.Read(&noOfRects); for(int i = 0; i < noOfRects; i++){ msg.Read(&r); - currentlayer->_layerdata->clippReg->Include(r); + cl->_layerdata->clippReg->Include(r); } - currentlayer->RebuildFullRegion(); + cl->RebuildFullRegion(); - currentlayer->RequestDraw(currentlayer->clipToPicture->Frame()); + cl->RequestDraw(cl->clipToPicture->Frame()); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_CLIP_REGION: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_CLIP_REGION: Layer: %s\n",_title->String(), cl->_name->String())); break; } @@ -1251,11 +1272,11 @@ TODO: Figure out what Adi did here and convert to PortMessages msg.Read(&invalRect); - currentlayer->Invalidate(invalRect); + cl->Invalidate(invalRect); - currentlayer->RequestDraw(invalRect); + cl->RequestDraw(invalRect); - STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",_title->String(), cl->_name->String())); break; } case AS_LAYER_INVAL_REGION: @@ -1272,11 +1293,11 @@ TODO: Figure out what Adi did here and convert to PortMessages invalReg.Include(rect); } - currentlayer->Invalidate(invalReg); + cl->Invalidate(invalReg); - currentlayer->RequestDraw(invalReg.Frame()); + cl->RequestDraw(invalReg.Frame()); - STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",_title->String(), currentlayer->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",_title->String(), cl->_name->String())); break; } @@ -1456,11 +1477,11 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) return; WindowClipRegion.Set(_winborder->Frame()); - sibling = _winborder->GetUpperSibling(); + sibling = _winborder->UpperSibling(); while (sibling) { WindowClipRegion.Exclude(sibling->Frame()); - sibling = sibling->GetUpperSibling(); + sibling = sibling->UpperSibling(); } if (!WindowClipRegion.Frame().IsValid()) @@ -1473,7 +1494,8 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) { code = read_from_buffer(&msgbuffer); view_token = read_from_buffer(&msgbuffer); - layer = desktop->ActiveRootLayer()->FindLayer(view_token); +//TODO: fix! + layer = NULL;//_workspace->GetRoot()->FindLayer(view_token); if (layer) { layerdata = layer->GetLayerData(); @@ -1982,40 +2004,36 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) int32 ServerWindow::MonitorWin(void *data) { ServerWindow *win = (ServerWindow *)data; - status_t stat; - PortMessage msg; + bool quiting = false; + int32 code; - for(;;) + for( ; !quiting; ) { - stat = msg.ReadFromPort(win->_receiver); + code = 0; + win->ses->ReadInt32(&code); - if (stat != B_BAD_PORT_ID){ - switch(msg.Code()){ - case B_QUIT_REQUESTED:{ - STRACE(("ServerWindow %s received Quit request\n",win->Title())); - // Our BWindow sent us this message when it quit. - // We need to ask its ServerApp to delete our monitor - win->_applink->SetOpCode(AS_DELETE_WINDOW); - win->_applink->Attach(win->_token); - win->_applink->Flush(); - break; - } - default:{ - win->DispatchMessage(msg); - break; - } + switch(code){ + // this means the client has been killed + case 0:{ + STRACE(("ServerWindow %s received '0' message code\n",win->Title())); + quiting = true; + delete win; + break; + } + case B_QUIT_REQUESTED:{ + STRACE(("ServerWindow %s received Quit request\n",win->Title())); + quiting = true; + delete win; + break; + } + default:{ + printf("SW(%s): got a message to dispatch...\n",win->Title()); +// snooze(3000000); + win->DispatchMessage(code); + break; } } - else{ - exit_thread(1); - return 1; - } - - if(msg.Code() == B_QUIT_REQUESTED) - break; } - - exit_thread(0); return 0; } @@ -2027,11 +2045,12 @@ int32 ServerWindow::MonitorWin(void *data) //void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer) void ServerWindow::HandleMouseEvent(PortMessage *msg) { -/* ServerWindow *mousewin=NULL; + ServerWindow *mousewin=NULL; // int8 *index=buffer; // Find the window which will receive our mouse event. - Layer *root=GetRootLayer(CurrentWorkspace(),ActiveScreen()); +//TODO: resolve + Layer *root=NULL;//GetRootLayer(CurrentWorkspace(),ActiveScreen()); WinBorder *_winborder; // activeborder is used to remember windows when resizing/moving windows @@ -2066,10 +2085,11 @@ void ServerWindow::HandleMouseEvent(PortMessage *msg) msg->Read(&dummy); msg->Read(&x); msg->Read(&y); - BPoint pt(x,y); +//TODO: resolve +// BPoint pt(x,y); // If we have clicked on a window, - active_winborder = _winborder = WindowContainsPoint(pt); + active_winborder = _winborder = NULL; if(_winborder) { mousewin=_winborder->Window(); @@ -2095,12 +2115,15 @@ void ServerWindow::HandleMouseEvent(PortMessage *msg) msg->Read(&dummy); msg->Read(&x); msg->Read(&y); - BPoint pt(x,y); +//TODO: resolve +// BPoint pt(x,y); -// set_is_sliding_tab(false); -// set_is_moving_window(false); -// set_is_resizing_window(false); - _winborder = WindowContainsPoint(pt); +/* set_is_sliding_tab(false); + set_is_moving_window(false); + set_is_resizing_window(false); +*/ +//TODO: resolve + _winborder = NULL;//WindowContainsPoint(pt); active_winborder=NULL; if(_winborder) { @@ -2129,29 +2152,28 @@ void ServerWindow::HandleMouseEvent(PortMessage *msg) msg->Read(&dummy); msg->Read(&x); msg->Read(&y); -// BPoint pt(x,y); -// -// if(is_moving_window() || is_resizing_window() || is_sliding_tab()) -// { -// active_winborder->MouseMoved((int8*)msg->Buffer()); -// } -// else -// { -// _winborder = WindowContainsPoint(pt); -// if(_winborder) -// { -// mousewin=_winborder->Window(); -// _winborder->MouseMoved((int8*)msg->Buffer()); -// } -// } - break; +/* BPoint pt(x,y); + + if(is_moving_window() || is_resizing_window() || is_sliding_tab()) + { + active_winborder->MouseMoved((int8*)msg->Buffer()); + } + else + { + _winborder = WindowContainsPoint(pt); + if(_winborder) + { + mousewin=_winborder->Window(); + _winborder->MouseMoved((int8*)msg->Buffer()); + } + } +*/ break; } default: { break; } } -*/ } /*! @@ -2181,18 +2203,14 @@ STRACE_KEY(("ServerWindow::HandleKeyEvent unimplemented\n")); If the window belongs to all workspaces, it returns the current workspace */ -/* Workspace *ServerWindow::GetWorkspace(void) { - if(_workspace_index==B_ALL_WORKSPACES) - { - return _workspace->GetScreen()->GetActiveWorkspace(); - - } + if(fWorkspaces==B_ALL_WORKSPACES) +//TODO: resolve + return NULL;//fWorkspaces->GetScreen()->GetActiveWorkspace(); - return _workspace; + return NULL; } -*/ /*! \brief Assign the window to a particular workspace object diff --git a/src/servers/app/server/ServerWindow.h b/src/servers/app/server/ServerWindow.h index 079fcfd051..89ff0413ac 100644 --- a/src/servers/app/server/ServerWindow.h +++ b/src/servers/app/server/ServerWindow.h @@ -65,107 +65,113 @@ class Layer; class ServerWindow { public: - ServerWindow(BRect rect, const char *string, uint32 wlook, uint32 wfeel, - uint32 wflags, ServerApp *winapp, port_id winport, - port_id looperPort, port_id replyport, uint32 index,int32 handlerID); - ~ServerWindow(void); + ServerWindow(BRect rect, const char *string, + uint32 wlook, uint32 wfeel, uint32 wflags, + ServerApp *winapp, port_id winport, + port_id looperPort, port_id replyport, uint32 index, + int32 handlerID); + ~ServerWindow(void); + + void ReplaceDecorator(void); + void Quit(void); + const char* GetTitle(void); + ServerApp* GetApp(void); + void Show(void); + void Hide(void); + bool IsHidden(void); + void Minimize(bool status); + void Zoom(void); + void SetFocus(bool value); + bool HasFocus(void); + void RequestDraw(BRect rect); + void RequestDraw(void); + + void WorkspaceActivated(int32 workspace, bool active); + void WorkspacesChanged(int32 oldone,int32 newone); + void WindowActivated(bool active); + void ScreenModeChanged(const BRect frame, const color_space cspace); + + void SetFrame(const BRect &rect); + BRect Frame(void); + + status_t Lock(void); + void Unlock(void); + bool IsLocked(void); + thread_id ThreadID() const { return _monitorthread;} + + void DispatchMessage(int32 code); + void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer); + static int32 MonitorWin(void *data); + static void HandleMouseEvent(PortMessage *msg); + static void HandleKeyEvent(int32 code, int8 *buffer); - void ReplaceDecorator(void); - void Quit(void); - - const char *GetTitle(void); - ServerApp *GetApp(void); - int32 GetLook(void) const { return _look; } - int32 GetFeel(void) const { return _feel; } - int32 GetFlags(void) const { return _flags; } - int32 GetHandlerID(void) const { return _handlertoken; } //! Returns the index of the workspaces to which it belongs - uint32 GetWorkspaces(void) const { return _workspaces; } - - team_id GetClientTeamID(void) const { return fClientTeamID; } - FMWList *GetFMWList(void) { return &fWinFMWList; } + int32 GetWorkspaceIndex(void) { return fWorkspaces; } + Workspace* GetWorkspace(void); + void SetWorkspace(Workspace *wkspc); - void SetLook(int32 look); - void SetFeel(int32 feel); - void SetFlags(int32 flags); - void SetWorkspaces(int32 workspaces); - - void Show(void); - void Hide(void); - bool IsHidden(void); - void Minimize(bool status); - void Zoom(void); - void SetFocus(bool value); - bool HasFocus(void); - void RequestDraw(BRect rect); - void RequestDraw(void); - - void WorkspaceActivated(int32 workspace, bool active); - void WorkspacesChanged(int32 oldone,int32 newone); - void WindowActivated(bool active); - void ScreenModeChanged(const BRect frame, const color_space cspace); - - void SetFrame(const BRect &rect); - BRect Frame(void); - - status_t Lock(void); - void Unlock(void); - bool IsLocked(void); - - void DispatchMessage(PortMessage msg); - void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer); - - static int32 MonitorWin(void *data); - static void HandleMouseEvent(PortMessage *msg); - static void HandleKeyEvent(int32 code, int8 *buffer); - -// Workspace* GetWorkspace(void); - void SetWorkspace(Workspace *wkspc); - //! Returns the window's title - const char *Title(void) { return _title->String(); } + const char* Title(void) { return _title->String(); } - Layer* FindLayer(const Layer* start, int32 token) const; - void SendMessageToClient( const BMessage* msg ) const; + Layer* FindLayer(const Layer* start, int32 token) const; + void SendMessageToClient( const BMessage* msg ) const; + int32 Look() const { return _look; } + int32 Feel() const { return _feel; } + uint32 Flags() const { return _flags; } + team_id ClientTeamID() const { return fClientTeamID; } + ServerApp* App() const { return _app; } + uint32 Workspaces() const { return fWorkspaces; } + WinBorder* GetWinBorder() const { return _winborder; } + + // server "private" - try not to use + void QuietlySetWorkspaces(uint32 wks) + { fWorkspaces = wks; } + void QuietlySetFeel(int32 feel) + { _feel = feel; } + + FMWList fWinFMWList; protected: friend class ServerApp; friend class WinBorder; friend class Screen; friend class Layer; - BString *_title; - int32 _look, - _feel, - _flags; - uint32 _workspaces; - Workspace *_workspace; - bool _active; + BString *_title; + int32 _look, + _feel, + _flags; + uint32 fWorkspaces; + Workspace *_workspace; + bool _active; - ServerApp *_app; - WinBorder *_winborder; + ServerApp *_app; + WinBorder *_winborder; - thread_id _monitorthread; + team_id fClientTeamID; + thread_id _monitorthread; + port_id _receiver; // Messages from window + port_id _sender; // Messages to window + PortLink *_winlink; - port_id _receiver; // Messages from window - port_id _sender; // Messages to window - - PortLink *_winlink, - *_applink; - BLocker _locker; - BRect _frame; - uint32 _token; - int32 _handlertoken; + BLocker _locker; + BRect _frame; + uint32 _token; + int32 _handlertoken; - port_id winLooperPort; - Layer *top_layer; - Layer *currentlayer; - FMWList fWinFMWList; - team_id fClientTeamID; + BSession *ses; + port_id winLooperPort; + Layer *top_layer; + Layer *cl; // short for currentLayer. We'll use it a lot, that's why it's short :-) }; void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin); #endif - +/* + @log + * added Layer as a friend. + * added a new member: port_id winLooperPort; We'll use it to send flattened BMessages(like _UPDATE_ / B_VIEW_RESIZED(MOVED)) to our BWindow counterpart. + * SendMessageToClient( BMessage ) sends that message BWindow's looper port. +*/ diff --git a/src/servers/app/server/WinBorder.cpp b/src/servers/app/server/WinBorder.cpp index 1ad80d6e48..d970c20931 100644 --- a/src/servers/app/server/WinBorder.cpp +++ b/src/servers/app/server/WinBorder.cpp @@ -27,10 +27,8 @@ #include #include #include -#include #include #include -#include "Globals.h" #include "View.h" // for mouse button defines #include "ServerWindow.h" #include "Decorator.h" @@ -342,48 +340,9 @@ void WinBorder::SetFocus(const bool &active) _decorator->SetFocus(active); } -void WinBorder::SetServerFeel(int32 feel) -{ - switch(_win->GetFeel()) - { - case B_NORMAL_WINDOW_FEEL: - _serverfeel = B_NORMAL_FEEL; - break; - case B_FLOATING_SUBSET_WINDOW_FEEL: - _serverfeel = B_FLOATING_SUBSET_FEEL; - break; - case B_FLOATING_APP_WINDOW_FEEL: - _serverfeel = B_FLOATING_APP_FEEL; - break; - case B_FLOATING_ALL_WINDOW_FEEL: - _serverfeel = B_FLOATING_ALL_FEEL; - break; - case B_MODAL_SUBSET_WINDOW_FEEL: - _serverfeel = B_MODAL_SUBSET_FEEL; - break; - case B_MODAL_APP_WINDOW_FEEL: - _serverfeel = B_MODAL_APP_FEEL; - break; - case B_MODAL_ALL_WINDOW_FEEL: - _serverfeel = B_MODAL_ALL_FEEL; - break; - case B_SYSTEM_LAST: - case B_SYSTEM_FIRST: -// if(_win->ServerTeamID() != _win->ClientTeamID()) -// _win->QuietlySetFeel(B_NORMAL_WINDOW_FEEL); -// else -// _serverfeel = _win->GetFeel(); - break; - default: - _win->SetFeel(B_NORMAL_WINDOW_FEEL); - _serverfeel = B_NORMAL_FEEL; - break; - } -} - void WinBorder::RebuildRegions( const BRect& r ){ /* WinBorder is a little bit special. It doesn't have a visible region - in witch to do its drawings. Instead the hole visible region is split + in which to do its drawings. Instead the whole visible region is split between decorator and top_layer. */ diff --git a/src/servers/app/server/WinBorder.h b/src/servers/app/server/WinBorder.h index c2cd5da2ed..3840633c6d 100644 --- a/src/servers/app/server/WinBorder.h +++ b/src/servers/app/server/WinBorder.h @@ -38,17 +38,17 @@ class DisplayDriver; class WinBorder : public Layer { public: - WinBorder(const BRect &r, const char *name, const int32 look, - const int32 feel, const int32 flags, ServerWindow *win); - virtual ~WinBorder(void); - + WinBorder(const BRect &r, const char *name, const int32 look, + const int32 feel, const int32 flags, ServerWindow *win); + virtual ~WinBorder(void); + virtual void RebuildRegions( const BRect& r ); virtual void Draw(const BRect &r); virtual void MoveBy(float x, float y); virtual void ResizeBy(float x, float y); bool HasPoint(BPoint pt) const; - + void MoveToBack(); void MoveToFront(); @@ -80,7 +80,6 @@ public: void SetMainWinBorder(WinBorder *newMain); protected: - ServerWindow *_win; //BString *_title; Decorator *_decorator; @@ -105,14 +104,14 @@ protected: */ }; -bool is_moving_window(void); -void set_is_moving_window(bool state); -bool is_resizing_window(void); -void set_is_resizing_window(bool state); -void set_active_winborder(WinBorder *win); -WinBorder *get_active_winborder(void); -void set_is_resizing_window(bool state); -void set_is_sliding_tab(bool state); -bool is_sliding_tab(void); +bool is_moving_window(void); +void set_is_moving_window(bool state); +bool is_resizing_window(void); +void set_is_resizing_window(bool state); +void set_active_winborder(WinBorder *win); +WinBorder* get_active_winborder(void); +void set_is_resizing_window(bool state); +void set_is_sliding_tab(bool state); +bool is_sliding_tab(void); #endif