ViewDriver functions won't do anything if not initialized
Style tweaks to a number of files to better match OT guidelines Added MsgCodeToBString to Utils.cpp Removed a crash on new_decorator git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6157 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -58,9 +58,10 @@
|
||||
#else
|
||||
# define STRACE(x) ;
|
||||
#endif
|
||||
|
||||
// Globals
|
||||
|
||||
Desktop* desktop;
|
||||
Desktop *desktop;
|
||||
|
||||
//! Used to access the app_server from new_decorator
|
||||
AppServer *app_server=NULL;
|
||||
@@ -83,14 +84,17 @@ AppServer::AppServer(void) : BApplication (SERVER_SIGNATURE)
|
||||
AppServer::AppServer(void)
|
||||
#endif
|
||||
{
|
||||
_mouseport = create_port(200,SERVER_INPUT_PORT);
|
||||
_messageport = create_port(200,SERVER_PORT_NAME);
|
||||
fMousePort= create_port(200,SERVER_INPUT_PORT);
|
||||
_fMessagePort= create_port(200,SERVER_PORT_NAME);
|
||||
|
||||
_applist = new BList(0);
|
||||
_quitting_server= false;
|
||||
_exit_poller = false;
|
||||
_ssindex = 1;
|
||||
make_decorator = NULL;
|
||||
fAppList= new BList(0);
|
||||
fQuittingServer= false;
|
||||
fExitPoller= false;
|
||||
fScreenShotIndex= 1;
|
||||
make_decorator= NULL;
|
||||
|
||||
// We need this in order for new_decorator to be able to instantiate new decorators
|
||||
app_server=this;
|
||||
|
||||
// Create the font server and scan the proper directories.
|
||||
fontserver=new FontServer;
|
||||
@@ -125,36 +129,36 @@ AppServer::AppServer(void)
|
||||
InitDecorators();
|
||||
|
||||
// Set up the Desktop
|
||||
desktop = new Desktop();
|
||||
desktop= new Desktop();
|
||||
desktop->Init();
|
||||
|
||||
// Create the cursor manager. Object declared in CursorManager.cpp
|
||||
cursormanager = new CursorManager();
|
||||
cursormanager= new CursorManager();
|
||||
cursormanager->SetCursor(B_CURSOR_DEFAULT);
|
||||
|
||||
// Create the bitmap allocator. Object declared in BitmapManager.cpp
|
||||
bitmapmanager = new BitmapManager();
|
||||
bitmapmanager= new BitmapManager();
|
||||
|
||||
// This is necessary to mediate access between the Poller and app_server threads
|
||||
_active_lock = create_sem(1,"app_server_active_sem");
|
||||
fActiveAppLock= create_sem(1,"app_server_active_sem");
|
||||
|
||||
// This locker is for app_server and Picasso to vy for control of the ServerApp list
|
||||
_applist_lock = create_sem(1,"app_server_applist_sem");
|
||||
fAppListLock= create_sem(1,"app_server_applist_sem");
|
||||
|
||||
// This locker is to mediate access to the make_decorator pointer
|
||||
_decor_lock = create_sem(1,"app_server_decor_sem");
|
||||
fDecoratorLock= create_sem(1,"app_server_decor_sem");
|
||||
|
||||
// Spawn our input-polling thread
|
||||
_poller_id = spawn_thread(PollerThread, "Poller", B_NORMAL_PRIORITY, this);
|
||||
if (_poller_id >= 0)
|
||||
resume_thread(_poller_id);
|
||||
fPollerThreadID= spawn_thread(PollerThread, "Poller", B_NORMAL_PRIORITY, this);
|
||||
if (fPollerThreadID >= 0)
|
||||
resume_thread(fPollerThreadID);
|
||||
|
||||
// Spawn our thread-monitoring thread
|
||||
_picasso_id = spawn_thread(PicassoThread,"Picasso", B_NORMAL_PRIORITY, this);
|
||||
if (_picasso_id >= 0)
|
||||
resume_thread(_picasso_id);
|
||||
fPicassoThreadID= spawn_thread(PicassoThread,"Picasso", B_NORMAL_PRIORITY, this);
|
||||
if (fPicassoThreadID >= 0)
|
||||
resume_thread(fPicassoThreadID);
|
||||
|
||||
decorator_name = "Default";
|
||||
fDecoratorName="Default";
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -168,15 +172,15 @@ AppServer::~AppServer(void)
|
||||
|
||||
ServerApp *tempapp;
|
||||
int32 i;
|
||||
acquire_sem(_applist_lock);
|
||||
for(i=0;i<_applist->CountItems();i++)
|
||||
acquire_sem(fAppListLock);
|
||||
for(i=0;i<fAppList->CountItems();i++)
|
||||
{
|
||||
tempapp=(ServerApp *)_applist->ItemAt(i);
|
||||
tempapp=(ServerApp *)fAppList->ItemAt(i);
|
||||
if(tempapp!=NULL)
|
||||
delete tempapp;
|
||||
}
|
||||
delete _applist;
|
||||
release_sem(_applist_lock);
|
||||
delete fAppList;
|
||||
release_sem(fAppListLock);
|
||||
|
||||
delete bitmapmanager;
|
||||
delete cursormanager;
|
||||
@@ -186,8 +190,8 @@ AppServer::~AppServer(void)
|
||||
// If these threads are still running, kill them - after this, if exit_poller
|
||||
// is deleted, who knows what will happen... These things will just return an
|
||||
// error and fail if the threads have already exited.
|
||||
kill_thread(_poller_id);
|
||||
kill_thread(_picasso_id);
|
||||
kill_thread(fPollerThreadID);
|
||||
kill_thread(fPicassoThreadID);
|
||||
|
||||
delete fontserver;
|
||||
|
||||
@@ -202,8 +206,8 @@ AppServer::~AppServer(void)
|
||||
int32 AppServer::PollerThread(void *data)
|
||||
{
|
||||
// This thread handles nothing but input messages for mouse and keyboard
|
||||
AppServer *appserver = (AppServer*)data;
|
||||
PortQueue mousequeue(appserver->_mouseport);
|
||||
AppServer *appserver=(AppServer*)data;
|
||||
PortQueue mousequeue(appserver->fMousePort);
|
||||
PortMessage *msg;
|
||||
|
||||
for(;;)
|
||||
@@ -213,7 +217,7 @@ int32 AppServer::PollerThread(void *data)
|
||||
else
|
||||
mousequeue.GetMessagesFromPort(false);
|
||||
|
||||
msg = mousequeue.GetMessageFromQueue();
|
||||
msg= mousequeue.GetMessageFromQueue();
|
||||
if(!msg)
|
||||
continue;
|
||||
|
||||
@@ -244,7 +248,7 @@ int32 AppServer::PollerThread(void *data)
|
||||
|
||||
delete msg;
|
||||
|
||||
if(appserver->_exit_poller)
|
||||
if(appserver->fExitPoller)
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
@@ -258,14 +262,14 @@ int32 AppServer::PollerThread(void *data)
|
||||
int32 AppServer::PicassoThread(void *data)
|
||||
{
|
||||
int32 i;
|
||||
AppServer *appserver = (AppServer*)data;
|
||||
AppServer *appserver=(AppServer*)data;
|
||||
ServerApp *app;
|
||||
for(;;)
|
||||
{
|
||||
acquire_sem(appserver->_applist_lock);
|
||||
for(i = 0; i < appserver->_applist->CountItems(); i++)
|
||||
acquire_sem(appserver->fAppListLock);
|
||||
for(i= 0; i < appserver->fAppList->CountItems(); i++)
|
||||
{
|
||||
app = (ServerApp*)appserver->_applist->ItemAt(i);
|
||||
app=(ServerApp*)appserver->fAppList->ItemAt(i);
|
||||
if(!app)
|
||||
{
|
||||
printf("PANIC: NULL app in app list\n");
|
||||
@@ -273,11 +277,11 @@ int32 AppServer::PicassoThread(void *data)
|
||||
}
|
||||
app->PingTarget();
|
||||
}
|
||||
release_sem(appserver->_applist_lock);
|
||||
release_sem(appserver->fAppListLock);
|
||||
|
||||
// if poller thread has to exit, so do we - I just was too lazy
|
||||
// to rename the variable name. ;)
|
||||
if(appserver->_exit_poller)
|
||||
if(appserver->fExitPoller)
|
||||
break;
|
||||
|
||||
// we do this every other second so as not to suck *too* many CPU cycles
|
||||
@@ -300,13 +304,13 @@ thread_id AppServer::Run(void)
|
||||
//! Main message-monitoring loop for the regular message port - no input messages!
|
||||
void AppServer::MainLoop(void)
|
||||
{
|
||||
PortMessage pmsg;
|
||||
PortMessage pmsg;
|
||||
|
||||
for(;;)
|
||||
while(1)
|
||||
{
|
||||
if(pmsg.ReadFromPort(_messageport) == B_OK)
|
||||
if(pmsg.ReadFromPort(_fMessagePort)== B_OK)
|
||||
{
|
||||
if(pmsg.Protocol() == B_QUIT_REQUESTED)
|
||||
if(pmsg.Protocol()== B_QUIT_REQUESTED)
|
||||
pmsg.SetCode(B_QUIT_REQUESTED);
|
||||
|
||||
switch(pmsg.Code())
|
||||
@@ -336,7 +340,7 @@ void AppServer::MainLoop(void)
|
||||
|
||||
if(pmsg.Code()==AS_DELETE_APP || (pmsg.Protocol()==B_QUIT_REQUESTED && DISPLAYDRIVER!=HWDRIVER))
|
||||
{
|
||||
if(_quitting_server == true && _applist->CountItems() == 0)
|
||||
if(fQuittingServer== true && fAppList->CountItems()== 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -361,15 +365,15 @@ bool AppServer::LoadDecorator(const char *path)
|
||||
// internal one
|
||||
if(!path)
|
||||
{
|
||||
make_decorator = NULL;
|
||||
make_decorator= NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
create_decorator *pcreatefunc = NULL;
|
||||
create_decorator *pcreatefunc= NULL;
|
||||
status_t stat;
|
||||
image_id addon;
|
||||
|
||||
addon = load_add_on(path);
|
||||
addon= load_add_on(path);
|
||||
if(addon < 0)
|
||||
return false;
|
||||
|
||||
@@ -379,19 +383,19 @@ bool AppServer::LoadDecorator(const char *path)
|
||||
// go here.
|
||||
|
||||
// Get the instantiation function
|
||||
stat = get_image_symbol(addon, "instantiate_decorator", B_SYMBOL_TYPE_TEXT, (void**)&pcreatefunc);
|
||||
stat= get_image_symbol(addon, "instantiate_decorator", B_SYMBOL_TYPE_TEXT, (void**)&pcreatefunc);
|
||||
if(stat != B_OK){
|
||||
unload_add_on(addon);
|
||||
return false;
|
||||
}
|
||||
|
||||
BPath temppath(path);
|
||||
decorator_name = temppath.Leaf();
|
||||
fDecoratorName= temppath.Leaf();
|
||||
|
||||
acquire_sem(_decor_lock);
|
||||
make_decorator = pcreatefunc;
|
||||
_decorator_id = addon;
|
||||
release_sem(_decor_lock);
|
||||
acquire_sem(fDecoratorLock);
|
||||
make_decorator=pcreatefunc;
|
||||
fDecoratorID=addon;
|
||||
release_sem(fDecoratorLock);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -467,26 +471,26 @@ void AppServer::DispatchMessage(PortMessage *msg)
|
||||
msg->Read<int32>(&reply_port);
|
||||
|
||||
// Create the ServerApp subthread for this app
|
||||
acquire_sem(_applist_lock);
|
||||
acquire_sem(fAppListLock);
|
||||
|
||||
port_id r = create_port(DEFAULT_MONITOR_PORT_SIZE, app_signature);
|
||||
if(r == B_NO_MORE_PORTS || r == B_BAD_VALUE)
|
||||
port_id r= create_port(DEFAULT_MONITOR_PORT_SIZE, app_signature);
|
||||
if(r== B_NO_MORE_PORTS || r== B_BAD_VALUE)
|
||||
{
|
||||
release_sem(_applist_lock);
|
||||
release_sem(fAppListLock);
|
||||
printf("No more ports left. Time to crash. Have a nice day! :)\n");
|
||||
break;
|
||||
}
|
||||
ServerApp *newapp;
|
||||
newapp = new ServerApp(app_port, r, clientLooperPort, clientTeamID, htoken, app_signature);
|
||||
newapp= new ServerApp(app_port, r, clientLooperPort, clientTeamID, htoken, app_signature);
|
||||
|
||||
// add the new ServerApp to the known list of ServerApps
|
||||
_applist->AddItem(newapp);
|
||||
fAppList->AddItem(newapp);
|
||||
|
||||
release_sem(_applist_lock);
|
||||
release_sem(fAppListLock);
|
||||
|
||||
PortLink replylink(reply_port);
|
||||
replylink.SetOpCode(AS_SET_SERVER_PORT);
|
||||
replylink.Attach<int32>(newapp->_receiver);
|
||||
replylink.Attach<int32>(newapp->fMessagePort);
|
||||
replylink.Flush();
|
||||
|
||||
// This is necessary because PortLink::ReadString allocates memory
|
||||
@@ -503,33 +507,33 @@ void AppServer::DispatchMessage(PortMessage *msg)
|
||||
// 1) thread_id - thread ID of the ServerApp to be deleted
|
||||
|
||||
int32 i,
|
||||
appnum = _applist->CountItems();
|
||||
appnum= fAppList->CountItems();
|
||||
ServerApp *srvapp;
|
||||
|
||||
thread_id srvapp_id;
|
||||
msg->Read<thread_id>(&srvapp_id);
|
||||
|
||||
acquire_sem(_applist_lock);
|
||||
acquire_sem(fAppListLock);
|
||||
|
||||
// Run through the list of apps and nuke the proper one
|
||||
for(i = 0; i < appnum; i++)
|
||||
for(i= 0; i < appnum; i++)
|
||||
{
|
||||
srvapp = (ServerApp *)_applist->ItemAt(i);
|
||||
srvapp=(ServerApp *)fAppList->ItemAt(i);
|
||||
|
||||
if(srvapp != NULL && srvapp->_monitor_thread == srvapp_id)
|
||||
if(srvapp != NULL && srvapp->fMonitorThreadID== srvapp_id)
|
||||
{
|
||||
srvapp = (ServerApp *)_applist->RemoveItem(i);
|
||||
srvapp=(ServerApp *)fAppList->RemoveItem(i);
|
||||
if(srvapp){
|
||||
status_t temp;
|
||||
wait_for_thread(srvapp_id, &temp);
|
||||
delete srvapp;
|
||||
srvapp = NULL;
|
||||
srvapp= NULL;
|
||||
}
|
||||
break; // jump out of our for() loop
|
||||
}
|
||||
}
|
||||
|
||||
release_sem(_applist_lock);
|
||||
release_sem(fAppListLock);
|
||||
break;
|
||||
}
|
||||
case AS_UPDATED_CLIENT_FONTLIST:
|
||||
@@ -615,7 +619,7 @@ void AppServer::DispatchMessage(PortMessage *msg)
|
||||
msg->Read<port_id>(&replyport);
|
||||
PortLink replylink(replyport);
|
||||
replylink.SetOpCode(AS_GET_DECORATOR);
|
||||
replylink.AttachString(decorator_name.String());
|
||||
replylink.AttachString(fDecoratorName.String());
|
||||
replylink.Flush();
|
||||
break;
|
||||
}
|
||||
@@ -666,9 +670,9 @@ void AppServer::DispatchMessage(PortMessage *msg)
|
||||
|
||||
PortLink replylink(replyport);
|
||||
replylink.SetOpCode(AS_GET_SCREEN_MODE);
|
||||
replylink.Attach<int16>(_driver->GetWidth());
|
||||
replylink.Attach<int16>(_driver->GetHeight());
|
||||
replylink.Attach<int16>(_driver->GetDepth());
|
||||
replylink.Attach<int16>(fDriver->GetWidth());
|
||||
replylink.Attach<int16>(fDriver->GetHeight());
|
||||
replylink.Attach<int16>(fDriver->GetDepth());
|
||||
replylink.Flush();
|
||||
break;
|
||||
}
|
||||
@@ -680,35 +684,59 @@ void AppServer::DispatchMessage(PortMessage *msg)
|
||||
// We've been asked to quit, so (for now) broadcast to all
|
||||
// test apps to quit. This situation will occur only when the server
|
||||
// is compiled as a regular Be application.
|
||||
if(DISPLAYDRIVER == HWDRIVER)
|
||||
if(DISPLAYDRIVER== HWDRIVER)
|
||||
break;
|
||||
|
||||
Broadcast(AS_QUIT_APP);
|
||||
|
||||
// we have to wait until *all* threads have finished!
|
||||
ServerApp *app = NULL;
|
||||
status_t rv;
|
||||
acquire_sem(_applist_lock);
|
||||
for(int32 i = 0; i < _applist->CountItems(); i++)
|
||||
// we have to wait until *all* threads have finished!
|
||||
ServerApp *app= NULL;
|
||||
acquire_sem(fAppListLock);
|
||||
thread_info tinfo;
|
||||
|
||||
for(int32 i= 0; i < fAppList->CountItems(); i++)
|
||||
{
|
||||
app = (ServerApp*)_applist->ItemAt(i);
|
||||
app=(ServerApp*)fAppList->ItemAt(i);
|
||||
if(!app)
|
||||
{ printf("PANIC in AppServer::Broadcast()\n"); continue; }
|
||||
|
||||
wait_for_thread(app->_monitor_thread, &rv);
|
||||
continue;
|
||||
|
||||
// Instead of calling wait_for_thread, we will wait a bit, check for the
|
||||
// thread_id. We will only wait so long, because then the app is probably crashed
|
||||
// or hung. Seeing that being the case, we'll kill its BApp team and fake the
|
||||
// quit message
|
||||
if(get_thread_info(app->fMonitorThreadID, &tinfo)==B_OK)
|
||||
{
|
||||
bool killteam=true;
|
||||
|
||||
for(int32 j=0; j<5; j++)
|
||||
{
|
||||
snooze(1000); // wait half a second for it to quit
|
||||
if(get_thread_info(app->fMonitorThreadID, &tinfo)!=B_OK)
|
||||
{
|
||||
killteam=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(killteam)
|
||||
{
|
||||
kill_team(app->ClientTeamID());
|
||||
app->PostMessage(B_QUIT_REQUESTED);
|
||||
}
|
||||
}
|
||||
}
|
||||
release_sem(_applist_lock);
|
||||
release_sem(fAppListLock);
|
||||
|
||||
// When we delete the last ServerApp, we can exit the server
|
||||
_quitting_server = true;
|
||||
_exit_poller = true;
|
||||
fQuittingServer=true;
|
||||
fExitPoller=true;
|
||||
|
||||
// also wait for picasso thread
|
||||
kill_thread(_picasso_id);
|
||||
kill_thread(fPicassoThreadID);
|
||||
|
||||
// poller thread is stuck reading messages from its input port
|
||||
// so, there is no cleaner way to make it quit, other than killing it!
|
||||
kill_thread(_poller_id);
|
||||
kill_thread(fPollerThreadID);
|
||||
|
||||
// we are now clear to exit
|
||||
break;
|
||||
@@ -732,17 +760,17 @@ void AppServer::DispatchMessage(PortMessage *msg)
|
||||
*/
|
||||
void AppServer::Broadcast(int32 code)
|
||||
{
|
||||
ServerApp *app = NULL;
|
||||
ServerApp *app= NULL;
|
||||
|
||||
acquire_sem(_applist_lock);
|
||||
for(int32 i = 0; i < _applist->CountItems(); i++)
|
||||
acquire_sem(fAppListLock);
|
||||
for(int32 i= 0; i < fAppList->CountItems(); i++)
|
||||
{
|
||||
app = (ServerApp*)_applist->ItemAt(i);
|
||||
app=(ServerApp*)fAppList->ItemAt(i);
|
||||
if(!app)
|
||||
{ printf("PANIC in AppServer::Broadcast()\n"); continue; }
|
||||
app->PostMessage(code, sizeof(int32), (int8*)&code);
|
||||
}
|
||||
release_sem(_applist_lock);
|
||||
release_sem(fAppListLock);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -783,7 +811,7 @@ void AppServer::HandleKeyMessage(int32 code, int8 *buffer)
|
||||
int32 modifiers=*((int32*)index); index+=sizeof(int32) + (sizeof(int8) * 3);
|
||||
int8 stringlength=*index; index+=stringlength;
|
||||
STRACE(("Key Down: 0x%lx\n",scancode));
|
||||
if(DISPLAYDRIVER == HWDRIVER)
|
||||
if(DISPLAYDRIVER==HWDRIVER)
|
||||
{
|
||||
// Check for workspace change or safe video mode
|
||||
if(scancode>0x01 && scancode<0x0e)
|
||||
@@ -803,7 +831,8 @@ void AppServer::HandleKeyMessage(int32 code, int8 *buffer)
|
||||
if(modifiers & B_CONTROL_KEY)
|
||||
{
|
||||
STRACE(("Set Workspace %ld\n",scancode-1));
|
||||
//TODO: change SetWorkspace(scancode-2);
|
||||
//TODO: change
|
||||
//SetWorkspace(scancode-2);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -821,21 +850,21 @@ void AppServer::HandleKeyMessage(int32 code, int8 *buffer)
|
||||
// PrintScreen
|
||||
if(scancode==0xe)
|
||||
{
|
||||
if(_driver)
|
||||
if(fDriver)
|
||||
{
|
||||
char filename[128];
|
||||
BEntry entry;
|
||||
|
||||
sprintf(filename,"/boot/home/screen%ld.png",_ssindex);
|
||||
sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex);
|
||||
entry.SetTo(filename);
|
||||
|
||||
while(entry.Exists())
|
||||
{
|
||||
_ssindex++;
|
||||
sprintf(filename,"/boot/home/screen%ld.png",_ssindex);
|
||||
fScreenShotIndex++;
|
||||
sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex);
|
||||
}
|
||||
_ssindex++;
|
||||
_driver->DumpToFile(filename);
|
||||
fScreenShotIndex++;
|
||||
fDriver->DumpToFile(filename);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -857,7 +886,8 @@ void AppServer::HandleKeyMessage(int32 code, int8 *buffer)
|
||||
if(modifiers & (B_LEFT_SHIFT_KEY | B_LEFT_CONTROL_KEY))
|
||||
{
|
||||
STRACE(("Set Workspace %ld\n",scancode-1));
|
||||
//TODO: resolve SetWorkspace(scancode-2);
|
||||
//TODO: resolve
|
||||
//SetWorkspace(scancode-2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -877,22 +907,22 @@ void AppServer::HandleKeyMessage(int32 code, int8 *buffer)
|
||||
// Pause/Break
|
||||
if(scancode==0x7f)
|
||||
{
|
||||
if(_driver)
|
||||
if(fDriver)
|
||||
{
|
||||
char filename[128];
|
||||
BEntry entry;
|
||||
|
||||
sprintf(filename,"/boot/home/screen%ld.png",_ssindex);
|
||||
sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex);
|
||||
entry.SetTo(filename);
|
||||
|
||||
while(entry.Exists())
|
||||
{
|
||||
_ssindex++;
|
||||
sprintf(filename,"/boot/home/screen%ld.png",_ssindex);
|
||||
fScreenShotIndex++;
|
||||
sprintf(filename,"/boot/home/screen%ld.png",fScreenShotIndex);
|
||||
}
|
||||
_ssindex++;
|
||||
fScreenShotIndex++;
|
||||
|
||||
_driver->DumpToFile(filename);
|
||||
fDriver->DumpToFile(filename);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1026,19 +1056,19 @@ ServerApp *AppServer::FindApp(const char *sig)
|
||||
|
||||
ServerApp *foundapp=NULL;
|
||||
|
||||
acquire_sem(_applist_lock);
|
||||
acquire_sem(fAppListLock);
|
||||
|
||||
for(int32 i=0; i<_applist->CountItems();i++)
|
||||
for(int32 i=0; i<fAppList->CountItems();i++)
|
||||
{
|
||||
foundapp=(ServerApp*)_applist->ItemAt(i);
|
||||
if(foundapp && foundapp->_signature==sig)
|
||||
foundapp=(ServerApp*)fAppList->ItemAt(i);
|
||||
if(foundapp && foundapp->fSignature==sig)
|
||||
{
|
||||
release_sem(_applist_lock);
|
||||
release_sem(fAppListLock);
|
||||
return foundapp;
|
||||
}
|
||||
}
|
||||
|
||||
release_sem(_applist_lock);
|
||||
release_sem(fAppListLock);
|
||||
|
||||
// couldn't find a match
|
||||
return NULL;
|
||||
@@ -1059,13 +1089,13 @@ Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel
|
||||
int32 wflags, DisplayDriver *ddriver)
|
||||
{
|
||||
Decorator *dec=NULL;
|
||||
// Temporary solution!
|
||||
|
||||
dec=new DefaultDecorator(rect,wlook,wfeel,wflags);
|
||||
/* if(!app_server->make_decorator)
|
||||
if(!app_server->make_decorator)
|
||||
dec=new DefaultDecorator(rect,wlook,wfeel,wflags);
|
||||
else
|
||||
dec=app_server->make_decorator(rect,wlook,wfeel,wflags);
|
||||
*/
|
||||
|
||||
gui_colorset.Lock();
|
||||
dec->SetDriver(ddriver);
|
||||
dec->SetColors(gui_colorset);
|
||||
@@ -1088,11 +1118,6 @@ int main( int argc, char** argv )
|
||||
if(find_port(SERVER_PORT_NAME)!=B_NAME_NOT_FOUND)
|
||||
return -1;
|
||||
|
||||
// why on the heap?
|
||||
/* app_server=new AppServer();
|
||||
app_server->Run();
|
||||
delete app_server;
|
||||
*/
|
||||
AppServer app_server;
|
||||
app_server.Run();
|
||||
return 0;
|
||||
|
||||
@@ -60,27 +60,27 @@ private:
|
||||
// global function pointer
|
||||
create_decorator *make_decorator;
|
||||
|
||||
port_id _messageport,
|
||||
_mouseport;
|
||||
port_id _fMessagePort,
|
||||
fMousePort;
|
||||
|
||||
image_id _decorator_id;
|
||||
image_id fDecoratorID;
|
||||
|
||||
BString decorator_name;
|
||||
BString fDecoratorName;
|
||||
|
||||
bool _quitting_server,
|
||||
_exit_poller;
|
||||
bool fQuittingServer,
|
||||
fExitPoller;
|
||||
|
||||
BList *_applist;
|
||||
thread_id _poller_id,
|
||||
_picasso_id;
|
||||
BList *fAppList;
|
||||
thread_id fPollerThreadID,
|
||||
fPicassoThreadID;
|
||||
|
||||
sem_id _active_lock,
|
||||
_applist_lock,
|
||||
_decor_lock;
|
||||
sem_id fActiveAppLock,
|
||||
fAppListLock,
|
||||
fDecoratorLock;
|
||||
|
||||
DisplayDriver *_driver;
|
||||
DisplayDriver *fDriver;
|
||||
|
||||
int32 _ssindex;
|
||||
int32 fScreenShotIndex;
|
||||
};
|
||||
|
||||
Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel,
|
||||
|
||||
@@ -308,18 +308,15 @@ int32 Decorator::_ClipTitle(float width)
|
||||
{
|
||||
int32 strlength=_title_string->CountChars();
|
||||
float pixwidth=_driver->StringWidth(_title_string->String(),strlength,&_layerdata);
|
||||
// printf("Initial width = %f\n", width );
|
||||
// printf("DEC: strlen = %ld\t pixwidth = %f\n", strlength, pixwidth);
|
||||
|
||||
while(strlength>=0)
|
||||
{
|
||||
if(pixwidth<width)
|
||||
break;
|
||||
return strlength;
|
||||
|
||||
strlength--;
|
||||
pixwidth=_driver->StringWidth(_title_string->String(),strlength,&_layerdata);
|
||||
// printf("DEC: strlen = %ld\t pixwidth = %f\n", strlength, pixwidth);
|
||||
}
|
||||
|
||||
return strlength;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -385,7 +385,7 @@ void Layer::MouseTransit(uint32 transit)
|
||||
else
|
||||
{
|
||||
if(_serverwin)
|
||||
_serverwin->GetApp()->SetAppCursor();
|
||||
_serverwin->App()->SetAppCursor();
|
||||
else
|
||||
cursormanager->SetCursor(B_CURSOR_DEFAULT);
|
||||
}
|
||||
|
||||
@@ -70,78 +70,80 @@
|
||||
\brief Constructor
|
||||
\param sendport port ID for the BApplication which will receive the ServerApp's messages
|
||||
\param rcvport port by which the ServerApp will receive messages from its BApplication.
|
||||
\param _signature NULL-terminated string which contains the BApplication's
|
||||
MIME _signature.
|
||||
\param fSignature NULL-terminated string which contains the BApplication's
|
||||
MIME fSignature.
|
||||
*/
|
||||
ServerApp::ServerApp(port_id sendport, port_id rcvport, port_id clientLooperPort,
|
||||
team_id clientTeamID, int32 handlerID, char *signature)
|
||||
{
|
||||
// it will be of *very* musch use in correct window order
|
||||
// it will be of *very* musch use in correct window order
|
||||
fClientTeamID = clientTeamID;
|
||||
// what to send a message to the client? Write a BMessage to this port.
|
||||
|
||||
// what to send a message to the client? Write a BMessage to this port.
|
||||
fClientLooperPort = clientLooperPort;
|
||||
|
||||
// need to copy the _signature because the message buffer
|
||||
// need to copy the fSignature because the message buffer
|
||||
// owns the copy which we are passed as a parameter.
|
||||
_signature=(signature)?signature:"application/x-vnd.NULL-application-signature";
|
||||
fSignature=(signature)?signature:"application/x-vnd.NULL-application-signature";
|
||||
|
||||
// token ID of the BApplication's BHandler object. Used for BMessage target specification
|
||||
_handlertoken=handlerID;
|
||||
fHandlerToken=handlerID;
|
||||
|
||||
// _sender is the our BApplication's event port
|
||||
_sender=sendport;
|
||||
_applink=new PortLink(_sender);
|
||||
_applink->SetPort(_sender);
|
||||
// fClientAppPort is the our BApplication's event port
|
||||
fClientAppPort=sendport;
|
||||
fAppLink=new PortLink(fClientAppPort);
|
||||
|
||||
// Gotta get the team ID so we can ping the application
|
||||
_target_id = clientTeamID;
|
||||
|
||||
// _receiver is the port we receive messages from our BApplication
|
||||
_receiver=rcvport;
|
||||
// fMessagePort is the port we receive messages from our BApplication
|
||||
fMessagePort=rcvport;
|
||||
|
||||
_winlist=new BList(0);
|
||||
_bmplist=new BList(0);
|
||||
_piclist=new BList(0);
|
||||
_isactive=false;
|
||||
fSWindowList=new BList(0);
|
||||
fBitmapList=new BList(0);
|
||||
fPictureList=new BList(0);
|
||||
fIsActive=false;
|
||||
|
||||
ServerCursor *defaultc=cursormanager->GetCursor(B_CURSOR_DEFAULT);
|
||||
|
||||
_appcursor=(defaultc)?new ServerCursor(defaultc):NULL;
|
||||
_lock=create_sem(1,"ServerApp sem");
|
||||
fAppCursor=(defaultc)?new ServerCursor(defaultc):NULL;
|
||||
fLockSem=create_sem(1,"ServerApp sem");
|
||||
|
||||
// Does this even belong here any more? --DW
|
||||
// _driver=desktop->GetDisplayDriver();
|
||||
|
||||
_cursorhidden=false;
|
||||
fCursorHidden=false;
|
||||
|
||||
Run();
|
||||
|
||||
STRACE(("ServerApp %s:\n",_signature.String()));
|
||||
STRACE(("\tBApp port: %ld\n",_sender));
|
||||
STRACE(("\tReceiver port: %ld\n",_receiver));
|
||||
STRACE(("ServerApp %s:\n",fSignature.String()));
|
||||
STRACE(("\tBApp port: %ld\n",fClientAppPort));
|
||||
STRACE(("\tReceiver port: %ld\n",fMessagePort));
|
||||
}
|
||||
|
||||
//! Does all necessary teardown for application
|
||||
ServerApp::~ServerApp(void)
|
||||
{
|
||||
STRACE(("*ServerApp %s:~ServerApp()\n",_signature.String()));
|
||||
STRACE(("*ServerApp %s:~ServerApp()\n",fSignature.String()));
|
||||
int32 i;
|
||||
|
||||
|
||||
WindowBroadcast(AS_QUIT_APP);
|
||||
|
||||
// wait for our ServerWindow threads
|
||||
bool ready = true;
|
||||
bool ready=true;
|
||||
desktop->fLayerLock.Lock();
|
||||
do{
|
||||
ready = true;
|
||||
|
||||
int32 count = desktop->fWinBorderList.CountItems();
|
||||
for( int32 i = 0; i < count; i++){
|
||||
ServerWindow *sw = ((WinBorder*)desktop->fWinBorderList.ItemAt(i))->Window();
|
||||
if (ClientTeamID() == sw->ClientTeamID()){
|
||||
for( int32 i = 0; i < count; i++)
|
||||
{
|
||||
ServerWindow *sw = ((WinBorder*)desktop->fWinBorderList.ItemAt(i))->Window();
|
||||
if (ClientTeamID() == sw->ClientTeamID())
|
||||
{
|
||||
thread_id tid = sw->ThreadID();
|
||||
status_t temp;
|
||||
|
||||
desktop->fLayerLock.Unlock();
|
||||
printf("waiting for thread %s\n", sw->Title());
|
||||
|
||||
printf("waiting for thread %s\n", sw->Title());
|
||||
wait_for_thread(tid, &temp);
|
||||
|
||||
desktop->fLayerLock.Lock();
|
||||
@@ -150,54 +152,56 @@ printf("waiting for thread %s\n", sw->Title());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}while(!ready);
|
||||
} while(!ready);
|
||||
desktop->fLayerLock.Unlock();
|
||||
|
||||
/*
|
||||
ServerWindow *tempwin;
|
||||
for(i=0;i<_winlist->CountItems();i++)
|
||||
for(i=0;i<fSWindowList->CountItems();i++)
|
||||
{
|
||||
tempwin=(ServerWindow*)_winlist->ItemAt(i);
|
||||
tempwin=(ServerWindow*)fSWindowList->ItemAt(i);
|
||||
if(tempwin)
|
||||
delete tempwin;
|
||||
}
|
||||
_winlist->MakeEmpty();
|
||||
delete _winlist;
|
||||
fSWindowList->MakeEmpty();
|
||||
delete fSWindowList;
|
||||
*/
|
||||
|
||||
ServerBitmap *tempbmp;
|
||||
for(i=0;i<_bmplist->CountItems();i++)
|
||||
for(i=0;i<fBitmapList->CountItems();i++)
|
||||
{
|
||||
tempbmp=(ServerBitmap*)_bmplist->ItemAt(i);
|
||||
tempbmp=(ServerBitmap*)fBitmapList->ItemAt(i);
|
||||
if(tempbmp)
|
||||
delete tempbmp;
|
||||
}
|
||||
_bmplist->MakeEmpty();
|
||||
delete _bmplist;
|
||||
fBitmapList->MakeEmpty();
|
||||
delete fBitmapList;
|
||||
|
||||
ServerPicture *temppic;
|
||||
for(i=0;i<_piclist->CountItems();i++)
|
||||
for(i=0;i<fPictureList->CountItems();i++)
|
||||
{
|
||||
temppic=(ServerPicture*)_piclist->ItemAt(i);
|
||||
temppic=(ServerPicture*)fPictureList->ItemAt(i);
|
||||
if(temppic)
|
||||
delete temppic;
|
||||
}
|
||||
_piclist->MakeEmpty();
|
||||
delete _piclist;
|
||||
fPictureList->MakeEmpty();
|
||||
delete fPictureList;
|
||||
|
||||
delete _applink;
|
||||
_applink=NULL;
|
||||
if(_appcursor)
|
||||
delete _appcursor;
|
||||
delete fAppLink;
|
||||
fAppLink=NULL;
|
||||
if(fAppCursor)
|
||||
delete fAppCursor;
|
||||
|
||||
|
||||
cursormanager->RemoveAppCursors(_signature.String());
|
||||
delete_sem(_lock);
|
||||
cursormanager->RemoveAppCursors(fSignature.String());
|
||||
delete_sem(fLockSem);
|
||||
|
||||
STRACE(("#ServerApp %s:~ServerApp()\n",_signature.String()));
|
||||
STRACE(("#ServerApp %s:~ServerApp()\n",fSignature.String()));
|
||||
|
||||
// Kill the monitor thread if it exists
|
||||
thread_info info;
|
||||
if(get_thread_info(_monitor_thread,&info)==B_OK)
|
||||
kill_thread(_monitor_thread);
|
||||
if(get_thread_info(fMonitorThreadID,&info)==B_OK)
|
||||
kill_thread(fMonitorThreadID);
|
||||
|
||||
}
|
||||
|
||||
@@ -209,11 +213,11 @@ bool ServerApp::Run(void)
|
||||
{
|
||||
// Unlike a BApplication, a ServerApp is *supposed* to return immediately
|
||||
// when its Run() function is called.
|
||||
_monitor_thread=spawn_thread(MonitorApp,_signature.String(),B_NORMAL_PRIORITY,this);
|
||||
if(_monitor_thread==B_NO_MORE_THREADS || _monitor_thread==B_NO_MEMORY)
|
||||
fMonitorThreadID=spawn_thread(MonitorApp,fSignature.String(),B_NORMAL_PRIORITY,this);
|
||||
if(fMonitorThreadID==B_NO_MORE_THREADS || fMonitorThreadID==B_NO_MEMORY)
|
||||
return false;
|
||||
|
||||
resume_thread(_monitor_thread);
|
||||
resume_thread(fMonitorThreadID);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -233,18 +237,18 @@ bool ServerApp::Run(void)
|
||||
bool ServerApp::PingTarget(void)
|
||||
{
|
||||
team_info tinfo;
|
||||
if(get_team_info(_target_id,&tinfo)==B_BAD_TEAM_ID)
|
||||
if(get_team_info(fClientTeamID,&tinfo)==B_BAD_TEAM_ID)
|
||||
{
|
||||
port_id serverport=find_port(SERVER_PORT_NAME);
|
||||
if(serverport==B_NAME_NOT_FOUND)
|
||||
{
|
||||
printf("PANIC: ServerApp %s could not find the app_server port in PingTarget()!\n",_signature.String());
|
||||
printf("PANIC: ServerApp %s could not find the app_server port in PingTarget()!\n",fSignature.String());
|
||||
return false;
|
||||
}
|
||||
_applink->SetPort(serverport);
|
||||
_applink->SetOpCode(AS_DELETE_APP);
|
||||
_applink->Attach(&_monitor_thread,sizeof(thread_id));
|
||||
_applink->Flush();
|
||||
fAppLink->SetPort(serverport);
|
||||
fAppLink->SetOpCode(AS_DELETE_APP);
|
||||
fAppLink->Attach(&fMonitorThreadID,sizeof(thread_id));
|
||||
fAppLink->Flush();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -256,20 +260,41 @@ bool ServerApp::PingTarget(void)
|
||||
*/
|
||||
void ServerApp::PostMessage(int32 code, size_t size, int8 *buffer)
|
||||
{
|
||||
write_port(_receiver,code, buffer, size);
|
||||
write_port(fMessagePort,code, buffer, size);
|
||||
}
|
||||
|
||||
void ServerApp::SendMessageToClient(const BMessage* msg) const{
|
||||
ssize_t size;
|
||||
char *buffer;
|
||||
|
||||
size = msg->FlattenedSize();
|
||||
buffer = new char[size];
|
||||
if (msg->Flatten(buffer, size) == B_OK){
|
||||
write_port(fClientLooperPort, msg->what, buffer, size);
|
||||
/*!
|
||||
\brief Send a simple message to all of the ServerApp's ServerWindows
|
||||
\param msg The message code to broadcast
|
||||
*/
|
||||
void ServerApp::WindowBroadcast(int32 code)
|
||||
{
|
||||
desktop->fLayerLock.Lock();
|
||||
int32 count=desktop->fWinBorderList.CountItems();
|
||||
for(int32 i=0; i<count; i++)
|
||||
{
|
||||
ServerWindow *sw = ((WinBorder*)desktop->fWinBorderList.ItemAt(i))->Window();
|
||||
sw->PostMessage(code);
|
||||
}
|
||||
desktop->fLayerLock.Unlock();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Send a message to the ServerApp's BApplication
|
||||
\param msg The message to send
|
||||
*/
|
||||
void ServerApp::SendMessageToClient(const BMessage *msg) const
|
||||
{
|
||||
ssize_t size;
|
||||
char *buffer;
|
||||
|
||||
size=msg->FlattenedSize();
|
||||
buffer=new char[size];
|
||||
|
||||
if (msg->Flatten(buffer, size) == B_OK)
|
||||
write_port(fClientLooperPort, msg->what, buffer, size);
|
||||
else
|
||||
printf("PANIC: ServerApp: '%s': can't flatten message in 'SendMessageToClient()'\n", _signature.String());
|
||||
printf("PANIC: ServerApp: '%s': can't flatten message in 'SendMessageToClient()'\n", fSignature.String());
|
||||
|
||||
delete buffer;
|
||||
}
|
||||
@@ -283,15 +308,15 @@ void ServerApp::SendMessageToClient(const BMessage* msg) const{
|
||||
*/
|
||||
void ServerApp::Activate(bool value)
|
||||
{
|
||||
_isactive=value;
|
||||
fIsActive=value;
|
||||
SetAppCursor();
|
||||
}
|
||||
|
||||
//! Sets the cursor to the application cursor, if any.
|
||||
void ServerApp::SetAppCursor(void)
|
||||
{
|
||||
if(_appcursor)
|
||||
cursormanager->SetCursor(_appcursor->ID());
|
||||
if(fAppCursor)
|
||||
cursormanager->SetCursor(fAppCursor->ID());
|
||||
else
|
||||
cursormanager->SetCursor(B_CURSOR_DEFAULT);
|
||||
}
|
||||
@@ -301,23 +326,23 @@ void ServerApp::SetAppCursor(void)
|
||||
\param data Pointer to the thread's ServerApp object
|
||||
\return Throwaway value - always 0
|
||||
*/
|
||||
int32 ServerApp::MonitorApp(void *data)
|
||||
int32 ServerApp::MonitorApp(void *data)
|
||||
{
|
||||
// Message-dispatching loop for the ServerApp
|
||||
|
||||
ServerApp *app = (ServerApp *)data;
|
||||
PortQueue msgqueue(app->_receiver);
|
||||
PortMessage *msg;
|
||||
bool quiting = false;
|
||||
ServerApp *app = (ServerApp *)data;
|
||||
PortQueue msgqueue(app->fMessagePort);
|
||||
PortMessage *msg;
|
||||
bool quitting = false;
|
||||
|
||||
for( ; !quiting; )
|
||||
for( ; !quitting; )
|
||||
{
|
||||
if(!msgqueue.MessagesWaiting())
|
||||
msgqueue.GetMessagesFromPort(true);
|
||||
else
|
||||
msgqueue.GetMessagesFromPort(false);
|
||||
|
||||
msg = msgqueue.GetMessageFromQueue();
|
||||
msg = msgqueue.GetMessageFromQueue();
|
||||
if(!msg)
|
||||
continue;
|
||||
|
||||
@@ -325,52 +350,53 @@ void ServerApp::SetAppCursor(void)
|
||||
{
|
||||
case AS_QUIT_APP:
|
||||
{
|
||||
STRACE(("ServerApp %s:Server shutdown notification received\n",app->_signature.String()));
|
||||
/*
|
||||
// This message is received only when the app_server is asked to shut down in
|
||||
// test/debug mode. Of course, if we are testing while using AccelerantDriver, we do
|
||||
// NOT want to shut down client applications. The server can be quit o in this fashion
|
||||
// through the driver's interface, such as closing the ViewDriver's window.
|
||||
|
||||
STRACE(("ServerApp %s:Server shutdown notification received\n",app->fSignature.String()));
|
||||
|
||||
// If we are using the real, accelerated version of the
|
||||
// DisplayDriver, we do NOT want the user to be able shut down
|
||||
// the server. The results would NOT be pretty
|
||||
if(DISPLAYDRIVER!=HWDRIVER)
|
||||
{
|
||||
// This message is received from the app_server thread
|
||||
// because the server was asked to quit. Thus, we
|
||||
// ask all apps to quit. This is NOT the same as system
|
||||
// shutdown and will happen only in testing
|
||||
|
||||
BMessage pleaseQuit(_QUIT_);
|
||||
BMessage pleaseQuit(B_QUIT_REQUESTED);
|
||||
app->SendMessageToClient(&pleaseQuit);
|
||||
}
|
||||
* Adi: I do not agree here! I think this is a reminiscence(?) since the "old" days...
|
||||
*/
|
||||
BMessage pleaseQuit(_QUIT_);
|
||||
app->SendMessageToClient(&pleaseQuit);
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: Fix
|
||||
// Using this case is a hack. The ServerApp is receiving a message with a '0' code after
|
||||
// it sends the quit message on server shutdown and I can't find what's sending it. This
|
||||
// must be found and fixed!
|
||||
case 0:
|
||||
case B_QUIT_REQUESTED:
|
||||
{
|
||||
STRACE(("ServerApp %s: B_QUIT_REQUESTED\n",app->_signature.String()));
|
||||
STRACE(("ServerApp %s: B_QUIT_REQUESTED\n",app->fSignature.String()));
|
||||
// Our BApplication sent us this message when it quit.
|
||||
// We need to ask the app_server to delete our monitor
|
||||
// ADI: No! This is a bad solution. A thead should continue its
|
||||
// execution until its exit point, and this can *very* easily be done
|
||||
quiting = true;
|
||||
quitting=true;
|
||||
// see... no need to ask the main thread to kill us.
|
||||
// still... it will delete this ServerApp object.
|
||||
port_id serverport = find_port(SERVER_PORT_NAME);
|
||||
if(serverport == B_NAME_NOT_FOUND){
|
||||
printf("PANIC: ServerApp %s could not find the app_server port!\n",app->_signature.String());
|
||||
printf("PANIC: ServerApp %s could not find the app_server port!\n",app->fSignature.String());
|
||||
break;
|
||||
}
|
||||
app->_applink->SetPort(serverport);
|
||||
app->_applink->SetOpCode(AS_DELETE_APP);
|
||||
app->_applink->Attach(&app->_monitor_thread, sizeof(thread_id));
|
||||
app->_applink->Flush();
|
||||
app->fAppLink->SetPort(serverport);
|
||||
app->fAppLink->SetOpCode(AS_DELETE_APP);
|
||||
app->fAppLink->Attach(&app->fMonitorThreadID, sizeof(thread_id));
|
||||
app->fAppLink->Flush();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
STRACE(("ServerApp %s: Got a Message to dispatch\n",app->_signature.String()));
|
||||
STRACE(("ServerApp %s: Got a Message to dispatch\n",app->fSignature.String()));
|
||||
app->_DispatchMessage(msg);
|
||||
break;
|
||||
}
|
||||
@@ -378,7 +404,8 @@ void ServerApp::SetAppCursor(void)
|
||||
|
||||
delete msg;
|
||||
} // end for
|
||||
// clean exit.
|
||||
|
||||
// clean exit.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -398,7 +425,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
{
|
||||
case AS_UPDATED_CLIENT_FONTLIST:
|
||||
{
|
||||
STRACE(("ServerApp %s: Acknowledged update of client-side font list\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Acknowledged update of client-side font list\n",fSignature.String()));
|
||||
|
||||
// received when the client-side global font list has been
|
||||
// refreshed
|
||||
@@ -409,47 +436,47 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
}
|
||||
case AS_UPDATE_COLORS:
|
||||
{
|
||||
STRACE(("ServerApp %s: Received global UI color update notification\n",_signature.String()));
|
||||
/* STRACE(("ServerApp %s: Received global UI color update notification\n",fSignature.String()));
|
||||
ServerWindow *win;
|
||||
BMessage msg(_COLORS_UPDATED);
|
||||
|
||||
for(int32 i=0; i<_winlist->CountItems(); i++)
|
||||
for(int32 i=0; i<fSWindowList->CountItems(); i++)
|
||||
{
|
||||
win=(ServerWindow*)_winlist->ItemAt(i);
|
||||
win=(ServerWindow*)fSWindowList->ItemAt(i);
|
||||
win->Lock();
|
||||
win->_winborder->UpdateColors();
|
||||
win->fWinBorder->UpdateColors();
|
||||
win->SendMessageToClient(&msg);
|
||||
win->Unlock();
|
||||
}
|
||||
break;
|
||||
*/ break;
|
||||
}
|
||||
case AS_UPDATE_FONTS:
|
||||
{
|
||||
STRACE(("ServerApp %s: Received global font update notification\n",_signature.String()));
|
||||
/* STRACE(("ServerApp %s: Received global font update notification\n",fSignature.String()));
|
||||
ServerWindow *win;
|
||||
BMessage msg(_FONTS_UPDATED);
|
||||
|
||||
for(int32 i=0; i<_winlist->CountItems(); i++)
|
||||
for(int32 i=0; i<fSWindowList->CountItems(); i++)
|
||||
{
|
||||
win=(ServerWindow*)_winlist->ItemAt(i);
|
||||
win=(ServerWindow*)fSWindowList->ItemAt(i);
|
||||
win->Lock();
|
||||
win->_winborder->UpdateFont();
|
||||
win->fWinBorder->UpdateFont();
|
||||
win->SendMessageToClient(&msg);
|
||||
win->Unlock();
|
||||
}
|
||||
break;
|
||||
*/ break;
|
||||
}
|
||||
case AS_UPDATE_DECORATOR:
|
||||
{
|
||||
STRACE(("ServerApp %s: Received decorator update notification\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Received decorator update notification\n",fSignature.String()));
|
||||
|
||||
ServerWindow *win;
|
||||
|
||||
for(int32 i=0; i<_winlist->CountItems(); i++)
|
||||
for(int32 i=0; i<fSWindowList->CountItems(); i++)
|
||||
{
|
||||
win=(ServerWindow*)_winlist->ItemAt(i);
|
||||
win=(ServerWindow*)fSWindowList->ItemAt(i);
|
||||
win->Lock();
|
||||
win->_winborder->UpdateDecorator();
|
||||
win->fWinBorder->UpdateDecorator();
|
||||
win->Unlock();
|
||||
}
|
||||
break;
|
||||
@@ -490,7 +517,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
msg->ReadString(&title);
|
||||
msg->Read<port_id>(&replyport);
|
||||
|
||||
STRACE(("ServerApp %s: Got 'New Window' message, trying to do smething...\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Got 'New Window' message, trying to do smething...\n",fSignature.String()));
|
||||
|
||||
// ServerWindow constructor will reply with port_id of a newly created port
|
||||
new ServerWindow(frame, title, look, feel, flags, this,
|
||||
@@ -499,7 +526,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
// We don't have to do anything here...
|
||||
|
||||
STRACE(("\nServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n",
|
||||
_signature.String(),title,frame.left,frame.top,frame.right,frame.bottom));
|
||||
fSignature.String(),title,frame.left,frame.top,frame.right,frame.bottom));
|
||||
|
||||
delete title;
|
||||
|
||||
@@ -507,7 +534,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
}
|
||||
case AS_CREATE_BITMAP:
|
||||
{
|
||||
STRACE(("ServerApp %s: Received BBitmap creation request\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Received BBitmap creation request\n",fSignature.String()));
|
||||
// Allocate a bitmap for an application
|
||||
|
||||
// Attached Data:
|
||||
@@ -541,7 +568,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
ServerBitmap *sbmp=bitmapmanager->CreateBitmap(r,cs,f,bpr,s);
|
||||
|
||||
STRACE(("ServerApp %s: Create Bitmap (%.1f,%.1f,%.1f,%.1f)\n",
|
||||
_signature.String(),r.left,r.top,r.right,r.bottom));
|
||||
fSignature.String(),r.left,r.top,r.right,r.bottom));
|
||||
|
||||
if(sbmp)
|
||||
{
|
||||
@@ -563,7 +590,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
}
|
||||
case AS_DELETE_BITMAP:
|
||||
{
|
||||
STRACE(("ServerApp %s: received BBitmap delete request\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: received BBitmap delete request\n",fSignature.String()));
|
||||
// Delete a bitmap's allocated memory
|
||||
|
||||
// Attached Data:
|
||||
@@ -581,9 +608,9 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
ServerBitmap *sbmp=_FindBitmap(bmp_id);
|
||||
if(sbmp)
|
||||
{
|
||||
STRACE(("ServerApp %s: Deleting Bitmap %ld\n",_signature.String(),bmp_id));
|
||||
STRACE(("ServerApp %s: Deleting Bitmap %ld\n",fSignature.String(),bmp_id));
|
||||
|
||||
_bmplist->RemoveItem(sbmp);
|
||||
fBitmapList->RemoveItem(sbmp);
|
||||
bitmapmanager->DeleteBitmap(sbmp);
|
||||
write_port(replyport,SERVER_TRUE,NULL,0);
|
||||
}
|
||||
@@ -595,34 +622,34 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
case AS_CREATE_PICTURE:
|
||||
{
|
||||
// TODO: Implement
|
||||
STRACE(("ServerApp %s: Create Picture unimplemented\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Create Picture unimplemented\n",fSignature.String()));
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_DELETE_PICTURE:
|
||||
{
|
||||
// TODO: Implement
|
||||
STRACE(("ServerApp %s: Delete Picture unimplemented\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Delete Picture unimplemented\n",fSignature.String()));
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_CLONE_PICTURE:
|
||||
{
|
||||
// TODO: Implement
|
||||
STRACE(("ServerApp %s: Clone Picture unimplemented\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Clone Picture unimplemented\n",fSignature.String()));
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_DOWNLOAD_PICTURE:
|
||||
{
|
||||
// TODO; Implement
|
||||
STRACE(("ServerApp %s: Download Picture unimplemented\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Download Picture unimplemented\n",fSignature.String()));
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_SET_SCREEN_MODE:
|
||||
{
|
||||
STRACE(("ServerApp %s: Set Screen Mode\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Set Screen Mode\n",fSignature.String()));
|
||||
|
||||
// Attached data
|
||||
// 1) int32 workspace #
|
||||
@@ -642,7 +669,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
}
|
||||
case AS_ACTIVATE_WORKSPACE:
|
||||
{
|
||||
STRACE(("ServerApp %s: Activate Workspace\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Activate Workspace\n",fSignature.String()));
|
||||
// Attached data
|
||||
// 1) int32 workspace index
|
||||
|
||||
@@ -659,39 +686,39 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
// call the CursorManager's version to allow for future expansion
|
||||
case AS_SHOW_CURSOR:
|
||||
{
|
||||
STRACE(("ServerApp %s: Show Cursor\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Show Cursor\n",fSignature.String()));
|
||||
cursormanager->ShowCursor();
|
||||
_cursorhidden=false;
|
||||
fCursorHidden=false;
|
||||
break;
|
||||
}
|
||||
case AS_HIDE_CURSOR:
|
||||
{
|
||||
STRACE(("ServerApp %s: Hide Cursor\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Hide Cursor\n",fSignature.String()));
|
||||
cursormanager->HideCursor();
|
||||
_cursorhidden=true;
|
||||
fCursorHidden=true;
|
||||
break;
|
||||
}
|
||||
case AS_OBSCURE_CURSOR:
|
||||
{
|
||||
STRACE(("ServerApp %s: Obscure Cursor\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Obscure Cursor\n",fSignature.String()));
|
||||
cursormanager->ObscureCursor();
|
||||
break;
|
||||
}
|
||||
case AS_QUERY_CURSOR_HIDDEN:
|
||||
{
|
||||
STRACE(("ServerApp %s: Received IsCursorHidden request\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Received IsCursorHidden request\n",fSignature.String()));
|
||||
// Attached data
|
||||
// 1) int32 port to reply to
|
||||
int32 replyport;
|
||||
msg->Read<int32>(&replyport);
|
||||
|
||||
write_port(replyport,(_cursorhidden)?SERVER_TRUE:SERVER_FALSE,NULL,0);
|
||||
write_port(replyport,(fCursorHidden)?SERVER_TRUE:SERVER_FALSE,NULL,0);
|
||||
break;
|
||||
}
|
||||
case AS_SET_CURSOR_DATA:
|
||||
{
|
||||
STRACE(("ServerApp %s: SetCursor via cursor data\n",_signature.String()));
|
||||
// Attached data: 68 bytes of _appcursor data
|
||||
STRACE(("ServerApp %s: SetCursor via cursor data\n",fSignature.String()));
|
||||
// Attached data: 68 bytes of fAppCursor data
|
||||
|
||||
int8 cdata[68];
|
||||
msg->Read(cdata,68);
|
||||
@@ -700,18 +727,18 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
// cursors, we will delete them if there is an existing one. It would
|
||||
// otherwise be easy to crash the server by calling SetCursor a
|
||||
// sufficient number of times
|
||||
if(_appcursor)
|
||||
cursormanager->DeleteCursor(_appcursor->ID());
|
||||
if(fAppCursor)
|
||||
cursormanager->DeleteCursor(fAppCursor->ID());
|
||||
|
||||
_appcursor=new ServerCursor(cdata);
|
||||
_appcursor->SetAppSignature(_signature.String());
|
||||
cursormanager->AddCursor(_appcursor);
|
||||
cursormanager->SetCursor(_appcursor->ID());
|
||||
fAppCursor=new ServerCursor(cdata);
|
||||
fAppCursor->SetAppSignature(fSignature.String());
|
||||
cursormanager->AddCursor(fAppCursor);
|
||||
cursormanager->SetCursor(fAppCursor->ID());
|
||||
break;
|
||||
}
|
||||
case AS_SET_CURSOR_BCURSOR:
|
||||
{
|
||||
STRACE(("ServerApp %s: SetCursor via BCursor\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: SetCursor via BCursor\n",fSignature.String()));
|
||||
// Attached data:
|
||||
// 1) bool flag to send a reply
|
||||
// 2) int32 token ID of the cursor to set
|
||||
@@ -738,9 +765,9 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
}
|
||||
case AS_CREATE_BCURSOR:
|
||||
{
|
||||
STRACE(("ServerApp %s: Create BCursor\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Create BCursor\n",fSignature.String()));
|
||||
// Attached data:
|
||||
// 1) 68 bytes of _appcursor data
|
||||
// 1) 68 bytes of fAppCursor data
|
||||
// 2) port_id reply port
|
||||
|
||||
port_id replyport;
|
||||
@@ -749,33 +776,33 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
msg->Read(cdata,68);
|
||||
msg->Read<int32>(&replyport);
|
||||
|
||||
_appcursor=new ServerCursor(cdata);
|
||||
_appcursor->SetAppSignature(_signature.String());
|
||||
cursormanager->AddCursor(_appcursor);
|
||||
fAppCursor=new ServerCursor(cdata);
|
||||
fAppCursor->SetAppSignature(fSignature.String());
|
||||
cursormanager->AddCursor(fAppCursor);
|
||||
|
||||
// Synchronous message - BApplication is waiting on the cursor's ID
|
||||
PortLink link(replyport);
|
||||
link.Attach<int32>(_appcursor->ID());
|
||||
link.Attach<int32>(fAppCursor->ID());
|
||||
link.Flush();
|
||||
break;
|
||||
}
|
||||
case AS_DELETE_BCURSOR:
|
||||
{
|
||||
STRACE(("ServerApp %s: Delete BCursor\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Delete BCursor\n",fSignature.String()));
|
||||
// Attached data:
|
||||
// 1) int32 token ID of the cursor to delete
|
||||
int32 ctoken;
|
||||
msg->Read<int32>(&ctoken);
|
||||
|
||||
if(_appcursor && _appcursor->ID()==ctoken)
|
||||
_appcursor=NULL;
|
||||
if(fAppCursor && fAppCursor->ID()==ctoken)
|
||||
fAppCursor=NULL;
|
||||
|
||||
cursormanager->DeleteCursor(ctoken);
|
||||
break;
|
||||
}
|
||||
case AS_GET_SCROLLBAR_INFO:
|
||||
{
|
||||
STRACE(("ServerApp %s: Get ScrollBar info\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Get ScrollBar info\n",fSignature.String()));
|
||||
// Attached data:
|
||||
// 1) port_id reply port - synchronous message
|
||||
|
||||
@@ -792,7 +819,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
}
|
||||
case AS_SET_SCROLLBAR_INFO:
|
||||
{
|
||||
STRACE(("ServerApp %s: Set ScrollBar info\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Set ScrollBar info\n",fSignature.String()));
|
||||
// Attached Data:
|
||||
// 1) scroll_bar_info scroll bar info structure
|
||||
scroll_bar_info sbi;
|
||||
@@ -803,7 +830,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
}
|
||||
case AS_FOCUS_FOLLOWS_MOUSE:
|
||||
{
|
||||
STRACE(("ServerApp %s: query Focus Follow Mouse in use\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: query Focus Follow Mouse in use\n",fSignature.String()));
|
||||
// Attached data:
|
||||
// 1) port_id reply port - synchronous message
|
||||
|
||||
@@ -818,7 +845,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
}
|
||||
case AS_SET_FOCUS_FOLLOWS_MOUSE:
|
||||
{
|
||||
STRACE(("ServerApp %s: Set Focus Follows Mouse in use\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Set Focus Follows Mouse in use\n",fSignature.String()));
|
||||
// Attached Data:
|
||||
// 1) scroll_bar_info scroll bar info structure
|
||||
scroll_bar_info sbi;
|
||||
@@ -829,7 +856,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
}
|
||||
case AS_SET_MOUSE_MODE:
|
||||
{
|
||||
STRACE(("ServerApp %s: Set Focus Follows Mouse mode\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Set Focus Follows Mouse mode\n",fSignature.String()));
|
||||
// Attached Data:
|
||||
// 1) enum mode_mouse FFM mouse mode
|
||||
mode_mouse mmode;
|
||||
@@ -840,7 +867,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
}
|
||||
case AS_GET_MOUSE_MODE:
|
||||
{
|
||||
STRACE(("ServerApp %s: Get Focus Follows Mouse mode\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Get Focus Follows Mouse mode\n",fSignature.String()));
|
||||
// Attached data:
|
||||
// 1) port_id reply port - synchronous message
|
||||
|
||||
@@ -857,7 +884,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
}
|
||||
case AS_GET_UI_COLOR:
|
||||
{
|
||||
STRACE(("ServerApp %s: Get UI color\n",_signature.String()));
|
||||
STRACE(("ServerApp %s: Get UI color\n",fSignature.String()));
|
||||
|
||||
RGBColor color;
|
||||
int32 whichcolor;
|
||||
@@ -878,7 +905,8 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
}
|
||||
default:
|
||||
{
|
||||
STRACE(("ServerApp %s received unhandled message code offset %s\n",_signature.String(),MsgCodeToString(msg->Code())));
|
||||
STRACE(("ServerApp %s received unhandled message code offset %s\n",fSignature.String(),
|
||||
MsgCodeToBString(msg->Code()).String()));
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -893,15 +921,16 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
ServerBitmap *ServerApp::_FindBitmap(int32 token)
|
||||
{
|
||||
ServerBitmap *temp;
|
||||
for(int32 i=0; i<_bmplist->CountItems();i++)
|
||||
for(int32 i=0; i<fBitmapList->CountItems();i++)
|
||||
{
|
||||
temp=(ServerBitmap*)_bmplist->ItemAt(i);
|
||||
temp=(ServerBitmap*)fBitmapList->ItemAt(i);
|
||||
if(temp && temp->Token()==token)
|
||||
return temp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
team_id ServerApp::ClientTeamID(){
|
||||
team_id ServerApp::ClientTeamID()
|
||||
{
|
||||
return fClientTeamID;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
//
|
||||
// File Name: ServerApp.h
|
||||
// Author: DarkWyrm <[email protected]>
|
||||
// Adi Oanca <[email protected]>
|
||||
// Description: Server-side BApplication counterpart
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -46,60 +47,60 @@ class ServerCursor;
|
||||
class ServerApp
|
||||
{
|
||||
public:
|
||||
ServerApp(port_id sendport, port_id rcvport, port_id clientLooperPort,
|
||||
team_id clientTeamID, int32 handlerID, char *signature);
|
||||
ServerApp(port_id sendport, port_id rcvport, port_id clientLooperPort,
|
||||
team_id clientTeamID, int32 handlerID, char *signature);
|
||||
virtual ~ServerApp(void);
|
||||
|
||||
bool Run(void);
|
||||
static int32 MonitorApp(void *data);
|
||||
void Lock(void);
|
||||
void Unlock(void);
|
||||
bool IsLocked(void);
|
||||
|
||||
bool Run(void);
|
||||
static int32 MonitorApp(void *data);
|
||||
void Lock(void);
|
||||
void Unlock(void);
|
||||
bool IsLocked(void);
|
||||
|
||||
/*!
|
||||
\brief Determines whether the application is the active one
|
||||
\return true if active, false if not.
|
||||
*/
|
||||
bool IsActive(void) const { return _isactive; }
|
||||
|
||||
void Activate(bool value);
|
||||
bool PingTarget(void);
|
||||
bool IsActive(void) const { return fIsActive; }
|
||||
|
||||
void Activate(bool value);
|
||||
bool PingTarget(void);
|
||||
|
||||
void PostMessage(int32 code, size_t size=0,int8 *buffer=NULL);
|
||||
void WindowBroadcast(int32 code);
|
||||
|
||||
void SendMessageToClient( const BMessage* msg ) const;
|
||||
void SetAppCursor(void);
|
||||
|
||||
team_id ClientTeamID();
|
||||
|
||||
FMWList fAppFMWList;
|
||||
|
||||
void PostMessage(int32 code, size_t size=0,
|
||||
int8 *buffer=NULL);
|
||||
void SendMessageToClient( const BMessage* msg ) const;
|
||||
|
||||
void SetAppCursor(void);
|
||||
|
||||
team_id ClientTeamID();
|
||||
|
||||
FMWList fAppFMWList;
|
||||
protected:
|
||||
friend class AppServer;
|
||||
friend class ServerWindow;
|
||||
|
||||
void _DispatchMessage(PortMessage *msg);
|
||||
ServerBitmap* _FindBitmap(int32 token);
|
||||
|
||||
port_id _sender,
|
||||
_receiver,
|
||||
fClientLooperPort;
|
||||
|
||||
BString _signature;
|
||||
thread_id _monitor_thread;
|
||||
|
||||
team_id fClientTeamID;
|
||||
|
||||
team_id _target_id;
|
||||
PortLink* _applink;
|
||||
BList *_winlist,
|
||||
*_bmplist,
|
||||
*_piclist;
|
||||
ServerCursor* _appcursor;
|
||||
sem_id _lock;
|
||||
bool _cursorhidden;
|
||||
bool _isactive;
|
||||
int32 _handlertoken;
|
||||
|
||||
void _DispatchMessage(PortMessage *msg);
|
||||
ServerBitmap *_FindBitmap(int32 token);
|
||||
|
||||
port_id fClientAppPort,
|
||||
fMessagePort,
|
||||
fClientLooperPort;
|
||||
|
||||
BString fSignature;
|
||||
thread_id fMonitorThreadID;
|
||||
|
||||
team_id fClientTeamID;
|
||||
|
||||
PortLink *fAppLink;
|
||||
BList *fSWindowList,
|
||||
*fBitmapList,
|
||||
*fPictureList;
|
||||
ServerCursor *fAppCursor;
|
||||
sem_id fLockSem;
|
||||
bool fCursorHidden;
|
||||
bool fIsActive;
|
||||
int32 fHandlerToken;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -65,114 +65,104 @@ class Layer;
|
||||
class ServerWindow
|
||||
{
|
||||
public:
|
||||
ServerWindow(BRect rect, const char *string,
|
||||
uint32 wlook, uint32 wfeel, uint32 wflags,
|
||||
ServerApp *winapp, port_id winport,
|
||||
port_id looperPort, port_id replyport, uint32 index,
|
||||
int32 handlerID);
|
||||
~ServerWindow(void);
|
||||
ServerWindow(BRect rect, const char *string, uint32 wlook, uint32 wfeel, uint32 wflags,
|
||||
ServerApp *winapp, port_id winport, port_id looperPort, port_id replyport,
|
||||
uint32 index, int32 handlerID);
|
||||
~ServerWindow(void);
|
||||
|
||||
void ReplaceDecorator(void);
|
||||
void Quit(void);
|
||||
const char* GetTitle(void);
|
||||
ServerApp* GetApp(void);
|
||||
void Show(void);
|
||||
void Hide(void);
|
||||
bool IsHidden(void);
|
||||
void Minimize(bool status);
|
||||
void Zoom(void);
|
||||
void SetFocus(bool value);
|
||||
bool HasFocus(void);
|
||||
void RequestDraw(BRect rect);
|
||||
void RequestDraw(void);
|
||||
void ReplaceDecorator(void);
|
||||
void Quit(void);
|
||||
void Show(void);
|
||||
void Hide(void);
|
||||
bool IsHidden(void);
|
||||
void Minimize(bool status);
|
||||
void Zoom(void);
|
||||
void SetFocus(bool value);
|
||||
bool HasFocus(void);
|
||||
void RequestDraw(BRect rect);
|
||||
void RequestDraw(void);
|
||||
|
||||
void WorkspaceActivated(int32 workspace, bool active);
|
||||
void WorkspacesChanged(int32 oldone,int32 newone);
|
||||
void WindowActivated(bool active);
|
||||
void ScreenModeChanged(const BRect frame, const color_space cspace);
|
||||
void WorkspaceActivated(int32 workspace, bool active);
|
||||
void WorkspacesChanged(int32 oldone,int32 newone);
|
||||
void WindowActivated(bool active);
|
||||
void ScreenModeChanged(const BRect frame, const color_space cspace);
|
||||
|
||||
void SetFrame(const BRect &rect);
|
||||
BRect Frame(void);
|
||||
void SetFrame(const BRect &rect);
|
||||
BRect Frame(void);
|
||||
|
||||
status_t Lock(void);
|
||||
void Unlock(void);
|
||||
bool IsLocked(void);
|
||||
thread_id ThreadID() const { return _monitorthread;}
|
||||
status_t Lock(void);
|
||||
void Unlock(void);
|
||||
bool IsLocked(void);
|
||||
thread_id ThreadID(void) const { return fMonitorThreadID;}
|
||||
|
||||
void DispatchMessage(int32 code);
|
||||
void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer);
|
||||
static int32 MonitorWin(void *data);
|
||||
static void HandleMouseEvent(PortMessage *msg);
|
||||
static void HandleKeyEvent(int32 code, int8 *buffer);
|
||||
void DispatchMessage(int32 code);
|
||||
void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer);
|
||||
static int32 MonitorWin(void *data);
|
||||
static void HandleMouseEvent(PortMessage *msg);
|
||||
static void HandleKeyEvent(int32 code, int8 *buffer);
|
||||
void PostMessage(int32 code, size_t size=0, int8 *buffer=NULL);
|
||||
|
||||
//! Returns the index of the workspaces to which it belongs
|
||||
int32 GetWorkspaceIndex(void) { return fWorkspaces; }
|
||||
Workspace* GetWorkspace(void);
|
||||
void SetWorkspace(Workspace *wkspc);
|
||||
|
||||
//! Returns the window's title
|
||||
const char* Title(void) { return _title->String(); }
|
||||
int32 GetWorkspaceIndex(void) { return fWorkspaces; }
|
||||
Workspace *GetWorkspace(void);
|
||||
void SetWorkspace(Workspace *wkspc);
|
||||
|
||||
//! Returns the window's title
|
||||
const char *Title(void) { return fTitle.String(); }
|
||||
|
||||
Layer* FindLayer(const Layer* start, int32 token) const;
|
||||
void SendMessageToClient( const BMessage* msg ) const;
|
||||
|
||||
int32 Look(void) const { return fLook; }
|
||||
int32 Feel(void) const { return fFeel; }
|
||||
uint32 Flags(void) const { return fFlags; }
|
||||
team_id ClientTeamID(void) const { return fClientTeamID; }
|
||||
ServerApp *App(void) const { return fServerApp; }
|
||||
uint32 Workspaces(void) const { return fWorkspaces; }
|
||||
WinBorder *GetWinBorder(void) const { return fWinBorder; }
|
||||
|
||||
Layer* FindLayer(const Layer* start, int32 token) const;
|
||||
void SendMessageToClient( const BMessage* msg ) const;
|
||||
|
||||
int32 Look() const { return _look; }
|
||||
int32 Feel() const { return _feel; }
|
||||
uint32 Flags() const { return _flags; }
|
||||
team_id ClientTeamID() const { return fClientTeamID; }
|
||||
ServerApp* App() const { return _app; }
|
||||
uint32 Workspaces() const { return fWorkspaces; }
|
||||
WinBorder* GetWinBorder() const { return _winborder; }
|
||||
|
||||
// server "private" - try not to use
|
||||
void QuietlySetWorkspaces(uint32 wks)
|
||||
{ fWorkspaces = wks; }
|
||||
void QuietlySetFeel(int32 feel)
|
||||
{ _feel = feel; }
|
||||
int32 ClientToken() const { return _handlertoken; }
|
||||
|
||||
FMWList fWinFMWList;
|
||||
void QuietlySetWorkspaces(uint32 wks) { fWorkspaces = wks; }
|
||||
void QuietlySetFeel(int32 feel) { fFeel = feel; }
|
||||
int32 ClientToken(void) const { return fHandlerToken; }
|
||||
|
||||
FMWList fWinFMWList;
|
||||
protected:
|
||||
friend class ServerApp;
|
||||
friend class WinBorder;
|
||||
friend class Screen;
|
||||
friend class Screen;
|
||||
friend class Layer;
|
||||
|
||||
BString *_title;
|
||||
int32 _look,
|
||||
_feel,
|
||||
_flags;
|
||||
uint32 fWorkspaces;
|
||||
Workspace *_workspace;
|
||||
bool _active;
|
||||
BString fTitle;
|
||||
int32 fLook,
|
||||
fFeel,
|
||||
fFlags;
|
||||
uint32 fWorkspaces;
|
||||
Workspace *fWorkspace;
|
||||
bool fIsActive;
|
||||
|
||||
ServerApp *_app;
|
||||
WinBorder *_winborder;
|
||||
ServerApp *fServerApp;
|
||||
WinBorder *fWinBorder;
|
||||
|
||||
team_id fClientTeamID;
|
||||
thread_id _monitorthread;
|
||||
port_id _receiver; // Messages from window
|
||||
port_id _sender; // Messages to window
|
||||
PortLink *_winlink;
|
||||
team_id fClientTeamID;
|
||||
thread_id fMonitorThreadID;
|
||||
|
||||
BLocker _locker;
|
||||
BRect _frame;
|
||||
uint32 _token;
|
||||
int32 _handlertoken;
|
||||
port_id fMessagePort;
|
||||
port_id fClientWinPort;
|
||||
port_id fClientLooperPort;
|
||||
|
||||
PortLink *fWinLink;
|
||||
|
||||
BSession *ses;
|
||||
port_id winLooperPort;
|
||||
Layer *top_layer;
|
||||
Layer *cl; // short for currentLayer. We'll use it a lot, that's why it's short :-)
|
||||
BLocker fLocker;
|
||||
BRect fFrame;
|
||||
uint32 fToken;
|
||||
int32 fHandlerToken;
|
||||
|
||||
BSession *fSession;
|
||||
Layer *fTopLayer;
|
||||
Layer *cl; // short for currentLayer. We'll use it a lot, that's why it's short :-)
|
||||
};
|
||||
|
||||
void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin);
|
||||
|
||||
|
||||
#endif
|
||||
/*
|
||||
@log
|
||||
* added Layer as a friend.
|
||||
* added a new member: port_id winLooperPort; We'll use it to send flattened BMessages(like _UPDATE_ / B_VIEW_RESIZED(MOVED)) to our BWindow counterpart.
|
||||
* SendMessageToClient( BMessage ) sends that message BWindow's looper port.
|
||||
*/
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <Entry.h>
|
||||
#include <stdio.h>
|
||||
#include "Utils.h"
|
||||
#include <String.h>
|
||||
|
||||
/*!
|
||||
\brief Send a BMessage to a Looper target
|
||||
@@ -92,9 +93,23 @@ const char *MsgCodeToString(int32 code)
|
||||
// Used to translate BMessage message codes back to a character
|
||||
// format
|
||||
char string [10];
|
||||
sprintf(string,"'%c%c%c%c'",(char)((code & 0xFF000000) >> 24),
|
||||
sprintf(string,"'%x%x%x%x'",(char)((code & 0xFF000000) >> 24),
|
||||
(char)((code & 0x00FF0000) >> 16),
|
||||
(char)((code & 0x0000FF00) >> 8),
|
||||
(char)((code & 0x000000FF)) );
|
||||
return string;
|
||||
}
|
||||
|
||||
BString MsgCodeToBString(int32 code)
|
||||
{
|
||||
// Used to translate BMessage message codes back to a character
|
||||
// format
|
||||
char string [10];
|
||||
sprintf(string,"'%x%x%x%x'",(char)((code & 0xFF000000) >> 24),
|
||||
(char)((code & 0x00FF0000) >> 16),
|
||||
(char)((code & 0x0000FF00) >> 8),
|
||||
(char)((code & 0x000000FF)) );
|
||||
|
||||
BString bstring(string);
|
||||
return bstring;
|
||||
}
|
||||
|
||||
@@ -32,5 +32,6 @@
|
||||
|
||||
void SendMessage(port_id port, BMessage *message, int32 target=-1);
|
||||
const char *MsgCodeToString(int32 code);
|
||||
BString MsgCodeToBString(int32 code);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -106,8 +106,10 @@ VDView::VDView(BRect bounds)
|
||||
VDView::~VDView(void)
|
||||
{
|
||||
delete serverlink;
|
||||
delete viewbmp;
|
||||
delete cursor;
|
||||
|
||||
viewbmp->Lock();
|
||||
delete viewbmp;
|
||||
}
|
||||
|
||||
void VDView::AttachedToWindow(void)
|
||||
@@ -581,6 +583,9 @@ void ViewDriver::Shutdown(void)
|
||||
|
||||
void ViewDriver::SetMode(const display_mode &mode)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
screenwin->Lock();
|
||||
|
||||
BBitmap *tempbmp=new BBitmap(BRect(0,0,mode.virtual_width-1,mode.virtual_height-1),
|
||||
@@ -620,6 +625,9 @@ void ViewDriver::SetMode(const display_mode &mode)
|
||||
|
||||
void ViewDriver::SetMode(int32 space)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
screenwin->Lock();
|
||||
int16 w=640,h=480;
|
||||
color_space s=B_CMAP8;
|
||||
@@ -696,6 +704,9 @@ void ViewDriver::SetMode(int32 space)
|
||||
|
||||
void ViewDriver::CopyBits(BRect src, BRect dest)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
drawview->CopyBits(src,dest);
|
||||
@@ -708,6 +719,9 @@ void ViewDriver::CopyBits(BRect src, BRect dest)
|
||||
|
||||
void ViewDriver::CopyRegion(BRegion *src, const BPoint &lefttop)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
STRACE(("ViewDriver:: CopyRegion not completely tested\n"));
|
||||
|
||||
screenwin->Lock();
|
||||
@@ -801,11 +815,17 @@ printf("Overlap\n");
|
||||
|
||||
void ViewDriver::DrawBitmap(ServerBitmap *bitmap, BRect src, BRect dest)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
STRACE(("ViewDriver:: DrawBitmap unimplemented()\n"));
|
||||
}
|
||||
|
||||
void ViewDriver::DrawChar(char c, BPoint pt, LayerData *d)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
char str[2];
|
||||
str[0]=c;
|
||||
str[1]='\0';
|
||||
@@ -814,6 +834,9 @@ void ViewDriver::DrawChar(char c, BPoint pt, LayerData *d)
|
||||
|
||||
void ViewDriver::DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
STRACE(("ViewDriver:: DrawString(\"%s\",%ld,BPoint(%f,%f))\n",string,length,pt.x,pt.y));
|
||||
if(!d)
|
||||
return;
|
||||
@@ -846,6 +869,9 @@ STRACE(("ViewDriver:: DrawString(\"%s\",%ld,BPoint(%f,%f))\n",string,length,pt.x
|
||||
|
||||
bool ViewDriver::DumpToFile(const char *path)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return false;
|
||||
|
||||
// Dump to PNG
|
||||
Lock();
|
||||
SaveToPNG(path,framebuffer->Bounds(),framebuffer->ColorSpace(),
|
||||
@@ -860,6 +886,9 @@ bool ViewDriver::DumpToFile(const char *path)
|
||||
|
||||
void ViewDriver::FillArc(const BRect r, float angle, float span, RGBColor& color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -878,6 +907,9 @@ void ViewDriver::FillArc(const BRect r, float angle, float span, RGBColor& color
|
||||
|
||||
void ViewDriver::FillArc(const BRect r, float angle, float span, const Pattern& pat, RGBColor& high_color, RGBColor& low_color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -896,6 +928,9 @@ void ViewDriver::FillArc(const BRect r, float angle, float span, const Pattern&
|
||||
|
||||
void ViewDriver::FillBezier(BPoint *pts, RGBColor& color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
if(!pts)
|
||||
return;
|
||||
Lock();
|
||||
@@ -917,6 +952,9 @@ void ViewDriver::FillBezier(BPoint *pts, RGBColor& color)
|
||||
|
||||
void ViewDriver::FillBezier(BPoint *pts, const Pattern& pat, RGBColor& high_color, RGBColor& low_color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
if(!pts)
|
||||
return;
|
||||
Lock();
|
||||
@@ -938,6 +976,9 @@ void ViewDriver::FillBezier(BPoint *pts, const Pattern& pat, RGBColor& high_colo
|
||||
|
||||
void ViewDriver::FillEllipse(BRect r, RGBColor& color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -954,6 +995,9 @@ void ViewDriver::FillEllipse(BRect r, RGBColor& color)
|
||||
|
||||
void ViewDriver::FillEllipse(BRect r, const Pattern& pat, RGBColor& high_color, RGBColor& low_color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -970,6 +1014,9 @@ void ViewDriver::FillEllipse(BRect r, const Pattern& pat, RGBColor& high_color,
|
||||
|
||||
void ViewDriver::FillPolygon(BPoint *ptlist, int32 numpts, RGBColor& color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -986,6 +1033,9 @@ void ViewDriver::FillPolygon(BPoint *ptlist, int32 numpts, RGBColor& color)
|
||||
|
||||
void ViewDriver::FillPolygon(BPoint *ptlist, int32 numpts, const Pattern& pat, RGBColor& high_color, RGBColor& low_color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1002,6 +1052,9 @@ void ViewDriver::FillPolygon(BPoint *ptlist, int32 numpts, const Pattern& pat, R
|
||||
|
||||
void ViewDriver::FillRect(const BRect r, RGBColor& color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1025,6 +1078,9 @@ void ViewDriver::FillRect(const BRect r, RGBColor& color)
|
||||
*/
|
||||
void ViewDriver::FillRect(const BRect r, const Pattern& pat, RGBColor& high_color, RGBColor& low_color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1041,6 +1097,9 @@ void ViewDriver::FillRect(const BRect r, const Pattern& pat, RGBColor& high_colo
|
||||
|
||||
void ViewDriver::FillRoundRect(BRect r, float xrad, float yrad, RGBColor& color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1057,6 +1116,9 @@ void ViewDriver::FillRoundRect(BRect r, float xrad, float yrad, RGBColor& color)
|
||||
|
||||
void ViewDriver::FillRoundRect(BRect r, float xrad, float yrad, const Pattern& pat, RGBColor& high_color, RGBColor& low_color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1073,6 +1135,9 @@ void ViewDriver::FillRoundRect(BRect r, float xrad, float yrad, const Pattern& p
|
||||
|
||||
void ViewDriver::FillTriangle(BPoint *pts, RGBColor& color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1102,6 +1167,9 @@ void ViewDriver::FillTriangle(BPoint *pts, RGBColor& color)
|
||||
|
||||
void ViewDriver::FillTriangle(BPoint *pts, const Pattern& pat, RGBColor& high_color, RGBColor& low_color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1131,6 +1199,9 @@ void ViewDriver::FillTriangle(BPoint *pts, const Pattern& pat, RGBColor& high_co
|
||||
|
||||
void ViewDriver::StrokeArc(BRect r, float angle, float span, float pensize, RGBColor& color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1148,6 +1219,9 @@ void ViewDriver::StrokeArc(BRect r, float angle, float span, float pensize, RGBC
|
||||
|
||||
void ViewDriver::StrokeArc(BRect r, float angle, float span, float pensize, const Pattern& pat, RGBColor& high_color, RGBColor& low_color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1165,6 +1239,9 @@ void ViewDriver::StrokeArc(BRect r, float angle, float span, float pensize, cons
|
||||
|
||||
void ViewDriver::StrokeBezier(BPoint *pts, float pensize, RGBColor& color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1182,6 +1259,9 @@ void ViewDriver::StrokeBezier(BPoint *pts, float pensize, RGBColor& color)
|
||||
|
||||
void ViewDriver::StrokeBezier(BPoint *pts, float pensize, const Pattern& pat, RGBColor& high_color, RGBColor& low_color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1199,6 +1279,9 @@ void ViewDriver::StrokeBezier(BPoint *pts, float pensize, const Pattern& pat, RG
|
||||
|
||||
void ViewDriver::StrokeEllipse(BRect r, float pensize, RGBColor& color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1216,6 +1299,9 @@ void ViewDriver::StrokeEllipse(BRect r, float pensize, RGBColor& color)
|
||||
|
||||
void ViewDriver::StrokeEllipse(BRect r, float pensize, const Pattern& pat, RGBColor& high_color, RGBColor& low_color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1233,6 +1319,9 @@ void ViewDriver::StrokeEllipse(BRect r, float pensize, const Pattern& pat, RGBCo
|
||||
|
||||
void ViewDriver::StrokeLine(BPoint start, BPoint end, float pensize, RGBColor& color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1250,6 +1339,9 @@ void ViewDriver::StrokeLine(BPoint start, BPoint end, float pensize, RGBColor& c
|
||||
|
||||
void ViewDriver::StrokeLine(BPoint start, BPoint end, float pensize, const Pattern& pat, RGBColor& high_color, RGBColor& low_color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1267,6 +1359,9 @@ void ViewDriver::StrokeLine(BPoint start, BPoint end, float pensize, const Patte
|
||||
|
||||
void ViewDriver::StrokePoint(BPoint& pt, RGBColor& color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
Unlock();
|
||||
}
|
||||
@@ -1309,11 +1404,17 @@ void ViewDriver::StrokePolygon(BPoint *ptlist, int32 numpts, float pensize, RGBC
|
||||
|
||||
void ViewDriver::StrokePolygon(BPoint *ptlist, int32 numpts, float pensize, const Pattern& pat, RGBColor& high_color, RGBColor& low_color, bool is_closed)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
StrokePolygon(ptlist,numpts,pensize,high_color,is_closed);
|
||||
}
|
||||
|
||||
void ViewDriver::StrokeRect(BRect r, float pensize, RGBColor& color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1331,6 +1432,9 @@ void ViewDriver::StrokeRect(BRect r, float pensize, RGBColor& color)
|
||||
|
||||
void ViewDriver::StrokeRect(BRect r, float pensize, const Pattern& pat, RGBColor& high_color, RGBColor& low_color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1348,6 +1452,9 @@ void ViewDriver::StrokeRect(BRect r, float pensize, const Pattern& pat, RGBColor
|
||||
|
||||
void ViewDriver::StrokeRoundRect(BRect r, float xrad, float yrad, float pensize, RGBColor& color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1365,6 +1472,9 @@ void ViewDriver::StrokeRoundRect(BRect r, float xrad, float yrad, float pensize,
|
||||
|
||||
void ViewDriver::StrokeRoundRect(BRect r, float xrad, float yrad, float pensize, const Pattern& pat, RGBColor& high_color, RGBColor& low_color)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
Lock();
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
@@ -1389,6 +1499,9 @@ void ViewDriver::StrokeRoundRect(BRect r, float xrad, float yrad, float pensize,
|
||||
*/
|
||||
void ViewDriver::StrokeLineArray(BPoint *pts, int32 numlines, float pensize, RGBColor *colors)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
if( !numlines || !pts || !colors)
|
||||
return;
|
||||
|
||||
@@ -1426,6 +1539,9 @@ void ViewDriver::StrokeLineArray(BPoint *pts, int32 numlines, float pensize, RGB
|
||||
|
||||
void ViewDriver::HideCursor(void)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
screenwin->Lock();
|
||||
Lock();
|
||||
|
||||
@@ -1438,6 +1554,9 @@ void ViewDriver::HideCursor(void)
|
||||
|
||||
void ViewDriver::InvertRect(BRect r)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
screenwin->Lock();
|
||||
framebuffer->Lock();
|
||||
drawview->InvertRect(r);
|
||||
@@ -1449,6 +1568,9 @@ void ViewDriver::InvertRect(BRect r)
|
||||
|
||||
bool ViewDriver::IsCursorHidden(void)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return false;
|
||||
|
||||
screenwin->Lock();
|
||||
bool value=(hide_cursor>0)?true:false;
|
||||
screenwin->Unlock();
|
||||
@@ -1457,6 +1579,9 @@ bool ViewDriver::IsCursorHidden(void)
|
||||
|
||||
void ViewDriver::ObscureCursor(void)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
screenwin->Lock();
|
||||
screenwin->PostMessage(VDWIN_OBSCURECURSOR);
|
||||
screenwin->Unlock();
|
||||
@@ -1464,6 +1589,9 @@ void ViewDriver::ObscureCursor(void)
|
||||
|
||||
void ViewDriver::MoveCursorTo(float x, float y)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
screenwin->Lock();
|
||||
BMessage *msg=new BMessage(VDWIN_MOVECURSOR);
|
||||
msg->AddFloat("x",x);
|
||||
@@ -1474,6 +1602,9 @@ void ViewDriver::MoveCursorTo(float x, float y)
|
||||
|
||||
void ViewDriver::SetCursor(ServerCursor *cursor)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
if(cursor!=NULL)
|
||||
{
|
||||
screenwin->Lock();
|
||||
@@ -1499,6 +1630,9 @@ void ViewDriver::SetCursor(ServerCursor *cursor)
|
||||
|
||||
void ViewDriver::ShowCursor(void)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
screenwin->Lock();
|
||||
if(hide_cursor>0)
|
||||
{
|
||||
@@ -1511,6 +1645,9 @@ void ViewDriver::ShowCursor(void)
|
||||
|
||||
void ViewDriver::SetLayerData(LayerData *d, bool set_font_data)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
if(!d)
|
||||
return;
|
||||
|
||||
@@ -1552,7 +1689,7 @@ void ViewDriver::SetLayerData(LayerData *d, bool set_font_data)
|
||||
|
||||
float ViewDriver::StringWidth(const char *string, int32 length, LayerData *d)
|
||||
{
|
||||
if(!string || !d )
|
||||
if(!string || !d || !is_initialized)
|
||||
return 0.0;
|
||||
screenwin->Lock();
|
||||
|
||||
@@ -1616,7 +1753,7 @@ float ViewDriver::StringWidth(const char *string, int32 length, LayerData *d)
|
||||
|
||||
float ViewDriver::StringHeight(const char *string, int32 length, LayerData *d)
|
||||
{
|
||||
if(!string || !d )
|
||||
if(!string || !d || !is_initialized)
|
||||
return 0.0;
|
||||
screenwin->Lock();
|
||||
|
||||
@@ -1666,6 +1803,9 @@ float ViewDriver::StringHeight(const char *string, int32 length, LayerData *d)
|
||||
/*
|
||||
void ViewDriver::DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *edelta)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
if(!string || !d )
|
||||
return;
|
||||
screenwin->Lock();
|
||||
@@ -1810,6 +1950,9 @@ void ViewDriver::DrawString(const char *string, int32 length, BPoint pt, LayerDa
|
||||
*/
|
||||
void ViewDriver::BlitMono2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
rgb_color color=d->highcolor.GetColor32();
|
||||
|
||||
// pointers to the top left corner of the area to be copied in each bitmap
|
||||
@@ -1895,6 +2038,9 @@ void ViewDriver::BlitMono2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d)
|
||||
|
||||
void ViewDriver::BlitGray2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return;
|
||||
|
||||
// pointers to the top left corner of the area to be copied in each bitmap
|
||||
uint8 *srcbuffer=NULL, *destbuffer=NULL;
|
||||
|
||||
@@ -2010,8 +2156,9 @@ void ViewDriver::BlitGray2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d)
|
||||
rgb_color ViewDriver::GetBlitColor(rgb_color src, rgb_color dest, LayerData *d, bool use_high)
|
||||
{
|
||||
rgb_color returncolor={0,0,0,0};
|
||||
|
||||
int16 value;
|
||||
if(!d)
|
||||
if(!d || !is_initialized)
|
||||
return returncolor;
|
||||
|
||||
switch(d->draw_mode)
|
||||
@@ -2111,6 +2258,9 @@ rgb_color ViewDriver::GetBlitColor(rgb_color src, rgb_color dest, LayerData *d,
|
||||
|
||||
status_t ViewDriver::SetDPMSMode(const uint32 &state)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return B_ERROR;
|
||||
|
||||
// TODO: Implement software DPMS
|
||||
return B_ERROR;
|
||||
}
|
||||
@@ -2129,7 +2279,7 @@ uint32 ViewDriver::DPMSCapabilities(void) const
|
||||
|
||||
status_t ViewDriver::GetDeviceInfo(accelerant_device_info *info)
|
||||
{
|
||||
if(!info)
|
||||
if(!info || !is_initialized)
|
||||
return B_ERROR;
|
||||
|
||||
// We really don't have to provide anything here because this is strictly
|
||||
@@ -2147,7 +2297,7 @@ status_t ViewDriver::GetDeviceInfo(accelerant_device_info *info)
|
||||
|
||||
status_t ViewDriver::GetModeList(display_mode **modes, uint32 *count)
|
||||
{
|
||||
if(!count)
|
||||
if(!count || !is_initialized)
|
||||
return B_ERROR;
|
||||
|
||||
screenwin->Lock();
|
||||
@@ -2214,16 +2364,25 @@ status_t ViewDriver::GetModeList(display_mode **modes, uint32 *count)
|
||||
|
||||
status_t ViewDriver::GetPixelClockLimits(display_mode *mode, uint32 *low, uint32 *high)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return B_ERROR;
|
||||
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
status_t ViewDriver::GetTimingConstraints(display_timing_constraints *dtc)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return B_ERROR;
|
||||
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
status_t ViewDriver::ProposeMode(display_mode *candidate, const display_mode *low, const display_mode *high)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return B_ERROR;
|
||||
|
||||
// TODO: Unhack
|
||||
|
||||
// We should be able to get away with this because we're not dealing with any
|
||||
@@ -2234,6 +2393,9 @@ status_t ViewDriver::ProposeMode(display_mode *candidate, const display_mode *lo
|
||||
|
||||
status_t ViewDriver::WaitForRetrace(bigtime_t timeout=B_INFINITE_TIMEOUT)
|
||||
{
|
||||
if(!is_initialized)
|
||||
return B_ERROR;
|
||||
|
||||
// Locking shouldn't be necessary here - R5 should handle this for us. :)
|
||||
BScreen screen;
|
||||
return screen.WaitForRetrace(timeout);
|
||||
|
||||
@@ -96,7 +96,7 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i
|
||||
_decorator = NULL;
|
||||
|
||||
if (feel == B_NO_BORDER_WINDOW_LOOK){
|
||||
_full = _win->top_layer->_full;
|
||||
_full = _win->fTopLayer->_full;
|
||||
fDecFull = NULL;
|
||||
fDecFullVisible = NULL;
|
||||
fDecVisible = NULL;
|
||||
@@ -109,8 +109,8 @@ WinBorder::WinBorder(const BRect &r, const char *name, const int32 look, const i
|
||||
|
||||
_decorator->GetFootprint( fDecFull );
|
||||
|
||||
// our full region is the union between decorator's region and top_layer's region
|
||||
_full = _win->top_layer->_full;
|
||||
// our full region is the union between decorator's region and fTopLayer's region
|
||||
_full = _win->fTopLayer->_full;
|
||||
_full.Include( fDecFull );
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ void WinBorder::MouseDown(int8 *buffer)
|
||||
BRect helpRect(pt.x, pt.y, pt.x+1, pt.y+1);
|
||||
msg.what = B_MOUSE_DOWN;
|
||||
msg.AddInt64("when", real_time_clock_usecs());
|
||||
msg.AddPoint("where", (_win->top_layer->LayerAt(pt)->ConvertFromTop(helpRect)).LeftTop() );
|
||||
msg.AddPoint("where", (_win->fTopLayer->LayerAt(pt)->ConvertFromTop(helpRect)).LeftTop() );
|
||||
msg.AddInt32("modifiers", modifiers);
|
||||
msg.AddInt32("buttons", buttons);
|
||||
msg.AddInt32("clicks", 1);
|
||||
@@ -246,7 +246,7 @@ void WinBorder::MouseMoved(int8 *buffer)
|
||||
BRect helpRect(pt.x, pt.y, pt.x+1, pt.y+1);
|
||||
msg.what = B_MOUSE_MOVED;
|
||||
msg.AddInt64("when", real_time_clock_usecs());
|
||||
msg.AddPoint("where", (_win->top_layer->ConvertFromTop(helpRect)).LeftTop() );
|
||||
msg.AddPoint("where", (_win->fTopLayer->ConvertFromTop(helpRect)).LeftTop() );
|
||||
msg.AddInt32("buttons", buttons);
|
||||
|
||||
_win->SendMessageToClient( &msg );
|
||||
@@ -311,7 +311,7 @@ STRACE_MOUSE(("WinBorder %s: MouseUp() \n",GetName()));
|
||||
BRect helpRect(pt.x, pt.y, pt.x+1, pt.y+1);
|
||||
msg.what = B_MOUSE_UP;
|
||||
msg.AddInt64("when", real_time_clock_usecs());
|
||||
msg.AddPoint("where", (_win->top_layer->LayerAt(pt)->ConvertFromTop(helpRect)).LeftTop() );
|
||||
msg.AddPoint("where", (_win->fTopLayer->LayerAt(pt)->ConvertFromTop(helpRect)).LeftTop() );
|
||||
msg.AddInt32("modifiers", modifiers);
|
||||
|
||||
_win->SendMessageToClient( &msg );
|
||||
@@ -373,25 +373,25 @@ void WinBorder::RebuildRegions( const BRect& r ){
|
||||
}
|
||||
|
||||
// rebuild top_layer:
|
||||
if ( _win->top_layer->_full.Intersects( r ) ){
|
||||
if ( _win->fTopLayer->_full.Intersects( r ) ){
|
||||
// build top_layer's visible region by intersecting its _full with winborder's _visible region.
|
||||
_win->top_layer->_visible = _win->top_layer->_full;
|
||||
_win->top_layer->_visible.IntersectWith( &(_visible) );
|
||||
_win->fTopLayer->_visible = _win->fTopLayer->_full;
|
||||
_win->fTopLayer->_visible.IntersectWith( &(_visible) );
|
||||
|
||||
// then exclude it from winborder's _visible...
|
||||
_visible.Exclude( &(_win->top_layer->_visible) );
|
||||
_visible.Exclude( &(_win->fTopLayer->_visible) );
|
||||
|
||||
_win->top_layer->_fullVisible = _win->top_layer->_visible;
|
||||
_win->fTopLayer->_fullVisible = _win->fTopLayer->_visible;
|
||||
|
||||
// Rebuild regions for children...
|
||||
for(Layer *lay = _win->top_layer->_bottomchild; lay != NULL; lay = lay->_uppersibling){
|
||||
for(Layer *lay = _win->fTopLayer->_bottomchild; lay != NULL; lay = lay->_uppersibling){
|
||||
if ( !(lay->_hidden) ){
|
||||
lay->RebuildRegions( r );
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
_visible.Exclude( &(_win->top_layer->_fullVisible) );
|
||||
_visible.Exclude( &(_win->fTopLayer->_fullVisible) );
|
||||
}
|
||||
|
||||
// rebuild decorator.
|
||||
@@ -431,9 +431,9 @@ printf("#WinBorder(%s)::Draw() ENDED\n", GetName());
|
||||
|
||||
// draw the top_layer
|
||||
reg.Set( r );
|
||||
reg.IntersectWith( &(_win->top_layer->_visible) );
|
||||
reg.IntersectWith( &(_win->fTopLayer->_visible) );
|
||||
if (reg.CountRects() > 0){
|
||||
_win->top_layer->RequestClientUpdate( reg.Frame() );
|
||||
_win->fTopLayer->RequestClientUpdate( reg.Frame() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,8 +445,8 @@ void WinBorder::MoveBy(float x, float y)
|
||||
_frame.OffsetBy(x, y);
|
||||
_full.OffsetBy(x, y);
|
||||
|
||||
_win->top_layer->_frame.OffsetBy(x, y);
|
||||
_win->top_layer->MoveRegionsBy(x, y);
|
||||
_win->fTopLayer->_frame.OffsetBy(x, y);
|
||||
_win->fTopLayer->MoveRegionsBy(x, y);
|
||||
|
||||
if (_decorator){
|
||||
// allow decorator to make its internal calculations.
|
||||
@@ -526,9 +526,9 @@ void WinBorder::ResizeBy(float x, float y)
|
||||
_frame.right = _frame.right + x;
|
||||
_frame.bottom = _frame.bottom + y;
|
||||
|
||||
_win->top_layer->ResizeRegionsBy(x, y);
|
||||
_win->fTopLayer->ResizeRegionsBy(x, y);
|
||||
|
||||
_full = _win->top_layer->_full;
|
||||
_full = _win->fTopLayer->_full;
|
||||
|
||||
if (_decorator){
|
||||
// allow decorator to make its internal calculations.
|
||||
|
||||
Reference in New Issue
Block a user