From 247a93434e2ab81f819f93d5f9063906d91aad67 Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Mon, 19 Jan 2004 22:18:37 +0000 Subject: [PATCH] ViewDriver functions won't do anything if not initialized Style tweaks to a number of files to better match OT guidelines Added MsgCodeToBString to Utils.cpp Removed a crash on new_decorator git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6157 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/server/AppServer.cpp | 267 ++++---- src/servers/app/server/AppServer.h | 28 +- src/servers/app/server/Decorator.cpp | 9 +- src/servers/app/server/Layer.cpp | 2 +- src/servers/app/server/ServerApp.cpp | 367 ++++++----- src/servers/app/server/ServerApp.h | 89 +-- src/servers/app/server/ServerWindow.cpp | 786 ++++++++++++------------ src/servers/app/server/ServerWindow.h | 166 +++-- src/servers/app/server/Utils.cpp | 17 +- src/servers/app/server/Utils.h | 1 + src/servers/app/server/ViewDriver.cpp | 174 +++++- src/servers/app/server/WinBorder.cpp | 38 +- 12 files changed, 1094 insertions(+), 850 deletions(-) diff --git a/src/servers/app/server/AppServer.cpp b/src/servers/app/server/AppServer.cpp index 4138e7d350..f446ea8c6e 100644 --- a/src/servers/app/server/AppServer.cpp +++ b/src/servers/app/server/AppServer.cpp @@ -58,9 +58,10 @@ #else # define STRACE(x) ; #endif + // Globals -Desktop* desktop; +Desktop *desktop; //! Used to access the app_server from new_decorator AppServer *app_server=NULL; @@ -83,14 +84,17 @@ AppServer::AppServer(void) : BApplication (SERVER_SIGNATURE) AppServer::AppServer(void) #endif { - _mouseport = create_port(200,SERVER_INPUT_PORT); - _messageport = create_port(200,SERVER_PORT_NAME); + fMousePort= create_port(200,SERVER_INPUT_PORT); + _fMessagePort= create_port(200,SERVER_PORT_NAME); - _applist = new BList(0); - _quitting_server= false; - _exit_poller = false; - _ssindex = 1; - make_decorator = NULL; + fAppList= new BList(0); + fQuittingServer= false; + fExitPoller= false; + fScreenShotIndex= 1; + make_decorator= NULL; + + // We need this in order for new_decorator to be able to instantiate new decorators + app_server=this; // Create the font server and scan the proper directories. fontserver=new FontServer; @@ -125,36 +129,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"); + fActiveAppLock= 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"); + fAppListLock= 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"); + fDecoratorLock= create_sem(1,"app_server_decor_sem"); // Spawn our input-polling thread - _poller_id = spawn_thread(PollerThread, "Poller", B_NORMAL_PRIORITY, this); - if (_poller_id >= 0) - resume_thread(_poller_id); + fPollerThreadID= spawn_thread(PollerThread, "Poller", B_NORMAL_PRIORITY, this); + if (fPollerThreadID >= 0) + resume_thread(fPollerThreadID); // Spawn our thread-monitoring thread - _picasso_id = spawn_thread(PicassoThread,"Picasso", B_NORMAL_PRIORITY, this); - if (_picasso_id >= 0) - resume_thread(_picasso_id); + fPicassoThreadID= spawn_thread(PicassoThread,"Picasso", B_NORMAL_PRIORITY, this); + if (fPicassoThreadID >= 0) + resume_thread(fPicassoThreadID); - decorator_name = "Default"; + fDecoratorName="Default"; } /*! @@ -168,15 +172,15 @@ AppServer::~AppServer(void) ServerApp *tempapp; int32 i; - acquire_sem(_applist_lock); - for(i=0;i<_applist->CountItems();i++) + acquire_sem(fAppListLock); + for(i=0;iCountItems();i++) { - tempapp=(ServerApp *)_applist->ItemAt(i); + tempapp=(ServerApp *)fAppList->ItemAt(i); if(tempapp!=NULL) delete tempapp; } - delete _applist; - release_sem(_applist_lock); + delete fAppList; + release_sem(fAppListLock); delete bitmapmanager; delete cursormanager; @@ -186,8 +190,8 @@ AppServer::~AppServer(void) // 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. - kill_thread(_poller_id); - kill_thread(_picasso_id); + kill_thread(fPollerThreadID); + kill_thread(fPicassoThreadID); delete fontserver; @@ -202,8 +206,8 @@ 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); + AppServer *appserver=(AppServer*)data; + PortQueue mousequeue(appserver->fMousePort); PortMessage *msg; for(;;) @@ -213,7 +217,7 @@ int32 AppServer::PollerThread(void *data) else mousequeue.GetMessagesFromPort(false); - msg = mousequeue.GetMessageFromQueue(); + msg= mousequeue.GetMessageFromQueue(); if(!msg) continue; @@ -244,7 +248,7 @@ int32 AppServer::PollerThread(void *data) delete msg; - if(appserver->_exit_poller) + if(appserver->fExitPoller) break; } return 0; @@ -258,14 +262,14 @@ int32 AppServer::PollerThread(void *data) int32 AppServer::PicassoThread(void *data) { int32 i; - AppServer *appserver = (AppServer*)data; + AppServer *appserver=(AppServer*)data; ServerApp *app; for(;;) { - acquire_sem(appserver->_applist_lock); - for(i = 0; i < appserver->_applist->CountItems(); i++) + acquire_sem(appserver->fAppListLock); + for(i= 0; i < appserver->fAppList->CountItems(); i++) { - app = (ServerApp*)appserver->_applist->ItemAt(i); + app=(ServerApp*)appserver->fAppList->ItemAt(i); if(!app) { printf("PANIC: NULL app in app list\n"); @@ -273,11 +277,11 @@ int32 AppServer::PicassoThread(void *data) } app->PingTarget(); } - release_sem(appserver->_applist_lock); + release_sem(appserver->fAppListLock); // if poller thread has to exit, so do we - I just was too lazy // to rename the variable name. ;) - if(appserver->_exit_poller) + if(appserver->fExitPoller) break; // we do this every other second so as not to suck *too* many CPU cycles @@ -300,13 +304,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(;;) + while(1) { - if(pmsg.ReadFromPort(_messageport) == B_OK) + if(pmsg.ReadFromPort(_fMessagePort)== B_OK) { - if(pmsg.Protocol() == B_QUIT_REQUESTED) + if(pmsg.Protocol()== B_QUIT_REQUESTED) pmsg.SetCode(B_QUIT_REQUESTED); switch(pmsg.Code()) @@ -336,7 +340,7 @@ 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(fQuittingServer== true && fAppList->CountItems()== 0) break; } } @@ -361,15 +365,15 @@ bool AppServer::LoadDecorator(const char *path) // internal one if(!path) { - make_decorator = NULL; + make_decorator= NULL; return true; } - create_decorator *pcreatefunc = NULL; + create_decorator *pcreatefunc= NULL; status_t stat; image_id addon; - addon = load_add_on(path); + addon= load_add_on(path); if(addon < 0) return false; @@ -379,19 +383,19 @@ 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); + 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(); + fDecoratorName= temppath.Leaf(); - acquire_sem(_decor_lock); - make_decorator = pcreatefunc; - _decorator_id = addon; - release_sem(_decor_lock); + acquire_sem(fDecoratorLock); + make_decorator=pcreatefunc; + fDecoratorID=addon; + release_sem(fDecoratorLock); return true; } @@ -467,26 +471,26 @@ void AppServer::DispatchMessage(PortMessage *msg) msg->Read(&reply_port); // Create the ServerApp subthread for this app - acquire_sem(_applist_lock); + acquire_sem(fAppListLock); - 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); + release_sem(fAppListLock); printf("No more ports left. Time to crash. Have a nice day! :)\n"); break; } ServerApp *newapp; - newapp = new ServerApp(app_port, r, clientLooperPort, clientTeamID, htoken, app_signature); + newapp= new ServerApp(app_port, r, clientLooperPort, clientTeamID, htoken, app_signature); // add the new ServerApp to the known list of ServerApps - _applist->AddItem(newapp); + fAppList->AddItem(newapp); - release_sem(_applist_lock); + release_sem(fAppListLock); PortLink replylink(reply_port); replylink.SetOpCode(AS_SET_SERVER_PORT); - replylink.Attach(newapp->_receiver); + replylink.Attach(newapp->fMessagePort); replylink.Flush(); // This is necessary because PortLink::ReadString allocates memory @@ -503,33 +507,33 @@ void AppServer::DispatchMessage(PortMessage *msg) // 1) thread_id - thread ID of the ServerApp to be deleted int32 i, - appnum = _applist->CountItems(); + appnum= fAppList->CountItems(); ServerApp *srvapp; thread_id srvapp_id; msg->Read(&srvapp_id); - acquire_sem(_applist_lock); + acquire_sem(fAppListLock); // Run through the list of apps and nuke the proper one - for(i = 0; i < appnum; i++) + for(i= 0; i < appnum; i++) { - srvapp = (ServerApp *)_applist->ItemAt(i); + srvapp=(ServerApp *)fAppList->ItemAt(i); - if(srvapp != NULL && srvapp->_monitor_thread == srvapp_id) + if(srvapp != NULL && srvapp->fMonitorThreadID== srvapp_id) { - srvapp = (ServerApp *)_applist->RemoveItem(i); + srvapp=(ServerApp *)fAppList->RemoveItem(i); if(srvapp){ status_t temp; wait_for_thread(srvapp_id, &temp); delete srvapp; - srvapp = NULL; + srvapp= NULL; } break; // jump out of our for() loop } } - release_sem(_applist_lock); + release_sem(fAppListLock); break; } case AS_UPDATED_CLIENT_FONTLIST: @@ -615,7 +619,7 @@ void AppServer::DispatchMessage(PortMessage *msg) msg->Read(&replyport); PortLink replylink(replyport); replylink.SetOpCode(AS_GET_DECORATOR); - replylink.AttachString(decorator_name.String()); + replylink.AttachString(fDecoratorName.String()); replylink.Flush(); break; } @@ -666,9 +670,9 @@ void AppServer::DispatchMessage(PortMessage *msg) PortLink replylink(replyport); replylink.SetOpCode(AS_GET_SCREEN_MODE); - replylink.Attach(_driver->GetWidth()); - replylink.Attach(_driver->GetHeight()); - replylink.Attach(_driver->GetDepth()); + replylink.Attach(fDriver->GetWidth()); + replylink.Attach(fDriver->GetHeight()); + replylink.Attach(fDriver->GetDepth()); replylink.Flush(); break; } @@ -680,35 +684,59 @@ 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); - // 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++) + // we have to wait until *all* threads have finished! + ServerApp *app= NULL; + acquire_sem(fAppListLock); + thread_info tinfo; + + for(int32 i= 0; i < fAppList->CountItems(); i++) { - app = (ServerApp*)_applist->ItemAt(i); + app=(ServerApp*)fAppList->ItemAt(i); if(!app) - { printf("PANIC in AppServer::Broadcast()\n"); continue; } - - wait_for_thread(app->_monitor_thread, &rv); + continue; + + // Instead of calling wait_for_thread, we will wait a bit, check for the + // thread_id. We will only wait so long, because then the app is probably crashed + // or hung. Seeing that being the case, we'll kill its BApp team and fake the + // quit message + if(get_thread_info(app->fMonitorThreadID, &tinfo)==B_OK) + { + bool killteam=true; + + for(int32 j=0; j<5; j++) + { + snooze(1000); // wait half a second for it to quit + if(get_thread_info(app->fMonitorThreadID, &tinfo)!=B_OK) + { + killteam=false; + break; + } + } + + if(killteam) + { + kill_team(app->ClientTeamID()); + app->PostMessage(B_QUIT_REQUESTED); + } + } } - release_sem(_applist_lock); + release_sem(fAppListLock); // When we delete the last ServerApp, we can exit the server - _quitting_server = true; - _exit_poller = true; + fQuittingServer=true; + fExitPoller=true; // also wait for picasso thread - kill_thread(_picasso_id); + kill_thread(fPicassoThreadID); // 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); + kill_thread(fPollerThreadID); // we are now clear to exit break; @@ -732,17 +760,17 @@ void AppServer::DispatchMessage(PortMessage *msg) */ void AppServer::Broadcast(int32 code) { - ServerApp *app = NULL; + ServerApp *app= NULL; - acquire_sem(_applist_lock); - for(int32 i = 0; i < _applist->CountItems(); i++) + acquire_sem(fAppListLock); + for(int32 i= 0; i < fAppList->CountItems(); i++) { - app = (ServerApp*)_applist->ItemAt(i); + app=(ServerApp*)fAppList->ItemAt(i); if(!app) { printf("PANIC in AppServer::Broadcast()\n"); continue; } app->PostMessage(code, sizeof(int32), (int8*)&code); } - release_sem(_applist_lock); + release_sem(fAppListLock); } /*! @@ -783,7 +811,7 @@ void AppServer::HandleKeyMessage(int32 code, int8 *buffer) int32 modifiers=*((int32*)index); index+=sizeof(int32) + (sizeof(int8) * 3); int8 stringlength=*index; index+=stringlength; STRACE(("Key Down: 0x%lx\n",scancode)); - if(DISPLAYDRIVER == HWDRIVER) + if(DISPLAYDRIVER==HWDRIVER) { // Check for workspace change or safe video mode if(scancode>0x01 && scancode<0x0e) @@ -803,7 +831,8 @@ void AppServer::HandleKeyMessage(int32 code, int8 *buffer) if(modifiers & B_CONTROL_KEY) { STRACE(("Set Workspace %ld\n",scancode-1)); -//TODO: change SetWorkspace(scancode-2); + //TODO: change + //SetWorkspace(scancode-2); break; } @@ -821,21 +850,21 @@ void AppServer::HandleKeyMessage(int32 code, int8 *buffer) // PrintScreen if(scancode==0xe) { - if(_driver) + if(fDriver) { char filename[128]; BEntry entry; - sprintf(filename,"/boot/home/screen%ld.png",_ssindex); + sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex); entry.SetTo(filename); while(entry.Exists()) { - _ssindex++; - sprintf(filename,"/boot/home/screen%ld.png",_ssindex); + fScreenShotIndex++; + sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex); } - _ssindex++; - _driver->DumpToFile(filename); + fScreenShotIndex++; + fDriver->DumpToFile(filename); break; } } @@ -857,7 +886,8 @@ void AppServer::HandleKeyMessage(int32 code, int8 *buffer) if(modifiers & (B_LEFT_SHIFT_KEY | B_LEFT_CONTROL_KEY)) { STRACE(("Set Workspace %ld\n",scancode-1)); -//TODO: resolve SetWorkspace(scancode-2); + //TODO: resolve + //SetWorkspace(scancode-2); break; } } @@ -877,22 +907,22 @@ void AppServer::HandleKeyMessage(int32 code, int8 *buffer) // Pause/Break if(scancode==0x7f) { - if(_driver) + if(fDriver) { char filename[128]; BEntry entry; - sprintf(filename,"/boot/home/screen%ld.png",_ssindex); + sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex); entry.SetTo(filename); while(entry.Exists()) { - _ssindex++; - sprintf(filename,"/boot/home/screen%ld.png",_ssindex); + fScreenShotIndex++; + sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex); } - _ssindex++; + fScreenShotIndex++; - _driver->DumpToFile(filename); + fDriver->DumpToFile(filename); break; } } @@ -1026,19 +1056,19 @@ ServerApp *AppServer::FindApp(const char *sig) ServerApp *foundapp=NULL; - acquire_sem(_applist_lock); + acquire_sem(fAppListLock); - for(int32 i=0; i<_applist->CountItems();i++) + for(int32 i=0; iCountItems();i++) { - foundapp=(ServerApp*)_applist->ItemAt(i); - if(foundapp && foundapp->_signature==sig) + foundapp=(ServerApp*)fAppList->ItemAt(i); + if(foundapp && foundapp->fSignature==sig) { - release_sem(_applist_lock); + release_sem(fAppListLock); return foundapp; } } - release_sem(_applist_lock); + release_sem(fAppListLock); // couldn't find a match return NULL; @@ -1059,13 +1089,13 @@ Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel int32 wflags, DisplayDriver *ddriver) { Decorator *dec=NULL; -// Temporary solution! + dec=new DefaultDecorator(rect,wlook,wfeel,wflags); -/* if(!app_server->make_decorator) + 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); @@ -1088,11 +1118,6 @@ int main( int argc, char** argv ) if(find_port(SERVER_PORT_NAME)!=B_NAME_NOT_FOUND) return -1; -// 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 d7a75241db..c4ca8bb08c 100644 --- a/src/servers/app/server/AppServer.h +++ b/src/servers/app/server/AppServer.h @@ -60,27 +60,27 @@ private: // global function pointer create_decorator *make_decorator; - port_id _messageport, - _mouseport; + port_id _fMessagePort, + fMousePort; - image_id _decorator_id; + image_id fDecoratorID; - BString decorator_name; + BString fDecoratorName; - bool _quitting_server, - _exit_poller; + bool fQuittingServer, + fExitPoller; - BList *_applist; - thread_id _poller_id, - _picasso_id; + BList *fAppList; + thread_id fPollerThreadID, + fPicassoThreadID; - sem_id _active_lock, - _applist_lock, - _decor_lock; + sem_id fActiveAppLock, + fAppListLock, + fDecoratorLock; - DisplayDriver *_driver; + DisplayDriver *fDriver; - int32 _ssindex; + int32 fScreenShotIndex; }; Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel, diff --git a/src/servers/app/server/Decorator.cpp b/src/servers/app/server/Decorator.cpp index feb1d2c5e3..7d8404505a 100644 --- a/src/servers/app/server/Decorator.cpp +++ b/src/servers/app/server/Decorator.cpp @@ -308,18 +308,15 @@ int32 Decorator::_ClipTitle(float width) { int32 strlength=_title_string->CountChars(); float pixwidth=_driver->StringWidth(_title_string->String(),strlength,&_layerdata); -// printf("Initial width = %f\n", width ); -// printf("DEC: strlen = %ld\t pixwidth = %f\n", strlength, pixwidth); + while(strlength>=0) { if(pixwidthStringWidth(_title_string->String(),strlength,&_layerdata); -// printf("DEC: strlen = %ld\t pixwidth = %f\n", strlength, pixwidth); } - - return strlength; } return 0; } diff --git a/src/servers/app/server/Layer.cpp b/src/servers/app/server/Layer.cpp index e346d35f5e..7164c0b6c3 100644 --- a/src/servers/app/server/Layer.cpp +++ b/src/servers/app/server/Layer.cpp @@ -385,7 +385,7 @@ void Layer::MouseTransit(uint32 transit) else { if(_serverwin) - _serverwin->GetApp()->SetAppCursor(); + _serverwin->App()->SetAppCursor(); else cursormanager->SetCursor(B_CURSOR_DEFAULT); } diff --git a/src/servers/app/server/ServerApp.cpp b/src/servers/app/server/ServerApp.cpp index a9712153b1..7a72509c7e 100644 --- a/src/servers/app/server/ServerApp.cpp +++ b/src/servers/app/server/ServerApp.cpp @@ -70,78 +70,80 @@ \brief Constructor \param sendport port ID for the BApplication which will receive the ServerApp's messages \param rcvport port by which the ServerApp will receive messages from its BApplication. - \param _signature NULL-terminated string which contains the BApplication's - MIME _signature. + \param fSignature NULL-terminated string which contains the BApplication's + MIME fSignature. */ 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 + // 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. + + // 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 + // need to copy the fSignature because the message buffer // owns the copy which we are passed as a parameter. - _signature=(signature)?signature:"application/x-vnd.NULL-application-signature"; + fSignature=(signature)?signature:"application/x-vnd.NULL-application-signature"; // token ID of the BApplication's BHandler object. Used for BMessage target specification - _handlertoken=handlerID; + fHandlerToken=handlerID; - // _sender is the our BApplication's event port - _sender=sendport; - _applink=new PortLink(_sender); - _applink->SetPort(_sender); + // fClientAppPort is the our BApplication's event port + fClientAppPort=sendport; + fAppLink=new PortLink(fClientAppPort); - // Gotta get the team ID so we can ping the application - _target_id = clientTeamID; - - // _receiver is the port we receive messages from our BApplication - _receiver=rcvport; + // fMessagePort is the port we receive messages from our BApplication + fMessagePort=rcvport; - _winlist=new BList(0); - _bmplist=new BList(0); - _piclist=new BList(0); - _isactive=false; + fSWindowList=new BList(0); + fBitmapList=new BList(0); + fPictureList=new BList(0); + fIsActive=false; ServerCursor *defaultc=cursormanager->GetCursor(B_CURSOR_DEFAULT); - _appcursor=(defaultc)?new ServerCursor(defaultc):NULL; - _lock=create_sem(1,"ServerApp sem"); + fAppCursor=(defaultc)?new ServerCursor(defaultc):NULL; + fLockSem=create_sem(1,"ServerApp sem"); // Does this even belong here any more? --DW // _driver=desktop->GetDisplayDriver(); - _cursorhidden=false; + fCursorHidden=false; Run(); - STRACE(("ServerApp %s:\n",_signature.String())); - STRACE(("\tBApp port: %ld\n",_sender)); - STRACE(("\tReceiver port: %ld\n",_receiver)); + STRACE(("ServerApp %s:\n",fSignature.String())); + STRACE(("\tBApp port: %ld\n",fClientAppPort)); + STRACE(("\tReceiver port: %ld\n",fMessagePort)); } //! Does all necessary teardown for application ServerApp::~ServerApp(void) { - STRACE(("*ServerApp %s:~ServerApp()\n",_signature.String())); + STRACE(("*ServerApp %s:~ServerApp()\n",fSignature.String())); int32 i; - + + WindowBroadcast(AS_QUIT_APP); + // wait for our ServerWindow threads - bool ready = true; + 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()){ + 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()); + + printf("waiting for thread %s\n", sw->Title()); wait_for_thread(tid, &temp); desktop->fLayerLock.Lock(); @@ -150,54 +152,56 @@ printf("waiting for thread %s\n", sw->Title()); break; } } - }while(!ready); + } while(!ready); desktop->fLayerLock.Unlock(); + /* ServerWindow *tempwin; - for(i=0;i<_winlist->CountItems();i++) + for(i=0;iCountItems();i++) { - tempwin=(ServerWindow*)_winlist->ItemAt(i); + tempwin=(ServerWindow*)fSWindowList->ItemAt(i); if(tempwin) delete tempwin; } - _winlist->MakeEmpty(); - delete _winlist; + fSWindowList->MakeEmpty(); + delete fSWindowList; */ + ServerBitmap *tempbmp; - for(i=0;i<_bmplist->CountItems();i++) + for(i=0;iCountItems();i++) { - tempbmp=(ServerBitmap*)_bmplist->ItemAt(i); + tempbmp=(ServerBitmap*)fBitmapList->ItemAt(i); if(tempbmp) delete tempbmp; } - _bmplist->MakeEmpty(); - delete _bmplist; + fBitmapList->MakeEmpty(); + delete fBitmapList; ServerPicture *temppic; - for(i=0;i<_piclist->CountItems();i++) + for(i=0;iCountItems();i++) { - temppic=(ServerPicture*)_piclist->ItemAt(i); + temppic=(ServerPicture*)fPictureList->ItemAt(i); if(temppic) delete temppic; } - _piclist->MakeEmpty(); - delete _piclist; + fPictureList->MakeEmpty(); + delete fPictureList; - delete _applink; - _applink=NULL; - if(_appcursor) - delete _appcursor; + delete fAppLink; + fAppLink=NULL; + if(fAppCursor) + delete fAppCursor; - cursormanager->RemoveAppCursors(_signature.String()); - delete_sem(_lock); + cursormanager->RemoveAppCursors(fSignature.String()); + delete_sem(fLockSem); - STRACE(("#ServerApp %s:~ServerApp()\n",_signature.String())); + STRACE(("#ServerApp %s:~ServerApp()\n",fSignature.String())); // Kill the monitor thread if it exists thread_info info; - if(get_thread_info(_monitor_thread,&info)==B_OK) - kill_thread(_monitor_thread); + if(get_thread_info(fMonitorThreadID,&info)==B_OK) + kill_thread(fMonitorThreadID); } @@ -209,11 +213,11 @@ bool ServerApp::Run(void) { // Unlike a BApplication, a ServerApp is *supposed* to return immediately // when its Run() function is called. - _monitor_thread=spawn_thread(MonitorApp,_signature.String(),B_NORMAL_PRIORITY,this); - if(_monitor_thread==B_NO_MORE_THREADS || _monitor_thread==B_NO_MEMORY) + fMonitorThreadID=spawn_thread(MonitorApp,fSignature.String(),B_NORMAL_PRIORITY,this); + if(fMonitorThreadID==B_NO_MORE_THREADS || fMonitorThreadID==B_NO_MEMORY) return false; - resume_thread(_monitor_thread); + resume_thread(fMonitorThreadID); return true; } @@ -233,18 +237,18 @@ bool ServerApp::Run(void) bool ServerApp::PingTarget(void) { team_info tinfo; - if(get_team_info(_target_id,&tinfo)==B_BAD_TEAM_ID) + if(get_team_info(fClientTeamID,&tinfo)==B_BAD_TEAM_ID) { 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 in PingTarget()!\n",_signature.String()); + printf("PANIC: ServerApp %s could not find the app_server port in PingTarget()!\n",fSignature.String()); return false; } - _applink->SetPort(serverport); - _applink->SetOpCode(AS_DELETE_APP); - _applink->Attach(&_monitor_thread,sizeof(thread_id)); - _applink->Flush(); + fAppLink->SetPort(serverport); + fAppLink->SetOpCode(AS_DELETE_APP); + fAppLink->Attach(&fMonitorThreadID,sizeof(thread_id)); + fAppLink->Flush(); return false; } return true; @@ -256,20 +260,41 @@ bool ServerApp::PingTarget(void) */ void ServerApp::PostMessage(int32 code, size_t size, int8 *buffer) { - write_port(_receiver,code, buffer, size); + write_port(fMessagePort,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); +/*! + \brief Send a simple message to all of the ServerApp's ServerWindows + \param msg The message code to broadcast +*/ +void ServerApp::WindowBroadcast(int32 code) +{ + desktop->fLayerLock.Lock(); + int32 count=desktop->fWinBorderList.CountItems(); + for(int32 i=0; ifWinBorderList.ItemAt(i))->Window(); + sw->PostMessage(code); } + desktop->fLayerLock.Unlock(); +} + +/*! + \brief Send a message to the ServerApp's BApplication + \param msg The message to send +*/ +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()); + printf("PANIC: ServerApp: '%s': can't flatten message in 'SendMessageToClient()'\n", fSignature.String()); delete buffer; } @@ -283,15 +308,15 @@ void ServerApp::SendMessageToClient(const BMessage* msg) const{ */ void ServerApp::Activate(bool value) { - _isactive=value; + fIsActive=value; SetAppCursor(); } //! Sets the cursor to the application cursor, if any. void ServerApp::SetAppCursor(void) { - if(_appcursor) - cursormanager->SetCursor(_appcursor->ID()); + if(fAppCursor) + cursormanager->SetCursor(fAppCursor->ID()); else cursormanager->SetCursor(B_CURSOR_DEFAULT); } @@ -301,23 +326,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; - bool quiting = false; + ServerApp *app = (ServerApp *)data; + PortQueue msgqueue(app->fMessagePort); + PortMessage *msg; + bool quitting = false; - for( ; !quiting; ) + for( ; !quitting; ) { if(!msgqueue.MessagesWaiting()) msgqueue.GetMessagesFromPort(true); else msgqueue.GetMessagesFromPort(false); - msg = msgqueue.GetMessageFromQueue(); + msg = msgqueue.GetMessageFromQueue(); if(!msg) continue; @@ -325,52 +350,53 @@ void ServerApp::SetAppCursor(void) { case AS_QUIT_APP: { - STRACE(("ServerApp %s:Server shutdown notification received\n",app->_signature.String())); -/* + // This message is received only when the app_server is asked to shut down in + // test/debug mode. Of course, if we are testing while using AccelerantDriver, we do + // NOT want to shut down client applications. The server can be quit o in this fashion + // through the driver's interface, such as closing the ViewDriver's window. + + STRACE(("ServerApp %s:Server shutdown notification received\n",app->fSignature.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 if(DISPLAYDRIVER!=HWDRIVER) { - // This message is received from the app_server thread - // because the server was asked to quit. Thus, we - // ask all apps to quit. This is NOT the same as system - // shutdown and will happen only in testing - - BMessage pleaseQuit(_QUIT_); + BMessage pleaseQuit(B_QUIT_REQUESTED); 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; } + // TODO: Fix + // Using this case is a hack. The ServerApp is receiving a message with a '0' code after + // it sends the quit message on server shutdown and I can't find what's sending it. This + // must be found and fixed! + case 0: case B_QUIT_REQUESTED: { - STRACE(("ServerApp %s: B_QUIT_REQUESTED\n",app->_signature.String())); + STRACE(("ServerApp %s: B_QUIT_REQUESTED\n",app->fSignature.String())); // Our BApplication sent us this message when it quit. // We need to ask the app_server to delete our monitor // 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; + quitting=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()); + printf("PANIC: ServerApp %s could not find the app_server port!\n",app->fSignature.String()); break; } - app->_applink->SetPort(serverport); - app->_applink->SetOpCode(AS_DELETE_APP); - app->_applink->Attach(&app->_monitor_thread, sizeof(thread_id)); - app->_applink->Flush(); + app->fAppLink->SetPort(serverport); + app->fAppLink->SetOpCode(AS_DELETE_APP); + app->fAppLink->Attach(&app->fMonitorThreadID, sizeof(thread_id)); + app->fAppLink->Flush(); break; } default: { - STRACE(("ServerApp %s: Got a Message to dispatch\n",app->_signature.String())); + STRACE(("ServerApp %s: Got a Message to dispatch\n",app->fSignature.String())); app->_DispatchMessage(msg); break; } @@ -378,7 +404,8 @@ void ServerApp::SetAppCursor(void) delete msg; } // end for - // clean exit. + + // clean exit. return 0; } @@ -398,7 +425,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) { case AS_UPDATED_CLIENT_FONTLIST: { - STRACE(("ServerApp %s: Acknowledged update of client-side font list\n",_signature.String())); + STRACE(("ServerApp %s: Acknowledged update of client-side font list\n",fSignature.String())); // received when the client-side global font list has been // refreshed @@ -409,47 +436,47 @@ void ServerApp::_DispatchMessage(PortMessage *msg) } case AS_UPDATE_COLORS: { - STRACE(("ServerApp %s: Received global UI color update notification\n",_signature.String())); +/* STRACE(("ServerApp %s: Received global UI color update notification\n",fSignature.String())); ServerWindow *win; BMessage msg(_COLORS_UPDATED); - for(int32 i=0; i<_winlist->CountItems(); i++) + for(int32 i=0; iCountItems(); i++) { - win=(ServerWindow*)_winlist->ItemAt(i); + win=(ServerWindow*)fSWindowList->ItemAt(i); win->Lock(); - win->_winborder->UpdateColors(); + win->fWinBorder->UpdateColors(); win->SendMessageToClient(&msg); win->Unlock(); } - break; +*/ break; } case AS_UPDATE_FONTS: { - STRACE(("ServerApp %s: Received global font update notification\n",_signature.String())); +/* STRACE(("ServerApp %s: Received global font update notification\n",fSignature.String())); ServerWindow *win; BMessage msg(_FONTS_UPDATED); - for(int32 i=0; i<_winlist->CountItems(); i++) + for(int32 i=0; iCountItems(); i++) { - win=(ServerWindow*)_winlist->ItemAt(i); + win=(ServerWindow*)fSWindowList->ItemAt(i); win->Lock(); - win->_winborder->UpdateFont(); + win->fWinBorder->UpdateFont(); win->SendMessageToClient(&msg); win->Unlock(); } - break; +*/ break; } case AS_UPDATE_DECORATOR: { - STRACE(("ServerApp %s: Received decorator update notification\n",_signature.String())); + STRACE(("ServerApp %s: Received decorator update notification\n",fSignature.String())); ServerWindow *win; - for(int32 i=0; i<_winlist->CountItems(); i++) + for(int32 i=0; iCountItems(); i++) { - win=(ServerWindow*)_winlist->ItemAt(i); + win=(ServerWindow*)fSWindowList->ItemAt(i); win->Lock(); - win->_winborder->UpdateDecorator(); + win->fWinBorder->UpdateDecorator(); win->Unlock(); } break; @@ -490,7 +517,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) msg->ReadString(&title); msg->Read(&replyport); - STRACE(("ServerApp %s: Got 'New Window' message, trying to do smething...\n",_signature.String())); + STRACE(("ServerApp %s: Got 'New Window' message, trying to do smething...\n",fSignature.String())); // ServerWindow constructor will reply with port_id of a newly created port new ServerWindow(frame, title, look, feel, flags, this, @@ -499,7 +526,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) // We don't have to do anything here... STRACE(("\nServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n", - _signature.String(),title,frame.left,frame.top,frame.right,frame.bottom)); + fSignature.String(),title,frame.left,frame.top,frame.right,frame.bottom)); delete title; @@ -507,7 +534,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) } case AS_CREATE_BITMAP: { - STRACE(("ServerApp %s: Received BBitmap creation request\n",_signature.String())); + STRACE(("ServerApp %s: Received BBitmap creation request\n",fSignature.String())); // Allocate a bitmap for an application // Attached Data: @@ -541,7 +568,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) ServerBitmap *sbmp=bitmapmanager->CreateBitmap(r,cs,f,bpr,s); STRACE(("ServerApp %s: Create Bitmap (%.1f,%.1f,%.1f,%.1f)\n", - _signature.String(),r.left,r.top,r.right,r.bottom)); + fSignature.String(),r.left,r.top,r.right,r.bottom)); if(sbmp) { @@ -563,7 +590,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) } case AS_DELETE_BITMAP: { - STRACE(("ServerApp %s: received BBitmap delete request\n",_signature.String())); + STRACE(("ServerApp %s: received BBitmap delete request\n",fSignature.String())); // Delete a bitmap's allocated memory // Attached Data: @@ -581,9 +608,9 @@ void ServerApp::_DispatchMessage(PortMessage *msg) ServerBitmap *sbmp=_FindBitmap(bmp_id); if(sbmp) { - STRACE(("ServerApp %s: Deleting Bitmap %ld\n",_signature.String(),bmp_id)); + STRACE(("ServerApp %s: Deleting Bitmap %ld\n",fSignature.String(),bmp_id)); - _bmplist->RemoveItem(sbmp); + fBitmapList->RemoveItem(sbmp); bitmapmanager->DeleteBitmap(sbmp); write_port(replyport,SERVER_TRUE,NULL,0); } @@ -595,34 +622,34 @@ void ServerApp::_DispatchMessage(PortMessage *msg) case AS_CREATE_PICTURE: { // TODO: Implement - STRACE(("ServerApp %s: Create Picture unimplemented\n",_signature.String())); + STRACE(("ServerApp %s: Create Picture unimplemented\n",fSignature.String())); break; } case AS_DELETE_PICTURE: { // TODO: Implement - STRACE(("ServerApp %s: Delete Picture unimplemented\n",_signature.String())); + STRACE(("ServerApp %s: Delete Picture unimplemented\n",fSignature.String())); break; } case AS_CLONE_PICTURE: { // TODO: Implement - STRACE(("ServerApp %s: Clone Picture unimplemented\n",_signature.String())); + STRACE(("ServerApp %s: Clone Picture unimplemented\n",fSignature.String())); break; } case AS_DOWNLOAD_PICTURE: { // TODO; Implement - STRACE(("ServerApp %s: Download Picture unimplemented\n",_signature.String())); + STRACE(("ServerApp %s: Download Picture unimplemented\n",fSignature.String())); break; } case AS_SET_SCREEN_MODE: { - STRACE(("ServerApp %s: Set Screen Mode\n",_signature.String())); + STRACE(("ServerApp %s: Set Screen Mode\n",fSignature.String())); // Attached data // 1) int32 workspace # @@ -642,7 +669,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) } case AS_ACTIVATE_WORKSPACE: { - STRACE(("ServerApp %s: Activate Workspace\n",_signature.String())); + STRACE(("ServerApp %s: Activate Workspace\n",fSignature.String())); // Attached data // 1) int32 workspace index @@ -659,39 +686,39 @@ void ServerApp::_DispatchMessage(PortMessage *msg) // call the CursorManager's version to allow for future expansion case AS_SHOW_CURSOR: { - STRACE(("ServerApp %s: Show Cursor\n",_signature.String())); + STRACE(("ServerApp %s: Show Cursor\n",fSignature.String())); cursormanager->ShowCursor(); - _cursorhidden=false; + fCursorHidden=false; break; } case AS_HIDE_CURSOR: { - STRACE(("ServerApp %s: Hide Cursor\n",_signature.String())); + STRACE(("ServerApp %s: Hide Cursor\n",fSignature.String())); cursormanager->HideCursor(); - _cursorhidden=true; + fCursorHidden=true; break; } case AS_OBSCURE_CURSOR: { - STRACE(("ServerApp %s: Obscure Cursor\n",_signature.String())); + STRACE(("ServerApp %s: Obscure Cursor\n",fSignature.String())); cursormanager->ObscureCursor(); break; } case AS_QUERY_CURSOR_HIDDEN: { - STRACE(("ServerApp %s: Received IsCursorHidden request\n",_signature.String())); + STRACE(("ServerApp %s: Received IsCursorHidden request\n",fSignature.String())); // Attached data // 1) int32 port to reply to int32 replyport; msg->Read(&replyport); - write_port(replyport,(_cursorhidden)?SERVER_TRUE:SERVER_FALSE,NULL,0); + write_port(replyport,(fCursorHidden)?SERVER_TRUE:SERVER_FALSE,NULL,0); break; } case AS_SET_CURSOR_DATA: { - STRACE(("ServerApp %s: SetCursor via cursor data\n",_signature.String())); - // Attached data: 68 bytes of _appcursor data + STRACE(("ServerApp %s: SetCursor via cursor data\n",fSignature.String())); + // Attached data: 68 bytes of fAppCursor data int8 cdata[68]; msg->Read(cdata,68); @@ -700,18 +727,18 @@ void ServerApp::_DispatchMessage(PortMessage *msg) // cursors, we will delete them if there is an existing one. It would // otherwise be easy to crash the server by calling SetCursor a // sufficient number of times - if(_appcursor) - cursormanager->DeleteCursor(_appcursor->ID()); + if(fAppCursor) + cursormanager->DeleteCursor(fAppCursor->ID()); - _appcursor=new ServerCursor(cdata); - _appcursor->SetAppSignature(_signature.String()); - cursormanager->AddCursor(_appcursor); - cursormanager->SetCursor(_appcursor->ID()); + fAppCursor=new ServerCursor(cdata); + fAppCursor->SetAppSignature(fSignature.String()); + cursormanager->AddCursor(fAppCursor); + cursormanager->SetCursor(fAppCursor->ID()); break; } case AS_SET_CURSOR_BCURSOR: { - STRACE(("ServerApp %s: SetCursor via BCursor\n",_signature.String())); + STRACE(("ServerApp %s: SetCursor via BCursor\n",fSignature.String())); // Attached data: // 1) bool flag to send a reply // 2) int32 token ID of the cursor to set @@ -738,9 +765,9 @@ void ServerApp::_DispatchMessage(PortMessage *msg) } case AS_CREATE_BCURSOR: { - STRACE(("ServerApp %s: Create BCursor\n",_signature.String())); + STRACE(("ServerApp %s: Create BCursor\n",fSignature.String())); // Attached data: - // 1) 68 bytes of _appcursor data + // 1) 68 bytes of fAppCursor data // 2) port_id reply port port_id replyport; @@ -749,33 +776,33 @@ void ServerApp::_DispatchMessage(PortMessage *msg) msg->Read(cdata,68); msg->Read(&replyport); - _appcursor=new ServerCursor(cdata); - _appcursor->SetAppSignature(_signature.String()); - cursormanager->AddCursor(_appcursor); + fAppCursor=new ServerCursor(cdata); + fAppCursor->SetAppSignature(fSignature.String()); + cursormanager->AddCursor(fAppCursor); // Synchronous message - BApplication is waiting on the cursor's ID PortLink link(replyport); - link.Attach(_appcursor->ID()); + link.Attach(fAppCursor->ID()); link.Flush(); break; } case AS_DELETE_BCURSOR: { - STRACE(("ServerApp %s: Delete BCursor\n",_signature.String())); + STRACE(("ServerApp %s: Delete BCursor\n",fSignature.String())); // Attached data: // 1) int32 token ID of the cursor to delete int32 ctoken; msg->Read(&ctoken); - if(_appcursor && _appcursor->ID()==ctoken) - _appcursor=NULL; + if(fAppCursor && fAppCursor->ID()==ctoken) + fAppCursor=NULL; cursormanager->DeleteCursor(ctoken); break; } case AS_GET_SCROLLBAR_INFO: { - STRACE(("ServerApp %s: Get ScrollBar info\n",_signature.String())); + STRACE(("ServerApp %s: Get ScrollBar info\n",fSignature.String())); // Attached data: // 1) port_id reply port - synchronous message @@ -792,7 +819,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) } case AS_SET_SCROLLBAR_INFO: { - STRACE(("ServerApp %s: Set ScrollBar info\n",_signature.String())); + STRACE(("ServerApp %s: Set ScrollBar info\n",fSignature.String())); // Attached Data: // 1) scroll_bar_info scroll bar info structure scroll_bar_info sbi; @@ -803,7 +830,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) } case AS_FOCUS_FOLLOWS_MOUSE: { - STRACE(("ServerApp %s: query Focus Follow Mouse in use\n",_signature.String())); + STRACE(("ServerApp %s: query Focus Follow Mouse in use\n",fSignature.String())); // Attached data: // 1) port_id reply port - synchronous message @@ -818,7 +845,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) } case AS_SET_FOCUS_FOLLOWS_MOUSE: { - STRACE(("ServerApp %s: Set Focus Follows Mouse in use\n",_signature.String())); + STRACE(("ServerApp %s: Set Focus Follows Mouse in use\n",fSignature.String())); // Attached Data: // 1) scroll_bar_info scroll bar info structure scroll_bar_info sbi; @@ -829,7 +856,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) } case AS_SET_MOUSE_MODE: { - STRACE(("ServerApp %s: Set Focus Follows Mouse mode\n",_signature.String())); + STRACE(("ServerApp %s: Set Focus Follows Mouse mode\n",fSignature.String())); // Attached Data: // 1) enum mode_mouse FFM mouse mode mode_mouse mmode; @@ -840,7 +867,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) } case AS_GET_MOUSE_MODE: { - STRACE(("ServerApp %s: Get Focus Follows Mouse mode\n",_signature.String())); + STRACE(("ServerApp %s: Get Focus Follows Mouse mode\n",fSignature.String())); // Attached data: // 1) port_id reply port - synchronous message @@ -857,7 +884,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg) } case AS_GET_UI_COLOR: { - STRACE(("ServerApp %s: Get UI color\n",_signature.String())); + STRACE(("ServerApp %s: Get UI color\n",fSignature.String())); RGBColor color; int32 whichcolor; @@ -878,7 +905,8 @@ void ServerApp::_DispatchMessage(PortMessage *msg) } default: { - STRACE(("ServerApp %s received unhandled message code offset %s\n",_signature.String(),MsgCodeToString(msg->Code()))); + STRACE(("ServerApp %s received unhandled message code offset %s\n",fSignature.String(), + MsgCodeToBString(msg->Code()).String())); break; } @@ -893,15 +921,16 @@ void ServerApp::_DispatchMessage(PortMessage *msg) ServerBitmap *ServerApp::_FindBitmap(int32 token) { ServerBitmap *temp; - for(int32 i=0; i<_bmplist->CountItems();i++) + for(int32 i=0; iCountItems();i++) { - temp=(ServerBitmap*)_bmplist->ItemAt(i); + temp=(ServerBitmap*)fBitmapList->ItemAt(i); if(temp && temp->Token()==token) return temp; } return NULL; } -team_id ServerApp::ClientTeamID(){ +team_id ServerApp::ClientTeamID() +{ return fClientTeamID; } diff --git a/src/servers/app/server/ServerApp.h b/src/servers/app/server/ServerApp.h index 02815ff281..59f41e1a62 100644 --- a/src/servers/app/server/ServerApp.h +++ b/src/servers/app/server/ServerApp.h @@ -21,6 +21,7 @@ // // File Name: ServerApp.h // Author: DarkWyrm +// Adi Oanca // Description: Server-side BApplication counterpart // //------------------------------------------------------------------------------ @@ -46,60 +47,60 @@ class ServerCursor; class ServerApp { public: - ServerApp(port_id sendport, port_id rcvport, port_id clientLooperPort, - team_id clientTeamID, int32 handlerID, char *signature); + 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; } - - void Activate(bool value); - bool PingTarget(void); + bool IsActive(void) const { return fIsActive; } + + void Activate(bool value); + bool PingTarget(void); + + void PostMessage(int32 code, size_t size=0,int8 *buffer=NULL); + void WindowBroadcast(int32 code); + + void SendMessageToClient( const BMessage* msg ) const; + void SetAppCursor(void); + + team_id ClientTeamID(); + + FMWList fAppFMWList; - void PostMessage(int32 code, size_t size=0, - int8 *buffer=NULL); - void SendMessageToClient( const BMessage* msg ) const; - - 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, - 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; + + void _DispatchMessage(PortMessage *msg); + ServerBitmap *_FindBitmap(int32 token); + + port_id fClientAppPort, + fMessagePort, + fClientLooperPort; + + BString fSignature; + thread_id fMonitorThreadID; + + team_id fClientTeamID; + + PortLink *fAppLink; + BList *fSWindowList, + *fBitmapList, + *fPictureList; + ServerCursor *fAppCursor; + sem_id fLockSem; + bool fCursorHidden; + bool fIsActive; + int32 fHandlerToken; }; #endif diff --git a/src/servers/app/server/ServerWindow.cpp b/src/servers/app/server/ServerWindow.cpp index 26e07310c3..a895354490 100644 --- a/src/servers/app/server/ServerWindow.cpp +++ b/src/servers/app/server/ServerWindow.cpp @@ -123,39 +123,40 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook, port_id looperPort, port_id replyport, uint32 index, int32 handlerID) { STRACE(("ServerWindow(%s)::ServerWindow()\n",string? string: "NULL")); - _app = winapp; - _title = new BString; + fServerApp = winapp; + if(string) - _title->SetTo(string); - _frame = rect; - _flags = wflags; - _look = wlook; - _feel = wfeel; - _handlertoken = handlerID; - winLooperPort = looperPort; + fTitle.SetTo(string); + fFrame = rect; + fFlags = wflags; + fLook = wlook; + fFeel = wfeel; + fHandlerToken = handlerID; + fClientLooperPort = looperPort; fWorkspaces = index; fClientTeamID = winapp->ClientTeamID(); - _workspace = NULL; - _token = win_token_handler.GetToken(); + fWorkspace = NULL; + fToken = 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()); + // fClientWinPort is the port to which the app awaits messages from the server + fClientWinPort = winport; - ses = new BSession(_receiver, _sender); + // fMessagePort is the port to which the app sends messages for the server + fMessagePort = create_port(30,fTitle.String()); + + fSession= new BSession(fMessagePort, fClientWinPort); - // Send a reply to our window - it is expecting _receiver port. + // Send a reply to our window - it is expecting fMessagePort port. // Temporarily use winlink to save time and memory - _winlink=new PortLink(replyport); + fWinLink=new PortLink(replyport); - _winlink->SetOpCode(AS_CREATE_WINDOW); - _winlink->Attach(_receiver); - _winlink->Flush(); + fWinLink->SetOpCode(AS_CREATE_WINDOW); + fWinLink->Attach(fMessagePort); + fWinLink->Flush(); - _winlink->SetPort(winport); + fWinLink->SetPort(winport); // Wait for top_view data and create ServerWindow's top most Layer int32 vToken; @@ -165,7 +166,7 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook, char* vName = NULL; PortMessage pmsg; - pmsg.ReadFromPort(_receiver); + pmsg.ReadFromPort(fMessagePort); if(pmsg.Code() != AS_LAYER_CREATE_ROOT) debugger("SERVER ERROR: ServerWindow(xxx): NO top_view data received!\n"); @@ -175,56 +176,55 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook, pmsg.Read(&vFlags); pmsg.ReadString(&vName); - top_layer = new Layer(vFrame, vName, vToken, vResizeMode, vFlags, this); + fTopLayer = new Layer(vFrame, vName, vToken, vResizeMode, vFlags, this); delete vName; - cl = top_layer; + cl = fTopLayer; // Create a WindoBorder object for our ServerWindow. - _winborder = new WinBorder(_frame,_title->String(),wlook,wfeel,wflags,this); + fWinBorder = new WinBorder(fFrame,fTitle.String(),wlook,wfeel,wflags,this); // NOTE: this MUST be before the monitor thread is spawned! - desktop->AddWinBorder(_winborder); + desktop->AddWinBorder(fWinBorder); - // 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); + // Spawn our message-monitoring fMonitorThreadID + fMonitorThreadID = spawn_thread(MonitorWin, fTitle.String(), B_NORMAL_PRIORITY, this); + if(fMonitorThreadID != B_NO_MORE_THREADS && fMonitorThreadID != B_NO_MEMORY) + resume_thread(fMonitorThreadID); - STRACE(("ServerWindow %s:\n",_title->String())); + STRACE(("ServerWindow %s:\n",fTitle.String())); STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom)); - STRACE(("\tPort: %ld\n",_receiver)); + STRACE(("\tPort: %ld\n",fMessagePort)); STRACE(("\tWorkspace: %ld\n",index)); } //!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",fTitle.String())); desktop->fGeneralLock.Lock(); - desktop->RemoveWinBorder(_winborder); -printf("SW(%s) Successfuly removed from the desktop\n", _title->String()); - if(ses){ - delete ses; - ses = NULL; + desktop->RemoveWinBorder(fWinBorder); + STRACE(("SW(%s) Successfuly removed from the desktop\n", fTitle.String())); + if(fSession){ + delete fSession; + fSession = NULL; } - if (_winlink){ - delete _winlink; - _winlink = NULL; + if (fWinLink){ + delete fWinLink; + fWinLink = NULL; } - if (_winborder){ - delete _winborder; - _winborder = NULL; + if (fWinBorder){ + delete fWinBorder; + fWinBorder = NULL; } cl = NULL; - if (top_layer) - delete top_layer; + if (fTopLayer) + delete fTopLayer; desktop->fGeneralLock.Unlock(); -printf("#ServerWindow(%s) will exit NOW!!!\n", _title->String()); - delete _title; + STRACE(("#ServerWindow(%s) will exit NOW!!!\n", fTitle.String())); } /*! @@ -235,7 +235,7 @@ printf("#ServerWindow(%s) will exit NOW!!!\n", _title->String()); */ void ServerWindow::RequestDraw(BRect rect) { -STRACE(("ServerWindow %s: Request Draw\n",_title->String())); +STRACE(("ServerWindow %s: Request Draw\n",fTitle.String())); BMessage msg; msg.what = _UPDATE_; @@ -247,20 +247,20 @@ STRACE(("ServerWindow %s: Request Draw\n",_title->String())); //! Requests an update for the entire window void ServerWindow::RequestDraw(void) { - RequestDraw(_frame); + RequestDraw(fFrame); } //! Forces the window border to update its decorator void ServerWindow::ReplaceDecorator(void) { -STRACE(("ServerWindow %s: Replace Decorator\n",_title->String())); - _winborder->UpdateDecorator(); +STRACE(("ServerWindow %s: Replace Decorator\n",fTitle.String())); + fWinBorder->UpdateDecorator(); } //! Requests that the ServerWindow's BWindow quit void ServerWindow::Quit(void) { -STRACE(("ServerWindow %s: Quit\n",_title->String())); +STRACE(("ServerWindow %s: Quit\n",fTitle.String())); BMessage msg; msg.what = B_QUIT_REQUESTED; @@ -268,98 +268,83 @@ STRACE(("ServerWindow %s: Quit\n",_title->String())); SendMessageToClient(&msg); } -/*! - \brief Gets the title for the window - \return The title for the window -*/ -const char *ServerWindow::GetTitle(void) -{ - return _title->String(); -} - -/*! - \brief Gets the window's ServerApp - \return The ServerApp for the window -*/ -ServerApp *ServerWindow::GetApp(void) -{ - return _app; -} - //! Shows the window's WinBorder void ServerWindow::Show(void) { - if(!_winborder->IsHidden()) + if(!fWinBorder->IsHidden()) return; -STRACE(("ServerWindow %s: Show\n",_title->String())); - if(_winborder) + STRACE(("ServerWindow %s: Show\n",fTitle.String())); + if(fWinBorder) { - RootLayer *rl = _winborder->GetRootLayer(); + RootLayer *rl = fWinBorder->GetRootLayer(); int32 wksCount; 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()); + STRACE(("ServerWindow(%s)::Show() - General lock acquired\n", fWinBorder->GetName())); - _winborder->Show(); + rl->fMainLock.Lock(); + STRACE(("ServerWindow(%s)::Show() - Main lock acquired\n", fWinBorder->GetName())); - if ((_feel == B_FLOATING_SUBSET_WINDOW_FEEL || _feel == B_MODAL_SUBSET_WINDOW_FEEL) - && _winborder->MainWinBorder() == NULL) + fWinBorder->Show(); + + if ((fFeel == B_FLOATING_SUBSET_WINDOW_FEEL || fFeel == B_MODAL_SUBSET_WINDOW_FEEL) + && fWinBorder->MainWinBorder() == NULL) { // This window hasn't been added to a normal window subset, // so don't call placement or redrawing methods! goto goOut; } - + wksCount = rl->WorkspaceCount(); for(int32 i = 0; i < wksCount; i++){ if (fWorkspaces & (0x00000001UL << i)){ Workspace *ws = rl->WorkspaceAt(i+1); - ws->BringToFrontANormalWindow(_winborder); - ws->SearchAndSetNewFront(_winborder); - ws->SetFocusLayer(_winborder); + ws->BringToFrontANormalWindow(fWinBorder); + ws->SearchAndSetNewFront(fWinBorder); + ws->SetFocusLayer(fWinBorder); } } goOut: rl->fMainLock.Unlock(); -printf("ServerWindow(%s)::Show() - Main lock released\n", _winborder->GetName()); + STRACE(("ServerWindow(%s)::Show() - Main lock released\n", fWinBorder->GetName())); desktop->fGeneralLock.Unlock(); -printf("ServerWindow(%s)::Show() - General lock released\n", _winborder->GetName()); + STRACE(("ServerWindow(%s)::Show() - General lock released\n", fWinBorder->GetName())); } } //! Hides the window's WinBorder void ServerWindow::Hide(void) { - if(_winborder->IsHidden()) +debugger(""); + if(fWinBorder->IsHidden()) return; -STRACE(("ServerWindow %s: Hide\n",_title->String())); - if(_winborder){ - RootLayer *rl = _winborder->GetRootLayer(); + STRACE(("ServerWindow %s: Hide\n",fTitle.String())); + if(fWinBorder){ + RootLayer *rl = fWinBorder->GetRootLayer(); Workspace *ws = NULL; desktop->fGeneralLock.Lock(); -printf("ServerWindow(%s)::Hide() - General lock acquired\n", _winborder->GetName()); - rl->fMainLock.Lock(); -printf("ServerWindow(%s)::Hide() - Main lock acquired\n", _winborder->GetName()); + STRACE(("ServerWindow(%s)::Hide() - General lock acquired\n", fWinBorder->GetName())); - _winborder->Hide(); + rl->fMainLock.Lock(); + STRACE(("ServerWindow(%s)::Hide() - Main lock acquired\n", fWinBorder->GetName())); + + fWinBorder->Hide(); int32 wksCount= rl->WorkspaceCount(); for(int32 i = 0; i < wksCount; i++){ ws = rl->WorkspaceAt(i+1); - if (ws->FrontLayer() == _winborder){ - ws->HideSubsetWindows(_winborder); + if (ws->FrontLayer() == fWinBorder){ + ws->HideSubsetWindows(fWinBorder); ws->SetFocusLayer(ws->FrontLayer()); } else{ - if (ws->FocusLayer() == _winborder){ - ws->SetFocusLayer(_winborder); + if (ws->FocusLayer() == fWinBorder){ + ws->SetFocusLayer(fWinBorder); } else{ ws->Invalidate(); @@ -367,9 +352,10 @@ printf("ServerWindow(%s)::Hide() - Main lock acquired\n", _winborder->GetName()) } } rl->fMainLock.Unlock(); -printf("ServerWindow(%s)::Hide() - Main lock released\n", _winborder->GetName()); + STRACE(("ServerWindow(%s)::Hide() - Main lock released\n", fWinBorder->GetName())); + desktop->fGeneralLock.Unlock(); -printf("ServerWindow(%s)::Hide() - General lock released\n", _winborder->GetName()); + STRACE(("ServerWindow(%s)::Hide() - General lock released\n", fWinBorder->GetName())); } } @@ -379,8 +365,8 @@ printf("ServerWindow(%s)::Hide() - General lock released\n", _winborder->GetName */ bool ServerWindow::IsHidden(void) { - if(_winborder) - return _winborder->IsHidden(); + if(fWinBorder) + return fWinBorder->IsHidden(); return true; } @@ -423,12 +409,12 @@ void ServerWindow::Zoom(){ */ void ServerWindow::SetFocus(bool value) { -STRACE(("ServerWindow %s: Set Focus to %s\n",_title->String(),value?"true":"false")); - if(_active!=value) +STRACE(("ServerWindow %s: Set Focus to %s\n",fTitle.String(),value?"true":"false")); + if(fIsActive!=value) { - _active=value; - _winborder->SetFocus(value); -// _winborder->RequestDraw(); + fIsActive=value; + fWinBorder->SetFocus(value); +// fWinBorder->RequestDraw(); } } @@ -438,7 +424,7 @@ STRACE(("ServerWindow %s: Set Focus to %s\n",_title->String(),value?"true":"fals */ bool ServerWindow::HasFocus(void) { - return _active; + return fIsActive; } /*! @@ -448,7 +434,7 @@ bool ServerWindow::HasFocus(void) */ void ServerWindow::WorkspaceActivated(int32 workspace, bool active) { -STRACE(("ServerWindow %s: WorkspaceActivated(%ld,%s)\n",_title->String(),workspace,(active)?"active":"inactive")); +STRACE(("ServerWindow %s: WorkspaceActivated(%ld,%s)\n",fTitle.String(),workspace,(active)?"active":"inactive")); BMessage msg; msg.what = B_WORKSPACE_ACTIVATED; @@ -465,7 +451,7 @@ STRACE(("ServerWindow %s: WorkspaceActivated(%ld,%s)\n",_title->String(),workspa */ void ServerWindow::WorkspacesChanged(int32 oldone,int32 newone) { -STRACE(("ServerWindow %s: WorkspacesChanged(%ld,%ld)\n",_title->String(),oldone,newone)); +STRACE(("ServerWindow %s: WorkspacesChanged(%ld,%ld)\n",fTitle.String(),oldone,newone)); BMessage msg; msg.what = B_WORKSPACES_CHANGED; @@ -481,7 +467,7 @@ STRACE(("ServerWindow %s: WorkspacesChanged(%ld,%ld)\n",_title->String(),oldone, */ void ServerWindow::WindowActivated(bool active) { -STRACE(("ServerWindow %s: WindowActivated(%s)\n",_title->String(),(active)?"active":"inactive")); +STRACE(("ServerWindow %s: WindowActivated(%s)\n",fTitle.String(),(active)?"active":"inactive")); BMessage msg; msg.what = B_WINDOW_ACTIVATED; @@ -497,7 +483,7 @@ STRACE(("ServerWindow %s: WindowActivated(%s)\n",_title->String(),(active)?"acti */ void ServerWindow::ScreenModeChanged(const BRect frame, const color_space cspace) { -STRACE(("ServerWindow %s: ScreenModeChanged\n",_title->String())); +STRACE(("ServerWindow %s: ScreenModeChanged\n",fTitle.String())); BMessage msg; msg.what = B_SCREEN_CHANGED; @@ -513,9 +499,9 @@ STRACE(("ServerWindow %s: ScreenModeChanged\n",_title->String())); */ void ServerWindow::SetFrame(const BRect &rect) { -STRACE(("ServerWindow %s: Set Frame to (%.1f,%.1f,%.1f,%.1f)\n",_title->String(), +STRACE(("ServerWindow %s: Set Frame to (%.1f,%.1f,%.1f,%.1f)\n",fTitle.String(), rect.left,rect.top,rect.right,rect.bottom)); - _frame=rect; + fFrame=rect; } /*! @@ -524,7 +510,7 @@ STRACE(("ServerWindow %s: Set Frame to (%.1f,%.1f,%.1f,%.1f)\n",_title->String() */ BRect ServerWindow::Frame(void) { - return _frame; + return fFrame; } /*! @@ -533,15 +519,15 @@ BRect ServerWindow::Frame(void) */ status_t ServerWindow::Lock(void) { -STRACE(("ServerWindow %s: Lock\n",_title->String())); - return (_locker.Lock())?B_OK:B_ERROR; +STRACE(("ServerWindow %s: Lock\n",fTitle.String())); + return (fLocker.Lock())?B_OK:B_ERROR; } //! Unlocks the window void ServerWindow::Unlock(void) { -STRACE(("ServerWindow %s: Unlock\n",_title->String())); - _locker.Unlock(); +STRACE(("ServerWindow %s: Unlock\n",fTitle.String())); + fLocker.Unlock(); } /*! @@ -550,7 +536,7 @@ STRACE(("ServerWindow %s: Unlock\n",_title->String())); */ bool ServerWindow::IsLocked(void) { - return _locker.IsLocked(); + return fLocker.IsLocked(); } void ServerWindow::DispatchMessage(int32 code) @@ -565,13 +551,13 @@ void ServerWindow::DispatchMessage(int32 code) msg.Read(&token); - Layer *current = FindLayer(top_layer, token); + Layer *current = FindLayer(fTopLayer, token); if (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(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_SET_CURRENT_LAYER: Layer name: %s\n", fTitle.String(), cl->_name->String())); break; } case AS_LAYER_CREATE: @@ -583,7 +569,7 @@ TODO: Figure out what Adi did here and convert to PortMessages // us to attach a layer in the tree in the same manner and invalidate // the area in which the new layer resides assuming that it is // visible. - STRACE(("ServerWindow %s: AS_LAYER_CREATE...\n", _title->String())); + STRACE(("ServerWindow %s: AS_LAYER_CREATE...\n", fTitle.String())); Layer *oldCL = cl; int32 token; @@ -629,7 +615,7 @@ TODO: Figure out what Adi did here and convert to PortMessages cl = oldCL; - STRACE(("DONE: ServerWindow %s: Message AS_CREATE_LAYER: Parent: %s, Child: %s\n", _title->String(), cl->_name->String(), name)); + STRACE(("DONE: ServerWindow %s: Message AS_CREATE_LAYER: Parent: %s, Child: %s\n", fTitle.String(), cl->_name->String(), name)); */ break; } @@ -639,7 +625,7 @@ TODO: Figure out what Adi did here and convert to PortMessages // the less taxing operation - we call PruneTree() on the removed // layer, detach the layer itself, delete it, and invalidate the // area assuming that the view was visible when removed - STRACE(("SW %s: AS_LAYER_DELETE(self)...\n", _title->String())); + STRACE(("SW %s: AS_LAYER_DELETE(self)...\n", fTitle.String())); Layer *parent; parent = cl->_parent; @@ -650,7 +636,7 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->PruneTree(); parent->PrintTree(); - STRACE(("DONE: ServerWindow %s: Message AS_DELETE_LAYER: Parent: %s Layer: %s\n", _title->String(), parent->_name->String(), cl->_name->String())); + STRACE(("DONE: ServerWindow %s: Message AS_DELETE_LAYER: Parent: %s Layer: %s\n", fTitle.String(), parent->_name->String(), cl->_name->String())); delete cl; @@ -711,7 +697,7 @@ TODO: Figure out what Adi did here and convert to PortMessages } } - STRACE(("ServerWindow %s: Message AS_LAYER_SET_STATE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_STATE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_SET_FONT_STATE: @@ -770,13 +756,14 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->_layerdata->font.SetFlags(flags); } - STRACE(("ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_GET_STATE: { LayerData *ld; - // these 4 are here because of a compiler warning. Maybe he's right... :-) + + // these 4 are here because of a compiler warning. Maybe he's right... :-) rgb_color hc, lc, vc; // high, low and view colors uint64 patt; // current pattern as a uint64 @@ -787,48 +774,48 @@ TODO: Figure out what Adi did here and convert to PortMessages patt = ld->patt.GetInt64(); // TODO: DW implement such a method in ServerFont class! - _winlink->Attach(0UL /*uint32 ld->font.GetFamAndStyle()*/); - _winlink->Attach(ld->font.Size()); - _winlink->Attach(ld->font.Shear()); - _winlink->Attach(ld->font.Rotation()); - _winlink->Attach(ld->font.Spacing()); - _winlink->Attach(ld->font.Encoding()); - _winlink->Attach(ld->font.Face()); - _winlink->Attach(ld->font.Flags()); + fWinLink->Attach(0UL /*uint32 ld->font.GetFamAndStyle()*/); + fWinLink->Attach(ld->font.Size()); + fWinLink->Attach(ld->font.Shear()); + fWinLink->Attach(ld->font.Rotation()); + fWinLink->Attach(ld->font.Spacing()); + fWinLink->Attach(ld->font.Encoding()); + fWinLink->Attach(ld->font.Face()); + fWinLink->Attach(ld->font.Flags()); - _winlink->Attach(ld->penlocation); - _winlink->Attach(ld->pensize); - _winlink->Attach(hc); - _winlink->Attach(lc); - _winlink->Attach(vc); + fWinLink->Attach(ld->penlocation); + fWinLink->Attach(ld->pensize); + fWinLink->Attach(hc); + fWinLink->Attach(lc); + fWinLink->Attach(vc); // TODO: fix this to use the templatized version - _winlink->Attach(&patt,sizeof(pattern)); - _winlink->Attach(ld->coordOrigin); - _winlink->Attach((uint8)(ld->draw_mode)); - _winlink->Attach((uint8)(ld->lineCap)); - _winlink->Attach((uint8)(ld->lineJoin)); - _winlink->Attach(ld->miterLimit); - _winlink->Attach((uint8)(ld->alphaSrcMode)); - _winlink->Attach((uint8)(ld->alphaFncMode)); - _winlink->Attach(ld->scale); - _winlink->Attach(ld->fontAliasing); + fWinLink->Attach(&patt,sizeof(pattern)); + fWinLink->Attach(ld->coordOrigin); + fWinLink->Attach((uint8)(ld->draw_mode)); + fWinLink->Attach((uint8)(ld->lineCap)); + fWinLink->Attach((uint8)(ld->lineJoin)); + fWinLink->Attach(ld->miterLimit); + fWinLink->Attach((uint8)(ld->alphaSrcMode)); + fWinLink->Attach((uint8)(ld->alphaFncMode)); + fWinLink->Attach(ld->scale); + fWinLink->Attach(ld->fontAliasing); int32 noOfRects = 0; if (ld->clippReg) noOfRects = ld->clippReg->CountRects(); - _winlink->Attach(noOfRects); + fWinLink->Attach(noOfRects); for(int i = 0; i < noOfRects; i++){ - _winlink->Attach(ld->clippReg->RectAt(i)); + fWinLink->Attach(ld->clippReg->RectAt(i)); } - _winlink->Attach(cl->_frame.left); - _winlink->Attach(cl->_frame.top); - _winlink->Attach(cl->_frame.OffsetToCopy(cl->_boundsLeftTop)); - _winlink->Flush(); + fWinLink->Attach(cl->_frame.left); + fWinLink->Attach(cl->_frame.top); + fWinLink->Attach(cl->_frame.OffsetToCopy(cl->_boundsLeftTop)); + fWinLink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_STATE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_STATE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_MOVETO: @@ -840,7 +827,7 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->MoveBy(x, y); - STRACE(("ServerWindow %s: Message AS_LAYER_MOVETO: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_MOVETO: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_RESIZETO: @@ -849,22 +836,23 @@ TODO: Figure out what Adi did here and convert to PortMessages msg.Read(&newWidth); msg.Read(&newHeight); - /* TODO: check for minimum alowed. WinBorder should provide such - * a method, based on its decorator. - */ + + // TODO: check for minimum alowed. WinBorder should provide such + // a method, based on its decorator. + cl->ResizeBy(newWidth, newHeight); - STRACE(("ServerWindow %s: Message AS_LAYER_RESIZETO: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_RESIZETO: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_GET_COORD: { - _winlink->Attach(cl->_frame.left); - _winlink->Attach(cl->_frame.top); - _winlink->Attach(cl->_frame.OffsetToCopy(cl->_boundsLeftTop)); - _winlink->Flush(); + fWinLink->Attach(cl->_frame.left); + fWinLink->Attach(cl->_frame.top); + fWinLink->Attach(cl->_frame.OffsetToCopy(cl->_boundsLeftTop)); + fWinLink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_SET_ORIGIN: @@ -876,22 +864,22 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->_layerdata->coordOrigin.Set(x, y); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_ORIGIN: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_ORIGIN: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_GET_ORIGIN: { - _winlink->Attach(cl->_layerdata->coordOrigin); - _winlink->Flush(); + fWinLink->Attach(cl->_layerdata->coordOrigin); + fWinLink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_RESIZE_MODE: { msg.Read(&(cl->_resize_mode)); - STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_MODE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_MODE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_CURSOR: @@ -902,38 +890,39 @@ 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(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_CURSOR: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_SET_FLAGS: { msg.Read(&(cl->_flags)); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_FLAGS: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_FLAGS: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_HIDE: { cl->Hide(); - STRACE(("ServerWindow %s: Message AS_LAYER_HIDE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_HIDE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_SHOW: { cl->Show(); - STRACE(("ServerWindow %s: Message AS_LAYER_SHOW: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SHOW: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_SET_LINE_MODE: { int8 lineCap, lineJoin; -/* TODO: speak with DW! Shouldn't we lock before modifying certain memebers? - * Because redraw code might use an updated value instead of one for witch - * it was called. e.g.: different lineCap or lineJoin. Strange result - * would appear. - */ + + // TODO: speak with DW! Shouldn't we lock before modifying certain memebers? + // Because redraw code might use an updated value instead of one for witch + // it was called. e.g.: different lineCap or lineJoin. Strange result + // would appear. + msg.Read(&lineCap); msg.Read(&lineJoin); msg.Read(&(cl->_layerdata->miterLimit)); @@ -941,17 +930,17 @@ TODO: Figure out what Adi did here and convert to PortMessages 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(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_LINE_MODE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_GET_LINE_MODE: { - _winlink->Attach((int8)(cl->_layerdata->lineCap)); - _winlink->Attach((int8)(cl->_layerdata->lineJoin)); - _winlink->Attach(cl->_layerdata->miterLimit); - _winlink->Flush(); + fWinLink->Attach((int8)(cl->_layerdata->lineCap)); + fWinLink->Attach((int8)(cl->_layerdata->lineJoin)); + fWinLink->Attach(cl->_layerdata->miterLimit); + fWinLink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_PUSH_STATE: @@ -962,13 +951,13 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->RebuildFullRegion(); - STRACE(("ServerWindow %s: Message AS_LAYER_PUSH_STATE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_PUSH_STATE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_POP_STATE: { 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())); + STRACE(("WARNING: SW(%s): User called BView(%s)::PopState(), but there is NO state on stack!\n", fTitle.String(), cl->_name->String())); break; } @@ -978,14 +967,14 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->RebuildFullRegion(); - STRACE(("ServerWindow %s: Message AS_LAYER_POP_STATE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_POP_STATE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_SET_SCALE: { msg.Read(&(cl->_layerdata->scale)); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_GET_SCALE: @@ -996,10 +985,10 @@ TODO: Figure out what Adi did here and convert to PortMessages while((ld = ld->prevState)) scale *= ld->scale; - _winlink->Attach(scale); - _winlink->Flush(); + fWinLink->Attach(scale); + fWinLink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_SET_PEN_LOC: @@ -1011,30 +1000,30 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->_layerdata->penlocation.Set(x, y); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_LOC: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_GET_PEN_LOC: { - _winlink->Attach(cl->_layerdata->penlocation); - _winlink->Flush(); + fWinLink->Attach(cl->_layerdata->penlocation); + fWinLink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_SET_PEN_SIZE: { msg.Read(&(cl->_layerdata->pensize)); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_GET_PEN_SIZE: { - _winlink->Attach(cl->_layerdata->pensize); - _winlink->Flush(); + fWinLink->Attach(cl->_layerdata->pensize); + fWinLink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_SET_HIGH_COLOR: @@ -1045,7 +1034,7 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->_layerdata->highcolor.SetColor(c); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_HIGH_COLOR: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_HIGH_COLOR: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_SET_LOW_COLOR: @@ -1056,7 +1045,7 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->_layerdata->lowcolor.SetColor(c); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_LOW_COLOR: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_LOW_COLOR: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_SET_VIEW_COLOR: @@ -1067,7 +1056,7 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->_layerdata->viewcolor.SetColor(c); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_VIEW_COLOR: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_VIEW_COLOR: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_GET_COLORS: @@ -1078,12 +1067,12 @@ TODO: Figure out what Adi did here and convert to PortMessages lowColor = cl->_layerdata->lowcolor.GetColor32(); viewColor = cl->_layerdata->viewcolor.GetColor32(); - _winlink->Attach(highColor); - _winlink->Attach(lowColor); - _winlink->Attach(viewColor); - _winlink->Flush(); + fWinLink->Attach(highColor); + fWinLink->Attach(lowColor); + fWinLink->Attach(viewColor); + fWinLink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_COLORS: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_COLORS: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_SET_BLEND_MODE: @@ -1096,16 +1085,16 @@ TODO: Figure out what Adi did here and convert to PortMessages 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(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_GET_BLEND_MODE: { - _winlink->Attach((int8)(cl->_layerdata->alphaSrcMode)); - _winlink->Attach((int8)(cl->_layerdata->alphaFncMode)); - _winlink->Flush(); + fWinLink->Attach((int8)(cl->_layerdata->alphaSrcMode)); + fWinLink->Attach((int8)(cl->_layerdata->alphaFncMode)); + fWinLink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_SET_DRAW_MODE: @@ -1116,27 +1105,27 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->_layerdata->draw_mode = (drawing_mode)drawingMode; - STRACE(("ServerWindow %s: Message AS_LAYER_SET_DRAW_MODE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_GET_DRAW_MODE: { - _winlink->Attach((int8)(cl->_layerdata->draw_mode)); - _winlink->Flush(); + fWinLink->Attach((int8)(cl->_layerdata->draw_mode)); + fWinLink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_PRINT_ALIASING: { msg.Read(&(cl->_layerdata->fontAliasing)); - STRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_CLIP_TO_PICTURE: { -// TODO: watch out for the coordinate system + // TODO: watch out for the coordinate system int32 pictureToken; BPoint where; @@ -1157,14 +1146,15 @@ TODO: Figure out what Adi did here and convert to PortMessages // search for a picture with the specified token. ServerPicture *sp = NULL; int32 i = 0; - for(;;){ - sp = static_cast(cl->_serverwin->_app->_piclist->ItemAt(i++)); + while(1) + { + sp=static_cast(cl->_serverwin->fServerApp->fPictureList->ItemAt(i++)); if (!sp) break; if(sp->GetToken() == pictureToken){ // cl->clipToPicture = sp; -// TODO: increase that picture's reference count.(~ allocate a picture) + // TODO: increase that picture's reference count.(~ allocate a picture) break; } } @@ -1199,7 +1189,7 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->Invalidate(reg); } - STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_CLIP_TO_INVERSE_PICTURE: @@ -1214,8 +1204,9 @@ TODO: Figure out what Adi did here and convert to PortMessages ServerPicture *sp = NULL; int32 i = 0; - for(;;){ - sp = static_cast(cl->_serverwin->_app->_piclist->ItemAt(i++)); + while(1) + { + sp= static_cast(cl->_serverwin->fServerApp->fPictureList->ItemAt(i++)); if (!sp) break; @@ -1238,7 +1229,7 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->RequestDraw(cl->clipToPicture->Frame()); } - STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_GET_CLIP_REGION: @@ -1259,15 +1250,15 @@ TODO: Figure out what Adi did here and convert to PortMessages reg.IntersectWith(ld->clippReg); noOfRects = reg.CountRects(); - _winlink->Attach(noOfRects); + fWinLink->Attach(noOfRects); for(int i = 0; i < noOfRects; i++){ - _winlink->Attach(reg.RectAt(i)); + fWinLink->Attach(reg.RectAt(i)); } - _winlink->Flush(); + fWinLink->Flush(); - STRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_SET_CLIP_REGION: @@ -1292,7 +1283,7 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->RequestDraw(cl->clipToPicture->Frame()); - STRACE(("ServerWindow %s: Message AS_LAYER_SET_CLIP_REGION: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_SET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } @@ -1307,7 +1298,7 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->RequestDraw(invalRect); - STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } case AS_LAYER_INVAL_REGION: @@ -1328,7 +1319,7 @@ TODO: Figure out what Adi did here and convert to PortMessages cl->RequestDraw(invalReg.Frame()); - STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",_title->String(), cl->_name->String())); + STRACE(("ServerWindow %s: Message AS_LAYER_INVAL_RECT: Layer: %s\n",fTitle.String(), cl->_name->String())); break; } @@ -1341,50 +1332,50 @@ TODO: Figure out what Adi did here and convert to PortMessages // Received when a window deletes its internal top view // TODO: Implement - STRACE(("ServerWindow %s: Message Delete_Layer_Root unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Delete_Layer_Root unimplemented\n",fTitle.String())); break; } case AS_SHOW_WINDOW: { - STRACE(("ServerWindow %s: Message AS_SHOW\n",_title->String())); + STRACE(("ServerWindow %s: Message AS_SHOW\n",fTitle.String())); Show(); break; } case AS_HIDE_WINDOW: { - STRACE(("ServerWindow %s: Message AS_HIDE\n",_title->String())); + STRACE(("ServerWindow %s: Message AS_HIDE\n",fTitle.String())); Hide(); break; } case AS_SEND_BEHIND: { // TODO: Implement - STRACE(("ServerWindow %s: Message Send_Behind unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Send_Behind unimplemented\n",fTitle.String())); break; } case AS_ENABLE_UPDATES: { // TODO: Implement - STRACE(("ServerWindow %s: Message Enable_Updates unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Enable_Updates unimplemented\n",fTitle.String())); break; } case AS_DISABLE_UPDATES: { // TODO: Implement - STRACE(("ServerWindow %s: Message Disable_Updates unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Disable_Updates unimplemented\n",fTitle.String())); break; } case AS_NEEDS_UPDATE: { // TODO: Implement - STRACE(("ServerWindow %s: Message Needs_Update unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Needs_Update unimplemented\n",fTitle.String())); break; } case AS_WINDOW_TITLE: { // TODO: Implement - STRACE(("ServerWindow %s: Message Set_Title unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Set_Title unimplemented\n",fTitle.String())); break; } case AS_ADD_TO_SUBSET: @@ -1393,22 +1384,22 @@ TODO: Figure out what Adi did here and convert to PortMessages int32 mainToken; team_id teamID; - ses->ReadInt32(&mainToken); - ses->ReadData(&teamID, sizeof(team_id)); + fSession->ReadInt32(&mainToken); + fSession->ReadData(&teamID, sizeof(team_id)); wb = desktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID); if(wb){ - ses->WriteInt32(SERVER_TRUE); - ses->Sync(); + fSession->WriteInt32(SERVER_TRUE); + fSession->Sync(); - _winborder->AddToSubsetOf(wb); + fWinBorder->AddToSubsetOf(wb); } else{ - ses->WriteInt32(SERVER_FALSE); - ses->Sync(); + fSession->WriteInt32(SERVER_FALSE); + fSession->Sync(); } // TODO: Implement - STRACE(("\n\n\n\n\n\nServerWindow %s: Message ADD_TO_SUBSET unimplemented\n",_title->String())); + STRACE(("\n\n\n\n\n\nServerWindow %s: Message ADD_TO_SUBSET unimplemented\n",fTitle.String())); break; } case AS_REM_FROM_SUBSET: @@ -1417,105 +1408,105 @@ TODO: Figure out what Adi did here and convert to PortMessages int32 mainToken; team_id teamID; - ses->ReadInt32(&mainToken); - ses->ReadData(&teamID, sizeof(team_id)); + fSession->ReadInt32(&mainToken); + fSession->ReadData(&teamID, sizeof(team_id)); wb = desktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID); if(wb){ - ses->WriteInt32(SERVER_TRUE); - ses->Sync(); + fSession->WriteInt32(SERVER_TRUE); + fSession->Sync(); - _winborder->RemoveFromSubsetOf(wb); + fWinBorder->RemoveFromSubsetOf(wb); } else{ - ses->WriteInt32(SERVER_FALSE); - ses->Sync(); + fSession->WriteInt32(SERVER_FALSE); + fSession->Sync(); } // TODO: Implement - STRACE(("ServerWindow %s: Message Remove_From_Subset unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Remove_From_Subset unimplemented\n",fTitle.String())); break; } case AS_SET_LOOK: { // TODO: Implement - STRACE(("ServerWindow %s: Message Set_Look unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Set_Look unimplemented\n",fTitle.String())); break; } case AS_SET_FLAGS: { // TODO: Implement - STRACE(("ServerWindow %s: Message Set_Flags unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Set_Flags unimplemented\n",fTitle.String())); break; } case AS_SET_FEEL: { // TODO: Implement - STRACE(("ServerWindow %s: Message Set_Feel unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Set_Feel unimplemented\n",fTitle.String())); break; } case AS_SET_ALIGNMENT: { // TODO: Implement - STRACE(("ServerWindow %s: Message Set_Alignment unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Set_Alignment unimplemented\n",fTitle.String())); break; } case AS_GET_ALIGNMENT: { // TODO: Implement - STRACE(("ServerWindow %s: Message Get_Alignment unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Get_Alignment unimplemented\n",fTitle.String())); break; } case AS_GET_WORKSPACES: { // TODO: Implement - STRACE(("ServerWindow %s: Message Get_Workspaces unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Get_Workspaces unimplemented\n",fTitle.String())); break; } case AS_SET_WORKSPACES: { // TODO: Implement - STRACE(("ServerWindow %s: Message Set_Workspaces unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Set_Workspaces unimplemented\n",fTitle.String())); break; } case AS_WINDOW_RESIZE: { // TODO: Implement - STRACE(("ServerWindow %s: Message Resize unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Resize unimplemented\n",fTitle.String())); break; } case B_MINIMIZE: { // TODO: Implement - STRACE(("ServerWindow %s: Message Minimize unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Minimize unimplemented\n",fTitle.String())); break; } case B_WINDOW_ACTIVATED: { // TODO: Implement - STRACE(("ServerWindow %s: Message Window_Activated unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Window_Activated unimplemented\n",fTitle.String())); break; } case B_ZOOM: { // TODO: Implement - STRACE(("ServerWindow %s: Message Zoom unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Zoom unimplemented\n",fTitle.String())); break; } case B_WINDOW_MOVE_TO: { // TODO: Implement - STRACE(("ServerWindow %s: Message Move_To unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Move_To unimplemented\n",fTitle.String())); break; } case B_WINDOW_MOVE_BY: { // TODO: Implement - STRACE(("ServerWindow %s: Message Move_By unimplemented\n",_title->String())); + STRACE(("ServerWindow %s: Message Move_By unimplemented\n",fTitle.String())); break; } default: { - printf("ServerWindow %s received unexpected code - message offset %lx\n",_title->String(), msg.Code() - SERVER_TRUE); + printf("ServerWindow %s received unexpected code - message offset %lx\n",fTitle.String(), msg.Code() - SERVER_TRUE); break; } } @@ -1543,8 +1534,8 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) if (IsHidden()) return; - WindowClipRegion.Set(_winborder->Frame()); - sibling = _winborder->UpperSibling(); + WindowClipRegion.Set(fWinBorder->Frame()); + sibling = fWinBorder->UpperSibling(); while (sibling) { WindowClipRegion.Exclude(sibling->Frame()); @@ -1562,7 +1553,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) code = read_from_buffer(&msgbuffer); view_token = read_from_buffer(&msgbuffer); //TODO: fix! - layer = NULL;//_workspace->GetRoot()->FindLayer(view_token); + layer = NULL;//fWorkspace->GetRoot()->FindLayer(view_token); if (layer) { layerdata = layer->GetLayerData(); @@ -1573,7 +1564,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) else { layerdata = NULL; - printf("ServerWindow %s received invalid view token %lx",_title->String(),view_token); + STRACE(("ServerWindow %s received invalid view token %lx",fTitle.String(),view_token)); } switch (code) { @@ -1592,7 +1583,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -1612,7 +1603,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -1632,7 +1623,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -1654,12 +1645,12 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) pattern = read_pattern_from_buffer(&msgbuffer); //BRect rect(left,top,right,bottom); //if (layerdata) - //_app->_driver->StrokeArc(rect,angle,span,layerdata,pattern); + //fServerApp->_driver->StrokeArc(rect,angle,span,layerdata,pattern); sizeRemaining -= AS_STROKE_ARC_MSG_SIZE; } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -1680,13 +1671,13 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) } pattern = read_pattern_from_buffer(&msgbuffer); //if (layerdata) - //_app->_driver->StrokeBezier(pts,layerdata,pattern); + //fServerApp->_driver->StrokeBezier(pts,layerdata,pattern); delete[] pts; sizeRemaining -= AS_STROKE_BEZIER_MSG_SIZE; } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -1705,12 +1696,12 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) pattern = read_pattern_from_buffer(&msgbuffer); //BRect rect(left,top,right,bottom); //if (layerdata) - //_app->_driver->StrokeEllipse(rect,layerdata,pattern); + //fServerApp->_driver->StrokeEllipse(rect,layerdata,pattern); sizeRemaining -= AS_STROKE_ELLIPSE_MSG_SIZE; } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -1730,12 +1721,12 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) //BPoint p1(x1,y1); //BPoint p2(x2,y2); //if (layerdata) - //_app->_driver->StrokeLine(p1,p2,layerdata,pattern); + //fServerApp->_driver->StrokeLine(p1,p2,layerdata,pattern); sizeRemaining -= AS_STROKE_LINE_MSG_SIZE; } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -1764,12 +1755,12 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) pattern = read_pattern_from_buffer(&msgbuffer); //BRect rect(left,top,right,bottom); //if (layerdata) - //_app->_driver->StrokeRect(rect,layerdata,pattern); + //fServerApp->_driver->StrokeRect(rect,layerdata,pattern); sizeRemaining -= AS_STROKE_RECT_MSG_SIZE; } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -1790,12 +1781,12 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) pattern = read_pattern_from_buffer(&msgbuffer); //BRect rect(left,top,right,bottom); //if (layerdata) - //_app->_driver->StrokeRoundRect(rect,xrad,yrad,layerdata,pattern); + //fServerApp->_driver->StrokeRoundRect(rect,xrad,yrad,layerdata,pattern); sizeRemaining -= AS_STROKE_ROUNDRECT_MSG_SIZE; } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -1827,13 +1818,13 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) pattern = read_pattern_from_buffer(&msgbuffer); //BRect rect(left,top,right,bottom); //if (layerdata) - //_app->_driver->StrokeTriangle(pts,rect,layerdata,pattern); + //fServerApp->_driver->StrokeTriangle(pts,rect,layerdata,pattern); delete[] pts; sizeRemaining -= AS_STROKE_TRIANGLE_MSG_SIZE; } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -1854,12 +1845,12 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) pattern = read_pattern_from_buffer(&msgbuffer); //BRect rect(left,top,right,bottom); //if (layerdata) - //_app->_driver->FillArc(rect,angle,span,layerdata,pattern); + //fServerApp->_driver->FillArc(rect,angle,span,layerdata,pattern); sizeRemaining -= AS_FILL_ARC_MSG_SIZE; } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -1880,13 +1871,13 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) } pattern = read_pattern_from_buffer(&msgbuffer); //if (layerdata) - //_app->_driver->FillBezier(pts,layerdata,pattern); + //fServerApp->_driver->FillBezier(pts,layerdata,pattern); delete[] pts; sizeRemaining -= AS_FILL_BEZIER_MSG_SIZE; } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -1905,12 +1896,12 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) pattern = read_pattern_from_buffer(&msgbuffer); //BRect rect(left,top,right,bottom); //if (layerdata) - //_app->_driver->FillEllipse(rect,layerdata,pattern); + //fServerApp->_driver->FillEllipse(rect,layerdata,pattern); sizeRemaining -= AS_FILL_ELLIPSE_MSG_SIZE; } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -1935,19 +1926,19 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) BRect rect(left,top,right,bottom); if (layerdata && numRects) if (numRects == 1) - _app->_driver->FillRect(rect,layerdata,pattern); + fServerApp->_driver->FillRect(rect,layerdata,pattern); else { int i; for (i=0; i_driver->FillRect(LayerClipRegion.RectAt(i),layerdata,pattern); + fServerApp->_driver->FillRect(LayerClipRegion.RectAt(i),layerdata,pattern); } */ sizeRemaining -= AS_FILL_RECT_MSG_SIZE; } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -1973,12 +1964,12 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) pattern = read_pattern_from_buffer(&msgbuffer); //BRect rect(left,top,right,bottom); //if (layerdata) - //_app->_driver->FillRoundRect(rect,xrad,yrad,layerdata,pattern); + //fServerApp->_driver->FillRoundRect(rect,xrad,yrad,layerdata,pattern); sizeRemaining -= AS_FILL_ROUNDRECT_MSG_SIZE; } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -2010,13 +2001,13 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) pattern = read_pattern_from_buffer(&msgbuffer); //BRect rect(left,top,right,bottom); //if (layerdata) - //_app->_driver->FillTriangle(pts,rect,layerdata,pattern); + //fServerApp->_driver->FillTriangle(pts,rect,layerdata,pattern); delete[] pts; sizeRemaining -= AS_FILL_TRIANGLE_MSG_SIZE; } else { - printf("ServerWindow %s received truncated graphics code %lx",_title->String(),code); + STRACE(("ServerWindow %s received truncated graphics code %lx",fTitle.String(),code)); sizeRemaining = 0; } break; @@ -2054,7 +2045,7 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) default: { sizeRemaining -= sizeof(int32); - printf("ServerWindow %s received unexpected graphics code %lx",_title->String(),code); + printf("ServerWindow %s received unexpected graphics code %lx",fTitle.String(),code); break; } } @@ -2071,30 +2062,49 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) int32 ServerWindow::MonitorWin(void *data) { ServerWindow *win = (ServerWindow *)data; - bool quiting = false; + bool quitting = false; int32 code; - for( ; !quiting; ) + while(!quitting) { code = 0; - win->ses->ReadInt32(&code); - switch(code){ + win->fSession->ReadInt32(&code); + switch(code) + { + case AS_QUIT_APP: + { + // Received when the app_server is told to shut down + + STRACE(("ServerWindow %s received server shutdown notification\n",win->Title())); + if(DISPLAYDRIVER!=HWDRIVER) + { + BMessage pleaseQuit(B_QUIT_REQUESTED); + win->SendMessageToClient(&pleaseQuit); + } + break; + } + case 0: + { // this means the client has been killed - case 0:{ + + // TODO: A message code should *never* be 0. The source sending this message + // needs to be changed to something like AS_CLIENT_DEAD or something. + STRACE(("ServerWindow %s received '0' message code\n",win->Title())); - quiting = true; + quitting = true; delete win; break; } - case B_QUIT_REQUESTED:{ + case B_QUIT_REQUESTED: + { STRACE(("ServerWindow %s received Quit request\n",win->Title())); - quiting = true; + quitting = true; delete win; break; } - default:{ - printf("SW(%s): got a message to dispatch...\n",win->Title()); -// snooze(3000000); + default: + { + STRACE(("ServerWindow %s: got a message to dispatch\n",win->Title())); win->DispatchMessage(code); break; } @@ -2111,13 +2121,14 @@ 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. + //TODO: resolve Layer *root=NULL;//GetRootLayer(CurrentWorkspace(),ActiveScreen()); - WinBorder *_winborder; + WinBorder *fWinBorder; // activeborder is used to remember windows when resizing/moving windows // or sliding a tab @@ -2155,11 +2166,11 @@ void ServerWindow::HandleMouseEvent(PortMessage *msg) // BPoint pt(x,y); // If we have clicked on a window, - active_winborder = _winborder = NULL; - if(_winborder) + active_winborder = fWinBorder = NULL; + if(fWinBorder) { - mousewin=_winborder->Window(); - _winborder->MouseDown((int8*)msg->Buffer()); + mousewin=fWinBorder->Window(); + fWinBorder->MouseDown((int8*)msg->Buffer()); } break; } @@ -2184,20 +2195,20 @@ void ServerWindow::HandleMouseEvent(PortMessage *msg) //TODO: resolve // BPoint pt(x,y); -/* set_is_sliding_tab(false); - set_is_moving_window(false); - set_is_resizing_window(false); -*/ +// set_is_sliding_tab(false); +// set_is_moving_window(false); +// set_is_resizing_window(false); + //TODO: resolve - _winborder = NULL;//WindowContainsPoint(pt); + fWinBorder = NULL;//WindowContainsPoint(pt); active_winborder=NULL; - if(_winborder) + if(fWinBorder) { - mousewin=_winborder->Window(); + mousewin=fWinBorder->Window(); // Eventually, we will build in MouseUp messages with buttons specified // For now, we just "assume" no mouse specification with a 0. - _winborder->MouseUp((int8*)msg->Buffer()); + fWinBorder->MouseUp((int8*)msg->Buffer()); } break; } @@ -2218,28 +2229,29 @@ 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 +// { +// fWinBorder = WindowContainsPoint(pt); +// if(fWinBorder) +// { +// mousewin=fWinBorder->Window(); +// fWinBorder->MouseMoved((int8*)msg->Buffer()); +// } +// } + break; } default: { break; } } +*/ } /*! @@ -2249,21 +2261,33 @@ void ServerWindow::HandleMouseEvent(PortMessage *msg) */ void ServerWindow::HandleKeyEvent(int32 code, int8 *buffer) { +/* STRACE_KEY(("ServerWindow::HandleKeyEvent unimplemented\n")); -/* ServerWindow *keywin=NULL; + ServerWindow *keywin=NULL; // Dispatch the key event to the active window keywin=GetActiveWindow(); if(keywin) { keywin->Lock(); - keywin->_winlink->SetOpCode(code); - keywin->_winlink + keywin->fWinLink->SetOpCode(code); + keywin->fWinLink keywin->Unlock(); } */ } +/*! + \brief Send a message to the ServerWindow + \param code ID code of the message to post + \param size size of the data buffer + \param buffer Any attached data +*/ +void ServerWindow::PostMessage(int32 code, size_t size, int8 *buffer) +{ + write_port(fMessagePort,code, buffer, size); +} + /*! \brief Returns the Workspace object to which the window belongs @@ -2271,8 +2295,8 @@ STRACE_KEY(("ServerWindow::HandleKeyEvent unimplemented\n")); */ Workspace *ServerWindow::GetWorkspace(void) { + //TODO: resolve if(fWorkspaces==B_ALL_WORKSPACES) -//TODO: resolve return NULL;//fWorkspaces->GetScreen()->GetActiveWorkspace(); return NULL; @@ -2284,24 +2308,23 @@ Workspace *ServerWindow::GetWorkspace(void) */ void ServerWindow::SetWorkspace(Workspace *wkspc) { -STRACE(("ServerWindow %s: Set Workspace\n",_title->String())); - _workspace=wkspc; +STRACE(("ServerWindow %s: Set Workspace\n",fTitle.String())); + fWorkspace=wkspc; } -//----------------------------------------------------------------------- - Layer* ServerWindow::FindLayer(const Layer* start, int32 token) const { if(!start) return NULL; - // see if we're looking for 'start' + // see if we're looking for 'start' if(start->_view_token == token) return const_cast(start); - Layer *c = start->_topchild; //c = short for: current + Layer *c = start->_topchild; //c = short for: current if(c != NULL) - while(true){ + while(true) + { // action block { if(c->_view_token == token) @@ -2309,21 +2332,25 @@ Layer* ServerWindow::FindLayer(const Layer* start, int32 token) const } // go deep - if( c->_topchild){ + if( c->_topchild) + { c = c->_topchild; } - // go right or up + // go right or up else - // go right - if(c->_lowersibling){ + // go right + if(c->_lowersibling) + { c = c->_lowersibling; } - // go up - else{ - while(!c->_parent->_lowersibling && c->_parent != start){ + // go up + else + { + while(!c->_parent->_lowersibling && c->_parent != start) + { c = c->_parent; } - // that enough! We've reached the start layer. + // that enough! We've reached the start layer. if(c->_parent == start) break; @@ -2334,25 +2361,22 @@ Layer* ServerWindow::FindLayer(const Layer* start, int32 token) const return NULL; } -//----------------------------------------------------------------------- - -void ServerWindow::SendMessageToClient(const BMessage* msg) const{ +void ServerWindow::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(winLooperPort, msg->what, buffer, size); - } + + if (msg->Flatten(buffer, size) == B_OK) + write_port(fClientLooperPort, msg->what, buffer, size); else - printf("PANIC: SW: '%s': can't flatten message in 'SendMessageToClient()'\n", _title->String()); + printf("PANIC: ServerWindow %s: can't flatten message in 'SendMessageToClient()'\n", fTitle.String()); delete buffer; } -//----------------------------------------------------------------------- - /*! \brief Handles window activation stuff. Called by Desktop functions */ diff --git a/src/servers/app/server/ServerWindow.h b/src/servers/app/server/ServerWindow.h index 3ba83c1966..f667a2e290 100644 --- a/src/servers/app/server/ServerWindow.h +++ b/src/servers/app/server/ServerWindow.h @@ -65,114 +65,104 @@ 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 ReplaceDecorator(void); + void Quit(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 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); + void SetFrame(const BRect &rect); + BRect Frame(void); - status_t Lock(void); - void Unlock(void); - bool IsLocked(void); - thread_id ThreadID() const { return _monitorthread;} + status_t Lock(void); + void Unlock(void); + bool IsLocked(void); + thread_id ThreadID(void) const { return fMonitorThreadID;} - 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 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 PostMessage(int32 code, size_t size=0, int8 *buffer=NULL); //! Returns the index of the workspaces to which it belongs - int32 GetWorkspaceIndex(void) { return fWorkspaces; } - Workspace* GetWorkspace(void); - void SetWorkspace(Workspace *wkspc); - - //! Returns the window's title - const char* Title(void) { return _title->String(); } + int32 GetWorkspaceIndex(void) { return fWorkspaces; } + Workspace *GetWorkspace(void); + void SetWorkspace(Workspace *wkspc); + + //! Returns the window's title + const char *Title(void) { return fTitle.String(); } + + Layer* FindLayer(const Layer* start, int32 token) const; + void SendMessageToClient( const BMessage* msg ) const; + + int32 Look(void) const { return fLook; } + int32 Feel(void) const { return fFeel; } + uint32 Flags(void) const { return fFlags; } + team_id ClientTeamID(void) const { return fClientTeamID; } + ServerApp *App(void) const { return fServerApp; } + uint32 Workspaces(void) const { return fWorkspaces; } + WinBorder *GetWinBorder(void) const { return fWinBorder; } - 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; } - int32 ClientToken() const { return _handlertoken; } - - FMWList fWinFMWList; + void QuietlySetWorkspaces(uint32 wks) { fWorkspaces = wks; } + void QuietlySetFeel(int32 feel) { fFeel = feel; } + int32 ClientToken(void) const { return fHandlerToken; } + + FMWList fWinFMWList; protected: friend class ServerApp; friend class WinBorder; - friend class Screen; + friend class Screen; friend class Layer; - BString *_title; - int32 _look, - _feel, - _flags; - uint32 fWorkspaces; - Workspace *_workspace; - bool _active; + BString fTitle; + int32 fLook, + fFeel, + fFlags; + uint32 fWorkspaces; + Workspace *fWorkspace; + bool fIsActive; - ServerApp *_app; - WinBorder *_winborder; + ServerApp *fServerApp; + WinBorder *fWinBorder; - team_id fClientTeamID; - thread_id _monitorthread; - port_id _receiver; // Messages from window - port_id _sender; // Messages to window - PortLink *_winlink; + team_id fClientTeamID; + thread_id fMonitorThreadID; - BLocker _locker; - BRect _frame; - uint32 _token; - int32 _handlertoken; + port_id fMessagePort; + port_id fClientWinPort; + port_id fClientLooperPort; + + PortLink *fWinLink; - 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 :-) + BLocker fLocker; + BRect fFrame; + uint32 fToken; + int32 fHandlerToken; + + BSession *fSession; + Layer *fTopLayer; + 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/Utils.cpp b/src/servers/app/server/Utils.cpp index aa2c3db5a4..772c57ea6e 100644 --- a/src/servers/app/server/Utils.cpp +++ b/src/servers/app/server/Utils.cpp @@ -27,6 +27,7 @@ #include #include #include "Utils.h" +#include /*! \brief Send a BMessage to a Looper target @@ -92,9 +93,23 @@ const char *MsgCodeToString(int32 code) // Used to translate BMessage message codes back to a character // format char string [10]; - sprintf(string,"'%c%c%c%c'",(char)((code & 0xFF000000) >> 24), + sprintf(string,"'%x%x%x%x'",(char)((code & 0xFF000000) >> 24), (char)((code & 0x00FF0000) >> 16), (char)((code & 0x0000FF00) >> 8), (char)((code & 0x000000FF)) ); return string; } + +BString MsgCodeToBString(int32 code) +{ + // Used to translate BMessage message codes back to a character + // format + char string [10]; + sprintf(string,"'%x%x%x%x'",(char)((code & 0xFF000000) >> 24), + (char)((code & 0x00FF0000) >> 16), + (char)((code & 0x0000FF00) >> 8), + (char)((code & 0x000000FF)) ); + + BString bstring(string); + return bstring; +} diff --git a/src/servers/app/server/Utils.h b/src/servers/app/server/Utils.h index ea752305df..d490e95e2f 100644 --- a/src/servers/app/server/Utils.h +++ b/src/servers/app/server/Utils.h @@ -32,5 +32,6 @@ void SendMessage(port_id port, BMessage *message, int32 target=-1); const char *MsgCodeToString(int32 code); +BString MsgCodeToBString(int32 code); #endif diff --git a/src/servers/app/server/ViewDriver.cpp b/src/servers/app/server/ViewDriver.cpp index 094d296d15..9f421fbb8c 100644 --- a/src/servers/app/server/ViewDriver.cpp +++ b/src/servers/app/server/ViewDriver.cpp @@ -106,8 +106,10 @@ VDView::VDView(BRect bounds) VDView::~VDView(void) { delete serverlink; - delete viewbmp; delete cursor; + + viewbmp->Lock(); + delete viewbmp; } void VDView::AttachedToWindow(void) @@ -581,6 +583,9 @@ void ViewDriver::Shutdown(void) void ViewDriver::SetMode(const display_mode &mode) { + if(!is_initialized) + return; + screenwin->Lock(); BBitmap *tempbmp=new BBitmap(BRect(0,0,mode.virtual_width-1,mode.virtual_height-1), @@ -620,6 +625,9 @@ void ViewDriver::SetMode(const display_mode &mode) void ViewDriver::SetMode(int32 space) { + if(!is_initialized) + return; + screenwin->Lock(); int16 w=640,h=480; color_space s=B_CMAP8; @@ -696,6 +704,9 @@ void ViewDriver::SetMode(int32 space) void ViewDriver::CopyBits(BRect src, BRect dest) { + if(!is_initialized) + return; + screenwin->Lock(); framebuffer->Lock(); drawview->CopyBits(src,dest); @@ -708,6 +719,9 @@ void ViewDriver::CopyBits(BRect src, BRect dest) void ViewDriver::CopyRegion(BRegion *src, const BPoint &lefttop) { + if(!is_initialized) + return; + STRACE(("ViewDriver:: CopyRegion not completely tested\n")); screenwin->Lock(); @@ -801,11 +815,17 @@ printf("Overlap\n"); void ViewDriver::DrawBitmap(ServerBitmap *bitmap, BRect src, BRect dest) { + if(!is_initialized) + return; + STRACE(("ViewDriver:: DrawBitmap unimplemented()\n")); } void ViewDriver::DrawChar(char c, BPoint pt, LayerData *d) { + if(!is_initialized) + return; + char str[2]; str[0]=c; str[1]='\0'; @@ -814,6 +834,9 @@ void ViewDriver::DrawChar(char c, BPoint pt, LayerData *d) void ViewDriver::DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL) { + if(!is_initialized) + return; + STRACE(("ViewDriver:: DrawString(\"%s\",%ld,BPoint(%f,%f))\n",string,length,pt.x,pt.y)); if(!d) return; @@ -846,6 +869,9 @@ STRACE(("ViewDriver:: DrawString(\"%s\",%ld,BPoint(%f,%f))\n",string,length,pt.x bool ViewDriver::DumpToFile(const char *path) { + if(!is_initialized) + return false; + // Dump to PNG Lock(); SaveToPNG(path,framebuffer->Bounds(),framebuffer->ColorSpace(), @@ -860,6 +886,9 @@ bool ViewDriver::DumpToFile(const char *path) void ViewDriver::FillArc(const BRect r, float angle, float span, RGBColor& color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -878,6 +907,9 @@ void ViewDriver::FillArc(const BRect r, float angle, float span, RGBColor& color void ViewDriver::FillArc(const BRect r, float angle, float span, const Pattern& pat, RGBColor& high_color, RGBColor& low_color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -896,6 +928,9 @@ void ViewDriver::FillArc(const BRect r, float angle, float span, const Pattern& void ViewDriver::FillBezier(BPoint *pts, RGBColor& color) { + if(!is_initialized) + return; + if(!pts) return; Lock(); @@ -917,6 +952,9 @@ void ViewDriver::FillBezier(BPoint *pts, RGBColor& color) void ViewDriver::FillBezier(BPoint *pts, const Pattern& pat, RGBColor& high_color, RGBColor& low_color) { + if(!is_initialized) + return; + if(!pts) return; Lock(); @@ -938,6 +976,9 @@ void ViewDriver::FillBezier(BPoint *pts, const Pattern& pat, RGBColor& high_colo void ViewDriver::FillEllipse(BRect r, RGBColor& color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -954,6 +995,9 @@ void ViewDriver::FillEllipse(BRect r, RGBColor& color) void ViewDriver::FillEllipse(BRect r, const Pattern& pat, RGBColor& high_color, RGBColor& low_color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -970,6 +1014,9 @@ void ViewDriver::FillEllipse(BRect r, const Pattern& pat, RGBColor& high_color, void ViewDriver::FillPolygon(BPoint *ptlist, int32 numpts, RGBColor& color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -986,6 +1033,9 @@ void ViewDriver::FillPolygon(BPoint *ptlist, int32 numpts, RGBColor& color) void ViewDriver::FillPolygon(BPoint *ptlist, int32 numpts, const Pattern& pat, RGBColor& high_color, RGBColor& low_color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1002,6 +1052,9 @@ void ViewDriver::FillPolygon(BPoint *ptlist, int32 numpts, const Pattern& pat, R void ViewDriver::FillRect(const BRect r, RGBColor& color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1025,6 +1078,9 @@ void ViewDriver::FillRect(const BRect r, RGBColor& color) */ void ViewDriver::FillRect(const BRect r, const Pattern& pat, RGBColor& high_color, RGBColor& low_color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1041,6 +1097,9 @@ void ViewDriver::FillRect(const BRect r, const Pattern& pat, RGBColor& high_colo void ViewDriver::FillRoundRect(BRect r, float xrad, float yrad, RGBColor& color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1057,6 +1116,9 @@ void ViewDriver::FillRoundRect(BRect r, float xrad, float yrad, RGBColor& color) void ViewDriver::FillRoundRect(BRect r, float xrad, float yrad, const Pattern& pat, RGBColor& high_color, RGBColor& low_color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1073,6 +1135,9 @@ void ViewDriver::FillRoundRect(BRect r, float xrad, float yrad, const Pattern& p void ViewDriver::FillTriangle(BPoint *pts, RGBColor& color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1102,6 +1167,9 @@ void ViewDriver::FillTriangle(BPoint *pts, RGBColor& color) void ViewDriver::FillTriangle(BPoint *pts, const Pattern& pat, RGBColor& high_color, RGBColor& low_color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1131,6 +1199,9 @@ void ViewDriver::FillTriangle(BPoint *pts, const Pattern& pat, RGBColor& high_co void ViewDriver::StrokeArc(BRect r, float angle, float span, float pensize, RGBColor& color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1148,6 +1219,9 @@ void ViewDriver::StrokeArc(BRect r, float angle, float span, float pensize, RGBC void ViewDriver::StrokeArc(BRect r, float angle, float span, float pensize, const Pattern& pat, RGBColor& high_color, RGBColor& low_color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1165,6 +1239,9 @@ void ViewDriver::StrokeArc(BRect r, float angle, float span, float pensize, cons void ViewDriver::StrokeBezier(BPoint *pts, float pensize, RGBColor& color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1182,6 +1259,9 @@ void ViewDriver::StrokeBezier(BPoint *pts, float pensize, RGBColor& color) void ViewDriver::StrokeBezier(BPoint *pts, float pensize, const Pattern& pat, RGBColor& high_color, RGBColor& low_color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1199,6 +1279,9 @@ void ViewDriver::StrokeBezier(BPoint *pts, float pensize, const Pattern& pat, RG void ViewDriver::StrokeEllipse(BRect r, float pensize, RGBColor& color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1216,6 +1299,9 @@ void ViewDriver::StrokeEllipse(BRect r, float pensize, RGBColor& color) void ViewDriver::StrokeEllipse(BRect r, float pensize, const Pattern& pat, RGBColor& high_color, RGBColor& low_color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1233,6 +1319,9 @@ void ViewDriver::StrokeEllipse(BRect r, float pensize, const Pattern& pat, RGBCo void ViewDriver::StrokeLine(BPoint start, BPoint end, float pensize, RGBColor& color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1250,6 +1339,9 @@ void ViewDriver::StrokeLine(BPoint start, BPoint end, float pensize, RGBColor& c void ViewDriver::StrokeLine(BPoint start, BPoint end, float pensize, const Pattern& pat, RGBColor& high_color, RGBColor& low_color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1267,6 +1359,9 @@ void ViewDriver::StrokeLine(BPoint start, BPoint end, float pensize, const Patte void ViewDriver::StrokePoint(BPoint& pt, RGBColor& color) { + if(!is_initialized) + return; + Lock(); Unlock(); } @@ -1309,11 +1404,17 @@ void ViewDriver::StrokePolygon(BPoint *ptlist, int32 numpts, float pensize, RGBC void ViewDriver::StrokePolygon(BPoint *ptlist, int32 numpts, float pensize, const Pattern& pat, RGBColor& high_color, RGBColor& low_color, bool is_closed) { + if(!is_initialized) + return; + StrokePolygon(ptlist,numpts,pensize,high_color,is_closed); } void ViewDriver::StrokeRect(BRect r, float pensize, RGBColor& color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1331,6 +1432,9 @@ void ViewDriver::StrokeRect(BRect r, float pensize, RGBColor& color) void ViewDriver::StrokeRect(BRect r, float pensize, const Pattern& pat, RGBColor& high_color, RGBColor& low_color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1348,6 +1452,9 @@ void ViewDriver::StrokeRect(BRect r, float pensize, const Pattern& pat, RGBColor void ViewDriver::StrokeRoundRect(BRect r, float xrad, float yrad, float pensize, RGBColor& color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1365,6 +1472,9 @@ void ViewDriver::StrokeRoundRect(BRect r, float xrad, float yrad, float pensize, void ViewDriver::StrokeRoundRect(BRect r, float xrad, float yrad, float pensize, const Pattern& pat, RGBColor& high_color, RGBColor& low_color) { + if(!is_initialized) + return; + Lock(); screenwin->Lock(); framebuffer->Lock(); @@ -1389,6 +1499,9 @@ void ViewDriver::StrokeRoundRect(BRect r, float xrad, float yrad, float pensize, */ void ViewDriver::StrokeLineArray(BPoint *pts, int32 numlines, float pensize, RGBColor *colors) { + if(!is_initialized) + return; + if( !numlines || !pts || !colors) return; @@ -1426,6 +1539,9 @@ void ViewDriver::StrokeLineArray(BPoint *pts, int32 numlines, float pensize, RGB void ViewDriver::HideCursor(void) { + if(!is_initialized) + return; + screenwin->Lock(); Lock(); @@ -1438,6 +1554,9 @@ void ViewDriver::HideCursor(void) void ViewDriver::InvertRect(BRect r) { + if(!is_initialized) + return; + screenwin->Lock(); framebuffer->Lock(); drawview->InvertRect(r); @@ -1449,6 +1568,9 @@ void ViewDriver::InvertRect(BRect r) bool ViewDriver::IsCursorHidden(void) { + if(!is_initialized) + return false; + screenwin->Lock(); bool value=(hide_cursor>0)?true:false; screenwin->Unlock(); @@ -1457,6 +1579,9 @@ bool ViewDriver::IsCursorHidden(void) void ViewDriver::ObscureCursor(void) { + if(!is_initialized) + return; + screenwin->Lock(); screenwin->PostMessage(VDWIN_OBSCURECURSOR); screenwin->Unlock(); @@ -1464,6 +1589,9 @@ void ViewDriver::ObscureCursor(void) void ViewDriver::MoveCursorTo(float x, float y) { + if(!is_initialized) + return; + screenwin->Lock(); BMessage *msg=new BMessage(VDWIN_MOVECURSOR); msg->AddFloat("x",x); @@ -1474,6 +1602,9 @@ void ViewDriver::MoveCursorTo(float x, float y) void ViewDriver::SetCursor(ServerCursor *cursor) { + if(!is_initialized) + return; + if(cursor!=NULL) { screenwin->Lock(); @@ -1499,6 +1630,9 @@ void ViewDriver::SetCursor(ServerCursor *cursor) void ViewDriver::ShowCursor(void) { + if(!is_initialized) + return; + screenwin->Lock(); if(hide_cursor>0) { @@ -1511,6 +1645,9 @@ void ViewDriver::ShowCursor(void) void ViewDriver::SetLayerData(LayerData *d, bool set_font_data) { + if(!is_initialized) + return; + if(!d) return; @@ -1552,7 +1689,7 @@ void ViewDriver::SetLayerData(LayerData *d, bool set_font_data) float ViewDriver::StringWidth(const char *string, int32 length, LayerData *d) { - if(!string || !d ) + if(!string || !d || !is_initialized) return 0.0; screenwin->Lock(); @@ -1616,7 +1753,7 @@ float ViewDriver::StringWidth(const char *string, int32 length, LayerData *d) float ViewDriver::StringHeight(const char *string, int32 length, LayerData *d) { - if(!string || !d ) + if(!string || !d || !is_initialized) return 0.0; screenwin->Lock(); @@ -1666,6 +1803,9 @@ float ViewDriver::StringHeight(const char *string, int32 length, LayerData *d) /* void ViewDriver::DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *edelta) { + if(!is_initialized) + return; + if(!string || !d ) return; screenwin->Lock(); @@ -1810,6 +1950,9 @@ void ViewDriver::DrawString(const char *string, int32 length, BPoint pt, LayerDa */ void ViewDriver::BlitMono2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d) { + if(!is_initialized) + return; + rgb_color color=d->highcolor.GetColor32(); // pointers to the top left corner of the area to be copied in each bitmap @@ -1895,6 +2038,9 @@ void ViewDriver::BlitMono2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d) void ViewDriver::BlitGray2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d) { + if(!is_initialized) + return; + // pointers to the top left corner of the area to be copied in each bitmap uint8 *srcbuffer=NULL, *destbuffer=NULL; @@ -2010,8 +2156,9 @@ void ViewDriver::BlitGray2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d) rgb_color ViewDriver::GetBlitColor(rgb_color src, rgb_color dest, LayerData *d, bool use_high) { rgb_color returncolor={0,0,0,0}; + int16 value; - if(!d) + if(!d || !is_initialized) return returncolor; switch(d->draw_mode) @@ -2111,6 +2258,9 @@ rgb_color ViewDriver::GetBlitColor(rgb_color src, rgb_color dest, LayerData *d, status_t ViewDriver::SetDPMSMode(const uint32 &state) { + if(!is_initialized) + return B_ERROR; + // TODO: Implement software DPMS return B_ERROR; } @@ -2129,7 +2279,7 @@ uint32 ViewDriver::DPMSCapabilities(void) const status_t ViewDriver::GetDeviceInfo(accelerant_device_info *info) { - if(!info) + if(!info || !is_initialized) return B_ERROR; // We really don't have to provide anything here because this is strictly @@ -2147,7 +2297,7 @@ status_t ViewDriver::GetDeviceInfo(accelerant_device_info *info) status_t ViewDriver::GetModeList(display_mode **modes, uint32 *count) { - if(!count) + if(!count || !is_initialized) return B_ERROR; screenwin->Lock(); @@ -2214,16 +2364,25 @@ status_t ViewDriver::GetModeList(display_mode **modes, uint32 *count) status_t ViewDriver::GetPixelClockLimits(display_mode *mode, uint32 *low, uint32 *high) { + if(!is_initialized) + return B_ERROR; + return B_ERROR; } status_t ViewDriver::GetTimingConstraints(display_timing_constraints *dtc) { + if(!is_initialized) + return B_ERROR; + return B_ERROR; } status_t ViewDriver::ProposeMode(display_mode *candidate, const display_mode *low, const display_mode *high) { + if(!is_initialized) + return B_ERROR; + // TODO: Unhack // We should be able to get away with this because we're not dealing with any @@ -2234,6 +2393,9 @@ status_t ViewDriver::ProposeMode(display_mode *candidate, const display_mode *lo status_t ViewDriver::WaitForRetrace(bigtime_t timeout=B_INFINITE_TIMEOUT) { + if(!is_initialized) + return B_ERROR; + // Locking shouldn't be necessary here - R5 should handle this for us. :) BScreen screen; return screen.WaitForRetrace(timeout); diff --git a/src/servers/app/server/WinBorder.cpp b/src/servers/app/server/WinBorder.cpp index 16ec79ef9a..a020754660 100644 --- a/src/servers/app/server/WinBorder.cpp +++ b/src/servers/app/server/WinBorder.cpp @@ -96,7 +96,7 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i _decorator = NULL; if (feel == B_NO_BORDER_WINDOW_LOOK){ - _full = _win->top_layer->_full; + _full = _win->fTopLayer->_full; fDecFull = NULL; fDecFullVisible = NULL; fDecVisible = NULL; @@ -109,8 +109,8 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i _decorator->GetFootprint( fDecFull ); - // our full region is the union between decorator's region and top_layer's region - _full = _win->top_layer->_full; + // our full region is the union between decorator's region and fTopLayer's region + _full = _win->fTopLayer->_full; _full.Include( fDecFull ); } @@ -193,7 +193,7 @@ void WinBorder::MouseDown(int8 *buffer) BRect helpRect(pt.x, pt.y, pt.x+1, pt.y+1); msg.what = B_MOUSE_DOWN; msg.AddInt64("when", real_time_clock_usecs()); - msg.AddPoint("where", (_win->top_layer->LayerAt(pt)->ConvertFromTop(helpRect)).LeftTop() ); + msg.AddPoint("where", (_win->fTopLayer->LayerAt(pt)->ConvertFromTop(helpRect)).LeftTop() ); msg.AddInt32("modifiers", modifiers); msg.AddInt32("buttons", buttons); msg.AddInt32("clicks", 1); @@ -246,7 +246,7 @@ void WinBorder::MouseMoved(int8 *buffer) BRect helpRect(pt.x, pt.y, pt.x+1, pt.y+1); msg.what = B_MOUSE_MOVED; msg.AddInt64("when", real_time_clock_usecs()); - msg.AddPoint("where", (_win->top_layer->ConvertFromTop(helpRect)).LeftTop() ); + msg.AddPoint("where", (_win->fTopLayer->ConvertFromTop(helpRect)).LeftTop() ); msg.AddInt32("buttons", buttons); _win->SendMessageToClient( &msg ); @@ -311,7 +311,7 @@ STRACE_MOUSE(("WinBorder %s: MouseUp() \n",GetName())); BRect helpRect(pt.x, pt.y, pt.x+1, pt.y+1); msg.what = B_MOUSE_UP; msg.AddInt64("when", real_time_clock_usecs()); - msg.AddPoint("where", (_win->top_layer->LayerAt(pt)->ConvertFromTop(helpRect)).LeftTop() ); + msg.AddPoint("where", (_win->fTopLayer->LayerAt(pt)->ConvertFromTop(helpRect)).LeftTop() ); msg.AddInt32("modifiers", modifiers); _win->SendMessageToClient( &msg ); @@ -373,25 +373,25 @@ void WinBorder::RebuildRegions( const BRect& r ){ } // rebuild top_layer: - if ( _win->top_layer->_full.Intersects( r ) ){ + if ( _win->fTopLayer->_full.Intersects( r ) ){ // build top_layer's visible region by intersecting its _full with winborder's _visible region. - _win->top_layer->_visible = _win->top_layer->_full; - _win->top_layer->_visible.IntersectWith( &(_visible) ); + _win->fTopLayer->_visible = _win->fTopLayer->_full; + _win->fTopLayer->_visible.IntersectWith( &(_visible) ); // then exclude it from winborder's _visible... - _visible.Exclude( &(_win->top_layer->_visible) ); + _visible.Exclude( &(_win->fTopLayer->_visible) ); - _win->top_layer->_fullVisible = _win->top_layer->_visible; + _win->fTopLayer->_fullVisible = _win->fTopLayer->_visible; // Rebuild regions for children... - for(Layer *lay = _win->top_layer->_bottomchild; lay != NULL; lay = lay->_uppersibling){ + for(Layer *lay = _win->fTopLayer->_bottomchild; lay != NULL; lay = lay->_uppersibling){ if ( !(lay->_hidden) ){ lay->RebuildRegions( r ); } } } else{ - _visible.Exclude( &(_win->top_layer->_fullVisible) ); + _visible.Exclude( &(_win->fTopLayer->_fullVisible) ); } // rebuild decorator. @@ -431,9 +431,9 @@ printf("#WinBorder(%s)::Draw() ENDED\n", GetName()); // draw the top_layer reg.Set( r ); - reg.IntersectWith( &(_win->top_layer->_visible) ); + reg.IntersectWith( &(_win->fTopLayer->_visible) ); if (reg.CountRects() > 0){ - _win->top_layer->RequestClientUpdate( reg.Frame() ); + _win->fTopLayer->RequestClientUpdate( reg.Frame() ); } } @@ -445,8 +445,8 @@ void WinBorder::MoveBy(float x, float y) _frame.OffsetBy(x, y); _full.OffsetBy(x, y); - _win->top_layer->_frame.OffsetBy(x, y); - _win->top_layer->MoveRegionsBy(x, y); + _win->fTopLayer->_frame.OffsetBy(x, y); + _win->fTopLayer->MoveRegionsBy(x, y); if (_decorator){ // allow decorator to make its internal calculations. @@ -526,9 +526,9 @@ void WinBorder::ResizeBy(float x, float y) _frame.right = _frame.right + x; _frame.bottom = _frame.bottom + y; - _win->top_layer->ResizeRegionsBy(x, y); + _win->fTopLayer->ResizeRegionsBy(x, y); - _full = _win->top_layer->_full; + _full = _win->fTopLayer->_full; if (_decorator){ // allow decorator to make its internal calculations.