Added BHandler token members to ServerApps and ServerWindows
Modified ServerApp and ServerWindow constructors to include BHandler tokens git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2948 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -414,6 +414,7 @@ void AppServer::DispatchMessage(int32 code, int8 *buffer)
|
|||||||
// Find the necessary data
|
// Find the necessary data
|
||||||
port_id reply_port=*((port_id*)index); index+=sizeof(port_id);
|
port_id reply_port=*((port_id*)index); index+=sizeof(port_id);
|
||||||
port_id app_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;
|
char *app_signature=(char *)index;
|
||||||
|
|
||||||
// Create the ServerApp subthread for this app
|
// 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");
|
printf("No more ports left. Time to crash. Have a nice day! :)\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ServerApp *newapp=new ServerApp(app_port,r,app_signature);
|
ServerApp *newapp=new ServerApp(app_port,r,htoken,app_signature);
|
||||||
_applist->AddItem(newapp);
|
_applist->AddItem(newapp);
|
||||||
|
|
||||||
release_sem(_applist_lock);
|
release_sem(_applist_lock);
|
||||||
@@ -822,4 +823,3 @@ int main( int argc, char** argv )
|
|||||||
delete app_server;
|
delete app_server;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ServerProtocol.h>
|
#include <ServerProtocol.h>
|
||||||
|
#include "SMessage.h"
|
||||||
|
|
||||||
#include "BitmapManager.h"
|
#include "BitmapManager.h"
|
||||||
#include "CursorManager.h"
|
#include "CursorManager.h"
|
||||||
@@ -43,6 +44,9 @@
|
|||||||
#include "ServerBitmap.h"
|
#include "ServerBitmap.h"
|
||||||
#include "ServerConfig.h"
|
#include "ServerConfig.h"
|
||||||
#include "LayerData.h"
|
#include "LayerData.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
|
#define DEBUG_SERVERAPP
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Constructor
|
\brief Constructor
|
||||||
@@ -53,11 +57,14 @@
|
|||||||
\param _signature NULL-terminated string which contains the BApplication's
|
\param _signature NULL-terminated string which contains the BApplication's
|
||||||
MIME _signature.
|
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
|
// need to copy the _signature because the message buffer
|
||||||
// owns the copy which we are passed as a parameter.
|
// 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 is the our BApplication's event port
|
||||||
_sender=sendport;
|
_sender=sendport;
|
||||||
@@ -83,11 +90,20 @@ ServerApp::ServerApp(port_id sendport, port_id rcvport, char *signature)
|
|||||||
|
|
||||||
_driver=GetGfxDriver();
|
_driver=GetGfxDriver();
|
||||||
_cursorhidden=false;
|
_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
|
//! Does all necessary teardown for application
|
||||||
ServerApp::~ServerApp(void)
|
ServerApp::~ServerApp(void)
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG_SERVERAPP
|
||||||
|
printf("ServerApp %s:~ServerApp()\n",_signature.String());
|
||||||
|
#endif
|
||||||
int32 i;
|
int32 i;
|
||||||
|
|
||||||
ServerWindow *tempwin;
|
ServerWindow *tempwin;
|
||||||
@@ -130,6 +146,9 @@ ServerApp::~ServerApp(void)
|
|||||||
*/
|
*/
|
||||||
bool ServerApp::Run(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
|
// Unlike a BApplication, a ServerApp is *supposed* to return immediately
|
||||||
// when its Run() function is called.
|
// when its Run() function is called.
|
||||||
_monitor_thread=spawn_thread(MonitorApp,_signature.String(),B_NORMAL_PRIORITY,this);
|
_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 ------------------------
|
// -------------- Messages received from the Server ------------------------
|
||||||
case AS_QUIT_APP:
|
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
|
// If we are using the real, accelerated version of the
|
||||||
// DisplayDriver, we do NOT want the user to be able shut down
|
// DisplayDriver, we do NOT want the user to be able shut down
|
||||||
// the server. The results would NOT be pretty
|
// the server. The results would NOT be pretty
|
||||||
if(DISPLAYDRIVER==HWDRIVER)
|
if(DISPLAYDRIVER!=HWDRIVER)
|
||||||
{
|
{
|
||||||
// This message is received from the app_server thread
|
// This message is received from the app_server thread
|
||||||
// because the server was asked to quit. Thus, we
|
// because the server was asked to quit. Thus, we
|
||||||
// ask all apps to quit. This is NOT the same as system
|
// ask all apps to quit. This is NOT the same as system
|
||||||
// shutdown and will happen only in testing
|
// shutdown and will happen only in testing
|
||||||
app->_applink->SetOpCode(B_QUIT_REQUESTED);
|
BMessage *shutdown=new BMessage(B_QUIT_REQUESTED);
|
||||||
app->_applink->Flush();
|
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;
|
break;
|
||||||
}
|
}
|
||||||
@@ -302,7 +328,8 @@ void ServerApp::_DispatchMessage(int32 code, int8 *buffer)
|
|||||||
// 3) uint32 window flags
|
// 3) uint32 window flags
|
||||||
// 4) port_id window's message port
|
// 4) port_id window's message port
|
||||||
// 5) uint32 workspace index
|
// 5) uint32 workspace index
|
||||||
// 6) const char * title
|
// 6) int32 BHandler token of the window
|
||||||
|
// 7) const char * title
|
||||||
|
|
||||||
// Find the necessary data
|
// Find the necessary data
|
||||||
port_id reply_port=*((port_id*)index); index+=sizeof(port_id);
|
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);
|
uint32 winflags=*((uint32*)index); index+=sizeof(uint32);
|
||||||
|
|
||||||
port_id win_port=*((port_id*)index); index+=sizeof(port_id);
|
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);
|
uint32 workspace=*((uint32*)index); index+=sizeof(uint32);
|
||||||
|
|
||||||
// Create the ServerWindow object for this window
|
// Create the ServerWindow object for this window
|
||||||
ServerWindow *newwin=new ServerWindow(rect,(const char *)index,
|
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);
|
_winlist->AddItem(newwin);
|
||||||
|
|
||||||
// Window looper is waiting for our reply. Send back the
|
// Window looper is waiting for our reply. Send back the
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class ServerCursor;
|
|||||||
class ServerApp
|
class ServerApp
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ServerApp(port_id sendport, port_id rcvport, char *signature);
|
ServerApp(port_id sendport, port_id rcvport, int32 handlerID, char *signature);
|
||||||
~ServerApp(void);
|
~ServerApp(void);
|
||||||
|
|
||||||
bool Run(void);
|
bool Run(void);
|
||||||
@@ -85,6 +85,7 @@ protected:
|
|||||||
sem_id _lock;
|
sem_id _lock;
|
||||||
bool _cursorhidden;
|
bool _cursorhidden;
|
||||||
bool _isactive;
|
bool _isactive;
|
||||||
|
int32 _handlertoken;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ TokenHandler win_token_handler;
|
|||||||
monitor thread.
|
monitor thread.
|
||||||
*/
|
*/
|
||||||
ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
|
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;
|
_title=new BString;
|
||||||
if(string)
|
if(string)
|
||||||
@@ -59,6 +59,7 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
|
|||||||
_flags=wflags;
|
_flags=wflags;
|
||||||
_look=wlook;
|
_look=wlook;
|
||||||
_feel=wfeel;
|
_feel=wfeel;
|
||||||
|
_handlertoken=handlerID;
|
||||||
|
|
||||||
_winborder=new WinBorder(_frame,_title->String(),wlook,wfeel,wflags,this);
|
_winborder=new WinBorder(_frame,_title->String(),wlook,wfeel,wflags,this);
|
||||||
|
|
||||||
@@ -329,15 +330,27 @@ void ServerWindow::DispatchMessage(int32 code, int8 *msgbuffer)
|
|||||||
Hide();
|
Hide();
|
||||||
break;
|
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_MINIMIZE:
|
||||||
case B_WINDOW_ACTIVATED:
|
case B_WINDOW_ACTIVATED:
|
||||||
case B_ZOOM:
|
case B_ZOOM:
|
||||||
case B_WINDOW_MOVE_TO:
|
case B_WINDOW_MOVE_TO:
|
||||||
case B_WINDOW_MOVE_BY:
|
case B_WINDOW_MOVE_BY:
|
||||||
case AS_SET_LOOK:
|
|
||||||
case AS_SET_FEEL:
|
|
||||||
case AS_SET_FLAGS:
|
|
||||||
case AS_SEND_BEHIND:
|
|
||||||
break;
|
break;
|
||||||
default:
|
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
|
\brief Message-dispatching loop for the ServerWindow
|
||||||
|
|
||||||
@@ -387,6 +410,11 @@ int32 ServerWindow::MonitorWin(void *data)
|
|||||||
win->_applink->Flush();
|
win->_applink->Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case AS_BEGIN_UPDATE:
|
||||||
|
{
|
||||||
|
win->DispatchGraphicsMessage(buffersize,msgbuffer);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
win->DispatchMessage(msgcode,msgbuffer);
|
win->DispatchMessage(msgcode,msgbuffer);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class ServerWindow
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ServerWindow(BRect rect, const char *string, uint32 wlook, uint32 wfeel,
|
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);
|
~ServerWindow(void);
|
||||||
|
|
||||||
void ReplaceDecorator(void);
|
void ReplaceDecorator(void);
|
||||||
@@ -85,6 +85,7 @@ public:
|
|||||||
bool IsLocked(void);
|
bool IsLocked(void);
|
||||||
|
|
||||||
void DispatchMessage(int32 code, int8 *msgbuffer);
|
void DispatchMessage(int32 code, int8 *msgbuffer);
|
||||||
|
void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer);
|
||||||
static int32 MonitorWin(void *data);
|
static int32 MonitorWin(void *data);
|
||||||
static void HandleMouseEvent(int32 code, int8 *buffer);
|
static void HandleMouseEvent(int32 code, int8 *buffer);
|
||||||
static void HandleKeyEvent(int32 code, int8 *buffer);
|
static void HandleKeyEvent(int32 code, int8 *buffer);
|
||||||
@@ -114,6 +115,7 @@ protected:
|
|||||||
BLocker _locker;
|
BLocker _locker;
|
||||||
BRect _frame;
|
BRect _frame;
|
||||||
uint32 _token;
|
uint32 _token;
|
||||||
|
int32 _handlertoken;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin);
|
void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin);
|
||||||
|
|||||||
Reference in New Issue
Block a user