Added message queuing (sp?) to ServerApp
Removed a memory bug in ServerCursor Tweaked message-reading code to reflect changes in the messaging classes BCursors work now! git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4943 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -242,12 +242,11 @@ int32 AppServer::PollerThread(void *data)
|
|||||||
// 3) float - y coordinate of mouse click
|
// 3) float - y coordinate of mouse click
|
||||||
// 4) int32 - buttons down
|
// 4) int32 - buttons down
|
||||||
|
|
||||||
// We're using
|
|
||||||
index=(int8*)msg->Buffer();
|
index=(int8*)msg->Buffer();
|
||||||
if(!index)
|
if(!index)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Skip past the message code packaged in the BSession-style message
|
// Skip past the message code
|
||||||
index += sizeof(int32);
|
index += sizeof(int32);
|
||||||
|
|
||||||
// Time sent is not necessary for cursor processing.
|
// Time sent is not necessary for cursor processing.
|
||||||
@@ -654,18 +653,13 @@ void AppServer::Broadcast(int32 code)
|
|||||||
int32 i;
|
int32 i;
|
||||||
ServerApp *app;
|
ServerApp *app;
|
||||||
|
|
||||||
int32 buffer[2];
|
|
||||||
buffer[0] = 8; // 4 for buffer size + 4 for our message
|
|
||||||
buffer[1] = AS_QUIT_APP;
|
|
||||||
|
|
||||||
acquire_sem(_applist_lock);
|
acquire_sem(_applist_lock);
|
||||||
for(i=0;i<_applist->CountItems(); i++)
|
for(i=0;i<_applist->CountItems(); i++)
|
||||||
{
|
{
|
||||||
app=(ServerApp*)_applist->ItemAt(i);
|
app=(ServerApp*)_applist->ItemAt(i);
|
||||||
if(!app)
|
if(!app)
|
||||||
continue;
|
continue;
|
||||||
//app->PostMessage(code);
|
app->PostMessage(code, sizeof(int32), (int8*)&code);
|
||||||
app->PostMessage(AS_SERVER_SESSION, 2*sizeof(int32), (int8*)&buffer);
|
|
||||||
}
|
}
|
||||||
release_sem(_applist_lock);
|
release_sem(_applist_lock);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,8 +163,8 @@ void CursorManager::RemoveAppCursors(const char *signature)
|
|||||||
for(int32 i=0; i<_cursorlist->CountItems();i++)
|
for(int32 i=0; i<_cursorlist->CountItems();i++)
|
||||||
{
|
{
|
||||||
temp=(ServerCursor*)_cursorlist->ItemAt(i);
|
temp=(ServerCursor*)_cursorlist->ItemAt(i);
|
||||||
if(temp && temp->_app_signature &&
|
if(temp && temp->GetAppSignature() &&
|
||||||
strcmp(signature, temp->_app_signature)==0)
|
strcmp(signature, temp->GetAppSignature())==0)
|
||||||
{
|
{
|
||||||
_cursorlist->RemoveItem(i);
|
_cursorlist->RemoveItem(i);
|
||||||
delete temp;
|
delete temp;
|
||||||
@@ -486,11 +486,9 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
|
|
||||||
_defaultcsr=cursor;
|
_defaultcsr=cursor;
|
||||||
|
|
||||||
if(cursor->_app_signature)
|
if(cursor->GetAppSignature())
|
||||||
{
|
cursor->SetAppSignature("");
|
||||||
delete cursor->_app_signature;
|
|
||||||
cursor->_app_signature=NULL;
|
|
||||||
}
|
|
||||||
_cursorlist->RemoveItem(cursor);
|
_cursorlist->RemoveItem(cursor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -501,11 +499,8 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
|
|
||||||
_textcsr=cursor;
|
_textcsr=cursor;
|
||||||
|
|
||||||
if(cursor->_app_signature)
|
if(cursor->GetAppSignature())
|
||||||
{
|
cursor->SetAppSignature("");
|
||||||
delete cursor->_app_signature;
|
|
||||||
cursor->_app_signature=NULL;
|
|
||||||
}
|
|
||||||
_cursorlist->RemoveItem(cursor);
|
_cursorlist->RemoveItem(cursor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -516,11 +511,8 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
|
|
||||||
_movecsr=cursor;
|
_movecsr=cursor;
|
||||||
|
|
||||||
if(cursor->_app_signature)
|
if(cursor->GetAppSignature())
|
||||||
{
|
cursor->SetAppSignature("");
|
||||||
delete cursor->_app_signature;
|
|
||||||
cursor->_app_signature=NULL;
|
|
||||||
}
|
|
||||||
_cursorlist->RemoveItem(cursor);
|
_cursorlist->RemoveItem(cursor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -531,11 +523,8 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
|
|
||||||
_dragcsr=cursor;
|
_dragcsr=cursor;
|
||||||
|
|
||||||
if(cursor->_app_signature)
|
if(cursor->GetAppSignature())
|
||||||
{
|
cursor->SetAppSignature("");
|
||||||
delete cursor->_app_signature;
|
|
||||||
cursor->_app_signature=NULL;
|
|
||||||
}
|
|
||||||
_cursorlist->RemoveItem(cursor);
|
_cursorlist->RemoveItem(cursor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -546,11 +535,8 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
|
|
||||||
_resizecsr=cursor;
|
_resizecsr=cursor;
|
||||||
|
|
||||||
if(cursor->_app_signature)
|
if(cursor->GetAppSignature())
|
||||||
{
|
cursor->SetAppSignature("");
|
||||||
delete cursor->_app_signature;
|
|
||||||
cursor->_app_signature=NULL;
|
|
||||||
}
|
|
||||||
_cursorlist->RemoveItem(cursor);
|
_cursorlist->RemoveItem(cursor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -561,11 +547,8 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
|
|
||||||
_resize_nwse_csr=cursor;
|
_resize_nwse_csr=cursor;
|
||||||
|
|
||||||
if(cursor->_app_signature)
|
if(cursor->GetAppSignature())
|
||||||
{
|
cursor->SetAppSignature("");
|
||||||
delete cursor->_app_signature;
|
|
||||||
cursor->_app_signature=NULL;
|
|
||||||
}
|
|
||||||
_cursorlist->RemoveItem(cursor);
|
_cursorlist->RemoveItem(cursor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -576,11 +559,8 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
|
|
||||||
_resize_nesw_csr=cursor;
|
_resize_nesw_csr=cursor;
|
||||||
|
|
||||||
if(cursor->_app_signature)
|
if(cursor->GetAppSignature())
|
||||||
{
|
cursor->SetAppSignature("");
|
||||||
delete cursor->_app_signature;
|
|
||||||
cursor->_app_signature=NULL;
|
|
||||||
}
|
|
||||||
_cursorlist->RemoveItem(cursor);
|
_cursorlist->RemoveItem(cursor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -591,11 +571,8 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
|
|
||||||
_resize_ns_csr=cursor;
|
_resize_ns_csr=cursor;
|
||||||
|
|
||||||
if(cursor->_app_signature)
|
if(cursor->GetAppSignature())
|
||||||
{
|
cursor->SetAppSignature("");
|
||||||
delete cursor->_app_signature;
|
|
||||||
cursor->_app_signature=NULL;
|
|
||||||
}
|
|
||||||
_cursorlist->RemoveItem(cursor);
|
_cursorlist->RemoveItem(cursor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -606,11 +583,8 @@ void CursorManager::ChangeCursor(cursor_which which, int32 token)
|
|||||||
|
|
||||||
_resize_ew_csr=cursor;
|
_resize_ew_csr=cursor;
|
||||||
|
|
||||||
if(cursor->_app_signature)
|
if(cursor->GetAppSignature())
|
||||||
{
|
cursor->SetAppSignature("");
|
||||||
delete cursor->_app_signature;
|
|
||||||
cursor->_app_signature=NULL;
|
|
||||||
}
|
|
||||||
_cursorlist->RemoveItem(cursor);
|
_cursorlist->RemoveItem(cursor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@
|
|||||||
#include <List.h>
|
#include <List.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <PortLink.h>
|
#include <PortLink.h>
|
||||||
|
#include <PortMessage.h>
|
||||||
|
#include <PortQueue.h>
|
||||||
#include <SysCursor.h>
|
#include <SysCursor.h>
|
||||||
|
|
||||||
#include <Session.h>
|
#include <Session.h>
|
||||||
@@ -143,10 +145,6 @@ ServerApp::~ServerApp(void)
|
|||||||
_piclist->MakeEmpty();
|
_piclist->MakeEmpty();
|
||||||
delete _piclist;
|
delete _piclist;
|
||||||
|
|
||||||
// ADI:
|
|
||||||
delete ses;
|
|
||||||
ses = NULL;
|
|
||||||
|
|
||||||
delete _applink;
|
delete _applink;
|
||||||
_applink=NULL;
|
_applink=NULL;
|
||||||
if(_appcursor)
|
if(_appcursor)
|
||||||
@@ -248,70 +246,80 @@ void ServerApp::SetAppCursor(void)
|
|||||||
*/
|
*/
|
||||||
int32 ServerApp::MonitorApp(void *data)
|
int32 ServerApp::MonitorApp(void *data)
|
||||||
{
|
{
|
||||||
ServerApp *app=(ServerApp *)data;
|
|
||||||
|
|
||||||
// Message-dispatching loop for the ServerApp
|
// Message-dispatching loop for the ServerApp
|
||||||
int32 msgCode;
|
|
||||||
|
|
||||||
app->ses=new BSession( app->_receiver, 0L );
|
ServerApp *app=(ServerApp *)data;
|
||||||
|
PortQueue msgqueue(app->_receiver);
|
||||||
|
PortMessage *msg;
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
if(app->ses->ReadInt32(&msgCode)!= B_BAD_PORT_ID ){
|
if(!msgqueue.MessagesWaiting())
|
||||||
switch (msgCode){
|
msgqueue.GetMessagesFromPort(true);
|
||||||
case AS_QUIT_APP:
|
else
|
||||||
{
|
msgqueue.GetMessagesFromPort(false);
|
||||||
STRACE(("ServerApp %s:Server shutdown notification received\n",app->_signature.String()));
|
|
||||||
// If we are using the real, accelerated version of the
|
|
||||||
// DisplayDriver, we do NOT want the user to be able shut down
|
|
||||||
// the server. The results would NOT be pretty
|
|
||||||
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
|
|
||||||
|
|
||||||
// For now, it seems that we can't seem to try to play nice and tell
|
msg=msgqueue.GetMessageFromQueue();
|
||||||
// an application to quit, so we'll just have to go postal. XD
|
if(!msg)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch(msg->Code())
|
||||||
|
{
|
||||||
|
case AS_QUIT_APP:
|
||||||
|
{
|
||||||
|
STRACE(("ServerApp %s:Server shutdown notification received\n",app->_signature.String()));
|
||||||
|
// If we are using the real, accelerated version of the
|
||||||
|
// DisplayDriver, we do NOT want the user to be able shut down
|
||||||
|
// the server. The results would NOT be pretty
|
||||||
|
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
|
||||||
|
|
||||||
|
// For now, it seems that we can't seem to try to play nice and tell
|
||||||
|
// an application to quit, so we'll just have to go postal. XD
|
||||||
|
|
||||||
// BMessage *shutdown=new BMessage(_QUIT_);
|
// BMessage *shutdown=new BMessage(_QUIT_);
|
||||||
// SendMessage(app->_sender,shutdown);
|
// SendMessage(app->_sender,shutdown);
|
||||||
|
|
||||||
// DIE! DIE! DIE! :P
|
// DIE! DIE! DIE! :P
|
||||||
port_info pi;
|
port_info pi;
|
||||||
get_port_info(app->_sender,&pi);
|
get_port_info(app->_sender,&pi);
|
||||||
kill_team(pi.team);
|
kill_team(pi.team);
|
||||||
app->PostMessage(B_QUIT_REQUESTED);
|
app->PostMessage(B_QUIT_REQUESTED);
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case B_QUIT_REQUESTED:
|
case B_QUIT_REQUESTED:
|
||||||
|
{
|
||||||
|
// Our BApplication sent us this message when it quit.
|
||||||
|
// We need to ask the app_server to delete our monitor
|
||||||
|
port_id serverport=find_port(SERVER_PORT_NAME);
|
||||||
|
if(serverport==B_NAME_NOT_FOUND)
|
||||||
{
|
{
|
||||||
// Our BApplication sent us this message when it quit.
|
printf("PANIC: ServerApp %s could not find the app_server port!\n",app->_signature.String());
|
||||||
// We need to ask the app_server to delete our monitor
|
|
||||||
port_id serverport=find_port(SERVER_PORT_NAME);
|
|
||||||
if(serverport==B_NAME_NOT_FOUND)
|
|
||||||
{
|
|
||||||
printf("PANIC: ServerApp %s could not find the app_server port!\n",app->_signature.String());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
app->_applink->SetPort(serverport);
|
|
||||||
app->_applink->SetOpCode(AS_DELETE_APP);
|
|
||||||
app->_applink->Attach(&app->_monitor_thread,sizeof(thread_id));
|
|
||||||
app->_applink->Flush();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
app->_applink->SetPort(serverport);
|
||||||
{
|
app->_applink->SetOpCode(AS_DELETE_APP);
|
||||||
STRACE(("ServerApp %s: Got a Message to dispatch\n",app->_signature.String()));
|
app->_applink->Attach(&app->_monitor_thread,sizeof(thread_id));
|
||||||
app->_DispatchMessage(msgCode);
|
app->_applink->Flush();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // switch
|
default:
|
||||||
} // if
|
{
|
||||||
} // for
|
STRACE(("ServerApp %s: Got a Message to dispatch\n",app->_signature.String()));
|
||||||
|
app->_DispatchMessage(msg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete msg;
|
||||||
|
|
||||||
|
} // end for
|
||||||
|
|
||||||
exit_thread(0);
|
exit_thread(0);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -326,11 +334,10 @@ int32 ServerApp::MonitorApp(void *data)
|
|||||||
All attachments are placed in the buffer via a PortLink, so it will be a
|
All attachments are placed in the buffer via a PortLink, so it will be a
|
||||||
matter of casting and incrementing an index variable to access them.
|
matter of casting and incrementing an index variable to access them.
|
||||||
*/
|
*/
|
||||||
void ServerApp::_DispatchMessage(int32 code)
|
void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||||
{
|
{
|
||||||
LayerData ld;
|
LayerData ld;
|
||||||
|
switch(msg->Code())
|
||||||
switch(code)
|
|
||||||
{
|
{
|
||||||
case AS_UPDATED_CLIENT_FONTLIST:
|
case AS_UPDATED_CLIENT_FONTLIST:
|
||||||
{
|
{
|
||||||
@@ -365,22 +372,23 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
port_id looperPort;
|
port_id looperPort;
|
||||||
char *title;
|
char *title;
|
||||||
|
|
||||||
ses->ReadRect( &frame );
|
msg->Read<BRect>( &frame );
|
||||||
ses->ReadInt32( (int32*)&look );
|
msg->Read<int32>( (int32*)&look );
|
||||||
ses->ReadInt32( (int32*)&feel );
|
msg->Read<int32>( (int32*)&feel );
|
||||||
ses->ReadInt32( (int32*)&flags );
|
msg->Read<int32>( (int32*)&flags );
|
||||||
ses->ReadInt32( (int32*)&wkspaces );
|
msg->Read<int32>( (int32*)&wkspaces );
|
||||||
ses->ReadInt32( &token );
|
msg->Read<int32>( &token );
|
||||||
ses->ReadData( &sendPort, sizeof(port_id) );
|
msg->Read<port_id>( &sendPort );
|
||||||
ses->ReadData( &looperPort, sizeof(port_id) );
|
msg->Read<port_id>( &looperPort );
|
||||||
title = ses->ReadString();
|
msg->ReadString( &title );
|
||||||
|
|
||||||
STRACE(("ServerApp %s: Got 'New Window' message, trying to do smething...\n",
|
STRACE(("ServerApp %s: Got 'New Window' message, trying to do smething...\n",
|
||||||
_signature.String()));
|
_signature.String()));
|
||||||
|
|
||||||
// ServerWindow constructor will reply with port_id of a newly created port
|
// ServerWindow constructor will reply with port_id of a newly created port
|
||||||
ServerWindow *newwin = new ServerWindow( frame, title,
|
ServerWindow *newwin = new ServerWindow( frame, title,
|
||||||
look, feel, flags, this, sendPort, looperPort, wkspaces, token);
|
look, feel, flags, this, sendPort, looperPort, wkspaces, token);
|
||||||
|
|
||||||
_winlist->AddItem( newwin );
|
_winlist->AddItem( newwin );
|
||||||
//AddWindowToDesktop( newwin, workspace, ActiveScreen() );
|
//AddWindowToDesktop( newwin, workspace, ActiveScreen() );
|
||||||
|
|
||||||
@@ -388,7 +396,7 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
STRACE(("ServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n",
|
STRACE(("ServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n",
|
||||||
_signature.String(),title,frame.left,frame.top,frame.right,frame.bottom));
|
_signature.String(),title,frame.left,frame.top,frame.right,frame.bottom));
|
||||||
|
|
||||||
delete title;
|
delete title;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -400,7 +408,7 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
// 1) uint32 ServerWindow ID token
|
// 1) uint32 ServerWindow ID token
|
||||||
ServerWindow *w;
|
ServerWindow *w;
|
||||||
uint32 winid;
|
uint32 winid;
|
||||||
ses->ReadUInt32(&winid);
|
msg->Read<uint32>(&winid);
|
||||||
|
|
||||||
for(int32 i=0;i<_winlist->CountItems();i++)
|
for(int32 i=0;i<_winlist->CountItems();i++)
|
||||||
{
|
{
|
||||||
@@ -417,6 +425,7 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
}
|
}
|
||||||
case AS_CREATE_BITMAP:
|
case AS_CREATE_BITMAP:
|
||||||
{
|
{
|
||||||
|
debugger("");
|
||||||
// Allocate a bitmap for an application
|
// Allocate a bitmap for an application
|
||||||
|
|
||||||
// Attached Data:
|
// Attached Data:
|
||||||
@@ -440,12 +449,12 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
int32 f,bpr;
|
int32 f,bpr;
|
||||||
screen_id s;
|
screen_id s;
|
||||||
|
|
||||||
ses->ReadRect(&r);
|
msg->Read<BRect>(&r);
|
||||||
ses->ReadData(&cs,sizeof(color_space));
|
msg->Read<color_space>(&cs);
|
||||||
ses->ReadInt32(&f);
|
msg->Read<int32>(&f);
|
||||||
ses->ReadInt32(&bpr);
|
msg->Read<int32>(&bpr);
|
||||||
ses->ReadData(&s,sizeof(screen_id));
|
msg->Read<screen_id>(&s);
|
||||||
ses->ReadInt32(&replyport);
|
msg->Read<int32>(&replyport);
|
||||||
|
|
||||||
ServerBitmap *sbmp=bitmapmanager->CreateBitmap(r,cs,f,bpr,s);
|
ServerBitmap *sbmp=bitmapmanager->CreateBitmap(r,cs,f,bpr,s);
|
||||||
|
|
||||||
@@ -454,18 +463,17 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
|
|
||||||
if(sbmp)
|
if(sbmp)
|
||||||
{
|
{
|
||||||
// list for doing faster lookups for a bitmap than what the BitmapManager
|
PortLink replylink(replyport);
|
||||||
// can do.
|
replylink.Attach<int32>(sbmp->Token());
|
||||||
BSession replysession(0,replyport);
|
replylink.Attach<int32>(sbmp->Area());
|
||||||
replysession.WriteInt32(sbmp->Token());
|
replylink.Attach<int32>(sbmp->AreaOffset());
|
||||||
replysession.WriteInt32(sbmp->Area());
|
replylink.Flush();
|
||||||
replysession.WriteInt32(sbmp->AreaOffset());
|
|
||||||
replysession.Sync();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// alternatively, if something went wrong, we reply with SERVER_FALSE
|
// alternatively, if something went wrong, we reply with SERVER_FALSE
|
||||||
write_port(replyport,SERVER_FALSE,NULL,0);
|
int32 code=SERVER_FALSE;
|
||||||
|
write_port(replyport,SERVER_FALSE,&code,sizeof(int32));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -483,8 +491,8 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
port_id replyport;
|
port_id replyport;
|
||||||
int32 bmp_id;
|
int32 bmp_id;
|
||||||
|
|
||||||
ses->ReadInt32(&bmp_id);
|
msg->Read<int32>(&bmp_id);
|
||||||
ses->ReadInt32(&replyport);
|
msg->Read<int32>(&replyport);
|
||||||
|
|
||||||
ServerBitmap *sbmp=_FindBitmap(bmp_id);
|
ServerBitmap *sbmp=_FindBitmap(bmp_id);
|
||||||
if(sbmp)
|
if(sbmp)
|
||||||
@@ -537,9 +545,9 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
int32 workspace;
|
int32 workspace;
|
||||||
uint32 mode;
|
uint32 mode;
|
||||||
bool stick;
|
bool stick;
|
||||||
ses->ReadInt32(&workspace);
|
msg->Read<int32>(&workspace);
|
||||||
ses->ReadUInt32(&mode);
|
msg->Read<uint32>(&mode);
|
||||||
ses->ReadBool(&stick);
|
msg->Read<bool>(&stick);
|
||||||
|
|
||||||
SetSpace(workspace,mode,ActiveScreen(),stick);
|
SetSpace(workspace,mode,ActiveScreen(),stick);
|
||||||
|
|
||||||
@@ -552,7 +560,7 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
|
|
||||||
// Error-checking is done in ActivateWorkspace, so this is a safe call
|
// Error-checking is done in ActivateWorkspace, so this is a safe call
|
||||||
int32 workspace;
|
int32 workspace;
|
||||||
ses->ReadInt32(&workspace);
|
msg->Read<int32>(&workspace);
|
||||||
SetWorkspace(workspace);
|
SetWorkspace(workspace);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -581,7 +589,7 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
// Attached data
|
// Attached data
|
||||||
// 1) int32 port to reply to
|
// 1) int32 port to reply to
|
||||||
int32 replyport;
|
int32 replyport;
|
||||||
ses->ReadInt32(&replyport);
|
msg->Read<int32>(&replyport);
|
||||||
|
|
||||||
write_port(replyport,(_cursorhidden)?SERVER_TRUE:SERVER_FALSE,NULL,0);
|
write_port(replyport,(_cursorhidden)?SERVER_TRUE:SERVER_FALSE,NULL,0);
|
||||||
break;
|
break;
|
||||||
@@ -591,7 +599,7 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
// Attached data: 68 bytes of _appcursor data
|
// Attached data: 68 bytes of _appcursor data
|
||||||
|
|
||||||
int8 cdata[68];
|
int8 cdata[68];
|
||||||
ses->ReadData(cdata,68);
|
msg->Read(cdata,68);
|
||||||
|
|
||||||
// Because we don't want an overaccumulation of these particular
|
// Because we don't want an overaccumulation of these particular
|
||||||
// cursors, we will delete them if there is an existing one. It would
|
// cursors, we will delete them if there is an existing one. It would
|
||||||
@@ -616,10 +624,10 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
int32 ctoken;
|
int32 ctoken;
|
||||||
port_id replyport;
|
port_id replyport;
|
||||||
|
|
||||||
ses->ReadBool(&sync);
|
msg->Read<bool>(&sync);
|
||||||
ses->ReadInt32(&ctoken);
|
msg->Read<int32>(&ctoken);
|
||||||
if(sync)
|
if(sync)
|
||||||
ses->ReadInt32(&replyport);
|
msg->Read<int32>(&replyport);
|
||||||
|
|
||||||
cursormanager->SetCursor(ctoken);
|
cursormanager->SetCursor(ctoken);
|
||||||
|
|
||||||
@@ -627,7 +635,8 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
{
|
{
|
||||||
// the application is expecting a reply, but plans to do literally nothing
|
// the application is expecting a reply, but plans to do literally nothing
|
||||||
// with the data, so we'll just reuse the cursor token variable
|
// with the data, so we'll just reuse the cursor token variable
|
||||||
write_port(replyport,AS_SERVER_SESSION, &ctoken, sizeof(int32));
|
ctoken=AS_SET_CURSOR_BCURSOR;
|
||||||
|
write_port(replyport,ctoken, &ctoken, sizeof(int32));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -640,17 +649,17 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
port_id replyport;
|
port_id replyport;
|
||||||
int8 cdata[68];
|
int8 cdata[68];
|
||||||
|
|
||||||
ses->ReadData(cdata,68);
|
msg->Read(cdata,68);
|
||||||
ses->ReadInt32(&replyport);
|
msg->Read<int32>(&replyport);
|
||||||
|
|
||||||
_appcursor=new ServerCursor(cdata);
|
_appcursor=new ServerCursor(cdata);
|
||||||
_appcursor->SetAppSignature(_signature.String());
|
_appcursor->SetAppSignature(_signature.String());
|
||||||
cursormanager->AddCursor(_appcursor);
|
cursormanager->AddCursor(_appcursor);
|
||||||
|
|
||||||
// Synchronous message - BApplication is waiting on the cursor's ID
|
// Synchronous message - BApplication is waiting on the cursor's ID
|
||||||
PortLink link(replyport);
|
BSession s(0,replyport);
|
||||||
link.Attach<int32>(_appcursor->ID());
|
s.WriteInt32(_appcursor->ID());
|
||||||
link.Flush();
|
s.Sync();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AS_DELETE_BCURSOR:
|
case AS_DELETE_BCURSOR:
|
||||||
@@ -658,7 +667,7 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
// Attached data:
|
// Attached data:
|
||||||
// 1) int32 token ID of the cursor to delete
|
// 1) int32 token ID of the cursor to delete
|
||||||
int32 ctoken;
|
int32 ctoken;
|
||||||
ses->ReadInt32(&ctoken);
|
msg->Read<int32>(&ctoken);
|
||||||
|
|
||||||
if(_appcursor && _appcursor->ID()==ctoken)
|
if(_appcursor && _appcursor->ID()==ctoken)
|
||||||
_appcursor=NULL;
|
_appcursor=NULL;
|
||||||
@@ -673,7 +682,7 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
scroll_bar_info sbi=GetScrollBarInfo();
|
scroll_bar_info sbi=GetScrollBarInfo();
|
||||||
|
|
||||||
port_id replyport;
|
port_id replyport;
|
||||||
ses->ReadInt32(&replyport);
|
msg->Read<int32>(&replyport);
|
||||||
|
|
||||||
BSession replysession(0,replyport);
|
BSession replysession(0,replyport);
|
||||||
replysession.WriteData(&sbi,sizeof(scroll_bar_info));
|
replysession.WriteData(&sbi,sizeof(scroll_bar_info));
|
||||||
@@ -685,7 +694,7 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
// Attached Data:
|
// Attached Data:
|
||||||
// 1) scroll_bar_info scroll bar info structure
|
// 1) scroll_bar_info scroll bar info structure
|
||||||
scroll_bar_info sbi;
|
scroll_bar_info sbi;
|
||||||
ses->ReadData(&sbi,sizeof(scroll_bar_info));
|
msg->Read<scroll_bar_info>(&sbi);
|
||||||
SetScrollBarInfo(sbi);
|
SetScrollBarInfo(sbi);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -695,7 +704,7 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
// 1) port_id reply port - synchronous message
|
// 1) port_id reply port - synchronous message
|
||||||
|
|
||||||
port_id replyport;
|
port_id replyport;
|
||||||
ses->ReadInt32(&replyport);
|
msg->Read<int32>(&replyport);
|
||||||
|
|
||||||
BSession replysession(0,replyport);
|
BSession replysession(0,replyport);
|
||||||
replysession.WriteBool(GetFFMouse());
|
replysession.WriteBool(GetFFMouse());
|
||||||
@@ -707,7 +716,7 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
// Attached Data:
|
// Attached Data:
|
||||||
// 1) scroll_bar_info scroll bar info structure
|
// 1) scroll_bar_info scroll bar info structure
|
||||||
scroll_bar_info sbi;
|
scroll_bar_info sbi;
|
||||||
ses->ReadData(&sbi,sizeof(scroll_bar_info));
|
msg->Read<scroll_bar_info>(&sbi);
|
||||||
SetScrollBarInfo(sbi);
|
SetScrollBarInfo(sbi);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -716,7 +725,7 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
// Attached Data:
|
// Attached Data:
|
||||||
// 1) enum mode_mouse FFM mouse mode
|
// 1) enum mode_mouse FFM mouse mode
|
||||||
mode_mouse mmode;
|
mode_mouse mmode;
|
||||||
ses->ReadData(&mmode,sizeof(mode_mouse));
|
msg->Read<mode_mouse>(&mmode);
|
||||||
SetFFMouseMode(mmode);
|
SetFFMouseMode(mmode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -727,7 +736,7 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
mode_mouse mmode=GetFFMouseMode();
|
mode_mouse mmode=GetFFMouseMode();
|
||||||
|
|
||||||
port_id replyport;
|
port_id replyport;
|
||||||
ses->ReadInt32(&replyport);
|
msg->Read<int32>(&replyport);
|
||||||
|
|
||||||
BSession replysession(0,replyport);
|
BSession replysession(0,replyport);
|
||||||
replysession.WriteData(&mmode,sizeof(mode_mouse));
|
replysession.WriteData(&mmode,sizeof(mode_mouse));
|
||||||
@@ -736,7 +745,7 @@ void ServerApp::_DispatchMessage(int32 code)
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
STRACE(("ServerApp %s received unhandled message code offset %s\n",_signature.String(),MsgCodeToString(code)));
|
STRACE(("ServerApp %s received unhandled message code offset %s\n",_signature.String(),MsgCodeToString(msg->Code())));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,11 +30,10 @@
|
|||||||
#include <OS.h>
|
#include <OS.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
#include <Session.h>
|
|
||||||
|
|
||||||
class AppServer;
|
class AppServer;
|
||||||
class BMessage;
|
class BMessage;
|
||||||
class PortLink;
|
class PortLink;
|
||||||
|
class PortMessage;
|
||||||
class BList;
|
class BList;
|
||||||
class DisplayDriver;
|
class DisplayDriver;
|
||||||
class ServerCursor;
|
class ServerCursor;
|
||||||
@@ -70,7 +69,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
friend class AppServer;
|
friend class AppServer;
|
||||||
friend class ServerWindow;
|
friend class ServerWindow;
|
||||||
void _DispatchMessage(int32 code);
|
void _DispatchMessage(PortMessage *msg);
|
||||||
ServerBitmap *_FindBitmap(int32 token);
|
ServerBitmap *_FindBitmap(int32 token);
|
||||||
|
|
||||||
port_id _sender,_receiver;
|
port_id _sender,_receiver;
|
||||||
@@ -85,7 +84,6 @@ protected:
|
|||||||
bool _cursorhidden;
|
bool _cursorhidden;
|
||||||
bool _isactive;
|
bool _isactive;
|
||||||
int32 _handlertoken;
|
int32 _handlertoken;
|
||||||
BSession *ses;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -26,7 +26,6 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
#include "ServerCursor.h"
|
#include "ServerCursor.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
|
||||||
/*!
|
/*!
|
||||||
\brief Constructor
|
\brief Constructor
|
||||||
\param r Size of the cursor
|
\param r Size of the cursor
|
||||||
@@ -41,7 +40,6 @@ ServerCursor::ServerCursor(BRect r, color_space cspace, int32 flags, BPoint hots
|
|||||||
{
|
{
|
||||||
_hotspot=hotspot;
|
_hotspot=hotspot;
|
||||||
_hotspot.ConstrainTo(Bounds());
|
_hotspot.ConstrainTo(Bounds());
|
||||||
_app_signature=NULL;
|
|
||||||
|
|
||||||
_AllocateBuffer();
|
_AllocateBuffer();
|
||||||
}
|
}
|
||||||
@@ -103,7 +101,6 @@ ServerCursor::ServerCursor(int8 *data)
|
|||||||
_bytesperrow=0;
|
_bytesperrow=0;
|
||||||
_space=B_NO_COLOR_SPACE;
|
_space=B_NO_COLOR_SPACE;
|
||||||
}
|
}
|
||||||
_app_signature=NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -115,7 +112,6 @@ ServerCursor::ServerCursor(const ServerCursor *cursor)
|
|||||||
{
|
{
|
||||||
_AllocateBuffer();
|
_AllocateBuffer();
|
||||||
_initialized=true;
|
_initialized=true;
|
||||||
_app_signature=NULL;
|
|
||||||
|
|
||||||
if(cursor)
|
if(cursor)
|
||||||
{
|
{
|
||||||
@@ -129,8 +125,6 @@ ServerCursor::ServerCursor(const ServerCursor *cursor)
|
|||||||
ServerCursor::~ServerCursor(void)
|
ServerCursor::~ServerCursor(void)
|
||||||
{
|
{
|
||||||
_FreeBuffer();
|
_FreeBuffer();
|
||||||
if(_app_signature)
|
|
||||||
delete _app_signature;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -145,12 +139,5 @@ void ServerCursor::SetHotSpot(BPoint pt)
|
|||||||
|
|
||||||
void ServerCursor::SetAppSignature(const char *signature)
|
void ServerCursor::SetAppSignature(const char *signature)
|
||||||
{
|
{
|
||||||
if(_app_signature)
|
_app_signature.SetTo( (signature)?signature:"" );
|
||||||
delete _app_signature;
|
|
||||||
|
|
||||||
if(signature)
|
|
||||||
{
|
|
||||||
_app_signature=new char[strlen(signature)];
|
|
||||||
strcpy(_app_signature, signature);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <GraphicsDefs.h>
|
#include <GraphicsDefs.h>
|
||||||
#include <PortLink.h>
|
#include <PortLink.h>
|
||||||
|
#include <Session.h>
|
||||||
#include "AppServer.h"
|
#include "AppServer.h"
|
||||||
#include "Layer.h"
|
#include "Layer.h"
|
||||||
#include "RootLayer.h"
|
#include "RootLayer.h"
|
||||||
|
|||||||
Reference in New Issue
Block a user