Pahtz's changes to use BPortLink systemwide, with a few minor other changes

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8520 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2004-07-30 15:16:59 +00:00
parent 3ceb31b96a
commit ad56ce66a3
18 changed files with 713 additions and 700 deletions
+124 -103
View File
@@ -26,15 +26,11 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include <AppDefs.h> #include <AppDefs.h>
#include <Accelerant.h> #include <Accelerant.h>
#include <PortMessage.h>
#include <Entry.h> #include <Entry.h>
#include <Path.h> #include <Path.h>
#include <Directory.h> #include <Directory.h>
#include <PortMessage.h>
#include <PortLink.h> #include <PortLink.h>
#include <Session.h>
#include <File.h> #include <File.h>
#include <Message.h> #include <Message.h>
#include "AppServer.h" #include "AppServer.h"
@@ -53,8 +49,17 @@
#include "Desktop.h" #include "Desktop.h"
//#define DEBUG_KEYHANDLING //#define DEBUG_KEYHANDLING
//#define DEBUG_SERVER
#ifdef DEBUG_KEYHANDLING #ifdef DEBUG_KEYHANDLING
# include <stdio.h> # include <stdio.h>
# define KBTRACE(x) printf x
#else
# define KBTRACE(x) ;
#endif
#ifdef DEBUG_SERVER
# include <stdio.h>
# define STRACE(x) printf x # define STRACE(x) printf x
#else #else
# define STRACE(x) ; # define STRACE(x) ;
@@ -86,7 +91,7 @@ AppServer::AppServer(void)
#endif #endif
{ {
fMousePort= create_port(200,SERVER_INPUT_PORT); fMousePort= create_port(200,SERVER_INPUT_PORT);
_fMessagePort= create_port(200,SERVER_PORT_NAME); fMessagePort= create_port(200,SERVER_PORT_NAME);
fAppList= new BList(0); fAppList= new BList(0);
fQuittingServer= false; fQuittingServer= false;
@@ -206,22 +211,23 @@ AppServer::~AppServer(void)
int32 AppServer::PollerThread(void *data) int32 AppServer::PollerThread(void *data)
{ {
// This thread handles nothing but input messages for mouse and keyboard // This thread handles nothing but input messages for mouse and keyboard
AppServer *appserver=(AppServer*)data; AppServer *appserver=(AppServer*)data;
PortQueue mousequeue(appserver->fMousePort); BPortLink mousequeue(-1,appserver->fMousePort);
PortMessage *msg; int32 code=0;
status_t err=B_OK;
for(;;) for(;;)
{ {
if(!mousequeue.MessagesWaiting()) STRACE(("info: AppServer::PollerThread listening on port %ld.\n", appserver->fMousePort));
mousequeue.GetMessagesFromPort(true); err=mousequeue.GetNextReply(&code);
else
mousequeue.GetMessagesFromPort(false); if(err<B_OK)
{
msg= mousequeue.GetMessageFromQueue(); STRACE(("PollerThread:mousequeue.GetNextReply failed\n"));
if(!msg)
continue; continue;
}
switch(msg->Code())
switch(code)
{ {
// We don't need to do anything with these two, so just pass them // We don't need to do anything with these two, so just pass them
// onto the active application. Eventually, we will end up passing // onto the active application. Eventually, we will end up passing
@@ -230,7 +236,7 @@ int32 AppServer::PollerThread(void *data)
case B_MOUSE_UP: case B_MOUSE_UP:
case B_MOUSE_WHEEL_CHANGED: case B_MOUSE_WHEEL_CHANGED:
case B_MOUSE_MOVED: case B_MOUSE_MOVED:
desktop->MouseEventHandler(msg); desktop->MouseEventHandler(code,mousequeue);
break; break;
case B_KEY_DOWN: case B_KEY_DOWN:
@@ -238,20 +244,18 @@ int32 AppServer::PollerThread(void *data)
case B_UNMAPPED_KEY_DOWN: case B_UNMAPPED_KEY_DOWN:
case B_UNMAPPED_KEY_UP: case B_UNMAPPED_KEY_UP:
case B_MODIFIERS_CHANGED: case B_MODIFIERS_CHANGED:
desktop->KeyboardEventHandler(msg); desktop->KeyboardEventHandler(code,mousequeue);
break; break;
default: default:
printf("Server::Poller received unexpected code %lx\n",msg->Code()); STRACE(("AppServer::Poller received unexpected code %lx\n",code));
break; break;
} }
delete msg;
if(appserver->fExitPoller) if(appserver->fExitPoller)
break; break;
} }
return 0; return err;
} }
/*! /*!
@@ -304,41 +308,45 @@ thread_id AppServer::Run(void)
//! Main message-monitoring loop for the regular message port - no input messages! //! Main message-monitoring loop for the regular message port - no input messages!
void AppServer::MainLoop(void) void AppServer::MainLoop(void)
{ {
PortMessage pmsg; BPortLink pmsg(-1,fMessagePort);
int32 code=0;
status_t err=B_OK;
while(1) while(1)
{ {
if(pmsg.ReadFromPort(_fMessagePort)== B_OK) STRACE(("info: AppServer::MainLoop listening on port %ld.\n", fMessagePort));
{ err=pmsg.GetNextReply(&code);
if(pmsg.Protocol()== B_QUIT_REQUESTED)
pmsg.SetCode(B_QUIT_REQUESTED);
switch(pmsg.Code())
{
case B_QUIT_REQUESTED:
case AS_CREATE_APP:
case AS_DELETE_APP:
case AS_GET_SCREEN_MODE:
case AS_UPDATED_CLIENT_FONTLIST:
case AS_QUERY_FONTS_CHANGED:
case AS_SET_UI_COLORS:
case AS_GET_UI_COLOR:
case AS_SET_DECORATOR:
case AS_GET_DECORATOR:
case AS_R5_SET_DECORATOR:
DispatchMessage(&pmsg);
break;
default:
{
printf("Server::MainLoop received unexpected code %ld(offset %ld)\n",
pmsg.Code(),pmsg.Code()-SERVER_TRUE);
break;
}
}
if(err<B_OK)
{
STRACE(("MainLoop:pmsg.GetNextReply failed\n"));
continue;
}
switch(code)
{
case B_QUIT_REQUESTED:
case AS_CREATE_APP:
case AS_DELETE_APP:
case AS_GET_SCREEN_MODE:
case AS_UPDATED_CLIENT_FONTLIST:
case AS_QUERY_FONTS_CHANGED:
case AS_SET_UI_COLORS:
case AS_GET_UI_COLOR:
case AS_SET_DECORATOR:
case AS_GET_DECORATOR:
case AS_R5_SET_DECORATOR:
DispatchMessage(code,pmsg);
break;
default:
{
STRACE(("Server::MainLoop received unexpected code %ld(offset %ld)\n",
code,code-SERVER_TRUE));
break;
}
} }
if(pmsg.Code()==AS_DELETE_APP || (pmsg.Protocol()==B_QUIT_REQUESTED && DISPLAYDRIVER!=HWDRIVER)) if(code==AS_DELETE_APP || (code==B_QUIT_REQUESTED && DISPLAYDRIVER!=HWDRIVER))
{ {
if(fQuittingServer== true && fAppList->CountItems()== 0) if(fQuittingServer== true && fAppList->CountItems()== 0)
break; break;
@@ -384,13 +392,14 @@ bool AppServer::LoadDecorator(const char *path)
// Get the instantiation function // 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){ if(stat != B_OK)
{
unload_add_on(addon); unload_add_on(addon);
return false; return false;
} }
BPath temppath(path); BPath temppath(path);
fDecoratorName= temppath.Leaf(); fDecoratorName=temppath.Leaf();
acquire_sem(fDecoratorLock); acquire_sem(fDecoratorLock);
make_decorator=pcreatefunc; make_decorator=pcreatefunc;
@@ -436,12 +445,12 @@ void AppServer::InitDecorators(void)
/*! /*!
\brief Message handling function for all messages sent to the app_server \brief Message handling function for all messages sent to the app_server
\param code ID of the message sent \param code ID of the message sent
\param buffer Attachement buffer for the message. \param buffer Attachment buffer for the message.
*/ */
void AppServer::DispatchMessage(PortMessage *msg) void AppServer::DispatchMessage(int32 code, BPortLink &msg)
{ {
switch(msg->Code()) switch(code)
{ {
case AS_CREATE_APP: case AS_CREATE_APP:
{ {
@@ -456,45 +465,47 @@ void AppServer::DispatchMessage(PortMessage *msg)
// 5) port_id - port to reply to // 5) port_id - port to reply to
// Find the necessary data // Find the necessary data
team_id clientTeamID; team_id clientTeamID=-1;
port_id clientLooperPort; port_id clientLooperPort=-1;
port_id reply_port; port_id reply_port=-1; // TODO: deprecated
port_id app_port; port_id app_port=-1;
int32 htoken; int32 htoken=B_NULL_TOKEN;
char* app_signature; char *app_signature=NULL;
msg->Read<port_id>(&app_port); msg.Read<port_id>(&app_port);
msg->Read<port_id>(&clientLooperPort); msg.Read<port_id>(&clientLooperPort);
msg->Read<team_id>(&clientTeamID); msg.Read<team_id>(&clientTeamID);
msg->Read<int32>(&htoken); msg.Read<int32>(&htoken);
msg->ReadString(&app_signature); msg.ReadString(&app_signature);
msg->Read<int32>(&reply_port); msg.Read<int32>(&reply_port);
// Create the ServerApp subthread for this app // Create the ServerApp subthread for this app
acquire_sem(fAppListLock); acquire_sem(fAppListLock);
port_id r= create_port(DEFAULT_MONITOR_PORT_SIZE, app_signature); port_id server_listen=create_port(DEFAULT_MONITOR_PORT_SIZE, app_signature);
if(r== B_NO_MORE_PORTS || r== B_BAD_VALUE) if(server_listen<B_OK)
{ {
release_sem(fAppListLock); release_sem(fAppListLock);
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; ServerApp *newapp=NULL;
newapp= new ServerApp(app_port, r, clientLooperPort, clientTeamID, htoken, app_signature); newapp= new ServerApp(app_port,server_listen, clientLooperPort, clientTeamID,
htoken, app_signature);
// add the new ServerApp to the known list of ServerApps // add the new ServerApp to the known list of ServerApps
fAppList->AddItem(newapp); fAppList->AddItem(newapp);
release_sem(fAppListLock); release_sem(fAppListLock);
PortLink replylink(reply_port); BPortLink replylink(reply_port);
replylink.SetOpCode(AS_SET_SERVER_PORT); replylink.StartMessage(AS_SET_SERVER_PORT);
replylink.Attach<int32>(newapp->fMessagePort); replylink.Attach<int32>(newapp->fMessagePort);
replylink.Flush(); replylink.Flush();
// This is necessary because PortLink::ReadString allocates memory // This is necessary because BPortLink::ReadString allocates memory
delete app_signature; if(app_signature)
free(app_signature);
break; break;
} }
@@ -506,12 +517,14 @@ void AppServer::DispatchMessage(PortMessage *msg)
// Attached Data: // Attached Data:
// 1) thread_id - thread ID of the ServerApp to be deleted // 1) thread_id - thread ID of the ServerApp to be deleted
int32 i, int32 i=0,
appnum= fAppList->CountItems(); appnum=fAppList->CountItems();
ServerApp *srvapp;
ServerApp *srvapp=NULL;
thread_id srvapp_id=-1;
thread_id srvapp_id; if(msg.Read<thread_id>(&srvapp_id)<B_OK)
msg->Read<thread_id>(&srvapp_id); break;
acquire_sem(fAppListLock); acquire_sem(fAppListLock);
@@ -523,7 +536,8 @@ void AppServer::DispatchMessage(PortMessage *msg)
if(srvapp != NULL && srvapp->fMonitorThreadID== srvapp_id) if(srvapp != NULL && srvapp->fMonitorThreadID== srvapp_id)
{ {
srvapp=(ServerApp *)fAppList->RemoveItem(i); srvapp=(ServerApp *)fAppList->RemoveItem(i);
if(srvapp){ if(srvapp)
{
status_t temp; status_t temp;
wait_for_thread(srvapp_id, &temp); wait_for_thread(srvapp_id, &temp);
delete srvapp; delete srvapp;
@@ -557,12 +571,15 @@ void AppServer::DispatchMessage(PortMessage *msg)
bool needs_update=fontserver->FontsNeedUpdated(); bool needs_update=fontserver->FontsNeedUpdated();
fontserver->Unlock(); fontserver->Unlock();
// Seeing how the client merely wants an answer, we'll skip the PortLink // Seeing how the client merely wants an answer, we'll skip the BPortLink
// and all its overhead and just write the code to port. // and all its overhead and just write the code to port.
port_id replyport; port_id replyport;
msg->Read<port_id>(&replyport); if (msg.Read<port_id>(&replyport) < B_OK)
break;
BPortLink replylink(replyport);
replylink.StartMessage(needs_update ? SERVER_TRUE : SERVER_FALSE);
replylink.Flush();
write_port(replyport, (needs_update)?SERVER_TRUE:SERVER_FALSE, NULL,0);
break; break;
} }
case AS_SET_UI_COLORS: case AS_SET_UI_COLORS:
@@ -574,7 +591,7 @@ void AppServer::DispatchMessage(PortMessage *msg)
// 1) ColorSet new colors to use // 1) ColorSet new colors to use
gui_colorset.Lock(); gui_colorset.Lock();
msg->Read<ColorSet>(&gui_colorset); msg.Read<ColorSet>(&gui_colorset);
gui_colorset.Unlock(); gui_colorset.Unlock();
Broadcast(AS_UPDATE_COLORS); Broadcast(AS_UPDATE_COLORS);
break; break;
@@ -587,8 +604,8 @@ void AppServer::DispatchMessage(PortMessage *msg)
// Attached Data: // Attached Data:
// char * name of the decorator in the decorators path to use // char * name of the decorator in the decorators path to use
char *decname; char *decname=NULL;
msg->ReadString(&decname); msg.ReadString(&decname);
if(decname) if(decname)
{ {
if(strcmp(decname,"Default")!=0) if(strcmp(decname,"Default")!=0)
@@ -605,7 +622,7 @@ void AppServer::DispatchMessage(PortMessage *msg)
Broadcast(AS_UPDATE_DECORATOR); Broadcast(AS_UPDATE_DECORATOR);
} }
} }
delete decname; free(decname);
break; break;
} }
@@ -614,10 +631,12 @@ void AppServer::DispatchMessage(PortMessage *msg)
// Attached Data: // Attached Data:
// 1) port_id reply port // 1) port_id reply port
port_id replyport; port_id replyport=-1;
msg->Read<port_id>(&replyport); if(msg.Read<port_id>(&replyport)<B_OK)
PortLink replylink(replyport); return;
replylink.SetOpCode(AS_GET_DECORATOR);
BPortLink replylink(replyport);
replylink.StartMessage(AS_GET_DECORATOR);
replylink.AttachString(fDecoratorName.String()); replylink.AttachString(fDecoratorName.String());
replylink.Flush(); replylink.Flush();
break; break;
@@ -630,8 +649,9 @@ void AppServer::DispatchMessage(PortMessage *msg)
// Attached Data: // Attached Data:
// char * name of the decorator in the decorators path to use // char * name of the decorator in the decorators path to use
int32 decindex; int32 decindex=0;
msg->Read<int32>(&decindex); if(msg.Read<int32>(&decindex)<B_OK)
break;
BString decpath; BString decpath;
decpath.SetTo(DECORATORS_DIR); decpath.SetTo(DECORATORS_DIR);
@@ -666,11 +686,12 @@ void AppServer::DispatchMessage(PortMessage *msg)
display_mode dmode; display_mode dmode;
fDriver->GetMode(&dmode); fDriver->GetMode(&dmode);
port_id replyport; port_id replyport=-1;
msg->Read<port_id>(&replyport); if(msg.Read<port_id>(&replyport)<B_OK)
break;
PortLink replylink(replyport); BPortLink replylink(replyport);
replylink.SetOpCode(AS_GET_SCREEN_MODE); replylink.StartMessage(AS_GET_SCREEN_MODE);
replylink.Attach<display_mode>(dmode); replylink.Attach<display_mode>(dmode);
replylink.Flush(); replylink.Flush();
break; break;
+2 -4
View File
@@ -6,7 +6,6 @@
#include <List.h> #include <List.h>
#include <Application.h> #include <Application.h>
#include <Window.h> #include <Window.h>
#include <PortQueue.h>
#include <String.h> #include <String.h>
#include "Decorator.h" #include "Decorator.h"
#include "ServerConfig.h" #include "ServerConfig.h"
@@ -17,7 +16,6 @@ class ServerApp;
class DisplayDriver; class DisplayDriver;
class CursorManager; class CursorManager;
class BitmapManager; class BitmapManager;
class PortMessage;
/*! /*!
\class AppServer AppServer.h \class AppServer AppServer.h
@@ -45,7 +43,7 @@ public:
bool LoadDecorator(const char *path); bool LoadDecorator(const char *path);
void InitDecorators(void); void InitDecorators(void);
void DispatchMessage(PortMessage *msg); void DispatchMessage(int32 code, BPortLink &link);
void Broadcast(int32 code); void Broadcast(int32 code);
ServerApp* FindApp(const char *sig); ServerApp* FindApp(const char *sig);
@@ -57,7 +55,7 @@ private:
// global function pointer // global function pointer
create_decorator *make_decorator; create_decorator *make_decorator;
port_id _fMessagePort, port_id fMessagePort,
fMousePort; fMousePort;
image_id fDecoratorID; image_id fDecoratorID;
+131 -83
View File
@@ -35,7 +35,6 @@
#include "DisplayDriver.h" #include "DisplayDriver.h"
#include "Globals.h" #include "Globals.h"
#include "Layer.h" #include "Layer.h"
#include "PortMessage.h"
#include "RootLayer.h" #include "RootLayer.h"
#include "ServerConfig.h" #include "ServerConfig.h"
#include "ServerScreen.h" #include "ServerScreen.h"
@@ -259,14 +258,6 @@ void Desktop::AddWinBorder(WinBorder* winBorder)
// other windows are added to the current RootLayer only. // other windows are added to the current RootLayer only.
ActiveRootLayer()->AddWinBorder(winBorder); ActiveRootLayer()->AddWinBorder(winBorder);
// TODO: try to unify this code with that for B_MOUSE_DOWN
winBorder->Window()->Lock();
BRegion invalidRegion;
invalidRegion.Include(&(winBorder->fFull));
invalidRegion.Include(&(winBorder->fTopLayer->fFull));
winBorder->fParent->RebuildAndForceRedraw(invalidRegion, winBorder);
winBorder->Window()->Unlock();
// add that pointer to user winboder list so that we can keep track of them. // add that pointer to user winboder list so that we can keep track of them.
fLayerLock.Lock(); fLayerLock.Lock();
fWinBorderList.AddItem(winBorder); fWinBorderList.AddItem(winBorder);
@@ -302,10 +293,10 @@ bool Desktop::HasWinBorder(WinBorder* winBorder)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Input related methods // Input related methods
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void Desktop::MouseEventHandler(PortMessage *msg) void Desktop::MouseEventHandler(int32 code, BPortLink& msg)
{ {
// TODO: locking mechanism needs SERIOUS rethought // TODO: locking mechanism needs SERIOUS rethought
switch(msg->Code()) switch(code)
{ {
case B_MOUSE_DOWN: case B_MOUSE_DOWN:
{ {
@@ -317,24 +308,24 @@ void Desktop::MouseEventHandler(PortMessage *msg)
// 5) int32 - buttons down // 5) int32 - buttons down
// 6) int32 - clicks // 6) int32 - clicks
BPoint pt; PointerEvent evt;
int64 dummy; evt.code = B_MOUSE_DOWN;
msg.Read<int64>(&evt.when);
msg.Read<float>(&evt.where.x);
msg.Read<float>(&evt.where.y);
msg.Read<int32>(&evt.modifiers);
msg.Read<int32>(&evt.buttons);
msg.Read<int32>(&evt.clicks);
msg->Read<int64>(&dummy); // printf("MOUSE DOWN: at (%f, %f)\n", evt.where.x, evt.where.y);
msg->Read<float>(&pt.x);
msg->Read<float>(&pt.y);
// After we read the data, we need to reset it for MouseDown() WinBorder *target=NULL;
msg->Rewind(); RootLayer *rl=NULL;
Workspace *ws=NULL
// printf("MOUSE DOWN: at (%f, %f)\n", pt.x, pt.y); ;
WinBorder *target;
RootLayer *rl;
Workspace *ws;
rl = ActiveRootLayer(); rl = ActiveRootLayer();
ws = rl->ActiveWorkspace(); ws = rl->ActiveWorkspace();
target = rl->WinBorderAt(pt); target = rl->WinBorderAt(evt.where);
if (target) if (target)
{ {
fGeneralLock.Lock(); fGeneralLock.Lock();
@@ -346,8 +337,8 @@ printf("Focus: %s\n", ws->FocusLayer()->GetName());
#endif #endif
if (target != ws->FrontLayer()) if (target != ws->FrontLayer())
{ {
WinBorder *previousFocus; WinBorder *previousFocus=NULL;
WinBorder *activeFocus; WinBorder *activeFocus=NULL;
BRegion invalidRegion; BRegion invalidRegion;
ws->BringToFrontANormalWindow(target); ws->BringToFrontANormalWindow(target);
@@ -359,12 +350,13 @@ printf("Focus: %s\n", ws->FocusLayer()->GetName());
activeFocus->Window()->Lock(); activeFocus->Window()->Lock();
if (target == activeFocus && target->Window()->Flags() & B_WILL_ACCEPT_FIRST_CLICK) if (target == activeFocus && target->Window()->Flags() & B_WILL_ACCEPT_FIRST_CLICK)
target->MouseDown(msg, true); target->MouseDown(evt, true);
else else
target->MouseDown(msg, false); target->MouseDown(evt, false);
// may be or may be empty. // may be or may be empty.
// TODO: what if modal of floating windows are in front of us?
// TODO: what if modal of floating windows are in front of us?
invalidRegion.Include(&(activeFocus->fFull)); invalidRegion.Include(&(activeFocus->fFull));
invalidRegion.Include(&(activeFocus->fTopLayer->fFull)); invalidRegion.Include(&(activeFocus->fTopLayer->fFull));
activeFocus->fParent->RebuildAndForceRedraw(invalidRegion, activeFocus); activeFocus->fParent->RebuildAndForceRedraw(invalidRegion, activeFocus);
@@ -394,7 +386,7 @@ printf("2Focus: %s\n", ws->FocusLayer()->GetName());
if (target == ws->FocusLayer()) if (target == ws->FocusLayer())
{ {
target->Window()->Lock(); target->Window()->Lock();
target->MouseDown(msg, true); target->MouseDown(evt, true);
target->Window()->Unlock(); target->Window()->Unlock();
} }
} }
@@ -415,37 +407,32 @@ printf("2Focus: %s\n", ws->FocusLayer()->GetName());
// 3) float - y coordinate of mouse click // 3) float - y coordinate of mouse click
// 4) int32 - modifier keys down // 4) int32 - modifier keys down
PointerEvent evt;
evt.code = B_MOUSE_UP;
msg.Read<int64>(&evt.when);
msg.Read<float>(&evt.where.x);
msg.Read<float>(&evt.where.y);
msg.Read<int32>(&evt.modifiers);
if (fMouseTarget) if (fMouseTarget)
{ {
fMouseTarget->Window()->Lock(); fMouseTarget->Window()->Lock();
fMouseTarget->MouseUp(msg); fMouseTarget->MouseUp(evt);
fMouseTarget->Window()->Unlock(); fMouseTarget->Window()->Unlock();
fMouseTarget = NULL; fMouseTarget = NULL;
} }
else else
{ {
BPoint pt; WinBorder *target = ActiveRootLayer()->WinBorderAt(evt.where);
int64 dummy;
int32 mod;
msg->Read<int64>(&dummy);
msg->Read<float>(&pt.x);
msg->Read<float>(&pt.y);
msg->Read<int32>(&mod);
// After we read the data, we need to reset it for MouseUp()
msg->Rewind();
WinBorder *target = ActiveRootLayer()->WinBorderAt(pt);
if(target){ if(target){
target->Window()->Lock(); target->Window()->Lock();
target->MouseUp(msg); target->MouseUp(evt);
target->Window()->Unlock(); target->Window()->Unlock();
} }
} }
// printf("MOUSE UP: at (%f, %f)\n", pt.x, pt.y); STRACE(("MOUSE UP: at (%f, %f)\n", evt.where.x, evt.where.y));
break; break;
} }
@@ -456,45 +443,50 @@ printf("2Focus: %s\n", ws->FocusLayer()->GetName());
// 2) float - x coordinate of mouse click // 2) float - x coordinate of mouse click
// 3) float - y coordinate of mouse click // 3) float - y coordinate of mouse click
// 4) int32 - buttons down // 4) int32 - buttons down
int64 dummy;
float x,y;
int32 buttons;
msg->Read<int64>(&dummy); PointerEvent evt;
msg->Read<float>(&x); evt.code = B_MOUSE_MOVED;
msg->Read<float>(&y); msg.Read<int64>(&evt.when);
msg->Read<int32>(&buttons); msg.Read<float>(&evt.where.x);
msg.Read<float>(&evt.where.y);
// After we read the data, we need to reset it for MouseDown() msg.Read<int32>(&evt.buttons);
msg->Rewind();
if (fMouseTarget) if (fMouseTarget)
{ {
fActiveScreen->DDriver()->HideCursor(); fActiveScreen->DDriver()->HideCursor();
fActiveScreen->DDriver()->MoveCursorTo(x,y); fActiveScreen->DDriver()->MoveCursorTo(evt.where.x, evt.where.y);
fMouseTarget->Window()->Lock(); fMouseTarget->Window()->Lock();
fMouseTarget->MouseMoved(msg); fMouseTarget->MouseMoved(evt);
fMouseTarget->Window()->Unlock(); fMouseTarget->Window()->Unlock();
fActiveScreen->DDriver()->ShowCursor(); fActiveScreen->DDriver()->ShowCursor();
} }
else else
{ {
WinBorder *target = ActiveRootLayer()->WinBorderAt(BPoint(x,y)); WinBorder *target = ActiveRootLayer()->WinBorderAt(BPoint(evt.where.x, evt.where.y));
if(target){ if(target){
target->Window()->Lock(); target->Window()->Lock();
target->MouseMoved(msg); target->MouseMoved(evt);
target->Window()->Unlock(); target->Window()->Unlock();
} }
fActiveScreen->DDriver()->MoveCursorTo(x,y); fActiveScreen->DDriver()->MoveCursorTo(evt.where.x, evt.where.y);
} }
break; break;
} }
case B_MOUSE_WHEEL_CHANGED: case B_MOUSE_WHEEL_CHANGED:
{ {
PointerEvent evt;
evt.code = B_MOUSE_WHEEL_CHANGED;
msg.Read<int64>(&evt.when);
msg.Read<float>(&evt.where.x);
msg.Read<float>(&evt.where.y);
msg.Read<float>(&evt.wheel_delta_x);
msg.Read<float>(&evt.wheel_delta_y);
msg.Read<int32>(&evt.modifiers);
// TODO: Pass this on to the client ServerWindow // TODO: Pass this on to the client ServerWindow
break; break;
} }
@@ -506,11 +498,10 @@ printf("2Focus: %s\n", ws->FocusLayer()->GetName());
} }
} }
void Desktop::KeyboardEventHandler(PortMessage *msg) void Desktop::KeyboardEventHandler(int32 code, BPortLink& msg)
{ {
int8 *index=(int8*)msg->Buffer();
switch(code)
switch(msg->Code())
{ {
case B_KEY_DOWN: case B_KEY_DOWN:
{ {
@@ -525,13 +516,22 @@ void Desktop::KeyboardEventHandler(PortMessage *msg)
// generated string // generated string
// 8) Character string generated by the keystroke // 8) Character string generated by the keystroke
// 9) int8[16] state of all keys // 9) int8[16] state of all keys
// Obtain only what data which we'll need bigtime_t time;
STRACE(("Key Down: 0x%lx\n",scancode)); int32 scancode, modifiers;
index+=sizeof(int64); int8 utf[3];
int32 scancode=*((int32*)index); index+=sizeof(int32) * 3; char *string = NULL;
int32 modifiers=*((int32*)index); index+=sizeof(int32) + (sizeof(int8) * 3); int32 keystate;
int8 stringlength=*index; index+=stringlength;
msg.Read<bigtime_t>(&time);
msg.Read<int32>(&scancode);
msg.Read<int32>(&modifiers);
msg.Read(utf, sizeof(utf));
msg.ReadString(&string);
msg.Read<int32>(&keystate);
if (string)
free(string);
if(DISPLAYDRIVER==HWDRIVER) if(DISPLAYDRIVER==HWDRIVER)
{ {
// Check for workspace change or safe video mode // Check for workspace change or safe video mode
@@ -669,11 +669,26 @@ void Desktop::KeyboardEventHandler(PortMessage *msg)
// 7) Character string generated by the keystroke // 7) Character string generated by the keystroke
// 8) int8[16] state of all keys // 8) int8[16] state of all keys
// Obtain only what data which we'll need bigtime_t time;
index+=sizeof(int64); int32 scancode;
int32 scancode=*((int32*)index); index+=sizeof(int32) * 3; int32 ascii;
int32 modifiers=*((int32*)index); index+=sizeof(int8) * 3; int32 modifiers;
int8 stringlength=*index; index+=stringlength + sizeof(int8); int8 utf[3];
int8 bytes;
char *string;
int8 keystate[16];
msg.Read<bigtime_t>(&time);
msg.Read<int32>(&scancode);
msg.Read<int32>(&ascii);
msg.Read<int32>(&modifiers);
msg.Read(utf, sizeof(utf));
msg.Read<int8>(&bytes);
msg.ReadString(&string);
msg.Read(keystate, sizeof(keystate));
if (string)
free(string);
STRACE(("Key Up: 0x%lx\n",scancode)); STRACE(("Key Up: 0x%lx\n",scancode));
if(DISPLAYDRIVER==HWDRIVER) if(DISPLAYDRIVER==HWDRIVER)
@@ -717,9 +732,20 @@ void Desktop::KeyboardEventHandler(PortMessage *msg)
// 4) int32 number of elements in the key state array to follow // 4) int32 number of elements in the key state array to follow
// 5) int8 state of all keys // 5) int8 state of all keys
bigtime_t time;
int32 scancode;
int32 modifiers;
int32 elements;
//int8 keystate[16];
msg.Read<bigtime_t>(&time);
msg.Read<int32>(&scancode);
msg.Read<int32>(&modifiers);
msg.Read<int32>(&elements);
//msg.Read(keystate, elements);
#ifdef DEBUG_KEYHANDLING #ifdef DEBUG_KEYHANDLING
index+=sizeof(bigtime_t); printf("Unmapped Key Down: 0x%lx\n", scancode);
printf("Unmapped Key Down: 0x%lx\n",*((int32*)index));
#endif #endif
// TODO: Pass on to client window with the focus // TODO: Pass on to client window with the focus
break; break;
@@ -733,9 +759,20 @@ void Desktop::KeyboardEventHandler(PortMessage *msg)
// 4) int32 number of elements in the key state array to follow // 4) int32 number of elements in the key state array to follow
// 5) int8 state of all keys // 5) int8 state of all keys
bigtime_t time;
int32 scancode;
int32 modifiers;
int32 elements;
//int8 keystate[16];
msg.Read<bigtime_t>(&time);
msg.Read<int32>(&scancode);
msg.Read<int32>(&modifiers);
msg.Read<int32>(&elements);
//msg.Read(keystate, elements);
#ifdef DEBUG_KEYHANDLING #ifdef DEBUG_KEYHANDLING
index+=sizeof(bigtime_t); printf("Unmapped Key Up: 0x%lx\n", scancode);
printf("Unmapped Key Up: 0x%lx\n",*((int32*)index));
#endif #endif
// TODO: Pass on to client window with the focus // TODO: Pass on to client window with the focus
@@ -750,8 +787,19 @@ void Desktop::KeyboardEventHandler(PortMessage *msg)
// 4) int32 number of elements in the key state array to follow // 4) int32 number of elements in the key state array to follow
// 5) int8 state of all keys // 5) int8 state of all keys
bigtime_t time;
int32 scancode;
int32 modifiers;
int32 elements;
//int8 keystate[16];
msg.Read<bigtime_t>(&time);
msg.Read<int32>(&scancode);
msg.Read<int32>(&modifiers);
msg.Read<int32>(&elements);
//msg.Read(keystate, elements);
#ifdef DEBUG_KEYHANDLING #ifdef DEBUG_KEYHANDLING
index+=sizeof(bigtime_t);
printf("Modifiers Changed\n"); printf("Modifiers Changed\n");
#endif #endif
+3 -3
View File
@@ -36,9 +36,9 @@ class RootLayer;
class Screen; class Screen;
class Layer; class Layer;
class BMessage; class BMessage;
class PortMessage;
class WinBorder; class WinBorder;
class DisplayDriver; class DisplayDriver;
class BPortLink;
class Desktop class Desktop
{ {
@@ -70,8 +70,8 @@ public:
bool HasWinBorder(WinBorder *winBorder); bool HasWinBorder(WinBorder *winBorder);
// Input related methods // Input related methods
void MouseEventHandler(PortMessage *msg); void MouseEventHandler(int32 code, BPortLink& link);
void KeyboardEventHandler(PortMessage *msg); void KeyboardEventHandler(int32 code, BPortLink& link);
void SetDragMessage(BMessage *msg); void SetDragMessage(BMessage *msg);
BMessage *DragMessage(void) const; BMessage *DragMessage(void) const;
+5 -5
View File
@@ -798,7 +798,7 @@ DDView::DDView(BRect bounds)
SetViewColor(B_TRANSPARENT_32_BIT); SetViewColor(B_TRANSPARENT_32_BIT);
#ifdef ENABLE_INPUT_SERVER_EMULATION #ifdef ENABLE_INPUT_SERVER_EMULATION
serverlink.SetPort(find_port(SERVER_INPUT_PORT)); serverlink.SetSendPort(find_port(SERVER_INPUT_PORT));
#endif #endif
} }
@@ -827,7 +827,7 @@ void DDView::MouseDown(BPoint pt)
GetMouse(&p,&buttons); GetMouse(&p,&buttons);
serverlink.SetOpCode(B_MOUSE_DOWN); serverlink.StartMessage(B_MOUSE_DOWN);
serverlink.Attach(&time, sizeof(int64)); serverlink.Attach(&time, sizeof(int64));
serverlink.Attach(&pt.x,sizeof(float)); serverlink.Attach(&pt.x,sizeof(float));
serverlink.Attach(&pt.y,sizeof(float)); serverlink.Attach(&pt.y,sizeof(float));
@@ -850,7 +850,7 @@ void DDView::MouseMoved(BPoint pt, uint32 transit, const BMessage *msg)
uint32 buttons; uint32 buttons;
int64 time=(int64)real_time_clock(); int64 time=(int64)real_time_clock();
serverlink.SetOpCode(B_MOUSE_MOVED); serverlink.StartMessage(B_MOUSE_MOVED);
serverlink.Attach(&time,sizeof(int64)); serverlink.Attach(&time,sizeof(int64));
serverlink.Attach(&pt.x,sizeof(float)); serverlink.Attach(&pt.x,sizeof(float));
serverlink.Attach(&pt.y,sizeof(float)); serverlink.Attach(&pt.y,sizeof(float));
@@ -877,7 +877,7 @@ void DDView::MouseUp(BPoint pt)
GetMouse(&p,&buttons); GetMouse(&p,&buttons);
serverlink.SetOpCode(B_MOUSE_UP); serverlink.StartMessage(B_MOUSE_UP);
serverlink.Attach(&time, sizeof(int64)); serverlink.Attach(&time, sizeof(int64));
serverlink.Attach(&pt.x,sizeof(float)); serverlink.Attach(&pt.x,sizeof(float));
serverlink.Attach(&pt.y,sizeof(float)); serverlink.Attach(&pt.y,sizeof(float));
@@ -897,7 +897,7 @@ void DDView::MessageReceived(BMessage *msg)
msg->FindFloat("be:wheel_delta_x",&x); msg->FindFloat("be:wheel_delta_x",&x);
msg->FindFloat("be:wheel_delta_y",&y); msg->FindFloat("be:wheel_delta_y",&y);
int64 time=real_time_clock(); int64 time=real_time_clock();
serverlink.SetOpCode(B_MOUSE_WHEEL_CHANGED); serverlink.StartMessage(B_MOUSE_WHEEL_CHANGED);
serverlink.Attach(&time,sizeof(int64)); serverlink.Attach(&time,sizeof(int64));
serverlink.Attach(x); serverlink.Attach(x);
serverlink.Attach(y); serverlink.Attach(y);
+2 -2
View File
@@ -73,7 +73,7 @@ public:
void MouseUp(BPoint pt); void MouseUp(BPoint pt);
void MessageReceived(BMessage *msg); void MessageReceived(BMessage *msg);
PortLink serverlink; BPortLink serverlink;
}; };
class DDWindow : public BDirectWindow class DDWindow : public BDirectWindow
@@ -162,7 +162,7 @@ protected:
rgb_color GetBlitColor(rgb_color src, rgb_color dest,DrawData *d, bool use_high=true); rgb_color GetBlitColor(rgb_color src, rgb_color dest,DrawData *d, bool use_high=true);
PortLink *serverlink; BPortLink *serverlink;
DDWindow *screenwin; DDWindow *screenwin;
BView *drawview; BView *drawview;
}; };
-1
View File
@@ -40,7 +40,6 @@ Server app_server :
FMWList.cpp FMWList.cpp
PicturePlayer.cpp PicturePlayer.cpp
PNGDump.cpp PNGDump.cpp
SessionStreamReader.cpp
Utils.cpp Utils.cpp
# Manager Classes # Manager Classes
+10 -26
View File
@@ -44,7 +44,7 @@ Layer::Layer(BRect frame, const char *name, int32 token, uint32 resize,
fBoundsLeftTop.Set( 0.0f, 0.0f ); fBoundsLeftTop.Set( 0.0f, 0.0f );
fName = new BString(name); fName = new BString(name ? name : B_EMPTY_STRING);
fLayerData = new LayerData(); fLayerData = new LayerData();
// driver init // driver init
@@ -65,7 +65,6 @@ Layer::Layer(BRect frame, const char *name, int32 token, uint32 resize,
fFlags = flags; fFlags = flags;
fAdFlags = 0; fAdFlags = 0;
fClassID = AS_LAYER_CLASS; fClassID = AS_LAYER_CLASS;
fFrameAction = B_LAYER_NONE;
fResizeMode = resize; fResizeMode = resize;
fHidden = false; fHidden = false;
@@ -446,15 +445,7 @@ void Layer::RequestDraw(const BRegion &reg, Layer *startFrom)
int redraw = false; int redraw = false;
if (startFrom == NULL) if (startFrom == NULL)
redraw = true; redraw = true;
/*
srand(real_time_clock_usecs());
RGBColor c(rand()/256,34,56);
BRegion reg1 = reg;
fDriver->ConstrainClippingRegion(&reg1);
fDriver->FillRect(reg.Frame(), c);
fDriver->ConstrainClippingRegion(NULL);
snooze(1000000);
*/
if (fVisible.CountRects() > 0) if (fVisible.CountRects() > 0)
{ {
// client side drawing. Send only one UPDATE message! // client side drawing. Send only one UPDATE message!
@@ -465,7 +456,7 @@ snooze(1000000);
// calculate the minimum region/rectangle to be updated with // calculate the minimum region/rectangle to be updated with
// a single message to the client. // a single message to the client.
fUpdateReg = fFullVisible; fUpdateReg = fFullVisible;
if (fFlags & B_FULL_UPDATE_ON_RESIZE && fFrameAction == B_LAYER_RESIZE){ } if (fFlags & B_FULL_UPDATE_ON_RESIZE){ }
else { fUpdateReg.IntersectWith(&reg); } else { fUpdateReg.IntersectWith(&reg); }
if (fUpdateReg.CountRects() > 0) if (fUpdateReg.CountRects() > 0)
@@ -479,7 +470,7 @@ snooze(1000000);
// calculate the update region, then... // calculate the update region, then...
fUpdateReg = fVisible; fUpdateReg = fVisible;
if (fFlags & B_FULL_UPDATE_ON_RESIZE && fFrameAction == B_LAYER_RESIZE){ } if (fFlags & B_FULL_UPDATE_ON_RESIZE){ }
else { fUpdateReg.IntersectWith(&reg); } else { fUpdateReg.IntersectWith(&reg); }
if (fUpdateReg.CountRects() > 0) if (fUpdateReg.CountRects() > 0)
@@ -495,7 +486,7 @@ snooze(1000000);
else else
{ {
fUpdateReg = fVisible; fUpdateReg = fVisible;
if (fFlags & B_FULL_UPDATE_ON_RESIZE && fFrameAction == B_LAYER_RESIZE){ } if (fFlags & B_FULL_UPDATE_ON_RESIZE){ }
else { fUpdateReg.IntersectWith(&reg); } else { fUpdateReg.IntersectWith(&reg); }
if (fUpdateReg.CountRects() > 0) if (fUpdateReg.CountRects() > 0)
@@ -534,6 +525,7 @@ snooze(1000000);
void Layer::Draw(const BRect &r) void Layer::Draw(const BRect &r)
{ {
// TODO/NOTE: this should be an empty method! the next lines are for testing only // TODO/NOTE: this should be an empty method! the next lines are for testing only
#ifdef DEBUG_LAYER #ifdef DEBUG_LAYER
printf("Layer::Draw: "); printf("Layer::Draw: ");
r.PrintToStream(); r.PrintToStream();
@@ -1022,9 +1014,7 @@ void Layer::MoveBy(float x, float y)
debugger("ERROR: in Layer::MoveBy()! - No parent!\n"); debugger("ERROR: in Layer::MoveBy()! - No parent!\n");
return; return;
} }
fFrameAction = B_LAYER_MOVE;
BPoint pt(x,y); BPoint pt(x,y);
BRect rect(fFull.Frame().OffsetByCopy(pt)); BRect rect(fFull.Frame().OffsetByCopy(pt));
@@ -1034,8 +1024,6 @@ void Layer::MoveBy(float x, float y)
EmptyGlobals(); EmptyGlobals();
fFrameAction = B_LAYER_NONE;
STRACE(("Layer(%s)::MoveBy() END\n", GetName())); STRACE(("Layer(%s)::MoveBy() END\n", GetName()));
} }
@@ -1127,9 +1115,7 @@ void Layer::ResizeBy(float x, float y)
printf("ERROR: in Layer::MoveBy()! - No parent!\n"); printf("ERROR: in Layer::MoveBy()! - No parent!\n");
return; return;
} }
fFrameAction = B_LAYER_RESIZE;
BPoint pt(x,y); BPoint pt(x,y);
BRect rect(fFull.Frame()); BRect rect(fFull.Frame());
rect.right += x; rect.right += x;
@@ -1141,9 +1127,7 @@ void Layer::ResizeBy(float x, float y)
fParent->Redraw(gRedrawReg, this); fParent->Redraw(gRedrawReg, this);
EmptyGlobals(); EmptyGlobals();
fFrameAction = B_LAYER_NONE;
STRACE(("Layer(%s)::ResizeBy() END\n", GetName())); STRACE(("Layer(%s)::ResizeBy() END\n", GetName()));
} }
@@ -1174,7 +1158,7 @@ void Layer::PrintToStream(void)
printf("Frame: (%f, %f, %f, %f)", fFrame.left, fFrame.top, fFrame.right, fFrame.bottom); printf("Frame: (%f, %f, %f, %f)", fFrame.left, fFrame.top, fFrame.right, fFrame.bottom);
printf("Token: %ld\n",fViewToken); printf("Token: %ld\n",fViewToken);
printf("Hidden - direct: %s\n", IsHidden()?"true":"false"); printf("Hidden - direct: %s\n", fHidden?"true":"false");
printf("Hidden - indirect: %s\n", IsHidden()?"true":"false"); printf("Hidden - indirect: %s\n", IsHidden()?"true":"false");
printf("ResizingMode: %lx\n", fResizeMode); printf("ResizingMode: %lx\n", fResizeMode);
printf("Flags: %lx\n", fFlags); printf("Flags: %lx\n", fFlags);
+4 -4
View File
@@ -43,7 +43,7 @@
#include "PatternHandler.h" #include "PatternHandler.h"
class BBitmap; class BBitmap;
class PortLink; class BPortLink;
class SDWindow; class SDWindow;
class LayerData; class LayerData;
class ScreenDriver; class ScreenDriver;
@@ -65,7 +65,7 @@ protected:
friend class ScreenDriver; friend class ScreenDriver;
bool is_connected; bool is_connected;
PortLink *serverlink; BPortLink *serverlink;
BPoint mousepos; BPoint mousepos;
uint32 buttons; uint32 buttons;
thread_id monitor_thread,copy_thread; thread_id monitor_thread,copy_thread;
@@ -89,7 +89,7 @@ public:
void MessageReceived(BMessage *msg); void MessageReceived(BMessage *msg);
BBitmap *viewbmp; BBitmap *viewbmp;
PortLink *serverlink; BPortLink *serverlink;
int hide_cursor; int hide_cursor;
BBitmap *cursor; BBitmap *cursor;
@@ -192,7 +192,7 @@ protected:
BBitmap *framebuffer; BBitmap *framebuffer;
BView *drawview; BView *drawview;
BRegion laregion; BRegion laregion;
PortLink *serverlink; BPortLink *serverlink;
rgb_color highcolor,lowcolor; rgb_color highcolor,lowcolor;
bool is_initialized; bool is_initialized;
+111 -111
View File
@@ -28,12 +28,7 @@
#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 <ColorSet.h> #include <ColorSet.h>
#include <RGBColor.h> #include <RGBColor.h>
#include <stdio.h> #include <stdio.h>
@@ -91,11 +86,12 @@ ServerApp::ServerApp(port_id sendport, port_id rcvport, port_id clientLooperPort
// fClientAppPort is the our BApplication's event port // fClientAppPort is the our BApplication's event port
fClientAppPort=sendport; fClientAppPort=sendport;
fAppLink=new PortLink(fClientAppPort);
// fMessagePort is the port we receive messages from our BApplication // fMessagePort is the port we receive messages from our BApplication
fMessagePort=rcvport; fMessagePort=rcvport;
fAppLink = new BPortLink(fClientAppPort, fMessagePort);
fSWindowList=new BList(0); fSWindowList=new BList(0);
fBitmapList=new BList(0); fBitmapList=new BList(0);
fPictureList=new BList(0); fPictureList=new BList(0);
@@ -246,8 +242,8 @@ bool ServerApp::PingTarget(void)
printf("PANIC: ServerApp %s could not find the app_server port in PingTarget()!\n",fSignature.String()); printf("PANIC: ServerApp %s could not find the app_server port in PingTarget()!\n",fSignature.String());
return false; return false;
} }
fAppLink->SetPort(serverport); fAppLink->SetSendPort(serverport);
fAppLink->SetOpCode(AS_DELETE_APP); fAppLink->StartMessage(AS_DELETE_APP);
fAppLink->Attach(&fMonitorThreadID,sizeof(thread_id)); fAppLink->Attach(&fMonitorThreadID,sizeof(thread_id));
fAppLink->Flush(); fAppLink->Flush();
return false; return false;
@@ -336,22 +332,19 @@ int32 ServerApp::MonitorApp(void *data)
// Message-dispatching loop for the ServerApp // Message-dispatching loop for the ServerApp
ServerApp *app = (ServerApp *)data; ServerApp *app = (ServerApp *)data;
PortQueue msgqueue(app->fMessagePort); BPortLink msgqueue(-1, app->fMessagePort);
PortMessage *msg;
bool quitting = false; bool quitting = false;
int32 code;
status_t err = B_OK;
for( ; !quitting; ) while(!quitting)
{ {
if(!msgqueue.MessagesWaiting()) STRACE(("info: ServerApp::MonitorApp listening on port %ld.\n", app->fMessagePort));
msgqueue.GetMessagesFromPort(true); err = msgqueue.GetNextReply(&code);
else if (err < B_OK)
msgqueue.GetMessagesFromPort(false); break;
msg = msgqueue.GetMessageFromQueue(); switch(code)
if(!msg)
continue;
switch(msg->Code())
{ {
case AS_QUIT_APP: case AS_QUIT_APP:
{ {
@@ -400,8 +393,8 @@ int32 ServerApp::MonitorApp(void *data)
printf("PANIC: ServerApp %s could not find the app_server port!\n",app->fSignature.String()); printf("PANIC: ServerApp %s could not find the app_server port!\n",app->fSignature.String());
break; break;
} }
app->fAppLink->SetPort(serverport); app->fAppLink->SetSendPort(serverport);
app->fAppLink->SetOpCode(AS_DELETE_APP); app->fAppLink->StartMessage(AS_DELETE_APP);
app->fAppLink->Attach(&app->fMonitorThreadID, sizeof(thread_id)); app->fAppLink->Attach(&app->fMonitorThreadID, sizeof(thread_id));
app->fAppLink->Flush(); app->fAppLink->Flush();
break; break;
@@ -409,12 +402,11 @@ int32 ServerApp::MonitorApp(void *data)
default: default:
{ {
STRACE(("ServerApp %s: Got a Message to dispatch\n",app->fSignature.String())); STRACE(("ServerApp %s: Got a Message to dispatch\n",app->fSignature.String()));
app->_DispatchMessage(msg); app->_DispatchMessage(code, msgqueue);
break; break;
} }
} }
delete msg;
} // end for } // end for
// clean exit. // clean exit.
@@ -430,10 +422,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(PortMessage *msg) void ServerApp::_DispatchMessage(int32 code, BPortLink& msg)
{ {
LayerData ld; LayerData ld;
switch(msg->Code()) switch(code)
{ {
case AS_UPDATED_CLIENT_FONTLIST: case AS_UPDATED_CLIENT_FONTLIST:
{ {
@@ -460,7 +452,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
win=(ServerWindow*)fSWindowList->ItemAt(i); win=(ServerWindow*)fSWindowList->ItemAt(i);
win->Lock(); win->Lock();
win->fWinBorder->UpdateColors(); win->fWinBorder->UpdateColors();
win->SendMessageToClient(&msg); win->SendMessageToClient(AS_UPDATE_COLORS, msg);
win->Unlock(); win->Unlock();
} }
*/ break; */ break;
@@ -479,7 +471,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
win=(ServerWindow*)fSWindowList->ItemAt(i); win=(ServerWindow*)fSWindowList->ItemAt(i);
win->Lock(); win->Lock();
win->fWinBorder->UpdateFont(); win->fWinBorder->UpdateFont();
win->SendMessageToClient(&msg); win->SendMessageToClient(AS_UPDATE_FONTS, msg);
win->Unlock(); win->Unlock();
} }
*/ break; */ break;
@@ -518,22 +510,24 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
uint32 feel; uint32 feel;
uint32 flags; uint32 flags;
uint32 wkspaces; uint32 wkspaces;
int32 token; int32 token = B_NULL_TOKEN;
port_id sendPort; port_id sendPort = -1;
port_id looperPort; port_id looperPort = -1;
port_id replyport; char *title = NULL;
char *title; port_id replyport = -1;
msg->Read<BRect>(&frame); msg.Read<BRect>(&frame);
msg->Read<int32>((int32*)&look); msg.Read<int32>((int32*)&look);
msg->Read<int32>((int32*)&feel); msg.Read<int32>((int32*)&feel);
msg->Read<int32>((int32*)&flags); msg.Read<int32>((int32*)&flags);
msg->Read<int32>((int32*)&wkspaces); msg.Read<int32>((int32*)&wkspaces);
msg->Read<int32>(&token); msg.Read<int32>(&token);
msg->Read<port_id>(&sendPort); msg.Read<port_id>(&sendPort);
msg->Read<port_id>(&looperPort); msg.Read<port_id>(&looperPort);
msg->ReadString(&title); msg.ReadString(&title);
msg->Read<port_id>(&replyport);
//TODO: deprecate - just use sendPort
msg.Read<port_id>(&replyport);
STRACE(("ServerApp %s: Got 'New Window' message, trying to do smething...\n",fSignature.String())); STRACE(("ServerApp %s: Got 'New Window' message, trying to do smething...\n",fSignature.String()));
@@ -546,7 +540,8 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
STRACE(("\nServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n", STRACE(("\nServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n",
fSignature.String(),title,frame.left,frame.top,frame.right,frame.bottom)); fSignature.String(),title,frame.left,frame.top,frame.right,frame.bottom));
delete [] title; if (title)
free(title);
break; break;
} }
@@ -570,40 +565,39 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
// 3) int32 area pointer offset used to calculate fBasePtr // 3) int32 area pointer offset used to calculate fBasePtr
// First, let's attempt to allocate the bitmap // First, let's attempt to allocate the bitmap
port_id replyport; port_id replyport = -1;
BRect r; BRect r;
color_space cs; color_space cs;
int32 f,bpr; int32 f,bpr;
screen_id s; screen_id s;
msg->Read<BRect>(&r); msg.Read<BRect>(&r);
msg->Read<color_space>(&cs); msg.Read<color_space>(&cs);
msg->Read<int32>(&f); msg.Read<int32>(&f);
msg->Read<int32>(&bpr); msg.Read<int32>(&bpr);
msg->Read<screen_id>(&s); msg.Read<screen_id>(&s);
msg->Read<int32>(&replyport); msg.Read<int32>(&replyport);
ServerBitmap *sbmp=bitmapmanager->CreateBitmap(r,cs,f,bpr,s); ServerBitmap *sbmp=bitmapmanager->CreateBitmap(r,cs,f,bpr,s);
STRACE(("ServerApp %s: Create Bitmap (%.1f,%.1f,%.1f,%.1f)\n", STRACE(("ServerApp %s: Create Bitmap (%.1f,%.1f,%.1f,%.1f)\n",
fSignature.String(),r.left,r.top,r.right,r.bottom)); fSignature.String(),r.left,r.top,r.right,r.bottom));
BPortLink replylink(replyport);
if(sbmp) if(sbmp)
{ {
fBitmapList->AddItem(sbmp); fBitmapList->AddItem(sbmp);
PortLink replylink(replyport); replylink.StartMessage(SERVER_TRUE);
replylink.SetOpCode(SERVER_TRUE);
replylink.Attach<int32>(sbmp->Token()); replylink.Attach<int32>(sbmp->Token());
replylink.Attach<int32>(sbmp->Area()); replylink.Attach<int32>(sbmp->Area());
replylink.Attach<int32>(sbmp->AreaOffset()); replylink.Attach<int32>(sbmp->AreaOffset());
replylink.Flush();
} }
else else
{ {
// alternatively, if something went wrong, we reply with SERVER_FALSE // alternatively, if something went wrong, we reply with SERVER_FALSE
int32 code=SERVER_FALSE; replylink.StartMessage(SERVER_FALSE);
write_port(replyport,SERVER_FALSE,&code,sizeof(int32));
} }
replylink.Flush();
break; break;
} }
@@ -618,24 +612,25 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
// Reply Code: SERVER_TRUE if successful, // Reply Code: SERVER_TRUE if successful,
// SERVER_FALSE if the buffer was already deleted or was not found // SERVER_FALSE if the buffer was already deleted or was not found
port_id replyport; port_id replyport = -1;
int32 bmp_id; int32 bmp_id;
msg->Read<int32>(&bmp_id); msg.Read<int32>(&bmp_id);
msg->Read<int32>(&replyport); msg.Read<int32>(&replyport);
ServerBitmap *sbmp=FindBitmap(bmp_id); ServerBitmap *sbmp=FindBitmap(bmp_id);
BPortLink replylink(replyport);
if(sbmp) if(sbmp)
{ {
STRACE(("ServerApp %s: Deleting Bitmap %ld\n",fSignature.String(),bmp_id)); STRACE(("ServerApp %s: Deleting Bitmap %ld\n",fSignature.String(),bmp_id));
fBitmapList->RemoveItem(sbmp); fBitmapList->RemoveItem(sbmp);
bitmapmanager->DeleteBitmap(sbmp); bitmapmanager->DeleteBitmap(sbmp);
write_port(replyport,SERVER_TRUE,NULL,0); replylink.StartMessage(SERVER_TRUE);
} }
else else
write_port(replyport,SERVER_FALSE,NULL,0); replylink.StartMessage(SERVER_TRUE);
replylink.Flush();
break; break;
} }
case AS_CREATE_PICTURE: case AS_CREATE_PICTURE:
@@ -677,9 +672,9 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
int32 workspace; int32 workspace;
uint32 mode; uint32 mode;
bool stick; bool stick;
msg->Read<int32>(&workspace); msg.Read<int32>(&workspace);
msg->Read<uint32>(&mode); msg.Read<uint32>(&mode);
msg->Read<bool>(&stick); msg.Read<bool>(&stick);
//TODO: Resolve //TODO: Resolve
//SetSpace(workspace,mode,ActiveScreen(),stick); //SetSpace(workspace,mode,ActiveScreen(),stick);
@@ -694,7 +689,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
// 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;
msg->Read<int32>(&workspace); msg.Read<int32>(&workspace);
//TODO: Resolve //TODO: Resolve
//SetWorkspace(workspace); //SetWorkspace(workspace);
@@ -729,9 +724,11 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
// Attached data // Attached data
// 1) int32 port to reply to // 1) int32 port to reply to
int32 replyport; int32 replyport;
msg->Read<int32>(&replyport); msg.Read<int32>(&replyport);
write_port(replyport,(fCursorHidden)?SERVER_TRUE:SERVER_FALSE,NULL,0); BPortLink replylink(replyport);
replylink.StartMessage(fCursorHidden ? SERVER_TRUE : SERVER_FALSE);
replylink.Flush();
break; break;
} }
case AS_SET_CURSOR_DATA: case AS_SET_CURSOR_DATA:
@@ -740,7 +737,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
// Attached data: 68 bytes of fAppCursor data // Attached data: 68 bytes of fAppCursor data
int8 cdata[68]; int8 cdata[68];
msg->Read(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
@@ -763,13 +760,13 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
// 2) int32 token ID of the cursor to set // 2) int32 token ID of the cursor to set
// 3) port_id port to receive a reply. Only exists if the sync flag is true. // 3) port_id port to receive a reply. Only exists if the sync flag is true.
bool sync; bool sync;
int32 ctoken; int32 ctoken = B_NULL_TOKEN;
port_id replyport; port_id replyport = -1;
msg->Read<bool>(&sync); msg.Read<bool>(&sync);
msg->Read<int32>(&ctoken); msg.Read<int32>(&ctoken);
if(sync) if(sync)
msg->Read<int32>(&replyport); msg.Read<int32>(&replyport);
cursormanager->SetCursor(ctoken); cursormanager->SetCursor(ctoken);
@@ -777,8 +774,9 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
{ {
// 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
ctoken=AS_SET_CURSOR_BCURSOR; BPortLink replylink(replyport);
write_port(replyport,ctoken, &ctoken, sizeof(int32)); replylink.StartMessage(SERVER_TRUE);
replylink.Flush();
} }
break; break;
} }
@@ -789,20 +787,21 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
// 1) 68 bytes of fAppCursor data // 1) 68 bytes of fAppCursor data
// 2) port_id reply port // 2) port_id reply port
port_id replyport; port_id replyport = -1;
int8 cdata[68]; int8 cdata[68];
msg->Read(cdata,68); msg.Read(cdata,68);
msg->Read<int32>(&replyport); msg.Read<int32>(&replyport);
fAppCursor=new ServerCursor(cdata); fAppCursor=new ServerCursor(cdata);
fAppCursor->SetAppSignature(fSignature.String()); fAppCursor->SetAppSignature(fSignature.String());
cursormanager->AddCursor(fAppCursor); cursormanager->AddCursor(fAppCursor);
// Synchronous message - BApplication is waiting on the cursor's ID // Synchronous message - BApplication is waiting on the cursor's ID
PortLink link(replyport); BPortLink replylink(replyport);
link.Attach<int32>(fAppCursor->ID()); replylink.StartMessage(SERVER_TRUE);
link.Flush(); replylink.Attach<int32>(fAppCursor->ID());
replylink.Flush();
break; break;
} }
case AS_DELETE_BCURSOR: case AS_DELETE_BCURSOR:
@@ -810,8 +809,8 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
STRACE(("ServerApp %s: Delete BCursor\n",fSignature.String())); STRACE(("ServerApp %s: Delete BCursor\n",fSignature.String()));
// 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 = B_NULL_TOKEN;
msg->Read<int32>(&ctoken); msg.Read<int32>(&ctoken);
if(fAppCursor && fAppCursor->ID()==ctoken) if(fAppCursor && fAppCursor->ID()==ctoken)
fAppCursor=NULL; fAppCursor=NULL;
@@ -828,12 +827,12 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
scroll_bar_info sbi=desktop->ScrollBarInfo(); scroll_bar_info sbi=desktop->ScrollBarInfo();
port_id replyport; port_id replyport;
msg->Read<int32>(&replyport); msg.Read<int32>(&replyport);
PortLink link(replyport); BPortLink replylink(replyport);
replylink.StartMessage(SERVER_TRUE);
link.Attach<scroll_bar_info>(sbi); replylink.Attach<scroll_bar_info>(sbi);
link.Flush(); replylink.Flush();
break; break;
} }
case AS_SET_SCROLLBAR_INFO: case AS_SET_SCROLLBAR_INFO:
@@ -842,7 +841,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
// 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;
msg->Read<scroll_bar_info>(&sbi); msg.Read<scroll_bar_info>(&sbi);
desktop->SetScrollBarInfo(sbi); desktop->SetScrollBarInfo(sbi);
break; break;
@@ -854,23 +853,23 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
// 1) port_id reply port - synchronous message // 1) port_id reply port - synchronous message
port_id replyport; port_id replyport;
msg->Read<int32>(&replyport); msg.Read<int32>(&replyport);
PortLink link(replyport); BPortLink replylink(replyport);
replylink.StartMessage(SERVER_TRUE);
link.Attach<bool>(desktop->FFMouseInUse()); replylink.Attach<bool>(desktop->FFMouseInUse());
link.Flush(); replylink.Flush();
break; break;
} }
case AS_SET_FOCUS_FOLLOWS_MOUSE: case AS_SET_FOCUS_FOLLOWS_MOUSE:
{ {
STRACE(("ServerApp %s: Set Focus Follows Mouse in use\n",fSignature.String())); STRACE(("ServerApp %s: Set Focus Follows Mouse in use\n",fSignature.String()));
// 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;
msg->Read<scroll_bar_info>(&sbi); msg.Read<scroll_bar_info>(&sbi);
desktop->SetScrollBarInfo(sbi); desktop->SetScrollBarInfo(sbi);*/
break; break;
} }
case AS_SET_MOUSE_MODE: case AS_SET_MOUSE_MODE:
@@ -879,7 +878,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
// Attached Data: // Attached Data:
// 1) enum mode_mouse FFM mouse mode // 1) enum mode_mouse FFM mouse mode
mode_mouse mmode; mode_mouse mmode;
msg->Read<mode_mouse>(&mmode); msg.Read<mode_mouse>(&mmode);
desktop->SetFFMouseMode(mmode); desktop->SetFFMouseMode(mmode);
break; break;
@@ -892,13 +891,13 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
mode_mouse mmode=desktop->FFMouseMode(); mode_mouse mmode=desktop->FFMouseMode();
port_id replyport; port_id replyport = -1;
msg->Read<int32>(&replyport); msg.Read<int32>(&replyport);
PortLink link(replyport); BPortLink replylink(replyport);
replylink.StartMessage(SERVER_TRUE);
link.Attach<mode_mouse>(mmode); replylink.Attach<mode_mouse>(mmode);
link.Flush(); replylink.Flush();
break; break;
} }
case AS_GET_UI_COLOR: case AS_GET_UI_COLOR:
@@ -907,17 +906,17 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
RGBColor color; RGBColor color;
int32 whichcolor; int32 whichcolor;
port_id replyport; port_id replyport = -1;
msg->Read<int32>(&whichcolor); msg.Read<int32>(&whichcolor);
msg->Read<port_id>(&replyport); msg.Read<port_id>(&replyport);
gui_colorset.Lock(); gui_colorset.Lock();
color=gui_colorset.AttributeToColor(whichcolor); color=gui_colorset.AttributeToColor(whichcolor);
gui_colorset.Unlock(); gui_colorset.Unlock();
PortLink replylink(replyport); BPortLink replylink(replyport);
replylink.SetOpCode(SERVER_TRUE); replylink.StartMessage(SERVER_TRUE);
replylink.Attach<rgb_color>(color.GetColor32()); replylink.Attach<rgb_color>(color.GetColor32());
replylink.Flush(); replylink.Flush();
break; break;
@@ -925,7 +924,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
default: default:
{ {
STRACE(("ServerApp %s received unhandled message code offset %s\n",fSignature.String(), STRACE(("ServerApp %s received unhandled message code offset %s\n",fSignature.String(),
MsgCodeToBString(msg->Code()).String())); MsgCodeToBString(code).String()));
break; break;
} }
@@ -953,3 +952,4 @@ team_id ServerApp::ClientTeamID()
{ {
return fClientTeamID; return fClientTeamID;
} }
+3 -4
View File
@@ -34,8 +34,7 @@
class AppServer; class AppServer;
class BMessage; class BMessage;
class PortLink; class BPortLink;
class PortMessage;
class BList; class BList;
class DisplayDriver; class DisplayDriver;
class ServerCursor; class ServerCursor;
@@ -82,7 +81,7 @@ protected:
friend class AppServer; friend class AppServer;
friend class ServerWindow; friend class ServerWindow;
void _DispatchMessage(PortMessage *msg); void _DispatchMessage(int32 code, BPortLink& link);
ServerBitmap* _FindBitmap(int32 token); ServerBitmap* _FindBitmap(int32 token);
port_id fClientAppPort, port_id fClientAppPort,
@@ -94,7 +93,7 @@ protected:
team_id fClientTeamID; team_id fClientTeamID;
PortLink *fAppLink; BPortLink *fAppLink;
BList *fSWindowList, BList *fSWindowList,
*fBitmapList, *fBitmapList,
*fPictureList; *fPictureList;
+240 -235
View File
@@ -124,6 +124,8 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
if(string) if(string)
fTitle.SetTo(string); fTitle.SetTo(string);
else
fTitle.SetTo(B_EMPTY_STRING);
fFrame = rect; fFrame = rect;
fFlags = wflags; fFlags = wflags;
@@ -136,6 +138,7 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
fWorkspaces = index; fWorkspaces = index;
fWinBorder = NULL; fWinBorder = NULL;
cl = NULL; //current layer
// fClientWinPort is the port to which the app awaits messages from the server // fClientWinPort is the port to which the app awaits messages from the server
fClientWinPort = winport; fClientWinPort = winport;
@@ -143,24 +146,12 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
// fMessagePort is the port to which the app sends messages for the server // fMessagePort is the port to which the app sends messages for the server
fMessagePort = create_port(30,fTitle.String()); fMessagePort = create_port(30,fTitle.String());
fSession = new BSession(fMessagePort, fClientWinPort); fSession = new BPortLink(fClientWinPort, fMessagePort);
// Send a reply to our window - it is expecting fMessagePort port. // Send a reply to our window - it is expecting fMessagePort port.
// Temporarily use winlink to save time and memory fSession->StartMessage(SERVER_TRUE);
PortLink winLink(replyport); fSession->Attach<port_id>(fMessagePort);
winLink.SetOpCode(AS_CREATE_WINDOW); fSession->Flush();
winLink.Attach<port_id>(fMessagePort);
winLink.Flush();
// check the next 2 messages to make sure we receive top_view's attributes.
int32 vCode;
fSession->ReadInt32(&vCode);
if(vCode != AS_LAYER_CREATE_ROOT)
debugger("SERVER ERROR: ServerWindow(xxx): NO top_view data received! - 1\n");
fSession->ReadInt32(&vCode);
if(vCode != AS_LAYER_CREATE)
debugger("SERVER ERROR: ServerWindow(xxx): NO top_view data received! - 2\n");
STRACE(("ServerWindow %s:\n",fTitle.String())); STRACE(("ServerWindow %s:\n",fTitle.String()));
STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom)); STRACE(("\tFrame (%.1f,%.1f,%.1f,%.1f)\n",rect.left,rect.top,rect.right,rect.bottom));
@@ -174,18 +165,6 @@ void ServerWindow::Init(void)
this, desktop->GetDisplayDriver()); this, desktop->GetDisplayDriver());
fWinBorder->RebuildFullRegion(); fWinBorder->RebuildFullRegion();
// Start receiving top_view data -- pass NULL as the parent view.
// This should be the *only* place where this happens.
fWinBorder->fTopLayer = CreateLayerTree(NULL);
fWinBorder->fTopLayer->SetAsTopLayer(true);
cl = fWinBorder->fTopLayer;
// connect decorator and top layer.
fWinBorder->AddChild(fWinBorder->fTopLayer, NULL);
// NOTE: this MUST be before the monitor thread is spawned!
desktop->AddWinBorder(fWinBorder);
// Spawn our message-monitoring thread // Spawn our message-monitoring thread
fMonitorThreadID = spawn_thread(MonitorWin, fTitle.String(), B_NORMAL_PRIORITY, this); fMonitorThreadID = spawn_thread(MonitorWin, fTitle.String(), B_NORMAL_PRIORITY, this);
@@ -283,13 +262,17 @@ void ServerWindow::Show(void)
WinBorder *previousFocus; WinBorder *previousFocus;
BRegion invalidRegion; BRegion invalidRegion;
Workspace *ws; Workspace *ws;
// TODO: can you unify this method with Desktop::MouseEventHandler::B_MOUSE_DOWN
// TODO: can you unify this method with Desktop::MouseEventHandler::B_MOUSE_DOWN
ws = rl->WorkspaceAt(i+1); ws = rl->WorkspaceAt(i+1);
ws->BringToFrontANormalWindow(fWinBorder); ws->BringToFrontANormalWindow(fWinBorder);
ws->SearchAndSetNewFront(fWinBorder); ws->SearchAndSetNewFront(fWinBorder);
previousFocus = ws->FocusLayer(); previousFocus = ws->FocusLayer();
ws->SearchAndSetNewFocus(fWinBorder); ws->SearchAndSetNewFocus(fWinBorder);
// TODO: only do this in for the active workspace!
// TODO: only do this in for the active workspace!
// first redraw previous window's decorator. It has lost focus state. // first redraw previous window's decorator. It has lost focus state.
if (previousFocus) if (previousFocus)
if (previousFocus->fDecorator) if (previousFocus->fDecorator)
@@ -358,7 +341,7 @@ void ServerWindow::Hide(void)
if (ws->FocusLayer() == fWinBorder) if (ws->FocusLayer() == fWinBorder)
ws->SearchAndSetNewFocus(fWinBorder); ws->SearchAndSetNewFocus(fWinBorder);
else{ else{
// TODO: RootLayer class should take care of this. (or Desktop) // TODO: RootLayer class should take care of this. (or Desktop)
// ws->Invalidate(); // ws->Invalidate();
} }
} }
@@ -531,13 +514,12 @@ void ServerWindow::SetLayerFontState(Layer *layer)
// NOTE: no need to check for a lock. This is a private method. // NOTE: no need to check for a lock. This is a private method.
uint16 mask; uint16 mask;
fSession->ReadUInt16(&mask); fSession->Read<uint16>(&mask);
if (mask & B_FONT_FAMILY_AND_STYLE) if (mask & B_FONT_FAMILY_AND_STYLE)
{ {
uint32 fontID; uint32 fontID;
fSession->ReadInt32((int32*)&fontID); fSession->Read<int32>((int32*)&fontID);
// TODO: implement later. Currently there is no SetFamAndStyle(uint32) // TODO: implement later. Currently there is no SetFamAndStyle(uint32)
// in ServerFont class. DW, could you add one? // in ServerFont class. DW, could you add one?
//layer->fLayerData->font-> //layer->fLayerData->font->
@@ -546,49 +528,49 @@ void ServerWindow::SetLayerFontState(Layer *layer)
if (mask & B_FONT_SIZE) if (mask & B_FONT_SIZE)
{ {
float size; float size;
fSession->ReadFloat(&size); fSession->Read<float>(&size);
layer->fLayerData->font.SetSize(size); layer->fLayerData->font.SetSize(size);
} }
if (mask & B_FONT_SHEAR) if (mask & B_FONT_SHEAR)
{ {
float shear; float shear;
fSession->ReadFloat(&shear); fSession->Read<float>(&shear);
layer->fLayerData->font.SetShear(shear); layer->fLayerData->font.SetShear(shear);
} }
if (mask & B_FONT_ROTATION) if (mask & B_FONT_ROTATION)
{ {
float rotation; float rotation;
fSession->ReadFloat(&rotation); fSession->Read<float>(&rotation);
layer->fLayerData->font.SetRotation(rotation); layer->fLayerData->font.SetRotation(rotation);
} }
if (mask & B_FONT_SPACING) if (mask & B_FONT_SPACING)
{ {
uint8 spacing; uint8 spacing;
fSession->ReadUInt8(&spacing); fSession->Read<uint8>(&spacing);
layer->fLayerData->font.SetSpacing(spacing); layer->fLayerData->font.SetSpacing(spacing);
} }
if (mask & B_FONT_ENCODING) if (mask & B_FONT_ENCODING)
{ {
uint8 encoding; uint8 encoding;
fSession->ReadUInt8((uint8*)&encoding); fSession->Read<uint8>((uint8*)&encoding);
layer->fLayerData->font.SetEncoding(encoding); layer->fLayerData->font.SetEncoding(encoding);
} }
if (mask & B_FONT_FACE) if (mask & B_FONT_FACE)
{ {
uint16 face; uint16 face;
fSession->ReadUInt16(&face); fSession->Read<uint16>(&face);
layer->fLayerData->font.SetFace(face); layer->fLayerData->font.SetFace(face);
} }
if (mask & B_FONT_FLAGS) if (mask & B_FONT_FLAGS)
{ {
uint32 flags; uint32 flags;
fSession->ReadUInt32(&flags); fSession->Read<uint32>(&flags);
layer->fLayerData->font.SetFlags(flags); layer->fLayerData->font.SetFlags(flags);
} }
STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer: %s\n", STRACE(("DONE: ServerWindow %s: Message AS_LAYER_SET_FONT_STATE: Layer: %s\n",
@@ -599,25 +581,25 @@ void ServerWindow::SetLayerState(Layer *layer)
{ {
// NOTE: no need to check for a lock. This is a private method. // NOTE: no need to check for a lock. This is a private method.
rgb_color highColor, lowColor, viewColor; rgb_color highColor, lowColor, viewColor;
pattern patt; pattern patt;
int32 clipRegRects; int32 clipRegRects;
fSession->ReadPoint( &(layer->fLayerData->penlocation)); fSession->Read<BPoint>( &(layer->fLayerData->penlocation));
fSession->ReadFloat( &(layer->fLayerData->pensize)); fSession->Read<float>( &(layer->fLayerData->pensize));
fSession->ReadData( &highColor, sizeof(rgb_color)); fSession->Read( &highColor, sizeof(rgb_color));
fSession->ReadData( &lowColor, sizeof(rgb_color)); fSession->Read( &lowColor, sizeof(rgb_color));
fSession->ReadData( &viewColor, sizeof(rgb_color)); fSession->Read( &viewColor, sizeof(rgb_color));
fSession->ReadData( &patt, sizeof(pattern)); fSession->Read( &patt, sizeof(pattern));
fSession->ReadInt8((int8*) &(layer->fLayerData->draw_mode)); fSession->Read<int8>((int8*) &(layer->fLayerData->draw_mode));
fSession->ReadPoint( &(layer->fLayerData->coordOrigin)); fSession->Read<BPoint>( &(layer->fLayerData->coordOrigin));
fSession->ReadInt8((int8*) &(layer->fLayerData->lineJoin)); fSession->Read<int8>((int8*) &(layer->fLayerData->lineJoin));
fSession->ReadInt8((int8*) &(layer->fLayerData->lineCap)); fSession->Read<int8>((int8*) &(layer->fLayerData->lineCap));
fSession->ReadFloat( &(layer->fLayerData->miterLimit)); fSession->Read<float>( &(layer->fLayerData->miterLimit));
fSession->ReadInt8((int8*) &(layer->fLayerData->alphaSrcMode)); fSession->Read<int8>((int8*) &(layer->fLayerData->alphaSrcMode));
fSession->ReadInt8((int8*) &(layer->fLayerData->alphaFncMode)); fSession->Read<int8>((int8*) &(layer->fLayerData->alphaFncMode));
fSession->ReadFloat( &(layer->fLayerData->scale)); fSession->Read<float>( &(layer->fLayerData->scale));
fSession->ReadBool( &(layer->fLayerData->fontAliasing)); fSession->Read<bool>( &(layer->fLayerData->fontAliasing));
fSession->ReadInt32( &clipRegRects); fSession->Read<int32>( &clipRegRects);
layer->fLayerData->patt.Set(*((uint64*)&patt)); layer->fLayerData->patt.Set(*((uint64*)&patt));
layer->fLayerData->highcolor.SetColor(highColor); layer->fLayerData->highcolor.SetColor(highColor);
@@ -635,7 +617,7 @@ void ServerWindow::SetLayerState(Layer *layer)
for(int32 i = 0; i < clipRegRects; i++) for(int32 i = 0; i < clipRegRects; i++)
{ {
fSession->ReadRect(&rect); fSession->Read<BRect>(&rect);
layer->fLayerData->clipReg->Include(rect); layer->fLayerData->clipReg->Include(rect);
} }
} }
@@ -662,61 +644,43 @@ Layer * ServerWindow::CreateLayerTree(Layer *localRoot)
uint32 flags; uint32 flags;
bool hidden; bool hidden;
int32 childCount; int32 childCount;
char *name; char *name = NULL;
fSession->ReadInt32(&token); fSession->Read<int32>(&token);
name = fSession->ReadString(); fSession->ReadString(&name);
fSession->ReadRect(&frame); fSession->Read<BRect>(&frame);
fSession->ReadUInt32(&resizeMask); fSession->Read<uint32>(&resizeMask);
fSession->ReadUInt32(&flags); fSession->Read<uint32>(&flags);
fSession->ReadBool(&hidden); fSession->Read<bool>(&hidden);
fSession->ReadInt32(&childCount); fSession->Read<int32>(&childCount);
Layer *newLayer; Layer *newLayer;
newLayer = new Layer(frame.OffsetToCopy(0.0, 0.0), name, token, resizeMask, newLayer = new Layer(frame, name, token, resizeMask,
flags, desktop->GetDisplayDriver()); flags, desktop->GetDisplayDriver());
delete name; if (name)
free(name);
// there is no way of setting this, other than manually :-) // there is no way of setting this, other than manually :-)
newLayer->fHidden = hidden; newLayer->fHidden = hidden;
int32 dummyMsg;
// next comes BView's font state
fSession->ReadInt32(&dummyMsg);
if (dummyMsg == AS_LAYER_SET_FONT_STATE)
SetLayerFontState(newLayer);
else
debugger("ServerWindow(%s) - AS_LAYER_SET_FONT_STATE Expected!\n");
// lastly, the BView's graphic state
fSession->ReadInt32(&dummyMsg);
if (dummyMsg == AS_LAYER_SET_STATE)
SetLayerState(newLayer);
else
debugger("ServerWindow(%s) - AS_LAYER_SET_STATE Expected!\n");
// add the new Layer to the tree structure. // add the new Layer to the tree structure.
if(localRoot) if(localRoot)
localRoot->AddChild(newLayer, NULL); localRoot->AddChild(newLayer, NULL);
// attach newLayer's children... STRACE(("DONE: ServerWindow %s: Message AS_LAYER_CREATE: Parent: %s, Child: %s\n", fTitle.String(),
for(int i = 0; i < childCount; i++)
{
fSession->ReadInt32(&dummyMsg);
if (dummyMsg == AS_LAYER_CREATE)
CreateLayerTree(newLayer);
else
debugger("ServerWindow(%s) - AS_LAYER_CREATE Expected!\n");
}
STRACE(("DONE: ServerWindow %s: Message AS_CREATE_LAYER: Parent: %s, Child: %s\n", fTitle.String(),
localRoot? localRoot->fName->String(): "NULL", newLayer->fName->String())); localRoot? localRoot->fName->String(): "NULL", newLayer->fName->String()));
return newLayer; return newLayer;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void ServerWindow::DispatchMessage(int32 code) void ServerWindow::DispatchMessage(int32 code)
{ {
if (cl == NULL && code != AS_LAYER_CREATE_ROOT)
{
printf("ServerWindow %s received unexpected code - message offset %lx before top_view attached.\n",fTitle.String(), code - SERVER_TRUE);
return;
}
switch(code) switch(code)
{ {
//--------- BView Messages ----------------- //--------- BView Messages -----------------
@@ -725,8 +689,8 @@ void ServerWindow::DispatchMessage(int32 code)
int32 bitmapToken; int32 bitmapToken;
BPoint point; BPoint point;
fSession->ReadInt32(&bitmapToken); fSession->Read<int32>(&bitmapToken);
fSession->ReadPoint(&point); fSession->Read<BPoint>(&point);
ServerBitmap *sbmp = fServerApp->FindBitmap(bitmapToken); ServerBitmap *sbmp = fServerApp->FindBitmap(bitmapToken);
if(sbmp) if(sbmp)
@@ -750,8 +714,8 @@ void ServerWindow::DispatchMessage(int32 code)
int32 bitmapToken; int32 bitmapToken;
BPoint point; BPoint point;
fSession->ReadInt32(&bitmapToken); fSession->Read<int32>(&bitmapToken);
fSession->ReadPoint(&point); fSession->Read<BPoint>(&point);
ServerBitmap *sbmp = fServerApp->FindBitmap(bitmapToken); ServerBitmap *sbmp = fServerApp->FindBitmap(bitmapToken);
if(sbmp) if(sbmp)
@@ -773,9 +737,9 @@ void ServerWindow::DispatchMessage(int32 code)
int32 bitmapToken; int32 bitmapToken;
BRect srcRect, dstRect; BRect srcRect, dstRect;
fSession->ReadInt32(&bitmapToken); fSession->Read<int32>(&bitmapToken);
fSession->ReadRect(&dstRect); fSession->Read<BRect>(&dstRect);
fSession->ReadRect(&srcRect); fSession->Read<BRect>(&srcRect);
ServerBitmap *sbmp = fServerApp->FindBitmap(bitmapToken); ServerBitmap *sbmp = fServerApp->FindBitmap(bitmapToken);
if(sbmp) if(sbmp)
@@ -797,9 +761,9 @@ void ServerWindow::DispatchMessage(int32 code)
int32 bitmapToken; int32 bitmapToken;
BRect srcRect, dstRect; BRect srcRect, dstRect;
fSession->ReadInt32(&bitmapToken); fSession->Read<int32>(&bitmapToken);
fSession->ReadRect(&dstRect); fSession->Read<BRect>(&dstRect);
fSession->ReadRect(&srcRect); fSession->Read<BRect>(&srcRect);
ServerBitmap *sbmp = fServerApp->FindBitmap(bitmapToken); ServerBitmap *sbmp = fServerApp->FindBitmap(bitmapToken);
if(sbmp) if(sbmp)
@@ -819,20 +783,42 @@ void ServerWindow::DispatchMessage(int32 code)
STRACE(("ServerWindow %s: Message AS_SET_CURRENT_LAYER: Layer name: %s\n", fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_SET_CURRENT_LAYER: Layer name: %s\n", fTitle.String(), cl->fName->String()));
int32 token; int32 token;
fSession->ReadInt32(&token); fSession->Read<int32>(&token);
Layer *current = FindLayer(fWinBorder->fTopLayer, token); Layer *current = FindLayer(fWinBorder->fTopLayer, token);
if (current) if (current)
cl=current; cl=current;
else // hope this NEVER happens! :-) else // hope this NEVER happens! :-)
debugger("Server PANIC: window cannot find Layer with ID\n"); debugger("Server PANIC: window cannot find Layer with ID\n");
break; break;
} }
case AS_LAYER_CREATE_ROOT:
{
// Start receiving top_view data -- pass NULL as the parent view.
// This should be the *only* place where this happens.
if (cl != NULL)
break;
fWinBorder->fTopLayer = CreateLayerTree(NULL);
fWinBorder->fTopLayer->SetAsTopLayer(true);
cl = fWinBorder->fTopLayer;
// connect decorator and top layer.
fWinBorder->AddChild(fWinBorder->fTopLayer, NULL);
desktop->AddWinBorder(fWinBorder);
break;
}
case AS_LAYER_CREATE: case AS_LAYER_CREATE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_CREATE: Layer name: %s\n", fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_CREATE: Layer name: %s\n", fTitle.String(), cl->fName->String()));
Layer *newLayer; Layer *newLayer;
if (cl == NULL)
break;
newLayer = CreateLayerTree(NULL); newLayer = CreateLayerTree(NULL);
cl->AddChild(newLayer, this); cl->AddChild(newLayer, this);
@@ -898,46 +884,49 @@ void ServerWindow::DispatchMessage(int32 code)
vc = ld->viewcolor.GetColor32(); vc = ld->viewcolor.GetColor32();
patt = ld->patt.GetInt64(); patt = ld->patt.GetInt64();
// TODO: DW implement such a method in ServerFont class // TODO: DW implement such a method in ServerFont class!
// fSession->WriteUInt32(ld->font.GetFamAndStyle()); fSession->StartMessage(SERVER_TRUE);
fSession->WriteUInt32(0UL); fSession->Attach<uint32>(0UL /*uint32 ld->font.GetFamAndStyle()*/);
fSession->WriteFloat(ld->font.Size()); fSession->Attach<float>(ld->font.Size());
fSession->WriteFloat(ld->font.Shear()); fSession->Attach<float>(ld->font.Shear());
fSession->WriteFloat(ld->font.Rotation()); fSession->Attach<float>(ld->font.Rotation());
fSession->WriteUInt8(ld->font.Spacing()); fSession->Attach<uint8>(ld->font.Spacing());
fSession->WriteUInt8(ld->font.Encoding()); fSession->Attach<uint8>(ld->font.Encoding());
fSession->WriteUInt16(ld->font.Face()); fSession->Attach<uint16>(ld->font.Face());
fSession->WriteUInt32(ld->font.Flags()); fSession->Attach<uint32>(ld->font.Flags());
fSession->WritePoint(ld->penlocation); fSession->Attach<BPoint>(ld->penlocation);
fSession->WriteFloat(ld->pensize); fSession->Attach<float>(ld->pensize);
fSession->WriteData(&hc, sizeof(rgb_color)); fSession->Attach(&hc, sizeof(rgb_color));
fSession->WriteData(&lc, sizeof(rgb_color)); fSession->Attach(&lc, sizeof(rgb_color));
fSession->WriteData(&vc, sizeof(rgb_color)); fSession->Attach(&vc, sizeof(rgb_color));
fSession->WriteData(&patt,sizeof(pattern));
fSession->WritePoint(ld->coordOrigin); // TODO: fix this to use the templatized version
fSession->WriteUInt8((uint8)(ld->draw_mode)); fSession->Attach(&patt,sizeof(pattern));
fSession->WriteUInt8((uint8)(ld->lineCap)); fSession->Attach<BPoint>(ld->coordOrigin);
fSession->WriteUInt8((uint8)(ld->lineJoin)); fSession->Attach<uint8>((uint8)(ld->draw_mode));
fSession->WriteFloat(ld->miterLimit); fSession->Attach<uint8>((uint8)(ld->lineCap));
fSession->WriteUInt8((uint8)(ld->alphaSrcMode)); fSession->Attach<uint8>((uint8)(ld->lineJoin));
fSession->WriteUInt8((uint8)(ld->alphaFncMode)); fSession->Attach<float>(ld->miterLimit);
fSession->WriteFloat(ld->scale); fSession->Attach<uint8>((uint8)(ld->alphaSrcMode));
fSession->WriteFloat(ld->fontAliasing); fSession->Attach<uint8>((uint8)(ld->alphaFncMode));
fSession->Attach<float>(ld->scale);
fSession->Attach<float>(ld->fontAliasing);
int32 noOfRects = 0; int32 noOfRects = 0;
if (ld->clipReg) if (ld->clipReg)
noOfRects = ld->clipReg->CountRects(); noOfRects = ld->clipReg->CountRects();
fSession->WriteInt32(noOfRects); fSession->Attach<int32>(noOfRects);
for(int i = 0; i < noOfRects; i++) for(int i = 0; i < noOfRects; i++)
fSession->WriteRect(ld->clipReg->RectAt(i)); fSession->Attach<BRect>(ld->clipReg->RectAt(i));
fSession->WriteFloat(cl->fFrame.left); fSession->Attach<float>(cl->fFrame.left);
fSession->WriteFloat(cl->fFrame.top); fSession->Attach<float>(cl->fFrame.top);
fSession->WriteRect(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop)); fSession->Attach<BRect>(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop));
fSession->Sync(); fSession->Flush();
break; break;
} }
case AS_LAYER_MOVETO: case AS_LAYER_MOVETO:
@@ -945,8 +934,8 @@ void ServerWindow::DispatchMessage(int32 code)
STRACE(("ServerWindow %s: Message AS_LAYER_MOVETO: Layer name: %s\n", fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_MOVETO: Layer name: %s\n", fTitle.String(), cl->fName->String()));
float x, y; float x, y;
fSession->ReadFloat(&x); fSession->Read<float>(&x);
fSession->ReadFloat(&y); fSession->Read<float>(&y);
cl->MoveBy(x, y); cl->MoveBy(x, y);
@@ -957,8 +946,8 @@ void ServerWindow::DispatchMessage(int32 code)
STRACE(("ServerWindow %s: Message AS_LAYER_RESIZETO: Layer name: %s\n", fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_RESIZETO: Layer name: %s\n", fTitle.String(), cl->fName->String()));
float newWidth, newHeight; float newWidth, newHeight;
fSession->ReadFloat(&newWidth); fSession->Read<float>(&newWidth);
fSession->ReadFloat(&newHeight); fSession->Read<float>(&newHeight);
// TODO: check for minimum alowed. WinBorder should provide such // TODO: check for minimum alowed. WinBorder should provide such
// a method, based on its decorator. // a method, based on its decorator.
@@ -970,10 +959,12 @@ void ServerWindow::DispatchMessage(int32 code)
case AS_LAYER_GET_COORD: case AS_LAYER_GET_COORD:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_COORD: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->WriteFloat(cl->fFrame.left); fSession->StartMessage(SERVER_TRUE);
fSession->WriteFloat(cl->fFrame.top); fSession->Attach<float>(cl->fFrame.left);
fSession->WriteRect(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop)); fSession->Attach<float>(cl->fFrame.top);
fSession->Sync(); fSession->Attach<BRect>(cl->fFrame.OffsetToCopy(cl->fBoundsLeftTop));
fSession->Flush();
break; break;
} }
case AS_LAYER_SET_ORIGIN: case AS_LAYER_SET_ORIGIN:
@@ -981,8 +972,8 @@ void ServerWindow::DispatchMessage(int32 code)
STRACE(("ServerWindow %s: Message AS_LAYER_SET_ORIGIN: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_ORIGIN: Layer: %s\n",fTitle.String(), cl->fName->String()));
float x, y; float x, y;
fSession->ReadFloat(&x); fSession->Read<float>(&x);
fSession->ReadFloat(&y); fSession->Read<float>(&y);
cl->fLayerData->coordOrigin.Set(x, y); cl->fLayerData->coordOrigin.Set(x, y);
@@ -991,15 +982,16 @@ void ServerWindow::DispatchMessage(int32 code)
case AS_LAYER_GET_ORIGIN: case AS_LAYER_GET_ORIGIN:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_ORIGIN: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->WritePoint(cl->fLayerData->coordOrigin); fSession->StartMessage(SERVER_TRUE);
fSession->Sync(); fSession->Attach<BPoint>(cl->fLayerData->coordOrigin);
fSession->Flush();
break; break;
} }
case AS_LAYER_RESIZE_MODE: case AS_LAYER_RESIZE_MODE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_MODE: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_RESIZE_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->ReadUInt32(&(cl->fResizeMode)); fSession->Read<uint32>(&(cl->fResizeMode));
break; break;
} }
@@ -1008,7 +1000,7 @@ void ServerWindow::DispatchMessage(int32 code)
STRACE(("ServerWindow %s: Message AS_LAYER_CURSOR: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_CURSOR: Layer: %s\n",fTitle.String(), cl->fName->String()));
int32 token; int32 token;
fSession->ReadInt32(&token); fSession->Read<int32>(&token);
cursormanager->SetCursor(token); cursormanager->SetCursor(token);
@@ -1016,7 +1008,7 @@ void ServerWindow::DispatchMessage(int32 code)
} }
case AS_LAYER_SET_FLAGS: case AS_LAYER_SET_FLAGS:
{ {
fSession->ReadUInt32(&(cl->fFlags)); fSession->Read<uint32>(&(cl->fFlags));
STRACE(("ServerWindow %s: Message AS_LAYER_SET_FLAGS: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_FLAGS: Layer: %s\n",fTitle.String(), cl->fName->String()));
break; break;
@@ -1043,9 +1035,9 @@ void ServerWindow::DispatchMessage(int32 code)
// it was called. e.g.: different lineCap or lineJoin. Strange results // it was called. e.g.: different lineCap or lineJoin. Strange results
// would appear. // would appear.
fSession->ReadInt8(&lineCap); fSession->Read<int8>(&lineCap);
fSession->ReadInt8(&lineJoin); fSession->Read<int8>(&lineJoin);
fSession->ReadFloat(&(cl->fLayerData->miterLimit)); fSession->Read<float>(&(cl->fLayerData->miterLimit));
cl->fLayerData->lineCap = (cap_mode)lineCap; cl->fLayerData->lineCap = (cap_mode)lineCap;
cl->fLayerData->lineJoin = (join_mode)lineJoin; cl->fLayerData->lineJoin = (join_mode)lineJoin;
@@ -1055,10 +1047,11 @@ void ServerWindow::DispatchMessage(int32 code)
case AS_LAYER_GET_LINE_MODE: case AS_LAYER_GET_LINE_MODE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_LINE_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->WriteInt8((int8)(cl->fLayerData->lineCap)); fSession->StartMessage(SERVER_TRUE);
fSession->WriteInt8((int8)(cl->fLayerData->lineJoin)); fSession->Attach<int8>((int8)(cl->fLayerData->lineCap));
fSession->WriteFloat(cl->fLayerData->miterLimit); fSession->Attach<int8>((int8)(cl->fLayerData->lineJoin));
fSession->Sync(); fSession->Attach<float>(cl->fLayerData->miterLimit);
fSession->Flush();
break; break;
} }
@@ -1092,9 +1085,8 @@ void ServerWindow::DispatchMessage(int32 code)
} }
case AS_LAYER_SET_SCALE: case AS_LAYER_SET_SCALE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_SCALE: Layer: %s\n",fTitle.String(), cl->_name->String()));
fSession->ReadFloat(&(cl->fLayerData->scale)); fSession->Read<float>(&(cl->fLayerData->scale));
break; break;
} }
case AS_LAYER_GET_SCALE: case AS_LAYER_GET_SCALE:
@@ -1107,9 +1099,10 @@ void ServerWindow::DispatchMessage(int32 code)
while((ld = ld->prevState)) while((ld = ld->prevState))
scale *= ld->scale; scale *= ld->scale;
fSession->WriteFloat(scale); fSession->StartMessage(SERVER_TRUE);
fSession->Sync(); fSession->Attach<float>(scale);
fSession->Flush();
break; break;
} }
case AS_LAYER_SET_PEN_LOC: case AS_LAYER_SET_PEN_LOC:
@@ -1117,34 +1110,36 @@ void ServerWindow::DispatchMessage(int32 code)
STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->fName->String()));
float x, y; float x, y;
fSession->ReadFloat(&x); fSession->Read<float>(&x);
fSession->ReadFloat(&y); fSession->Read<float>(&y);
cl->fLayerData->penlocation.Set(x, y); cl->fLayerData->penlocation.Set(x, y);
break; break;
} }
case AS_LAYER_GET_PEN_LOC: case AS_LAYER_GET_PEN_LOC:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_LOC: Layer: %s\n",fTitle.String(), cl->_name->String()));
fSession->WritePoint(cl->fLayerData->penlocation); fSession->StartMessage(SERVER_TRUE);
fSession->Attach<BPoint>(cl->fLayerData->penlocation);
fSession->Sync(); fSession->Flush();
break; break;
} }
case AS_LAYER_SET_PEN_SIZE: case AS_LAYER_SET_PEN_SIZE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->_name->String()));
fSession->ReadFloat(&(cl->fLayerData->pensize)); fSession->Read<float>(&(cl->fLayerData->pensize));
break; break;
} }
case AS_LAYER_GET_PEN_SIZE: case AS_LAYER_GET_PEN_SIZE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_PEN_SIZE: Layer: %s\n",fTitle.String(), cl->_name->String()));
fSession->WriteFloat(cl->fLayerData->pensize); fSession->StartMessage(SERVER_TRUE);
fSession->Sync(); fSession->Attach<float>(cl->fLayerData->pensize);
fSession->Flush();
break; break;
} }
case AS_LAYER_SET_HIGH_COLOR: case AS_LAYER_SET_HIGH_COLOR:
@@ -1152,10 +1147,10 @@ void ServerWindow::DispatchMessage(int32 code)
STRACE(("ServerWindow %s: Message AS_LAYER_SET_HIGH_COLOR: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_HIGH_COLOR: Layer: %s\n",fTitle.String(), cl->fName->String()));
rgb_color c; rgb_color c;
fSession->ReadData(&c, sizeof(rgb_color)); fSession->Read(&c, sizeof(rgb_color));
cl->fLayerData->highcolor.SetColor(c); cl->fLayerData->highcolor.SetColor(c);
break; break;
} }
case AS_LAYER_SET_LOW_COLOR: case AS_LAYER_SET_LOW_COLOR:
@@ -1163,7 +1158,7 @@ void ServerWindow::DispatchMessage(int32 code)
STRACE(("ServerWindow %s: Message AS_LAYER_SET_LOW_COLOR: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_LOW_COLOR: Layer: %s\n",fTitle.String(), cl->fName->String()));
rgb_color c; rgb_color c;
fSession->ReadData(&c, sizeof(rgb_color)); fSession->Read(&c, sizeof(rgb_color));
cl->fLayerData->lowcolor.SetColor(c); cl->fLayerData->lowcolor.SetColor(c);
@@ -1174,7 +1169,7 @@ void ServerWindow::DispatchMessage(int32 code)
STRACE(("ServerWindow %s: Message AS_LAYER_SET_VIEW_COLOR: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_VIEW_COLOR: Layer: %s\n",fTitle.String(), cl->fName->String()));
rgb_color c; rgb_color c;
fSession->ReadData(&c, sizeof(rgb_color)); fSession->Read(&c, sizeof(rgb_color));
cl->fLayerData->viewcolor.SetColor(c); cl->fLayerData->viewcolor.SetColor(c);
@@ -1191,10 +1186,11 @@ void ServerWindow::DispatchMessage(int32 code)
lowColor = cl->fLayerData->lowcolor.GetColor32(); lowColor = cl->fLayerData->lowcolor.GetColor32();
viewColor = cl->fLayerData->viewcolor.GetColor32(); viewColor = cl->fLayerData->viewcolor.GetColor32();
fSession->WriteData(&highColor, sizeof(rgb_color)); fSession->StartMessage(SERVER_TRUE);
fSession->WriteData(&lowColor, sizeof(rgb_color)); fSession->Attach(&highColor, sizeof(rgb_color));
fSession->WriteData(&viewColor, sizeof(rgb_color)); fSession->Attach(&lowColor, sizeof(rgb_color));
fSession->Sync(); fSession->Attach(&viewColor, sizeof(rgb_color));
fSession->Flush();
break; break;
} }
@@ -1203,21 +1199,21 @@ void ServerWindow::DispatchMessage(int32 code)
STRACE(("ServerWindow %s: Message AS_LAYER_SET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
int8 srcAlpha, alphaFunc; int8 srcAlpha, alphaFunc;
fSession->ReadInt8(&srcAlpha); fSession->Read<int8>(&srcAlpha);
fSession->ReadInt8(&alphaFunc); fSession->Read<int8>(&alphaFunc);
cl->fLayerData->alphaSrcMode = (source_alpha)srcAlpha; cl->fLayerData->alphaSrcMode = (source_alpha)srcAlpha;
cl->fLayerData->alphaFncMode = (alpha_function)alphaFunc; cl->fLayerData->alphaFncMode = (alpha_function)alphaFunc;
break; break;
} }
case AS_LAYER_GET_BLEND_MODE: case AS_LAYER_GET_BLEND_MODE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_BLEND_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->WriteInt8((int8)(cl->fLayerData->alphaSrcMode)); fSession->StartMessage(SERVER_TRUE);
fSession->WriteInt8((int8)(cl->fLayerData->alphaFncMode)); fSession->Attach<int8>((int8)(cl->fLayerData->alphaSrcMode));
fSession->Attach<int8>((int8)(cl->fLayerData->alphaFncMode));
fSession->Sync(); fSession->Flush();
break; break;
} }
@@ -1226,7 +1222,7 @@ void ServerWindow::DispatchMessage(int32 code)
STRACE(("ServerWindow %s: Message AS_LAYER_SET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_SET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
int8 drawingMode; int8 drawingMode;
fSession->ReadInt8(&drawingMode); fSession->Read<int8>(&drawingMode);
cl->fLayerData->draw_mode = (drawing_mode)drawingMode; cl->fLayerData->draw_mode = (drawing_mode)drawingMode;
@@ -1235,27 +1231,29 @@ void ServerWindow::DispatchMessage(int32 code)
case AS_LAYER_GET_DRAW_MODE: case AS_LAYER_GET_DRAW_MODE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_DRAW_MODE: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->WriteInt8((int8)(cl->fLayerData->draw_mode)); fSession->StartMessage(SERVER_TRUE);
fSession->Sync(); fSession->Attach<int8>((int8)(cl->fLayerData->draw_mode));
fSession->Flush();
break; break;
} }
case AS_LAYER_PRINT_ALIASING: case AS_LAYER_PRINT_ALIASING:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_PRINT_ALIASING: Layer: %s\n",fTitle.String(), cl->fName->String()));
fSession->ReadBool(&(cl->fLayerData->fontAliasing)); fSession->Read<bool>(&(cl->fLayerData->fontAliasing));
break; break;
} }
case AS_LAYER_CLIP_TO_PICTURE: case AS_LAYER_CLIP_TO_PICTURE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_PICTURE: Layer: %s\n",fTitle.String(), cl->fName->String()));
// TODO: watch out for the coordinate system // TODO: watch out for the coordinate system
int32 pictureToken; int32 pictureToken;
BPoint where; BPoint where;
fSession->ReadInt32(&pictureToken); fSession->Read<int32>(&pictureToken);
fSession->ReadPoint(&where); fSession->Read<BPoint>(&where);
BRegion reg; BRegion reg;
@@ -1324,12 +1322,13 @@ void ServerWindow::DispatchMessage(int32 code)
case AS_LAYER_CLIP_TO_INVERSE_PICTURE: case AS_LAYER_CLIP_TO_INVERSE_PICTURE:
{ {
STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_CLIP_TO_INVERSE_PICTURE: Layer: %s\n",fTitle.String(), cl->fName->String()));
// TODO: watch out for the coordinate system // TODO: watch out for the coordinate system
int32 pictureToken; int32 pictureToken;
BPoint where; BPoint where;
fSession->ReadInt32(&pictureToken); fSession->Read<int32>(&pictureToken);
fSession->ReadPoint(&where); fSession->Read<BPoint>(&where);
ServerPicture *sp = NULL; ServerPicture *sp = NULL;
int32 i = 0; int32 i = 0;
@@ -1365,8 +1364,9 @@ void ServerWindow::DispatchMessage(int32 code)
STRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->fName->String())); STRACE(("ServerWindow %s: Message AS_LAYER_GET_CLIP_REGION: Layer: %s\n",fTitle.String(), cl->fName->String()));
// if this Layer is hidden, it is clear that its visible region is void. // if this Layer is hidden, it is clear that its visible region is void.
if (cl->IsHidden()){ if (cl->IsHidden()){
fSession->WriteInt32(0L); fSession->StartMessage(SERVER_TRUE);
fSession->Sync(); fSession->Attach<int32>(0L);
fSession->Flush();
} }
else{ else{
// TODO: watch out for the coordinate system // TODO: watch out for the coordinate system
@@ -1387,10 +1387,11 @@ void ServerWindow::DispatchMessage(int32 code)
} }
noOfRects = reg.CountRects(); noOfRects = reg.CountRects();
fSession->WriteInt32(noOfRects); fSession->StartMessage(SERVER_TRUE);
fSession->Attach<int32>(noOfRects);
for(int i = 0; i < noOfRects; i++) for(int i = 0; i < noOfRects; i++)
fSession->WriteRect(reg.RectAt(i)); fSession->Attach<BRect>(reg.RectAt(i));
} }
break; break;
} }
@@ -1406,11 +1407,11 @@ void ServerWindow::DispatchMessage(int32 code)
else else
cl->fLayerData->clipReg = new BRegion(); cl->fLayerData->clipReg = new BRegion();
fSession->ReadInt32(&noOfRects); fSession->Read<int32>(&noOfRects);
for(int i = 0; i < noOfRects; i++) for(int i = 0; i < noOfRects; i++)
{ {
fSession->ReadRect(&r); fSession->Read<BRect>(&r);
cl->fLayerData->clipReg->Include(r); cl->fLayerData->clipReg->Include(r);
} }
@@ -1431,7 +1432,7 @@ void ServerWindow::DispatchMessage(int32 code)
// TODO: watch out for the coordinate system // TODO: watch out for the coordinate system
BRect invalRect; BRect invalRect;
fSession->ReadRect(&invalRect); fSession->Read<BRect>(&invalRect);
cl->Invalidate(invalRect); cl->Invalidate(invalRect);
@@ -1445,11 +1446,11 @@ void ServerWindow::DispatchMessage(int32 code)
int32 noOfRects; int32 noOfRects;
BRect rect; BRect rect;
fSession->ReadInt32(&noOfRects); fSession->Read<int32>(&noOfRects);
for(int i = 0; i < noOfRects; i++) for(int i = 0; i < noOfRects; i++)
{ {
fSession->ReadRect(&rect); fSession->Read<BRect>(&rect);
invalReg.Include(rect); invalReg.Include(rect);
} }
@@ -1527,21 +1528,21 @@ void ServerWindow::DispatchMessage(int32 code)
int32 mainToken; int32 mainToken;
team_id teamID; team_id teamID;
fSession->ReadInt32(&mainToken); fSession->Read<int32>(&mainToken);
fSession->ReadData(&teamID, sizeof(team_id)); fSession->Read(&teamID, sizeof(team_id));
wb = desktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID); wb = desktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID);
if(wb) if(wb)
{ {
fSession->WriteInt32(SERVER_TRUE); fSession->StartMessage(SERVER_TRUE);
fSession->Sync(); fSession->Flush();
fWinBorder->AddToSubsetOf(wb); fWinBorder->AddToSubsetOf(wb);
} }
else else
{ {
fSession->WriteInt32(SERVER_FALSE); fSession->StartMessage(SERVER_FALSE);
fSession->Sync(); fSession->Flush();
} }
break; break;
} }
@@ -1551,21 +1552,21 @@ void ServerWindow::DispatchMessage(int32 code)
int32 mainToken; int32 mainToken;
team_id teamID; team_id teamID;
fSession->ReadInt32(&mainToken); fSession->Read<int32>(&mainToken);
fSession->ReadData(&teamID, sizeof(team_id)); fSession->Read(&teamID, sizeof(team_id));
wb = desktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID); wb = desktop->FindWinBorderByServerWindowTokenAndTeamID(mainToken, teamID);
if(wb) if(wb)
{ {
fSession->WriteInt32(SERVER_TRUE); fSession->StartMessage(SERVER_TRUE);
fSession->Sync(); fSession->Flush();
fWinBorder->RemoveFromSubsetOf(wb); fWinBorder->RemoveFromSubsetOf(wb);
} }
else else
{ {
fSession->WriteInt32(SERVER_FALSE); fSession->StartMessage(SERVER_FALSE);
fSession->Sync(); fSession->Flush();
} }
break; break;
} }
@@ -1616,8 +1617,8 @@ void ServerWindow::DispatchMessage(int32 code)
float xResizeBy; float xResizeBy;
float yResizeBy; float yResizeBy;
fSession->ReadFloat(&xResizeBy); fSession->Read<float>(&xResizeBy);
fSession->ReadFloat(&yResizeBy); fSession->Read<float>(&yResizeBy);
fWinBorder->ResizeBy(xResizeBy, yResizeBy); fWinBorder->ResizeBy(xResizeBy, yResizeBy);
@@ -1628,8 +1629,8 @@ void ServerWindow::DispatchMessage(int32 code)
float xMoveBy; float xMoveBy;
float yMoveBy; float yMoveBy;
fSession->ReadFloat(&xMoveBy); fSession->Read<float>(&xMoveBy);
fSession->ReadFloat(&yMoveBy); fSession->Read<float>(&yMoveBy);
fWinBorder->MoveBy(xMoveBy, yMoveBy); fWinBorder->MoveBy(xMoveBy, yMoveBy);
@@ -2216,14 +2217,18 @@ void ServerWindow::DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer)
int32 ServerWindow::MonitorWin(void *data) int32 ServerWindow::MonitorWin(void *data)
{ {
ServerWindow *win = (ServerWindow *)data; ServerWindow *win = (ServerWindow *)data;
BSession *ses = win->fSession; BPortLink *ses = win->fSession;
bool quitting = false; bool quitting = false;
int32 code; int32 code;
status_t err = B_OK;
while(!quitting) while(!quitting)
{ {
printf("info: ServerWindow::MonitorWin listening on port %ld.\n", win->fMessagePort);
code = AS_CLIENT_DEAD; code = AS_CLIENT_DEAD;
ses->ReadInt32(&code); err = ses->GetNextReply(&code);
if (err < B_OK)
return err;
win->Lock(); win->Lock();
@@ -2255,7 +2260,7 @@ int32 ServerWindow::MonitorWin(void *data)
win->Unlock(); win->Unlock();
} }
return 0; return err;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Layer* ServerWindow::FindLayer(const Layer* start, int32 token) const Layer* ServerWindow::FindLayer(const Layer* start, int32 token) const
+2 -4
View File
@@ -34,7 +34,6 @@
#include <Rect.h> #include <Rect.h>
#include <String.h> #include <String.h>
#include <Window.h> #include <Window.h>
#include <PortMessage.h>
#include "FMWList.h" #include "FMWList.h"
class BString; class BString;
@@ -43,10 +42,9 @@ class BPoint;
class BMessage; class BMessage;
class ServerApp; class ServerApp;
class Decorator; class Decorator;
class PortLink; class BPortLink;
class WinBorder; class WinBorder;
class Workspace; class Workspace;
class BSession;
class Layer; class Layer;
#define AS_UPDATE_DECORATOR 'asud' #define AS_UPDATE_DECORATOR 'asud'
@@ -159,7 +157,7 @@ protected:
uint32 fToken; uint32 fToken;
int32 fHandlerToken; int32 fHandlerToken;
BSession *fSession; BPortLink *fSession;
// cl is short for currentLayer. We'll use it a lot, that's why it's short :-) // cl is short for currentLayer. We'll use it a lot, that's why it's short :-)
Layer *cl; Layer *cl;
+25 -23
View File
@@ -25,7 +25,7 @@
// //
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include <PortLink.h> #include <PortLink.h>
#include <PortMessage.h> #include <AppServerLink.h>
#include <ServerProtocol.h> #include <ServerProtocol.h>
#include <OS.h> #include <OS.h>
#include <String.h> #include <String.h>
@@ -43,8 +43,8 @@ void set_syscursor(cursor_which which, const BCursor *cursor)
port_id server=find_port(SERVER_PORT_NAME); port_id server=find_port(SERVER_PORT_NAME);
if(server!=B_NAME_NOT_FOUND) if(server!=B_NAME_NOT_FOUND)
{ {
PortLink link(server); BPortLink link(server);
link.SetOpCode(AS_SET_SYSCURSOR_BCURSOR); link.StartMessage(AS_SET_SYSCURSOR_BCURSOR);
link.Attach<cursor_which>(which); link.Attach<cursor_which>(which);
// The easy (and clean) way for us to access the cursor's token // The easy (and clean) way for us to access the cursor's token
@@ -69,8 +69,8 @@ void set_syscursor(cursor_which which, const BBitmap *bitmap)
port_id server=find_port(SERVER_PORT_NAME); port_id server=find_port(SERVER_PORT_NAME);
if(server!=B_NAME_NOT_FOUND) if(server!=B_NAME_NOT_FOUND)
{ {
PortLink link(server); BPortLink link(server);
link.SetOpCode(AS_SET_SYSCURSOR_BBITMAP); link.StartMessage(AS_SET_SYSCURSOR_BBITMAP);
link.Attach<cursor_which>(which); link.Attach<cursor_which>(which);
// Just like the BCursor version, we will use a hack until R1. // Just like the BCursor version, we will use a hack until R1.
@@ -89,17 +89,19 @@ void set_syscursor(cursor_which which, const BBitmap *bitmap)
cursor_which get_syscursor(void) cursor_which get_syscursor(void)
{ {
port_id server=find_port(SERVER_PORT_NAME); port_id server=find_port(SERVER_PORT_NAME);
if(server!=B_NAME_NOT_FOUND) if(server >= 0)
{ {
PortMessage pmsg; int32 code = SERVER_FALSE;
BPrivate::BAppServerLink link;
PortLink link(server);
link.SetOpCode(AS_GET_SYSCURSOR);
link.FlushWithReply(&pmsg);
cursor_which which; cursor_which which;
pmsg.Read<cursor_which>(&which);
return which; link.SetSendPort(server);
link.StartMessage(AS_GET_SYSCURSOR);
link.FlushWithReply(&code);
if (code == SERVER_TRUE)
if (link.Read<cursor_which>(&which) == B_OK)
return which;
} }
return B_CURSOR_INVALID; return B_CURSOR_INVALID;
} }
@@ -111,10 +113,10 @@ cursor_which get_syscursor(void)
void setcursor(cursor_which which) void setcursor(cursor_which which)
{ {
port_id server=find_port(SERVER_PORT_NAME); port_id server=find_port(SERVER_PORT_NAME);
if(server!=B_NAME_NOT_FOUND) if(server >= 0)
{ {
PortLink link(server); BPortLink link(server);
link.SetOpCode(AS_SET_CURSOR_SYSTEM); link.StartMessage(AS_SET_CURSOR_SYSTEM);
link.Flush(); link.Flush();
} }
} }
@@ -270,7 +272,7 @@ status_t CursorSet::FindCursor(cursor_which which, BBitmap **cursor, BPoint *hot
return B_NAME_NOT_FOUND; return B_NAME_NOT_FOUND;
const void *buffer; const void *buffer;
BString tempstr; const char *tempstr;
int32 bufferLength; int32 bufferLength;
BBitmap *bmp; BBitmap *bmp;
BPoint hotpt; BPoint hotpt;
@@ -282,7 +284,7 @@ status_t CursorSet::FindCursor(cursor_which which, BBitmap **cursor, BPoint *hot
return B_ERROR; return B_ERROR;
if(tempstr.Compare("cursor")==0) if(strcmp(tempstr, "cursor")==0)
{ {
bmp=new BBitmap( msg.FindRect("_frame"), bmp=new BBitmap( msg.FindRect("_frame"),
(color_space) msg.FindInt32("_cspace"),true ); (color_space) msg.FindInt32("_cspace"),true );
@@ -316,7 +318,7 @@ status_t CursorSet::FindCursor(cursor_which which, ServerCursor **cursor)
return B_NAME_NOT_FOUND; return B_NAME_NOT_FOUND;
const void *buffer; const void *buffer;
BString tempstr; const char *tempstr;
int32 bufferLength; int32 bufferLength;
ServerCursor *csr; ServerCursor *csr;
BPoint hotpt; BPoint hotpt;
@@ -327,7 +329,7 @@ status_t CursorSet::FindCursor(cursor_which which, ServerCursor **cursor)
if(msg.FindPoint("hotspot",&hotpt)!=B_OK) if(msg.FindPoint("hotspot",&hotpt)!=B_OK)
return B_ERROR; return B_ERROR;
if(tempstr.Compare("cursor")==0) if(strcmp(tempstr, "cursor")==0)
{ {
csr=new ServerCursor(msg.FindRect("_frame"),(color_space) msg.FindInt32("_cspace"),0, hotpt); csr=new ServerCursor(msg.FindRect("_frame"),(color_space) msg.FindInt32("_cspace"),0, hotpt);
msg.FindData("_data",B_RAW_TYPE,(const void **)&buffer, (ssize_t*)&bufferLength); msg.FindData("_data",B_RAW_TYPE,(const void **)&buffer, (ssize_t*)&bufferLength);
@@ -345,8 +347,8 @@ status_t CursorSet::FindCursor(cursor_which which, ServerCursor **cursor)
*/ */
const char *CursorSet::GetName(void) const char *CursorSet::GetName(void)
{ {
const char *name = NULL; const char *name;
if (FindString("name", &name) == B_OK) if(FindString("name",&name)==B_OK)
return name; return name;
return NULL; return NULL;
} }
+10 -10
View File
@@ -83,7 +83,7 @@ VDView::VDView(BRect bounds)
// This link for sending mouse messages to the OBAppServer. // This link for sending mouse messages to the OBAppServer.
// This is only to take the place of the Input Server. // This is only to take the place of the Input Server.
serverlink=new PortLink(find_port(SERVER_INPUT_PORT)); serverlink = new BPortLink(find_port(SERVER_INPUT_PORT));
// Create a cursor which isn't just a box // Create a cursor which isn't just a box
cursor=new BBitmap(BRect(0,0,20,20),B_RGBA32,true); cursor=new BBitmap(BRect(0,0,20,20),B_RGBA32,true);
@@ -159,7 +159,7 @@ void VDView::MouseDown(BPoint pt)
GetMouse(&p,&buttons); GetMouse(&p,&buttons);
serverlink->SetOpCode(B_MOUSE_DOWN); serverlink->StartMessage(B_MOUSE_DOWN);
serverlink->Attach(&time, sizeof(int64)); serverlink->Attach(&time, sizeof(int64));
serverlink->Attach(&pt.x,sizeof(float)); serverlink->Attach(&pt.x,sizeof(float));
serverlink->Attach(&pt.y,sizeof(float)); serverlink->Attach(&pt.y,sizeof(float));
@@ -182,7 +182,7 @@ void VDView::MouseMoved(BPoint pt, uint32 transit, const BMessage *msg)
uint32 buttons; uint32 buttons;
int64 time=(int64)real_time_clock(); int64 time=(int64)real_time_clock();
serverlink->SetOpCode(B_MOUSE_MOVED); serverlink->StartMessage(B_MOUSE_MOVED);
serverlink->Attach(&time,sizeof(int64)); serverlink->Attach(&time,sizeof(int64));
serverlink->Attach(&pt.x,sizeof(float)); serverlink->Attach(&pt.x,sizeof(float));
serverlink->Attach(&pt.y,sizeof(float)); serverlink->Attach(&pt.y,sizeof(float));
@@ -209,7 +209,7 @@ void VDView::MouseUp(BPoint pt)
GetMouse(&p,&buttons); GetMouse(&p,&buttons);
serverlink->SetOpCode(B_MOUSE_UP); serverlink->StartMessage(B_MOUSE_UP);
serverlink->Attach(&time, sizeof(int64)); serverlink->Attach(&time, sizeof(int64));
serverlink->Attach(&pt.x,sizeof(float)); serverlink->Attach(&pt.x,sizeof(float));
serverlink->Attach(&pt.y,sizeof(float)); serverlink->Attach(&pt.y,sizeof(float));
@@ -229,7 +229,7 @@ void VDView::MessageReceived(BMessage *msg)
msg->FindFloat("be:wheel_delta_x",&x); msg->FindFloat("be:wheel_delta_x",&x);
msg->FindFloat("be:wheel_delta_y",&y); msg->FindFloat("be:wheel_delta_y",&y);
int64 time=real_time_clock(); int64 time=real_time_clock();
serverlink->SetOpCode(B_MOUSE_WHEEL_CHANGED); serverlink->StartMessage(B_MOUSE_WHEEL_CHANGED);
serverlink->Attach(&time,sizeof(int64)); serverlink->Attach(&time,sizeof(int64));
serverlink->Attach(x); serverlink->Attach(x);
serverlink->Attach(y); serverlink->Attach(y);
@@ -289,7 +289,7 @@ void VDWindow::MessageReceived(BMessage *msg)
msg->FindString("bytes",&string); msg->FindString("bytes",&string);
for(int8 i=0;i<15;i++) for(int8 i=0;i<15;i++)
msg->FindInt8("states",i,&keyarray[i]); msg->FindInt8("states",i,&keyarray[i]);
view->serverlink->SetOpCode(B_KEY_DOWN); view->serverlink->StartMessage(B_KEY_DOWN);
view->serverlink->Attach(&systime,sizeof(bigtime_t)); view->serverlink->Attach(&systime,sizeof(bigtime_t));
view->serverlink->Attach(scancode); view->serverlink->Attach(scancode);
view->serverlink->Attach(asciicode); view->serverlink->Attach(asciicode);
@@ -330,7 +330,7 @@ void VDWindow::MessageReceived(BMessage *msg)
msg->FindString("bytes",&string); msg->FindString("bytes",&string);
for(int8 i=0;i<15;i++) for(int8 i=0;i<15;i++)
msg->FindInt8("states",i,&keyarray[i]); msg->FindInt8("states",i,&keyarray[i]);
view->serverlink->SetOpCode(B_KEY_UP); view->serverlink->StartMessage(B_KEY_UP);
view->serverlink->Attach(&systime,sizeof(bigtime_t)); view->serverlink->Attach(&systime,sizeof(bigtime_t));
view->serverlink->Attach(scancode); view->serverlink->Attach(scancode);
view->serverlink->Attach(asciicode); view->serverlink->Attach(asciicode);
@@ -358,7 +358,7 @@ void VDWindow::MessageReceived(BMessage *msg)
msg->FindInt32("modifiers",&modifiers); msg->FindInt32("modifiers",&modifiers);
for(int8 i=0;i<15;i++) for(int8 i=0;i<15;i++)
msg->FindInt8("states",i,&keyarray[i]); msg->FindInt8("states",i,&keyarray[i]);
view->serverlink->SetOpCode(B_UNMAPPED_KEY_DOWN); view->serverlink->StartMessage(B_UNMAPPED_KEY_DOWN);
view->serverlink->Attach(&systime,sizeof(bigtime_t)); view->serverlink->Attach(&systime,sizeof(bigtime_t));
view->serverlink->Attach(scancode); view->serverlink->Attach(scancode);
view->serverlink->Attach(modifiers); view->serverlink->Attach(modifiers);
@@ -382,7 +382,7 @@ void VDWindow::MessageReceived(BMessage *msg)
msg->FindInt32("modifiers",&modifiers); msg->FindInt32("modifiers",&modifiers);
for(int8 i=0;i<15;i++) for(int8 i=0;i<15;i++)
msg->FindInt8("states",i,&keyarray[i]); msg->FindInt8("states",i,&keyarray[i]);
view->serverlink->SetOpCode(B_UNMAPPED_KEY_UP); view->serverlink->StartMessage(B_UNMAPPED_KEY_UP);
view->serverlink->Attach(&systime,sizeof(bigtime_t)); view->serverlink->Attach(&systime,sizeof(bigtime_t));
view->serverlink->Attach(scancode); view->serverlink->Attach(scancode);
view->serverlink->Attach(modifiers); view->serverlink->Attach(modifiers);
@@ -407,7 +407,7 @@ void VDWindow::MessageReceived(BMessage *msg)
msg->FindInt32("be:old_modifiers",&oldmodifiers); msg->FindInt32("be:old_modifiers",&oldmodifiers);
for(int8 i=0;i<15;i++) for(int8 i=0;i<15;i++)
msg->FindInt8("states",i,&keyarray[i]); msg->FindInt8("states",i,&keyarray[i]);
view->serverlink->SetOpCode(B_MODIFIERS_CHANGED); view->serverlink->StartMessage(B_MODIFIERS_CHANGED);
view->serverlink->Attach(&systime,sizeof(bigtime_t)); view->serverlink->Attach(&systime,sizeof(bigtime_t));
view->serverlink->Attach(scancode); view->serverlink->Attach(scancode);
view->serverlink->Attach(modifiers); view->serverlink->Attach(modifiers);
+3 -3
View File
@@ -40,7 +40,7 @@
#include "FontServer.h" #include "FontServer.h"
class BBitmap; class BBitmap;
class PortLink; class BPortLink;
class VDWindow; class VDWindow;
class DrawData; class DrawData;
@@ -57,7 +57,7 @@ public:
void MessageReceived(BMessage *msg); void MessageReceived(BMessage *msg);
BBitmap *viewbmp; BBitmap *viewbmp;
PortLink *serverlink; BPortLink *serverlink;
int hide_cursor; int hide_cursor;
BBitmap *cursor; BBitmap *cursor;
@@ -160,7 +160,7 @@ protected:
BView *drawview; BView *drawview;
BRegion laregion; BRegion laregion;
PortLink *serverlink; BPortLink *serverlink;
// drawing_mode drawmode; // drawing_mode drawmode;
rgb_color highcolor,lowcolor; rgb_color highcolor,lowcolor;
+19 -69
View File
@@ -30,7 +30,7 @@
#include <Locker.h> #include <Locker.h>
#include <Debug.h> #include <Debug.h>
#include <TokenSpace.h> #include <TokenSpace.h>
#include "PortMessage.h" #include "PortLink.h"
#include "View.h" // for mouse button defines #include "View.h" // for mouse button defines
#include "ServerWindow.h" #include "ServerWindow.h"
#include "Decorator.h" #include "Decorator.h"
@@ -90,7 +90,6 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i
fMouseButtons = 0; fMouseButtons = 0;
fKeyModifiers = 0; fKeyModifiers = 0;
fServerHidden = false;
fMainWinBorder = NULL; fMainWinBorder = NULL;
fDecorator = NULL; fDecorator = NULL;
fTopLayer = NULL; fTopLayer = NULL;
@@ -140,7 +139,7 @@ void WinBorder::RebuildFullRegion(void)
fDecorator->GetFootprint(&fFull); fDecorator->GetFootprint(&fFull);
} }
void WinBorder::MouseDown(PortMessage *msg, bool sendMessage) void WinBorder::MouseDown(PointerEvent& evt, bool sendMessage)
{ {
if (!(Window()->IsLocked())) if (!(Window()->IsLocked()))
debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseDown()\n"); debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseDown()\n");
@@ -150,34 +149,13 @@ void WinBorder::MouseDown(PortMessage *msg, bool sendMessage)
// user clicked on WinBorder's visible region, which is in fact decorator's. // user clicked on WinBorder's visible region, which is in fact decorator's.
// so, if true, we find out if the user clicked the decorator. // so, if true, we find out if the user clicked the decorator.
// Attached data: Layer *target = LayerAt(evt.where);
// 1) int64 - time of mouse click
// 2) float - x coordinate of mouse click
// 3) float - y coordinate of mouse click
// 4) int32 - modifier keys down
// 5) int32 - buttons down
// 6) int32 - clicks
int64 time;
BPoint pt;
int32 modifierkeys;
int32 buttons;
int32 clicks;
msg->Read<int64>(&time);
msg->Read<float>(&pt.x);
msg->Read<float>(&pt.y);
msg->Read<int32>(&modifierkeys);
msg->Read<int32>(&buttons);
msg->Read<int32>(&clicks);
Layer *target = LayerAt(pt);
if (target == this) if (target == this)
{ {
click_type action; click_type action;
// find out where user clicked in Decorator // find out where user clicked in Decorator
action = fDecorator->Clicked(pt, buttons, modifierkeys); action = fDecorator->Clicked(evt.where, evt.buttons, evt.modifiers);
switch(action) switch(action)
{ {
case DEC_CLOSE: case DEC_CLOSE:
@@ -236,42 +214,29 @@ void WinBorder::MouseDown(PortMessage *msg, bool sendMessage)
else if (sendMessage){ else if (sendMessage){
BMessage msg; BMessage msg;
msg.what= B_MOUSE_DOWN; msg.what= B_MOUSE_DOWN;
msg.AddInt64("when", time); msg.AddInt64("when", evt.when);
msg.AddPoint("where", pt); msg.AddPoint("where", evt.where);
msg.AddInt32("modifiers", modifierkeys); msg.AddInt32("modifiers", evt.modifiers);
msg.AddInt32("buttons", buttons); msg.AddInt32("buttons", evt.buttons);
msg.AddInt32("clicks", clicks); msg.AddInt32("clicks", evt.clicks);
// TODO: figure out how to specify the target // TODO: figure out how to specify the target
// msg.AddInt32("token", token); // msg.AddInt32("token", token);
Window()->SendMessageToClient(&msg); Window()->SendMessageToClient(&msg);
} }
// Just to clean up any mess we've made. :) fLastMousePosition = evt.where;
msg->Rewind();
fLastMousePosition = pt;
} }
void WinBorder::MouseMoved(PortMessage *msg) void WinBorder::MouseMoved(PointerEvent& evt)
{ {
if (!(Window()->IsLocked())) if (!(Window()->IsLocked()))
debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseMoved()\n"); debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseMoved()\n");
BPoint pt;
int64 dummy;
int32 buttons;
msg->Read<int64>(&dummy);
msg->Read<float>(&pt.x);
msg->Read<float>(&pt.y);
msg->Read<int32>(&buttons);
msg->Rewind();
if (fIsMoving) if (fIsMoving)
{ {
STRACE_CLICK(("===> Moving...\n")); STRACE_CLICK(("===> Moving...\n"));
BPoint offset = pt; BPoint offset = evt.where;
offset -= fLastMousePosition; offset -= fLastMousePosition;
MoveBy(offset.x, offset.y); MoveBy(offset.x, offset.y);
} }
@@ -279,14 +244,14 @@ void WinBorder::MouseMoved(PortMessage *msg)
if (fIsResizing) if (fIsResizing)
{ {
STRACE_CLICK(("===> Resizing...\n")); STRACE_CLICK(("===> Resizing...\n"));
BPoint offset = pt; BPoint offset = evt.where;
offset -= fLastMousePosition; offset -= fLastMousePosition;
ResizeBy(offset.x, offset.y); ResizeBy(offset.x, offset.y);
} }
else else
{ {
// Do a click test only if we have to, which would be now. :) // Do a click test only if we have to, which would be now. :)
click_type location=fDecorator->Clicked(pt,buttons,fKeyModifiers); click_type location=fDecorator->Clicked(evt.where, evt.buttons,fKeyModifiers);
if (fIsZooming && location!=DEC_ZOOM) if (fIsZooming && location!=DEC_ZOOM)
{ {
@@ -306,10 +271,10 @@ void WinBorder::MouseMoved(PortMessage *msg)
fDecorator->DrawMinimize(); fDecorator->DrawMinimize();
} }
} }
fLastMousePosition = pt; fLastMousePosition = evt.where;
} }
void WinBorder::MouseUp(PortMessage *msg) void WinBorder::MouseUp(PointerEvent& evt)
{ {
if (!(Window()->IsLocked())) if (!(Window()->IsLocked()))
debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseUp()\n"); debugger("you must lock the attached ServerWindow object\n\t before calling WinBorder::MouseUp()\n");
@@ -411,22 +376,7 @@ void WinBorder::ResizeBy(float x, float y)
Layer::ResizeBy(x,y); Layer::ResizeBy(x,y);
} }
bool WinBorder::IsHidden() const{ bool WinBorder::HasPoint(BPoint pt) const
if (fServerHidden)
return true;
return Layer::IsHidden();
}
void WinBorder::ServerHide(){
fServerHidden = true;
}
void WinBorder::ServerUnhide(){
fServerHidden = false;
}
bool WinBorder::HasPoint(const BPoint& pt) const
{ {
return fFullVisible.Contains(pt); return fFullVisible.Contains(pt);
} }
@@ -495,7 +445,7 @@ void WinBorder::AddToSubsetOf(WinBorder* main)
{ {
// if the main window is hidden also hide this one. // if the main window is hidden also hide this one.
if(main->IsHidden()) if(main->IsHidden())
Hide();//fHidden = true; fHidden = true;
// add to main window's subset // add to main window's subset
main->Window()->fWinFMWList.AddItem(this); main->Window()->fWinFMWList.AddItem(this);
@@ -603,7 +553,7 @@ void WinBorder::PrintToStream()
if (fLevel == B_NORMAL_FEEL) if (fLevel == B_NORMAL_FEEL)
printf("\t%s", "B_NORMAL_WINDOW_FEEL"); printf("\t%s", "B_NORMAL_WINDOW_FEEL");
printf("\t%s\n", IsHidden()?"hidden" : "not hidden"); printf("\t%s\n", fHidden?"hidden" : "not hidden");
} }
void WinBorder::UpdateColors(void) void WinBorder::UpdateColors(void)
+19 -10
View File
@@ -35,9 +35,23 @@
class ServerWindow; class ServerWindow;
class Decorator; class Decorator;
class DisplayDriver; class DisplayDriver;
class PortMessage;
class Desktop; class Desktop;
class PointerEvent
{
public:
int32 code; //B_MOUSE_UP, B_MOUSE_DOWN, B_MOUSE_MOVED
//B_MOUSE_WHEEL_CHANGED
bigtime_t when;
BPoint where;
float wheel_delta_x;
float wheel_delta_y;
int32 modifiers;
int32 buttons; //B_PRIMARY_MOUSE_BUTTON, B_SECONDARY_MOUSE_BUTTON
//B_TERTIARY_MOUSE_BUTTON
int32 clicks;
};
class WinBorder : public Layer class WinBorder : public Layer
{ {
public: public:
@@ -52,13 +66,9 @@ public:
virtual void RebuildFullRegion(void); virtual void RebuildFullRegion(void);
virtual bool IsHidden() const; void MouseDown(PointerEvent& evt, bool sendMessage);
void ServerHide(); void MouseMoved(PointerEvent& evt);
void ServerUnhide(); void MouseUp(PointerEvent& evt);
void MouseDown(PortMessage *msg, bool sendMessage);
void MouseMoved(PortMessage *msg);
void MouseUp(PortMessage *msg);
void UpdateColors(void); void UpdateColors(void);
void UpdateDecorator(void); void UpdateDecorator(void);
@@ -71,7 +81,7 @@ public:
void SetLevel(); void SetLevel();
void HighlightDecorator(const bool &active); void HighlightDecorator(const bool &active);
bool HasPoint(const BPoint &pt) const; bool HasPoint(BPoint pt) const;
void AddToSubsetOf(WinBorder* main); void AddToSubsetOf(WinBorder* main);
void RemoveFromSubsetOf(WinBorder* main); void RemoveFromSubsetOf(WinBorder* main);
@@ -93,7 +103,6 @@ protected:
int32 fKeyModifiers; int32 fKeyModifiers;
BPoint fLastMousePosition; BPoint fLastMousePosition;
bool fServerHidden;
WinBorder *fMainWinBorder; WinBorder *fMainWinBorder;
bool fIsMoving; bool fIsMoving;
bool fIsResizing; bool fIsResizing;