diff --git a/src/servers/app/server/AppServer.cpp b/src/servers/app/server/AppServer.cpp index 2b94c0366c..c159e5edef 100644 --- a/src/servers/app/server/AppServer.cpp +++ b/src/servers/app/server/AppServer.cpp @@ -414,6 +414,7 @@ void AppServer::DispatchMessage(int32 code, int8 *buffer) // Find the necessary data port_id reply_port=*((port_id*)index); index+=sizeof(port_id); port_id app_port=*((port_id*)index); index+=sizeof(port_id); + int32 htoken=*((int32*)index); index+=sizeof(int32); char *app_signature=(char *)index; // Create the ServerApp subthread for this app @@ -426,7 +427,7 @@ void AppServer::DispatchMessage(int32 code, int8 *buffer) printf("No more ports left. Time to crash. Have a nice day! :)\n"); break; } - ServerApp *newapp=new ServerApp(app_port,r,app_signature); + ServerApp *newapp=new ServerApp(app_port,r,htoken,app_signature); _applist->AddItem(newapp); release_sem(_applist_lock); @@ -822,4 +823,3 @@ int main( int argc, char** argv ) delete app_server; return 0; } - diff --git a/src/servers/app/server/ServerApp.cpp b/src/servers/app/server/ServerApp.cpp index 72117067b6..7d2ffb116f 100644 --- a/src/servers/app/server/ServerApp.cpp +++ b/src/servers/app/server/ServerApp.cpp @@ -31,6 +31,7 @@ #include #include #include +#include "SMessage.h" #include "BitmapManager.h" #include "CursorManager.h" @@ -43,6 +44,9 @@ #include "ServerBitmap.h" #include "ServerConfig.h" #include "LayerData.h" +#include "Utils.h" + +#define DEBUG_SERVERAPP /*! \brief Constructor @@ -53,11 +57,14 @@ \param _signature NULL-terminated string which contains the BApplication's MIME _signature. */ -ServerApp::ServerApp(port_id sendport, port_id rcvport, char *signature) +ServerApp::ServerApp(port_id sendport, port_id rcvport, int32 handlerID, char *signature) { // need to copy the _signature because the message buffer // owns the copy which we are passed as a parameter. - _signature=(signature)?signature:"BeApplication"; + _signature=(signature)?signature:"application/x-vnd.unknown-application"; + + // token ID of the BApplication's BHandler object. Used for BMessage target specification + _handlertoken=handlerID; // _sender is the our BApplication's event port _sender=sendport; @@ -83,11 +90,20 @@ ServerApp::ServerApp(port_id sendport, port_id rcvport, char *signature) _driver=GetGfxDriver(); _cursorhidden=false; + +#ifdef DEBUG_SERVERAPP +printf("ServerApp %s:\n",_signature.String()); +printf("\tBApp port: %ld\n",_sender); +printf("\tReceiver port: %ld\n",_receiver); +#endif } //! Does all necessary teardown for application ServerApp::~ServerApp(void) { +#ifdef DEBUG_SERVERAPP +printf("ServerApp %s:~ServerApp()\n",_signature.String()); +#endif int32 i; ServerWindow *tempwin; @@ -130,6 +146,9 @@ ServerApp::~ServerApp(void) */ bool ServerApp::Run(void) { +#ifdef DEBUG_SERVERAPP +printf("ServerApp %s:Run()\n",_signature.String()); +#endif // 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); @@ -216,17 +235,24 @@ int32 ServerApp::MonitorApp(void *data) // -------------- Messages received from the Server ------------------------ case AS_QUIT_APP: { +#ifdef DEBUG_SERVERAPP +printf("ServerApp %s:Server shutdown notification received\n",app->_signature.String()); +#endif // 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) + 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 - app->_applink->SetOpCode(B_QUIT_REQUESTED); - app->_applink->Flush(); + BMessage *shutdown=new BMessage(B_QUIT_REQUESTED); + shutdown->fPreferred=true; + SendMessage(app->_sender,shutdown); +#ifdef DEBUG_SERVERAPP +printf("ServerApp %s:Sent server shutdown message to BApp\n",app->_signature.String()); +#endif } break; } @@ -302,7 +328,8 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer) // 3) uint32 window flags // 4) port_id window's message port // 5) uint32 workspace index - // 6) const char * title + // 6) int32 BHandler token of the window + // 7) const char * title // Find the necessary data port_id reply_port=*((port_id*)index); index+=sizeof(port_id); @@ -313,11 +340,12 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer) uint32 winflags=*((uint32*)index); index+=sizeof(uint32); port_id win_port=*((port_id*)index); index+=sizeof(port_id); + int32 htoken=*((int32*)index); index+=sizeof(int32); uint32 workspace=*((uint32*)index); index+=sizeof(uint32); // Create the ServerWindow object for this window ServerWindow *newwin=new ServerWindow(rect,(const char *)index, - winlook, winfeel, winflags,this,win_port,workspace); + winlook, winfeel, winflags,this,win_port,workspace,htoken); _winlist->AddItem(newwin); // Window looper is waiting for our reply. Send back the diff --git a/src/servers/app/server/ServerApp.h b/src/servers/app/server/ServerApp.h index de386e7704..3e64f5389c 100644 --- a/src/servers/app/server/ServerApp.h +++ b/src/servers/app/server/ServerApp.h @@ -43,7 +43,7 @@ class ServerCursor; class ServerApp { public: - ServerApp(port_id sendport, port_id rcvport, char *signature); + ServerApp(port_id sendport, port_id rcvport, int32 handlerID, char *signature); ~ServerApp(void); bool Run(void); @@ -85,6 +85,7 @@ protected: sem_id _lock; bool _cursorhidden; bool _isactive; + int32 _handlertoken; }; #endif diff --git a/src/servers/app/server/ServerWindow.cpp b/src/servers/app/server/ServerWindow.cpp index cf08d04ca8..e1b7cabe03 100644 --- a/src/servers/app/server/ServerWindow.cpp +++ b/src/servers/app/server/ServerWindow.cpp @@ -50,7 +50,7 @@ TokenHandler win_token_handler; monitor thread. */ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook, - uint32 wfeel, uint32 wflags, ServerApp *winapp, port_id winport, uint32 index) + uint32 wfeel, uint32 wflags, ServerApp *winapp, port_id winport, uint32 index, int32 handlerID) { _title=new BString; if(string) @@ -59,6 +59,7 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook, _flags=wflags; _look=wlook; _feel=wfeel; + _handlertoken=handlerID; _winborder=new WinBorder(_frame,_title->String(),wlook,wfeel,wflags,this); @@ -329,15 +330,27 @@ void ServerWindow::DispatchMessage(int32 code, int8 *msgbuffer) Hide(); break; } + case AS_SEND_BEHIND: + case AS_ENABLE_UPDATES: + case AS_DISABLE_UPDATES: + case AS_NEEDS_UPDATE: + case AS_WINDOW_TITLE: + case AS_ADD_TO_SUBSET: + case AS_REM_FROM_SUBSET: + case AS_SET_LOOK: + case AS_SET_FLAGS: + case AS_SET_FEEL: + case AS_SET_ALIGNMENT: + case AS_GET_ALIGNMENT: + case AS_GET_WORKSPACES: + case AS_SET_WORKSPACES: + case AS_WINDOW_RESIZEBY: + case AS_WINDOW_RESIZETO: case B_MINIMIZE: case B_WINDOW_ACTIVATED: case B_ZOOM: case B_WINDOW_MOVE_TO: case B_WINDOW_MOVE_BY: - case AS_SET_LOOK: - case AS_SET_FEEL: - case AS_SET_FLAGS: - case AS_SEND_BEHIND: break; default: { @@ -347,6 +360,16 @@ void ServerWindow::DispatchMessage(int32 code, int8 *msgbuffer) } } +/*! + \brief Iterator for graphics update messages + \param msgsize Size of the buffer containing the graphics messages + \param msgbuffer Buffer containing the graphics message +*/ +void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer) +{ + +} + /*! \brief Message-dispatching loop for the ServerWindow @@ -387,6 +410,11 @@ int32 ServerWindow::MonitorWin(void *data) win->_applink->Flush(); break; } + case AS_BEGIN_UPDATE: + { + win->DispatchGraphicsMessage(buffersize,msgbuffer); + break; + } default: win->DispatchMessage(msgcode,msgbuffer); break; diff --git a/src/servers/app/server/ServerWindow.h b/src/servers/app/server/ServerWindow.h index 70cc1e82ac..0db57e463d 100644 --- a/src/servers/app/server/ServerWindow.h +++ b/src/servers/app/server/ServerWindow.h @@ -57,7 +57,7 @@ class ServerWindow { public: ServerWindow(BRect rect, const char *string, uint32 wlook, uint32 wfeel, - uint32 wflags, ServerApp *winapp, port_id winport, uint32 index); + uint32 wflags, ServerApp *winapp, port_id winport, uint32 index, int32 handlerID); ~ServerWindow(void); void ReplaceDecorator(void); @@ -85,6 +85,7 @@ public: bool IsLocked(void); void DispatchMessage(int32 code, int8 *msgbuffer); + void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer); static int32 MonitorWin(void *data); static void HandleMouseEvent(int32 code, int8 *buffer); static void HandleKeyEvent(int32 code, int8 *buffer); @@ -114,6 +115,7 @@ protected: BLocker _locker; BRect _frame; uint32 _token; + int32 _handlertoken; }; void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin);