new desktop management code
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6057 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -38,7 +38,6 @@
|
||||
#include <Message.h>
|
||||
#include "AppServer.h"
|
||||
#include "ColorSet.h"
|
||||
#include "Desktop.h"
|
||||
#include "DisplayDriver.h"
|
||||
#include "ServerApp.h"
|
||||
#include "ServerCursor.h"
|
||||
@@ -50,6 +49,7 @@
|
||||
#include "CursorManager.h"
|
||||
#include "Utils.h"
|
||||
#include "FontServer.h"
|
||||
#include "Desktop.h"
|
||||
|
||||
//#define DEBUG_KEYHANDLING
|
||||
#ifdef DEBUG_KEYHANDLING
|
||||
@@ -60,6 +60,8 @@
|
||||
#endif
|
||||
// Globals
|
||||
|
||||
Desktop* desktop;
|
||||
|
||||
//! Used to access the app_server from new_decorator
|
||||
AppServer *app_server=NULL;
|
||||
|
||||
@@ -81,14 +83,14 @@ AppServer::AppServer(void) : BApplication (SERVER_SIGNATURE)
|
||||
AppServer::AppServer(void)
|
||||
#endif
|
||||
{
|
||||
_mouseport=create_port(200,SERVER_INPUT_PORT);
|
||||
_messageport=create_port(200,SERVER_PORT_NAME);
|
||||
_mouseport = create_port(200,SERVER_INPUT_PORT);
|
||||
_messageport = create_port(200,SERVER_PORT_NAME);
|
||||
|
||||
_applist=new BList(0);
|
||||
_quitting_server=false;
|
||||
_exit_poller=false;
|
||||
_ssindex=1;
|
||||
make_decorator=NULL;
|
||||
_applist = new BList(0);
|
||||
_quitting_server= false;
|
||||
_exit_poller = false;
|
||||
_ssindex = 1;
|
||||
make_decorator = NULL;
|
||||
|
||||
// Create the font server and scan the proper directories.
|
||||
fontserver=new FontServer;
|
||||
@@ -123,40 +125,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");
|
||||
_active_lock = 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");
|
||||
_applist_lock = 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");
|
||||
_decor_lock = create_sem(1,"app_server_decor_sem");
|
||||
|
||||
// Get the driver first - Poller thread utilizes the thing
|
||||
_driver=desktop->GetGfxDriver();
|
||||
|
||||
// Spawn our input-polling thread
|
||||
_poller_id=spawn_thread(PollerThread, "Poller", B_NORMAL_PRIORITY, this);
|
||||
_poller_id = spawn_thread(PollerThread, "Poller", B_NORMAL_PRIORITY, this);
|
||||
if (_poller_id >= 0)
|
||||
resume_thread(_poller_id);
|
||||
|
||||
// Spawn our thread-monitoring thread
|
||||
_picasso_id = spawn_thread(PicassoThread,"Picasso", B_NORMAL_PRIORITY, this);
|
||||
_picasso_id = spawn_thread(PicassoThread,"Picasso", B_NORMAL_PRIORITY, this);
|
||||
if (_picasso_id >= 0)
|
||||
resume_thread(_picasso_id);
|
||||
|
||||
_active_app=-1;
|
||||
_p_active_app=NULL;
|
||||
decorator_name="Default";
|
||||
decorator_name = "Default";
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -183,6 +181,8 @@ AppServer::~AppServer(void)
|
||||
delete bitmapmanager;
|
||||
delete cursormanager;
|
||||
|
||||
delete desktop;
|
||||
|
||||
// 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.
|
||||
@@ -192,8 +192,6 @@ AppServer::~AppServer(void)
|
||||
delete fontserver;
|
||||
|
||||
make_decorator=NULL;
|
||||
delete desktop;
|
||||
desktop=NULL;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -204,10 +202,10 @@ 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);
|
||||
PortMessage *msg;
|
||||
|
||||
AppServer *appserver = (AppServer*)data;
|
||||
PortQueue mousequeue(appserver->_mouseport);
|
||||
PortMessage *msg;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
if(!mousequeue.MessagesWaiting())
|
||||
@@ -215,10 +213,10 @@ int32 AppServer::PollerThread(void *data)
|
||||
else
|
||||
mousequeue.GetMessagesFromPort(false);
|
||||
|
||||
msg=mousequeue.GetMessageFromQueue();
|
||||
msg = mousequeue.GetMessageFromQueue();
|
||||
if(!msg)
|
||||
continue;
|
||||
|
||||
|
||||
switch(msg->Code())
|
||||
{
|
||||
// We don't need to do anything with these two, so just pass them
|
||||
@@ -227,44 +225,18 @@ int32 AppServer::PollerThread(void *data)
|
||||
case B_MOUSE_DOWN:
|
||||
case B_MOUSE_UP:
|
||||
case B_MOUSE_WHEEL_CHANGED:
|
||||
{
|
||||
if(!msg->Buffer())
|
||||
break;
|
||||
ServerWindow::HandleMouseEvent(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
// Process the cursor and then pass it on
|
||||
case B_MOUSE_MOVED:
|
||||
{
|
||||
// Attached data:
|
||||
// 1) int64 - time of mouse click
|
||||
// 2) float - x coordinate of mouse click
|
||||
// 3) float - y coordinate of mouse click
|
||||
// 4) int32 - buttons down
|
||||
|
||||
int64 dummy;
|
||||
float tempx=0,tempy=0;
|
||||
|
||||
msg->Read<int64>(&dummy);
|
||||
msg->Read<float>(&tempx);
|
||||
msg->Read<float>(&tempy);
|
||||
msg->Rewind();
|
||||
|
||||
if(appserver->_driver)
|
||||
{
|
||||
appserver->_driver->MoveCursorTo(tempx,tempy);
|
||||
ServerWindow::HandleMouseEvent(msg);
|
||||
}
|
||||
desktop->MouseEventHandler(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
case B_KEY_DOWN:
|
||||
case B_KEY_UP:
|
||||
case B_UNMAPPED_KEY_DOWN:
|
||||
case B_UNMAPPED_KEY_UP:
|
||||
case B_MODIFIERS_CHANGED:
|
||||
appserver->HandleKeyMessage(msg->Code(),(int8*)msg->Buffer());
|
||||
desktop->KeyboardEventHandler(msg);
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Server::Poller received unexpected code %lx\n",msg->Code());
|
||||
break;
|
||||
@@ -285,15 +257,15 @@ int32 AppServer::PollerThread(void *data)
|
||||
*/
|
||||
int32 AppServer::PicassoThread(void *data)
|
||||
{
|
||||
int32 i;
|
||||
AppServer *appserver=(AppServer*)data;
|
||||
ServerApp *app;
|
||||
int32 i;
|
||||
AppServer *appserver = (AppServer*)data;
|
||||
ServerApp *app;
|
||||
for(;;)
|
||||
{
|
||||
acquire_sem(appserver->_applist_lock);
|
||||
for(i=0;i<appserver->_applist->CountItems(); i++)
|
||||
for(i = 0; i < appserver->_applist->CountItems(); i++)
|
||||
{
|
||||
app=(ServerApp*)appserver->_applist->ItemAt(i);
|
||||
app = (ServerApp*)appserver->_applist->ItemAt(i);
|
||||
if(!app)
|
||||
{
|
||||
printf("PANIC: NULL app in app list\n");
|
||||
@@ -328,13 +300,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(;;)
|
||||
{
|
||||
if(pmsg.ReadFromPort(_messageport)==B_OK)
|
||||
if(pmsg.ReadFromPort(_messageport) == B_OK)
|
||||
{
|
||||
if(pmsg.Protocol()==B_QUIT_REQUESTED)
|
||||
if(pmsg.Protocol() == B_QUIT_REQUESTED)
|
||||
pmsg.SetCode(B_QUIT_REQUESTED);
|
||||
|
||||
switch(pmsg.Code())
|
||||
@@ -364,13 +336,10 @@ 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(_quitting_server == true && _applist->CountItems() == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Make sure our polling thread has exited
|
||||
if(find_thread("Poller")!=B_NAME_NOT_FOUND)
|
||||
kill_thread(_poller_id);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -392,16 +361,16 @@ bool AppServer::LoadDecorator(const char *path)
|
||||
// internal one
|
||||
if(!path)
|
||||
{
|
||||
make_decorator=NULL;
|
||||
make_decorator = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
create_decorator *pcreatefunc=NULL;
|
||||
status_t stat;
|
||||
image_id addon;
|
||||
create_decorator *pcreatefunc = NULL;
|
||||
status_t stat;
|
||||
image_id addon;
|
||||
|
||||
addon=load_add_on(path);
|
||||
if(addon<0)
|
||||
addon = load_add_on(path);
|
||||
if(addon < 0)
|
||||
return false;
|
||||
|
||||
// As of now, we do nothing with decorator versions, but the possibility exists
|
||||
@@ -410,19 +379,18 @@ 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);
|
||||
if(stat!=B_OK)
|
||||
{
|
||||
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();
|
||||
BPath temppath(path);
|
||||
decorator_name = temppath.Leaf();
|
||||
|
||||
acquire_sem(_decor_lock);
|
||||
make_decorator=pcreatefunc;
|
||||
_decorator_id=addon;
|
||||
make_decorator = pcreatefunc;
|
||||
_decorator_id = addon;
|
||||
release_sem(_decor_lock);
|
||||
return true;
|
||||
}
|
||||
@@ -477,17 +445,23 @@ void AppServer::DispatchMessage(PortMessage *msg)
|
||||
|
||||
// Attached data:
|
||||
// 1) port_id - receiver port of a regular app
|
||||
// 2) int32 - handler token of the regular app
|
||||
// 2) char * - signature of the regular app
|
||||
// 3) port_id - port to reply to
|
||||
// 2) port_id - client looper port - for send messages to the client
|
||||
// 2) team_id - app's team ID
|
||||
// 3) int32 - handler token of the regular app
|
||||
// 4) char * - signature of the regular app
|
||||
// 5) port_id - port to reply to
|
||||
|
||||
// Find the necessary data
|
||||
port_id reply_port;
|
||||
port_id app_port;
|
||||
int32 htoken;
|
||||
char *app_signature;
|
||||
team_id clientTeamID;
|
||||
port_id clientLooperPort;
|
||||
port_id reply_port;
|
||||
port_id app_port;
|
||||
int32 htoken;
|
||||
char* app_signature;
|
||||
|
||||
msg->Read<int32>(&app_port);
|
||||
msg->Read<port_id>(&app_port);
|
||||
msg->Read<port_id>(&clientLooperPort);
|
||||
msg->Read<team_id>(&clientTeamID);
|
||||
msg->Read<int32>(&htoken);
|
||||
msg->ReadString(&app_signature);
|
||||
msg->Read<int32>(&reply_port);
|
||||
@@ -495,22 +469,21 @@ void AppServer::DispatchMessage(PortMessage *msg)
|
||||
// Create the ServerApp subthread for this app
|
||||
acquire_sem(_applist_lock);
|
||||
|
||||
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);
|
||||
printf("No more ports left. Time to crash. Have a nice day! :)\n");
|
||||
break;
|
||||
}
|
||||
ServerApp *newapp=new ServerApp(app_port,r,htoken,app_signature);
|
||||
ServerApp *newapp;
|
||||
newapp = new ServerApp(app_port, r, clientLooperPort, clientTeamID, htoken, app_signature);
|
||||
|
||||
// add the new ServerApp to the known list of ServerApps
|
||||
_applist->AddItem(newapp);
|
||||
|
||||
release_sem(_applist_lock);
|
||||
|
||||
acquire_sem(_active_lock);
|
||||
_p_active_app=newapp;
|
||||
_active_app=_applist->CountItems()-1;
|
||||
|
||||
PortLink replylink(reply_port);
|
||||
replylink.SetOpCode(AS_SET_SERVER_PORT);
|
||||
replylink.Attach<int32>(newapp->_receiver);
|
||||
@@ -518,10 +491,7 @@ void AppServer::DispatchMessage(PortMessage *msg)
|
||||
|
||||
// This is necessary because PortLink::ReadString allocates memory
|
||||
delete app_signature;
|
||||
|
||||
release_sem(_active_lock);
|
||||
|
||||
newapp->Run();
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_DELETE_APP:
|
||||
@@ -532,47 +502,32 @@ void AppServer::DispatchMessage(PortMessage *msg)
|
||||
// Attached Data:
|
||||
// 1) thread_id - thread ID of the ServerApp to be deleted
|
||||
|
||||
int32 i, appnum=_applist->CountItems();
|
||||
ServerApp *srvapp;
|
||||
thread_id srvapp_id;
|
||||
int32 i,
|
||||
appnum = _applist->CountItems();
|
||||
ServerApp *srvapp;
|
||||
|
||||
thread_id srvapp_id;
|
||||
msg->Read<thread_id>(&srvapp_id);
|
||||
|
||||
|
||||
acquire_sem(_applist_lock);
|
||||
|
||||
// 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 *)_applist->ItemAt(i);
|
||||
|
||||
if(srvapp!=NULL && srvapp->_monitor_thread==srvapp_id)
|
||||
if(srvapp != NULL && srvapp->_monitor_thread == srvapp_id)
|
||||
{
|
||||
acquire_sem(_applist_lock);
|
||||
srvapp=(ServerApp *)_applist->RemoveItem(i);
|
||||
if(srvapp)
|
||||
{
|
||||
srvapp = (ServerApp *)_applist->RemoveItem(i);
|
||||
if(srvapp){
|
||||
delete srvapp;
|
||||
srvapp=NULL;
|
||||
srvapp = NULL;
|
||||
}
|
||||
release_sem(_applist_lock);
|
||||
acquire_sem(_active_lock);
|
||||
|
||||
if(_applist->CountItems()==0)
|
||||
{
|
||||
// active==-1 signifies that no other apps are running - NOT good
|
||||
_active_app=-1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// we actually still have apps running, so make a new one active
|
||||
if(_active_app>0)
|
||||
_active_app--;
|
||||
else
|
||||
_active_app=0;
|
||||
}
|
||||
_p_active_app=(_active_app>-1)?(ServerApp*)_applist->ItemAt(_active_app):NULL;
|
||||
release_sem(_active_lock);
|
||||
break; // jump out of our for() loop
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
release_sem(_applist_lock);
|
||||
break;
|
||||
}
|
||||
case AS_UPDATED_CLIENT_FONTLIST:
|
||||
@@ -723,14 +678,34 @@ 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);
|
||||
|
||||
// So when we delete the last ServerApp, we can exit the server
|
||||
_quitting_server=true;
|
||||
_exit_poller=true;
|
||||
// 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++)
|
||||
{
|
||||
app = (ServerApp*)_applist->ItemAt(i);
|
||||
if(!app)
|
||||
{ printf("PANIC in AppServer::Broadcast()\n"); continue; }
|
||||
|
||||
wait_for_thread(app->_monitor_thread, &rv);
|
||||
}
|
||||
release_sem(_applist_lock);
|
||||
|
||||
// When we delete the last ServerApp, we can exit the server
|
||||
_quitting_server = true;
|
||||
_exit_poller = true;
|
||||
// also wait for picasso thread
|
||||
wait_for_thread(_picasso_id, &rv);
|
||||
// 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);
|
||||
// we are now clear to exit
|
||||
break;
|
||||
}
|
||||
case AS_SET_SYSCURSOR_DEFAULTS:
|
||||
@@ -752,15 +727,14 @@ void AppServer::DispatchMessage(PortMessage *msg)
|
||||
*/
|
||||
void AppServer::Broadcast(int32 code)
|
||||
{
|
||||
int32 i;
|
||||
ServerApp *app;
|
||||
ServerApp *app = NULL;
|
||||
|
||||
acquire_sem(_applist_lock);
|
||||
for(i=0;i<_applist->CountItems(); i++)
|
||||
for(int32 i = 0; i < _applist->CountItems(); i++)
|
||||
{
|
||||
app=(ServerApp*)_applist->ItemAt(i);
|
||||
app = (ServerApp*)_applist->ItemAt(i);
|
||||
if(!app)
|
||||
continue;
|
||||
{ printf("PANIC in AppServer::Broadcast()\n"); continue; }
|
||||
app->PostMessage(code, sizeof(int32), (int8*)&code);
|
||||
}
|
||||
release_sem(_applist_lock);
|
||||
@@ -824,7 +798,7 @@ void AppServer::HandleKeyMessage(int32 code, int8 *buffer)
|
||||
if(modifiers & B_CONTROL_KEY)
|
||||
{
|
||||
STRACE(("Set Workspace %ld\n",scancode-1));
|
||||
desktop->SetWorkspace(scancode-2);
|
||||
//TODO: change SetWorkspace(scancode-2);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -878,7 +852,7 @@ void AppServer::HandleKeyMessage(int32 code, int8 *buffer)
|
||||
if(modifiers & (B_LEFT_SHIFT_KEY | B_LEFT_CONTROL_KEY))
|
||||
{
|
||||
STRACE(("Set Workspace %ld\n",scancode-1));
|
||||
desktop->SetWorkspace(scancode-2);
|
||||
//TODO: resolve SetWorkspace(scancode-2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1080,11 +1054,13 @@ Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel
|
||||
int32 wflags, DisplayDriver *ddriver)
|
||||
{
|
||||
Decorator *dec=NULL;
|
||||
if(!app_server->make_decorator)
|
||||
// Temporary solution!
|
||||
dec=new DefaultDecorator(rect,wlook,wfeel,wflags);
|
||||
/* 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);
|
||||
@@ -1101,15 +1077,18 @@ Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel
|
||||
\param argv String array of the command-line arguments
|
||||
\return -1 if the app_server is already running, 0 if everything's OK.
|
||||
*/
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
// There can be only one....
|
||||
if(find_port(SERVER_PORT_NAME)!=B_NAME_NOT_FOUND)
|
||||
return -1;
|
||||
|
||||
app_server=new AppServer();
|
||||
// why on the heap?
|
||||
/* app_server=new AppServer();
|
||||
app_server->Run();
|
||||
delete app_server;
|
||||
*/
|
||||
AppServer app_server;
|
||||
app_server.Run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -34,37 +34,52 @@ class AppServer : public BApplication
|
||||
#endif
|
||||
{
|
||||
public:
|
||||
AppServer(void);
|
||||
~AppServer(void);
|
||||
static int32 PollerThread(void *data);
|
||||
static int32 PicassoThread(void *data);
|
||||
thread_id Run(void);
|
||||
void MainLoop(void);
|
||||
bool LoadDecorator(const char *path);
|
||||
void InitDecorators(void);
|
||||
void DispatchMessage(PortMessage *msg);
|
||||
void Broadcast(int32 code);
|
||||
void HandleKeyMessage(int32 code, int8 *buffer);
|
||||
ServerApp *FindApp(const char *sig);
|
||||
AppServer(void);
|
||||
~AppServer(void);
|
||||
|
||||
static int32 PollerThread(void *data);
|
||||
static int32 PicassoThread(void *data);
|
||||
thread_id Run(void);
|
||||
void MainLoop(void);
|
||||
|
||||
bool LoadDecorator(const char *path);
|
||||
void InitDecorators(void);
|
||||
|
||||
void DispatchMessage(PortMessage *msg);
|
||||
void Broadcast(int32 code);
|
||||
// TODO: remove shortly!
|
||||
void HandleKeyMessage(int32 code, int8 *buffer);
|
||||
|
||||
ServerApp* FindApp(const char *sig);
|
||||
|
||||
private:
|
||||
friend Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel,
|
||||
int32 wflags, DisplayDriver *ddriver);
|
||||
friend Decorator* new_decorator(BRect rect, const char *title,
|
||||
int32 wlook, int32 wfeel,
|
||||
int32 wflags, DisplayDriver *ddriver);
|
||||
|
||||
create_decorator *make_decorator; // global function pointer
|
||||
create_decorator *make_decorator; // global function pointer
|
||||
|
||||
port_id _messageport,_mouseport;
|
||||
image_id _decorator_id;
|
||||
BString decorator_name;
|
||||
bool _quitting_server;
|
||||
BList *_applist;
|
||||
int32 _active_app;
|
||||
ServerApp *_p_active_app;
|
||||
thread_id _poller_id, _picasso_id;
|
||||
port_id _messageport,
|
||||
_mouseport;
|
||||
|
||||
sem_id _active_lock, _applist_lock, _decor_lock;
|
||||
bool _exit_poller;
|
||||
DisplayDriver *_driver;
|
||||
int32 _ssindex;
|
||||
image_id _decorator_id;
|
||||
|
||||
BString decorator_name;
|
||||
|
||||
bool _quitting_server,
|
||||
_exit_poller;
|
||||
|
||||
BList *_applist;
|
||||
thread_id _poller_id,
|
||||
_picasso_id;
|
||||
|
||||
sem_id _active_lock,
|
||||
_applist_lock,
|
||||
_decor_lock;
|
||||
|
||||
DisplayDriver *_driver;
|
||||
|
||||
int32 _ssindex;
|
||||
};
|
||||
|
||||
Decorator *new_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel,
|
||||
|
||||
+253
-212
@@ -1,8 +1,10 @@
|
||||
#include "Desktop.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <Region.h>
|
||||
#include <Message.h>
|
||||
|
||||
#include "Desktop.h"
|
||||
#include "RootLayer.h"
|
||||
#include "ServerScreen.h"
|
||||
#include "Screen.h"
|
||||
#include "Layer.h"
|
||||
#include "PortMessage.h"
|
||||
#include "DisplayDriver.h"
|
||||
@@ -12,72 +14,66 @@
|
||||
#include "Workspace.h"
|
||||
#include "Globals.h"
|
||||
#include "ServerWindow.h"
|
||||
#include "ServerConfig.h"
|
||||
|
||||
#include <Region.h>
|
||||
#include <stdio.h>
|
||||
//#define REAL_MODE
|
||||
|
||||
Desktop *desktop=NULL;
|
||||
Desktop::Desktop(void){
|
||||
// desktop = this;
|
||||
|
||||
Desktop::Desktop(void)
|
||||
{
|
||||
fDragMessage = NULL;
|
||||
fActiveRootLayer = NULL;
|
||||
fFrontWinBorder = NULL;
|
||||
fFocusWinBorder = NULL;
|
||||
fActiveScreen = NULL;
|
||||
Init();
|
||||
fCursorScreen = NULL;
|
||||
}
|
||||
|
||||
Desktop::~Desktop(void)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
Desktop::~Desktop(void){
|
||||
//printf("~Desktop()\n");
|
||||
if (fDragMessage)
|
||||
delete fDragMessage;
|
||||
|
||||
void *ptr;
|
||||
for(int32 i=0; (ptr=fRootLayerList.ItemAt(i)); i++)
|
||||
void *ptr;
|
||||
for(int32 i=0; (ptr=fRootLayerList.ItemAt(i)); i++){
|
||||
delete (RootLayer*)ptr;
|
||||
}
|
||||
|
||||
for(int32 i=0; (ptr=fScreenList.ItemAt(i)); i++)
|
||||
for(int32 i=0; (ptr=fScreenList.ItemAt(i)); i++){
|
||||
delete (Screen*)ptr;
|
||||
}
|
||||
|
||||
for(int32 i=0; (ptr=fWinBorderList.ItemAt(i)); i++)
|
||||
for(int32 i=0; (ptr=fWinBorderList.ItemAt(i)); i++){
|
||||
delete (WinBorder*)ptr;
|
||||
}
|
||||
}
|
||||
|
||||
void Desktop::Init(void)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::Init(void){
|
||||
DisplayDriver *driver = NULL;
|
||||
int32 driverCount = 0;
|
||||
bool initDrivers = true;
|
||||
int32 driverCount = 0;
|
||||
bool initDrivers = true;
|
||||
|
||||
while(initDrivers)
|
||||
{
|
||||
#ifdef TEST_MODE
|
||||
driver = new ViewDriver();
|
||||
#else
|
||||
|
||||
// If we're using the AccelerantDriver for rendering, eventually we will loop through
|
||||
// drivers until one can't initialize in order to support multiple monitors. For now,
|
||||
// we'll just load one and be done with it.
|
||||
driver = new AccelerantDriver();
|
||||
#endif
|
||||
|
||||
if(driver->Initialize())
|
||||
{
|
||||
while(initDrivers){
|
||||
|
||||
#ifdef REAL_MODE
|
||||
// If we're using the AccelerantDriver for rendering, eventually we will loop through
|
||||
// drivers until one can't initialize in order to support multiple monitors. For now,
|
||||
// we'll just load one and be done with it.
|
||||
driver = new AccelerantDriver();
|
||||
#else
|
||||
driver = new ViewDriver();
|
||||
#endif
|
||||
|
||||
if(driver->Initialize()){
|
||||
driverCount++;
|
||||
|
||||
Screen *sc = new Screen(driver, BPoint(640, 480), B_RGB32, driverCount);
|
||||
|
||||
// TODO: be careful, it may fail to initialize! - Monitor may not support 640x480
|
||||
|
||||
Screen *sc = new Screen(driver, BPoint(640, 480), B_RGB32, driverCount);
|
||||
// TODO: be careful, it may fail to initialize! - Monitor may not support 640x480
|
||||
fScreenList.AddItem(sc);
|
||||
|
||||
// TODO: remove this when you have a real Driver.
|
||||
if (driverCount == 2)
|
||||
|
||||
// TODO: remove this when you have a real Driver.
|
||||
if (driverCount == 1)//2)
|
||||
initDrivers = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
else{
|
||||
driver->Shutdown();
|
||||
delete driver;
|
||||
driver = NULL;
|
||||
@@ -85,89 +81,77 @@ void Desktop::Init(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (driverCount < 1)
|
||||
if (driverCount < 1){
|
||||
delete this;
|
||||
}
|
||||
|
||||
InitMode();
|
||||
|
||||
|
||||
SetActiveRootLayerByIndex(0);
|
||||
}
|
||||
|
||||
void Desktop::InitMode(void)
|
||||
{
|
||||
// this is init mode for n-SS.
|
||||
for (int32 i=0; i<fScreenList.CountItems(); i++)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::InitMode(void){
|
||||
// this is init mode for n-SS.
|
||||
fCursorScreen = fScreenList.ItemAt(0)? (Screen*)fScreenList.ItemAt(0): NULL;
|
||||
for (int32 i=0; i<fScreenList.CountItems(); i++){
|
||||
char name[32];
|
||||
sprintf(name, "RootLayer %ld", i+1);
|
||||
|
||||
Screen *screens[1];
|
||||
screens[0] = (Screen*)fScreenList.ItemAt(i);
|
||||
|
||||
Screen *screens[1];
|
||||
screens[0]= (Screen*)fScreenList.ItemAt(i);
|
||||
|
||||
RootLayer *rl = new RootLayer(name, 4, this);
|
||||
RootLayer *rl = new RootLayer(name, 4, this);
|
||||
rl->SetScreens(screens, 1, 1);
|
||||
|
||||
fRootLayerList.AddItem(rl);
|
||||
}
|
||||
}
|
||||
|
||||
// Methods for multiple monitors.
|
||||
Screen* Desktop::ScreenAt(int32 index) const
|
||||
{
|
||||
// Methods for multiple monitors.
|
||||
//---------------------------------------------------------------------------
|
||||
Screen* Desktop::ScreenAt(int32 index) const{
|
||||
Screen *sc;
|
||||
sc = static_cast<Screen*>(fScreenList.ItemAt(index));
|
||||
sc = static_cast<Screen*>(fScreenList.ItemAt(index));
|
||||
|
||||
return sc;
|
||||
}
|
||||
|
||||
int32 Desktop::ScreenCount(void) const
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
int32 Desktop::ScreenCount() const{
|
||||
return fScreenList.CountItems();
|
||||
}
|
||||
|
||||
void Desktop::SetActiveScreen(int32 index)
|
||||
{
|
||||
if(index<0 || index>fScreenList.CountItems()-1)
|
||||
return;
|
||||
|
||||
// TODO: Once we get multiple monitor support going officially, we'll likely
|
||||
// need to do something with the cursor here.
|
||||
|
||||
fActiveScreen=(Screen*)fScreenList.ItemAt(index);
|
||||
//---------------------------------------------------------------------------
|
||||
Screen* Desktop::CursorScreen() const{
|
||||
return fCursorScreen;
|
||||
}
|
||||
|
||||
void Desktop::SetActiveRootLayerByIndex(int32 listIndex)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::SetActiveRootLayerByIndex(int32 listIndex){
|
||||
RootLayer *rl;
|
||||
rl = RootLayerAt(listIndex);
|
||||
rl = RootLayerAt(listIndex);
|
||||
if (rl)
|
||||
SetActiveRootLayer(rl);
|
||||
}
|
||||
|
||||
void Desktop::SetActiveRootLayer(RootLayer* rl)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::SetActiveRootLayer(RootLayer* rl){
|
||||
if (fActiveRootLayer == rl)
|
||||
return;
|
||||
|
||||
fActiveRootLayer = rl;
|
||||
|
||||
// also set he new front and focus
|
||||
// also set he new front and focus
|
||||
SetFrontWinBorder(fActiveRootLayer->ActiveWorkspace()->FrontLayer());
|
||||
SetFocusWinBorder(fActiveRootLayer->ActiveWorkspace()->FocusLayer());
|
||||
|
||||
// TODO: other tasks required when this happens. I don't know them now.
|
||||
// Rebuild & Invalidate
|
||||
// hide the mouse in the old ActiveRootLayer
|
||||
// show the mouse in new ActiveRootLayer
|
||||
// TODO: other tasks required when this happens. I don't know them now.
|
||||
// Rebuild & Invalidate
|
||||
// hide the mouse in the old ActiveRootLayer
|
||||
// show the mouse in new ActiveRootLayer
|
||||
}
|
||||
|
||||
RootLayer* Desktop::ActiveRootLayer(void) const
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
RootLayer* Desktop::ActiveRootLayer() const{
|
||||
return fActiveRootLayer;
|
||||
}
|
||||
|
||||
int32 Desktop::ActiveRootLayerIndex(void) const
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
int32 Desktop::ActiveRootLayerIndex() const{
|
||||
int32 rootLayerCount = CountRootLayers();
|
||||
for(int32 i=0; i<rootLayerCount; i++){
|
||||
if(fActiveRootLayer == (RootLayer*)(fRootLayerList.ItemAt(i)))
|
||||
@@ -175,106 +159,189 @@ int32 Desktop::ActiveRootLayerIndex(void) const
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
RootLayer* Desktop::RootLayerAt(int32 index)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
RootLayer* Desktop::RootLayerAt(int32 index){
|
||||
RootLayer *rl;
|
||||
rl = static_cast<RootLayer*>(fRootLayerList.ItemAt(index));
|
||||
rl = static_cast<RootLayer*>(fRootLayerList.ItemAt(index));
|
||||
|
||||
return rl;
|
||||
}
|
||||
|
||||
int32 Desktop::CountRootLayers(void) const{
|
||||
//---------------------------------------------------------------------------
|
||||
int32 Desktop::CountRootLayers() const{
|
||||
return fRootLayerList.CountItems();
|
||||
}
|
||||
|
||||
// Methods for layer(WinBorder) manipulation.
|
||||
|
||||
void Desktop::AddWinBorder(WinBorder* winBorder)
|
||||
{
|
||||
DisplayDriver* Desktop::GetDisplayDriver() const{
|
||||
return ScreenAt(0)->DDriver();
|
||||
}
|
||||
// Methods for layer(WinBorder) manipulation.
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::AddWinBorder(WinBorder* winBorder){
|
||||
if(fWinBorderList.HasItem(winBorder))
|
||||
return;
|
||||
|
||||
// special case for Tracker background window.
|
||||
if (winBorder->GetServerFeel() == B_SYSTEM_LAST)
|
||||
{
|
||||
// it's added in all RottLayers
|
||||
for(int32 i=0; i<fRootLayerList.CountItems(); i++)
|
||||
{
|
||||
// special case for Tracker background window.
|
||||
if (winBorder->_level == B_SYSTEM_LAST){
|
||||
// it's added in all RottLayers
|
||||
for(int32 i=0; i<fRootLayerList.CountItems(); i++){
|
||||
((RootLayer*)fRootLayerList.ItemAt(i))->AddWinBorder(winBorder);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// other windows are added to the current RootLayer only.
|
||||
else
|
||||
ActiveRootLayer()->AddWinBorder(winBorder);
|
||||
}
|
||||
|
||||
// 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();
|
||||
fWinBorderList.AddItem(winBorder);
|
||||
fLayerLock.Unlock();
|
||||
|
||||
SetFrontWinBorder(fActiveRootLayer->ActiveWorkspace()->FrontLayer());
|
||||
SetFocusWinBorder(fActiveRootLayer->ActiveWorkspace()->FocusLayer());
|
||||
}
|
||||
|
||||
void Desktop::RemoveWinBorder(WinBorder* winBorder)
|
||||
{
|
||||
if(winBorder->GetServerFeel() == B_SYSTEM_LAST)
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::RemoveWinBorder(WinBorder* winBorder){
|
||||
if(winBorder->_level == B_SYSTEM_LAST){
|
||||
for(int32 i=0; i<fRootLayerList.CountItems(); i++)
|
||||
((RootLayer*)fRootLayerList.ItemAt(i))->RemoveWinBorder(winBorder);
|
||||
else
|
||||
}
|
||||
else{
|
||||
winBorder->GetRootLayer()->RemoveWinBorder(winBorder);
|
||||
}
|
||||
|
||||
if (winBorder == fFrontWinBorder)
|
||||
SetFrontWinBorder(fActiveRootLayer->ActiveWorkspace()->FrontLayer());
|
||||
|
||||
if (winBorder == fFocusWinBorder)
|
||||
SetFocusWinBorder(fActiveRootLayer->ActiveWorkspace()->FocusLayer());
|
||||
|
||||
fLayerLock.Lock();
|
||||
fWinBorderList.RemoveItem(winBorder);
|
||||
fLayerLock.Unlock();
|
||||
}
|
||||
|
||||
bool Desktop::HasWinBorder(WinBorder* winBorder)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
bool Desktop::HasWinBorder(WinBorder* winBorder){
|
||||
return fWinBorderList.HasItem(winBorder);
|
||||
}
|
||||
|
||||
void Desktop::SetFrontWinBorder(WinBorder* winBorder)
|
||||
{
|
||||
// TODO: implement
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::SetFrontWinBorder(WinBorder* winBorder){
|
||||
fFrontWinBorder = winBorder;
|
||||
// TODO: implement
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::SetFocusWinBorder(WinBorder* winBorder){
|
||||
if (fFocusWinBorder == winBorder && (winBorder && !winBorder->IsHidden()))
|
||||
return;
|
||||
|
||||
void Desktop::SetFocusWinBorder(WinBorder* winBorder)
|
||||
{
|
||||
// TODO: implement
|
||||
fFocusWinBorder = winBorder;
|
||||
// NOTE: we assume both, the old and new focus layer are in the active workspace
|
||||
WinBorder *newFocus = NULL;
|
||||
|
||||
if(fFocusWinBorder){
|
||||
fFocusWinBorder->SetFocus(false);
|
||||
}
|
||||
|
||||
if(winBorder){
|
||||
newFocus = winBorder->GetRootLayer()->ActiveWorkspace()->SetFocusLayer(winBorder);
|
||||
newFocus->SetFocus(true);
|
||||
}
|
||||
|
||||
fFocusWinBorder = newFocus;
|
||||
}
|
||||
|
||||
WinBorder* Desktop::FrontWinBorder(void) const
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
WinBorder* Desktop::FrontWinBorder(void) const{
|
||||
return fActiveRootLayer->ActiveWorkspace()->FrontLayer();
|
||||
// return fFrontWinBorder;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
WinBorder* Desktop::FocusWinBorder(void) const{
|
||||
// return fActiveRootLayer->ActiveWorkspace()->FocusLayer();
|
||||
return fFocusWinBorder;
|
||||
}
|
||||
|
||||
WinBorder* Desktop::FocusWinBorder(void) const
|
||||
{
|
||||
return fActiveRootLayer->ActiveWorkspace()->FocusLayer();
|
||||
// Input related methods
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::MouseEventHandler(PortMessage *msg){
|
||||
switch(msg->Code()){
|
||||
case B_MOUSE_DOWN:{
|
||||
// Attached data:
|
||||
// 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
|
||||
|
||||
BPoint pt;
|
||||
int64 dummy;
|
||||
msg->Read<int64>(&dummy);
|
||||
msg->Read<float>(&pt.x);
|
||||
msg->Read<float>(&pt.y);
|
||||
|
||||
printf("MOUSE DOWN: at (%f, %f)\n", pt.x, pt.y);
|
||||
|
||||
WinBorder *target;
|
||||
RootLayer *rl;
|
||||
Workspace *ws;
|
||||
rl = ActiveRootLayer();
|
||||
ws = rl->ActiveWorkspace();
|
||||
target = ws->SearchLayerUnderPoint(pt);
|
||||
if (target){
|
||||
printf("\t '%s' was selected.\n", target->GetName());
|
||||
fGeneralLock.Lock();
|
||||
rl->fMainLock.Lock();
|
||||
|
||||
|
||||
ws->SetFrontLayer(target);
|
||||
SetFocusWinBorder(target);
|
||||
// TODO: improve!
|
||||
rl->Invalidate(rl->Bounds());
|
||||
|
||||
|
||||
rl->fMainLock.Unlock();
|
||||
fGeneralLock.Unlock();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case B_MOUSE_UP:{
|
||||
// Attached data:
|
||||
// 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
|
||||
|
||||
BPoint pt;
|
||||
int64 dummy;
|
||||
msg->Read<int64>(&dummy);
|
||||
msg->Read<float>(&pt.x);
|
||||
msg->Read<float>(&pt.y);
|
||||
|
||||
printf("MOUSE UP: at (%f, %f)\n", pt.x, pt.y);
|
||||
|
||||
break;
|
||||
}
|
||||
case B_MOUSE_MOVED:{
|
||||
// Attached data:
|
||||
// 1) int64 - time of mouse click
|
||||
// 2) float - x coordinate of mouse click
|
||||
// 3) float - y coordinate of mouse click
|
||||
// 4) int32 - buttons down
|
||||
|
||||
break;
|
||||
}
|
||||
case B_MOUSE_WHEEL_CHANGED:{
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
printf("\nDesktop::MouseEventHandler(): WARNING: unknown message\n\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Input related methods
|
||||
|
||||
void Desktop::MouseEventHandler(PortMessage *msg)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::KeyboardEventHandler(PortMessage *msg){
|
||||
}
|
||||
|
||||
void Desktop::KeyboardEventHandler(PortMessage *msg)
|
||||
{
|
||||
}
|
||||
|
||||
void Desktop::SetDragMessage(BMessage* msg)
|
||||
{
|
||||
if (fDragMessage)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::SetDragMessage(BMessage* msg){
|
||||
if (fDragMessage){
|
||||
delete fDragMessage;
|
||||
fDragMessage = NULL;
|
||||
}
|
||||
@@ -282,86 +349,71 @@ void Desktop::SetDragMessage(BMessage* msg)
|
||||
if (msg)
|
||||
fDragMessage = new BMessage(*msg);
|
||||
}
|
||||
|
||||
BMessage* Desktop::DragMessage(void) const
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
BMessage* Desktop::DragMessage(void) const{
|
||||
return fDragMessage;
|
||||
}
|
||||
|
||||
// Methods for various desktop stuff handled by the server
|
||||
void Desktop::SetScrollBarInfo(const scroll_bar_info &info)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::SetScrollBarInfo(const scroll_bar_info &info){
|
||||
fScrollBarInfo = info;
|
||||
}
|
||||
|
||||
scroll_bar_info Desktop::ScrollBarInfo(void) const
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
scroll_bar_info Desktop::ScrollBarInfo(void) const{
|
||||
return fScrollBarInfo;
|
||||
}
|
||||
|
||||
void Desktop::SetMenuInfo(const menu_info &info)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::SetMenuInfo(const menu_info &info){
|
||||
fMenuInfo = info;
|
||||
}
|
||||
|
||||
menu_info Desktop::MenuInfo(void) const
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
menu_info Desktop::MenuInfo(void) const{
|
||||
return fMenuInfo;
|
||||
}
|
||||
|
||||
void Desktop::UseFFMouse(const bool &useffm)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::UseFFMouse(const bool &useffm){
|
||||
fFFMouseMode = useffm;
|
||||
}
|
||||
|
||||
bool Desktop::FFMouseInUse(void) const
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
bool Desktop::FFMouseInUse(void) const{
|
||||
return fFFMouseMode;
|
||||
}
|
||||
|
||||
void Desktop::SetFFMouseMode(const mode_mouse &value)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::SetFFMouseMode(const mode_mouse &value){
|
||||
fMouseMode = value;
|
||||
}
|
||||
|
||||
mode_mouse Desktop::FFMouseMode(void) const
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
mode_mouse Desktop::FFMouseMode(void) const{
|
||||
return fMouseMode;
|
||||
}
|
||||
|
||||
bool Desktop::ReadWorkspaceData(void)
|
||||
{
|
||||
// TODO: implement
|
||||
//---------------------------------------------------------------------------
|
||||
bool Desktop::ReadWorkspaceData(void){
|
||||
// TODO: implement
|
||||
return true;
|
||||
}
|
||||
|
||||
void Desktop::SaveWorkspaceData(void)
|
||||
{
|
||||
// TODO: implement
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::SaveWorkspaceData(void){
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
void Desktop::RemoveSubsetWindow(WinBorder* wb)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::RemoveSubsetWindow(WinBorder* wb){
|
||||
WinBorder *winBorder = NULL;
|
||||
int32 count = fWinBorderList.CountItems();
|
||||
|
||||
for(int32 i=0; i < count; i++)
|
||||
{
|
||||
for(int32 i=0; i < count; i++){
|
||||
winBorder = static_cast<WinBorder*>(fWinBorderList.ItemAt(i));
|
||||
if (winBorder->GetServerFeel() == B_NORMAL_FEEL)
|
||||
winBorder->Window()->GetFMWList()->RemoveItem(wb);
|
||||
if (winBorder->_level == B_NORMAL_FEEL)
|
||||
winBorder->Window()->fWinFMWList.RemoveItem(wb);
|
||||
}
|
||||
|
||||
RootLayer *rl = winBorder->GetRootLayer();
|
||||
int32 countWKs = rl->WorkspaceCount();
|
||||
for (int32 i=0; i < countWKs; i++)
|
||||
{
|
||||
for (int32 i=0; i < countWKs; i++){
|
||||
rl->WorkspaceAt(i+1)->RemoveLayerPtr(wb);
|
||||
}
|
||||
}
|
||||
|
||||
void Desktop::PrintToStream(void)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::PrintToStream(){
|
||||
printf("RootLayer List:\n=======\n");
|
||||
for(int32 i=0; i<fRootLayerList.CountItems(); i++){
|
||||
printf("\t%s\n", ((RootLayer*)fRootLayerList.ItemAt(i))->GetName());
|
||||
@@ -369,7 +421,7 @@ void Desktop::PrintToStream(void)
|
||||
printf("-------\n");
|
||||
}
|
||||
printf("=======\nActive RootLayer: %s\n", fActiveRootLayer? fActiveRootLayer->GetName(): "NULL");
|
||||
// printf("Active WinBorder: %s\n", fActiveWinBorder? fActiveWinBorder->Name(void): "NULL");
|
||||
// printf("Active WinBorder: %s\n", fActiveWinBorder? fActiveWinBorder->Name(): "NULL");
|
||||
|
||||
printf("Screen List:\n");
|
||||
for(int32 i=0; i<fScreenList.CountItems(); i++){
|
||||
@@ -377,9 +429,8 @@ void Desktop::PrintToStream(void)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Desktop::PrintVisibleInRootLayerNo(int32 no)
|
||||
{
|
||||
//---------------------------------------------------------------------------
|
||||
void Desktop::PrintVisibleInRootLayerNo(int32 no){
|
||||
if (no<0 || no>=fRootLayerList.CountItems())
|
||||
return;
|
||||
|
||||
@@ -392,13 +443,3 @@ void Desktop::PrintVisibleInRootLayerNo(int32 no)
|
||||
wb->PrintToStream();
|
||||
}
|
||||
}
|
||||
|
||||
DisplayDriver *Desktop::GetGfxDriver(void)
|
||||
{
|
||||
return fActiveScreen->GetDriver();
|
||||
}
|
||||
|
||||
void Desktop::SetWorkspace(int32 index)
|
||||
{
|
||||
fActiveRootLayer->SetActiveWorkspaceByIndex(index);
|
||||
}
|
||||
|
||||
@@ -6,101 +6,97 @@
|
||||
#include <Menu.h>
|
||||
#include <InterfaceDefs.h>
|
||||
|
||||
class DisplayDriver;
|
||||
class RootLayer;
|
||||
class Screen;
|
||||
class Layer;
|
||||
class BMessage;
|
||||
class PortMessage;
|
||||
class WinBorder;
|
||||
class DisplayDriver;
|
||||
|
||||
class Desktop
|
||||
{
|
||||
public:
|
||||
// startup methods
|
||||
Desktop(void);
|
||||
~Desktop(void);
|
||||
void Init(void);
|
||||
// startup methods
|
||||
Desktop(void);
|
||||
~Desktop(void);
|
||||
void Init(void);
|
||||
void InitMode(void); // 1-BigScreen or n-SmallScreens
|
||||
|
||||
// 1-BigScreen or n-SmallScreens
|
||||
void InitMode(void);
|
||||
|
||||
// Methods for multiple monitors.
|
||||
Screen *ScreenAt(int32 index) const;
|
||||
int32 ScreenCount(void) const;
|
||||
Screen *ActiveScreen(void) const { return fActiveScreen; }
|
||||
void SetActiveScreen(int32 index);
|
||||
|
||||
void SetActiveRootLayerByIndex(int32 listIndex);
|
||||
void SetActiveRootLayer(RootLayer* rl);
|
||||
RootLayer* RootLayerAt(int32 index);
|
||||
RootLayer* ActiveRootLayer(void) const;
|
||||
int32 ActiveRootLayerIndex(void) const;
|
||||
int32 CountRootLayers(void) const;
|
||||
// Methods for multiple monitors.
|
||||
Screen* ScreenAt(int32 index) const;
|
||||
int32 ScreenCount() const;
|
||||
Screen* CursorScreen() const;
|
||||
|
||||
// Stuff for easy access
|
||||
DisplayDriver *GetGfxDriver(void);
|
||||
void SetWorkspace(int32 index);
|
||||
|
||||
// Methods for layer(WinBorder) manipulation.
|
||||
void AddWinBorder(WinBorder* winBorder);
|
||||
void RemoveWinBorder(WinBorder* winBorder);
|
||||
bool HasWinBorder(WinBorder* winBorder);
|
||||
void SetFrontWinBorder(WinBorder* winBorder);
|
||||
void SetFocusWinBorder(WinBorder* winBorder);
|
||||
WinBorder* FrontWinBorder(void) const;
|
||||
WinBorder* FocusWinBorder(void) const;
|
||||
|
||||
// Input related methods
|
||||
void MouseEventHandler(PortMessage *msg);
|
||||
void KeyboardEventHandler(PortMessage *msg);
|
||||
|
||||
void SetDragMessage(BMessage* msg);
|
||||
BMessage* DragMessage(void) const;
|
||||
|
||||
// Methods for various desktop stuff handled by the server
|
||||
void SetScrollBarInfo(const scroll_bar_info &info);
|
||||
scroll_bar_info ScrollBarInfo(void) const;
|
||||
|
||||
void SetMenuInfo(const menu_info &info);
|
||||
menu_info MenuInfo(void) const;
|
||||
|
||||
|
||||
void UseFFMouse(const bool &useffm);
|
||||
bool FFMouseInUse(void) const;
|
||||
void SetFFMouseMode(const mode_mouse &value);
|
||||
mode_mouse FFMouseMode(void) const;
|
||||
|
||||
bool ReadWorkspaceData(void);
|
||||
void SaveWorkspaceData(void);
|
||||
|
||||
// Debugging methods
|
||||
void PrintToStream(void);
|
||||
void PrintVisibleInRootLayerNo(int32 no);
|
||||
|
||||
// "Private" to app_server :-) - means they should not be used very much
|
||||
void RemoveSubsetWindow(WinBorder* wb);
|
||||
void SetActiveRootLayerByIndex(int32 listIndex);
|
||||
void SetActiveRootLayer(RootLayer* rl);
|
||||
RootLayer* RootLayerAt(int32 index);
|
||||
RootLayer* ActiveRootLayer() const;
|
||||
int32 ActiveRootLayerIndex() const;
|
||||
int32 CountRootLayers() const;
|
||||
DisplayDriver* GetDisplayDriver() const;
|
||||
|
||||
// Methods for layer(WinBorder) manipulation.
|
||||
void AddWinBorder(WinBorder* winBorder);
|
||||
void RemoveWinBorder(WinBorder* winBorder);
|
||||
bool HasWinBorder(WinBorder* winBorder);
|
||||
void SetFrontWinBorder(WinBorder* winBorder);
|
||||
void SetFocusWinBorder(WinBorder* winBorder);
|
||||
WinBorder* FrontWinBorder(void) const;
|
||||
WinBorder* FocusWinBorder(void) const;
|
||||
|
||||
// Input related methods
|
||||
void MouseEventHandler(PortMessage *msg);
|
||||
void KeyboardEventHandler(PortMessage *msg);
|
||||
|
||||
void SetDragMessage(BMessage* msg);
|
||||
BMessage* DragMessage(void) const;
|
||||
|
||||
// Methods for various desktop stuff handled by the server
|
||||
void SetScrollBarInfo(const scroll_bar_info &info);
|
||||
scroll_bar_info ScrollBarInfo(void) const;
|
||||
|
||||
void SetMenuInfo(const menu_info &info);
|
||||
menu_info MenuInfo(void) const;
|
||||
|
||||
|
||||
void UseFFMouse(const bool &useffm);
|
||||
bool FFMouseInUse(void) const;
|
||||
void SetFFMouseMode(const mode_mouse &value);
|
||||
mode_mouse FFMouseMode(void) const;
|
||||
|
||||
bool ReadWorkspaceData(void);
|
||||
void SaveWorkspaceData(void);
|
||||
|
||||
// Debugging methods
|
||||
void PrintToStream();
|
||||
void PrintVisibleInRootLayerNo(int32 no);
|
||||
|
||||
// "Private" to app_server :-) - means they should not be used very much
|
||||
void RemoveSubsetWindow(WinBorder* wb);
|
||||
BLocker fGeneralLock;
|
||||
BLocker fLayerLock;
|
||||
BList fWinBorderList;
|
||||
|
||||
private:
|
||||
BLocker fLayerLock;
|
||||
BList fWinBorderList;
|
||||
|
||||
BMessage *fDragMessage;
|
||||
|
||||
BList fRootLayerList;
|
||||
RootLayer* fActiveRootLayer;
|
||||
WinBorder* fFrontWinBorder;
|
||||
WinBorder* fFocusWinBorder;
|
||||
|
||||
BList fScreenList;
|
||||
|
||||
scroll_bar_info fScrollBarInfo;
|
||||
menu_info fMenuInfo;
|
||||
mode_mouse fMouseMode;
|
||||
bool fFFMouseMode;
|
||||
Screen *fActiveScreen;
|
||||
|
||||
BMessage *fDragMessage;
|
||||
|
||||
BList fRootLayerList;
|
||||
RootLayer* fActiveRootLayer;
|
||||
WinBorder* fFrontWinBorder;
|
||||
WinBorder* fFocusWinBorder;
|
||||
|
||||
BList fScreenList;
|
||||
int32 fScreenMode; // '1' or 'n' Screen(s). Not sure it's needed though.
|
||||
Screen* fCursorScreen;
|
||||
|
||||
scroll_bar_info fScrollBarInfo;
|
||||
menu_info fMenuInfo;
|
||||
mode_mouse fMouseMode;
|
||||
bool fFFMouseMode;
|
||||
};
|
||||
|
||||
extern Desktop* desktop;
|
||||
|
||||
#endif // _DESKTOP_H_
|
||||
#endif _DESKTOP_H_
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <View.h>
|
||||
#include <Message.h>
|
||||
#include <AppDefs.h>
|
||||
#include <Region.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "Layer.h"
|
||||
@@ -39,7 +40,6 @@
|
||||
#include "ServerCursor.h"
|
||||
#include "CursorManager.h"
|
||||
#include "TokenHandler.h"
|
||||
#include "RectUtils.h"
|
||||
#include "RootLayer.h"
|
||||
#include "DisplayDriver.h"
|
||||
#include "Desktop.h"
|
||||
@@ -81,6 +81,7 @@ Layer::Layer(BRect frame, const char *name, int32 token, uint32 resize,
|
||||
_lowersibling = NULL;
|
||||
_topchild = NULL;
|
||||
_bottomchild = NULL;
|
||||
fRootLayer = NULL;
|
||||
|
||||
/* NOW all regions (_visible, _fullVisible, _full) are empty */
|
||||
|
||||
@@ -95,9 +96,8 @@ Layer::Layer(BRect frame, const char *name, int32 token, uint32 resize,
|
||||
_serverwin = win;
|
||||
_cursor = NULL;
|
||||
clipToPicture = NULL;
|
||||
|
||||
//TODO: Fix
|
||||
// fDriver = GetGfxDriver(ActiveScreen());
|
||||
// TODO: modify!
|
||||
fDriver = desktop->GetDisplayDriver();
|
||||
}
|
||||
|
||||
//! Destructor frees all allocated heap space
|
||||
@@ -127,13 +127,20 @@ Layer::~Layer(void)
|
||||
\param before Add the child in front of this layer
|
||||
\param rebuild Flag to fully rebuild all visibility regions
|
||||
*/
|
||||
void Layer::AddChild(Layer *layer, Layer *before)
|
||||
void Layer::AddChild(Layer *layer, RootLayer *rootLayer)
|
||||
{
|
||||
if( layer->_parent != NULL ) {
|
||||
printf("ERROR: AddChild(): Layer already has a _parent\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (layer->GetRootLayer()){
|
||||
printf("Error: Layer already belongs to a RootLayer!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
layer->fRootLayer = rootLayer;
|
||||
|
||||
// attach layer to the tree structure
|
||||
layer->_parent = this;
|
||||
if( _bottomchild ){
|
||||
@@ -164,24 +171,6 @@ void Layer::AddChild(Layer *layer, Layer *before)
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Used in the new Desktop Management code
|
||||
*/
|
||||
void Layer::AddChild(Layer *layer, RootLayer *rootLayer)
|
||||
{
|
||||
// TODO: Document
|
||||
|
||||
if (layer->GetRootLayer())
|
||||
{
|
||||
printf("Error: Layer already belongs to a RootLayer!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
layer->fRootLayer = rootLayer;
|
||||
|
||||
fLayerList.AddItem(layer);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Removes a layer from the child stack
|
||||
\param layer The layer to remove
|
||||
@@ -193,13 +182,13 @@ void Layer::RemoveChild(Layer *layer)
|
||||
printf("ERROR: RemoveChild(): Layer doesn't have a _parent\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(fLayerList.HasItem(layer)))
|
||||
{
|
||||
printf("Error: Layer is not a child of this RootLayer!\n");
|
||||
if( layer->_parent != this ){
|
||||
printf("ERROR: RemoveChild(): Layer is not a child of this layer\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fRootLayer = NULL;
|
||||
|
||||
// cache some things. The rebuilding/redrawing process will need those.
|
||||
Layer* cachedUpperSibling = layer->_uppersibling;
|
||||
|
||||
@@ -236,9 +225,6 @@ void Layer::RemoveChild(Layer *layer)
|
||||
DoInvalidate( BRegion(invalidRect), cachedUpperSibling );
|
||||
}
|
||||
}
|
||||
|
||||
fRootLayer = NULL;
|
||||
fLayerList.RemoveItem(layer);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -255,35 +241,23 @@ void Layer::RemoveSelf()
|
||||
_parent->RemoveChild(this);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Used in the new Desktop Management code
|
||||
*/
|
||||
bool Layer::HasChild(Layer* layer) const
|
||||
{
|
||||
return fLayerList.HasItem(layer);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Used in the new Desktop Management code
|
||||
*/
|
||||
void Layer::SetRootLayer(RootLayer* rl)
|
||||
{
|
||||
fRootLayer = rl;
|
||||
bool Layer::HasChild(Layer* layer) const{
|
||||
for(Layer *lay = VirtualTopChild(); lay; lay = lay->VirtualLowerSibling()){
|
||||
if(lay == layer)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Finds the first child at a given point.
|
||||
\param pt Point to look for a child
|
||||
\param recursive Flag to look for the bottom-most child
|
||||
\return non-NULL if found, NULL if not
|
||||
|
||||
Find out which child gets hit if we click at a certain spot. Returns NULL
|
||||
if there are no _visible children or if the click does not hit a child layer
|
||||
If recursive==true, then it will continue to call until it reaches a layer
|
||||
which has no children, i.e. a layer that is at the top of its 'branch' in
|
||||
the layer tree
|
||||
*/
|
||||
Layer* Layer::GetLayerAt(const BPoint &pt)
|
||||
Layer* Layer::LayerAt(const BPoint &pt)
|
||||
{
|
||||
if (_visible.Contains(pt)){
|
||||
return this;
|
||||
@@ -292,7 +266,7 @@ Layer* Layer::GetLayerAt(const BPoint &pt)
|
||||
if (_fullVisible.Contains(pt)){
|
||||
Layer *lay = NULL;
|
||||
for ( Layer* child = _bottomchild; child != NULL; child = child->_uppersibling ){
|
||||
if ( (lay = child->GetLayerAt( pt )) )
|
||||
if ( (lay = child->LayerAt( pt )) )
|
||||
return lay;
|
||||
}
|
||||
}
|
||||
@@ -421,7 +395,15 @@ void Layer::MouseTransit(uint32 transit)
|
||||
|
||||
void Layer::DoInvalidate(const BRegion ®, Layer *start){
|
||||
//TODO: REMOVE this! For Test purposes only!
|
||||
printf("**********Layer::DoInvalidate()\n");
|
||||
if (GetRootLayer())
|
||||
GetRootLayer()->Draw(GetRootLayer()->Bounds());
|
||||
else{
|
||||
if(dynamic_cast<RootLayer*>(this))
|
||||
Draw(Bounds());
|
||||
}
|
||||
return;
|
||||
//----------------
|
||||
|
||||
if (_hidden || !(_fullVisible.Intersects(reg.Frame())) ){
|
||||
printf("SERVER: WARNING: Layer(%s)::DoInvalidate() 1 \n\n", _name->String());
|
||||
@@ -586,6 +568,12 @@ void Layer::Show(void)
|
||||
|
||||
_hidden = false;
|
||||
|
||||
//TODO: *****!*!*!*!*!*!*!**!***REMOVE this! For Test purposes only!
|
||||
printf("**********Layer::Show()\n");
|
||||
DoInvalidate(BRegion(Bounds()), NULL);
|
||||
return;
|
||||
//----------------
|
||||
|
||||
// rebuild layer visible region based on its parent's and those supplied by user
|
||||
if (_parent){
|
||||
_parent->RebuildChildRegions( _full.Frame(), this );
|
||||
@@ -608,6 +596,12 @@ void Layer::Hide(void)
|
||||
|
||||
_hidden = true;
|
||||
|
||||
//TODO: *****!*!*!*!*!*!*!**!***REMOVE this! For Test purposes only!
|
||||
printf("**********Layer::Hide()\n");
|
||||
DoInvalidate(BRegion(Bounds()), NULL);
|
||||
return;
|
||||
//----------------
|
||||
|
||||
if (_fullVisible.CountRects() > 0){
|
||||
|
||||
BRegion cachedFullVisible = _fullVisible;
|
||||
@@ -1034,7 +1028,12 @@ void Layer::RebuildRegions( const BRect& r )
|
||||
}
|
||||
|
||||
void Layer::RebuildFullRegion( ){
|
||||
_full.Set( ConvertToTop( _frame ) );
|
||||
// TODO: temporary patch?
|
||||
if (_parent && dynamic_cast<RootLayer*>(_parent) ){
|
||||
}
|
||||
else{
|
||||
_full.Set( ConvertToTop( _frame ) );
|
||||
}
|
||||
|
||||
LayerData *ld;
|
||||
|
||||
@@ -1255,59 +1254,15 @@ BRect Layer::ConvertFromTop(BRect rect)
|
||||
return(rect);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Makes the layer the backmost layer belonging to its parent
|
||||
|
||||
This function will do nothing if the Layer has no parent or no siblings. Region
|
||||
rebuilding is not performed.
|
||||
*/
|
||||
void Layer::MakeTopChild(void)
|
||||
{
|
||||
// Handle redundant and pointless cases
|
||||
if(!_parent || (!_uppersibling && !_lowersibling) || _parent->_topchild==this)
|
||||
return;
|
||||
|
||||
// Pull ourselves out of the layer tree
|
||||
if(_uppersibling)
|
||||
_uppersibling->_lowersibling=_lowersibling;
|
||||
|
||||
if(_lowersibling)
|
||||
_lowersibling->_uppersibling=_uppersibling;
|
||||
|
||||
// Set this layer's upper/lower sib pointers to appropriate values
|
||||
_uppersibling=NULL;
|
||||
_lowersibling=_parent->_topchild;
|
||||
|
||||
// move former top child down a layer
|
||||
_lowersibling->_uppersibling=this;
|
||||
_parent->_topchild=this;
|
||||
RootLayer* Layer::GetRootLayer() const{
|
||||
return fRootLayer;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Makes the layer the frontmost layer belonging to its parent
|
||||
|
||||
This function will do nothing if the Layer has no parent or no siblings. Region
|
||||
rebuilding is not performed.
|
||||
*/
|
||||
void Layer::MakeBottomChild(void)
|
||||
{
|
||||
// Handle redundant and pointless cases
|
||||
if(!_parent || (!_uppersibling && !_lowersibling) || _parent->_bottomchild==this)
|
||||
return;
|
||||
|
||||
// Pull ourselves out of the layer tree
|
||||
if(_uppersibling)
|
||||
_uppersibling->_lowersibling=_lowersibling;
|
||||
|
||||
if(_lowersibling)
|
||||
_lowersibling->_uppersibling=_uppersibling;
|
||||
|
||||
// Set this layer's upper/lower sib pointers to appropriate values
|
||||
_uppersibling=_parent->_bottomchild;
|
||||
_lowersibling=NULL;
|
||||
|
||||
// move former bottom child up a layer
|
||||
_uppersibling->_lowersibling=this;
|
||||
_parent->_bottomchild=this;
|
||||
|
||||
void Layer::SetRootLayer(RootLayer* rl){
|
||||
fRootLayer = rl;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
@log
|
||||
*/
|
||||
|
||||
+103
-87
@@ -44,6 +44,8 @@ class WinBorder;
|
||||
class Screen;
|
||||
class ServerCursor;
|
||||
class DisplayDriver;
|
||||
class Desktop;
|
||||
class Workspace;
|
||||
|
||||
/*!
|
||||
\class Layer Layer.h
|
||||
@@ -56,105 +58,119 @@ class DisplayDriver;
|
||||
class Layer
|
||||
{
|
||||
public:
|
||||
Layer(BRect frame, const char *name, int32 token, uint32 resize, uint32 flags, ServerWindow *win);
|
||||
virtual ~Layer(void);
|
||||
|
||||
void AddChild(Layer *child, Layer *before=NULL);
|
||||
void AddChild(Layer *layer, RootLayer *rootLayer);
|
||||
void RemoveChild(Layer *child);
|
||||
void RemoveSelf();
|
||||
bool HasChild(Layer* layer) const;
|
||||
uint32 CountChildren(void) const;
|
||||
void MakeTopChild(void);
|
||||
void MakeBottomChild(void);
|
||||
Layer* FindLayer(const int32 token);
|
||||
Layer* GetLayerAt(const BPoint &pt);
|
||||
Layer* GetUpperSibling() const { return _uppersibling; }
|
||||
Layer* GetLowerSibling() const { return _lowersibling; }
|
||||
RootLayer *GetRootLayer() const { return fRootLayer; }
|
||||
void SetRootLayer(RootLayer* rl);
|
||||
|
||||
const char* GetName(void) const { return (_name)?_name->String():NULL; }
|
||||
LayerData* GetLayerData(void) const { return _layerdata; }
|
||||
Layer(BRect frame, const char *name, int32 token, uint32 resize,
|
||||
uint32 flags, ServerWindow *win);
|
||||
virtual ~Layer(void);
|
||||
|
||||
void SetLayerCursor(ServerCursor *csr);
|
||||
ServerCursor *GetLayerCursor(void) const;
|
||||
virtual void MouseTransit(uint32 transit);
|
||||
void AddChild(Layer *child, RootLayer *rootLayer);
|
||||
void RemoveChild(Layer *child);
|
||||
void RemoveSelf();
|
||||
bool HasChild(Layer* layer) const;
|
||||
RootLayer* GetRootLayer() const;
|
||||
|
||||
uint32 CountChildren(void) const;
|
||||
Layer* FindLayer(const int32 token);
|
||||
Layer* LayerAt(const BPoint &pt);
|
||||
|
||||
virtual Layer* TopLayer() const { return _topchild; }
|
||||
virtual Layer* LowerSibling() const { return _lowersibling; }
|
||||
virtual Layer* UpperSibling() const { return _uppersibling; }
|
||||
virtual Layer* BottomLayer() const { return _bottomchild; }
|
||||
|
||||
virtual Layer* VirtualTopChild() const{ return _topchild; }
|
||||
virtual Layer* VirtualLowerSibling() const{ return _lowersibling; }
|
||||
virtual Layer* VirtualUpperSibling() const{ return _uppersibling; }
|
||||
virtual Layer* VirtualBottomChild() const{ return _bottomchild; }
|
||||
|
||||
|
||||
const char* GetName(void) const { return (_name)?_name->String():NULL; }
|
||||
LayerData* GetLayerData(void) const { return _layerdata; }
|
||||
|
||||
void Invalidate(const BRect &rect);
|
||||
void Invalidate(const BRegion ®ion);
|
||||
void DoInvalidate(const BRegion ®, Layer *start);
|
||||
|
||||
virtual void RebuildRegions( const BRect& r );
|
||||
void RebuildChildRegions( const BRect &r, Layer* startFrom );
|
||||
void RebuildFullRegion(void);
|
||||
void MoveRegionsBy(float x, float y);
|
||||
void ResizeRegionsBy(float x, float y);
|
||||
|
||||
void RequestClientUpdate(const BRect &rect);
|
||||
void RequestDraw(const BRect &r);
|
||||
virtual void Draw(const BRect &r);
|
||||
|
||||
void Show(void);
|
||||
void Hide(void);
|
||||
bool IsHidden(void) const;
|
||||
|
||||
BRect Bounds(void) const;
|
||||
BRect Frame(void) const;
|
||||
|
||||
virtual void MoveBy(float x, float y);
|
||||
virtual void ResizeBy(float x, float y);
|
||||
|
||||
BRect ConvertToParent(BRect rect);
|
||||
BRegion ConvertToParent(BRegion *reg);
|
||||
BRect ConvertFromParent(BRect rect);
|
||||
BRegion ConvertFromParent(BRegion *reg);
|
||||
BRegion ConvertToTop(BRegion *reg);
|
||||
BRect ConvertToTop(BRect rect);
|
||||
BRegion ConvertFromTop(BRegion *reg);
|
||||
BRect ConvertFromTop(BRect rect);
|
||||
|
||||
void PruneTree(void);
|
||||
|
||||
void PrintToStream(void);
|
||||
void PrintNode(void);
|
||||
void PrintTree();
|
||||
void SetLayerCursor(ServerCursor *csr);
|
||||
ServerCursor* GetLayerCursor(void) const;
|
||||
virtual void MouseTransit(uint32 transit);
|
||||
|
||||
void Invalidate(const BRect &rect);
|
||||
void Invalidate(const BRegion ®ion);
|
||||
void DoInvalidate(const BRegion ®, Layer *start);
|
||||
|
||||
virtual void RebuildRegions( const BRect& r );
|
||||
void RebuildChildRegions( const BRect &r, Layer* startFrom );
|
||||
void RebuildFullRegion(void);
|
||||
void MoveRegionsBy(float x, float y);
|
||||
void ResizeRegionsBy(float x, float y);
|
||||
|
||||
void RequestClientUpdate(const BRect &rect);
|
||||
void RequestDraw(const BRect &r);
|
||||
virtual void Draw(const BRect &r);
|
||||
|
||||
virtual void Show(void);
|
||||
virtual void Hide(void);
|
||||
bool IsHidden(void) const;
|
||||
|
||||
BRect Bounds(void) const;
|
||||
BRect Frame(void) const;
|
||||
|
||||
virtual void MoveBy(float x, float y);
|
||||
virtual void ResizeBy(float x, float y);
|
||||
|
||||
BRect ConvertToParent(BRect rect);
|
||||
BRegion ConvertToParent(BRegion *reg);
|
||||
BRect ConvertFromParent(BRect rect);
|
||||
BRegion ConvertFromParent(BRegion *reg);
|
||||
BRegion ConvertToTop(BRegion *reg);
|
||||
BRect ConvertToTop(BRect rect);
|
||||
BRegion ConvertFromTop(BRegion *reg);
|
||||
BRect ConvertFromTop(BRect rect);
|
||||
|
||||
void PruneTree(void);
|
||||
|
||||
void PrintToStream(void);
|
||||
void PrintNode(void);
|
||||
void PrintTree();
|
||||
|
||||
// server "private" - should not be used
|
||||
void SetRootLayer(RootLayer* rl);
|
||||
protected:
|
||||
friend class RootLayer;
|
||||
friend class WinBorder;
|
||||
friend class Screen;
|
||||
friend class ServerWindow;
|
||||
friend class Desktop;
|
||||
friend class Workspace;
|
||||
|
||||
BRect _frame;
|
||||
BPoint _boundsLeftTop;
|
||||
Layer *_parent,
|
||||
*_uppersibling,
|
||||
*_lowersibling,
|
||||
*_topchild,
|
||||
*_bottomchild;
|
||||
|
||||
BRegion _visible,
|
||||
_fullVisible,
|
||||
_full;
|
||||
BRect _frame;
|
||||
BPoint _boundsLeftTop;
|
||||
Layer *_parent,
|
||||
*_uppersibling,
|
||||
*_lowersibling,
|
||||
*_topchild,
|
||||
*_bottomchild;
|
||||
|
||||
BRegion *clipToPicture;
|
||||
bool clipToPictureInverse;
|
||||
BRegion _visible,
|
||||
_fullVisible,
|
||||
_full;
|
||||
|
||||
ServerWindow *_serverwin;
|
||||
BString *_name;
|
||||
int32 _view_token;
|
||||
int32 _level;
|
||||
uint32 _flags;
|
||||
uint32 _resize_mode;
|
||||
bool _hidden;
|
||||
bool _is_updating;
|
||||
LayerData *_layerdata;
|
||||
ServerCursor *_cursor;
|
||||
DisplayDriver *fDriver;
|
||||
BRegion *clipToPicture;
|
||||
bool clipToPictureInverse;
|
||||
|
||||
RootLayer* fRootLayer;
|
||||
BList fLayerList;
|
||||
ServerWindow *_serverwin;
|
||||
BString *_name;
|
||||
int32 _view_token;
|
||||
int32 _level;
|
||||
uint32 _flags;
|
||||
uint32 _resize_mode;
|
||||
bool _hidden;
|
||||
bool _is_updating;
|
||||
LayerData *_layerdata;
|
||||
ServerCursor *_cursor;
|
||||
DisplayDriver* fDriver;
|
||||
RootLayer* fRootLayer;
|
||||
};
|
||||
|
||||
#endif
|
||||
/*
|
||||
@log
|
||||
* added a new member, BPoint _boundsLeftTop. Beside other uses, (DW don't forget!)it will be needed in redraw code.
|
||||
* _flags is now declared as uint32
|
||||
*/
|
||||
|
||||
@@ -3,16 +3,19 @@
|
||||
#include <Window.h>
|
||||
#include <List.h>
|
||||
|
||||
#include "ServerApp.h"
|
||||
#include "Globals.h"
|
||||
#include "RootLayer.h"
|
||||
#include "Layer.h"
|
||||
#include "Workspace.h"
|
||||
#include "ServerScreen.h"
|
||||
#include "Screen.h"
|
||||
#include "WinBorder.h"
|
||||
#include "ServerWindow.h"
|
||||
#include "ServerApp.h"
|
||||
#include "Desktop.h"
|
||||
#include "FMWList.h"
|
||||
#include "DisplayDriver.h"
|
||||
|
||||
//#define DISPLAYDRIVER_TEST_HACK
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
RootLayer::RootLayer(const char *layername, int32 workspaceCount, Desktop *desktop)
|
||||
@@ -34,7 +37,6 @@ RootLayer::RootLayer(const char *layername, int32 workspaceCount, Desktop *deskt
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
RootLayer::~RootLayer(){
|
||||
//printf("~RootLayer( %s )\n", Name());
|
||||
// RootLayer object just uses Screen objects, it is not allowed to delete them.
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -42,8 +44,29 @@ void RootLayer::Draw(const BRect &r){
|
||||
/* THIS method is here because of DisplayDriver testing!
|
||||
* It SHOULD BE REMOVED as soon as testing is done!!!!
|
||||
*/
|
||||
/*
|
||||
printf("*RootLayer(%s)::Draw(r)\n", GetName());
|
||||
// NOTE: (!!!) fMainLock MUST be locked when this method is called!!!
|
||||
if (!fMainLock.IsLocked())
|
||||
printf("\n\n\tWARNING: fMainLock MUST be locked!!!\n\n");
|
||||
// NOTE: (!!!) desktop->fGeneralLock MUST be locked when this method is called!!!
|
||||
if (!desktop->fGeneralLock.IsLocked())
|
||||
printf("\n\n\tWARNING: desktop->fGeneralLock MUST be locked!!!\n\n");
|
||||
|
||||
RGBColor c(51,102,152);
|
||||
|
||||
fDriver->FillRect(Bounds(), c);
|
||||
|
||||
Workspace *as = ActiveWorkspace();
|
||||
WinBorder *wb = NULL;
|
||||
for (wb = as->GoToTopItem(); wb; wb = as->GoToLowerItem()){
|
||||
printf("requesting draw? %s from %s\n", wb->IsHidden()?"NO":"YES", wb->GetName());
|
||||
if (!(wb->IsHidden()))
|
||||
wb->Draw(wb->Bounds());
|
||||
}
|
||||
printf("#RootLayer(%s)::Draw(r) END\n", GetName());
|
||||
//--------REMOVE ABOVE--------------
|
||||
#ifdef DISPLAYDRIVER_TEST_HACK
|
||||
DisplayDriver *_driver = fDriver;
|
||||
int8 pattern[8];
|
||||
int8 pattern2[8];
|
||||
memset(pattern,255,8);
|
||||
@@ -104,7 +127,7 @@ void RootLayer::Draw(const BRect &r){
|
||||
_driver->FillPolygon(polygon,6,polygonRect,_layerdata,pattern);
|
||||
// _driver->FillTriangle(triangle,triangleRect,_layerdata,pattern);
|
||||
#endif
|
||||
*/
|
||||
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void RootLayer::MoveBy(float x, float y){
|
||||
@@ -146,11 +169,15 @@ void RootLayer::AddWinBorderToWorkspaces(WinBorder* winBorder, uint32 wks){
|
||||
*/
|
||||
//---------------------------------------------------------------------------
|
||||
void RootLayer::AddWinBorder(WinBorder* winBorder){
|
||||
printf("*RootLayer::AddWinBorder(%s)\n", winBorder->GetName());
|
||||
desktop->fGeneralLock.Lock();
|
||||
printf("*RootLayer::AddWinBorder(%s) - General lock acquired\n", winBorder->GetName());
|
||||
fMainLock.Lock();
|
||||
printf("*RootLayer::AddWinBorder(%s) - Main lock acquired\n", winBorder->GetName());
|
||||
// add winBorder to the known list of WinBorders so we can keep track of it.
|
||||
AddChild(winBorder, this);
|
||||
|
||||
// add winBorder to the desired workspaces
|
||||
switch(winBorder->Window()->GetFeel()){
|
||||
switch(winBorder->Window()->Feel()){
|
||||
case B_MODAL_SUBSET_WINDOW_FEEL:{
|
||||
/* this kind of window isn't added anywhere. It *will* be added
|
||||
to main window's subset when winBorder::AddToSubsetOf(main)
|
||||
@@ -160,7 +187,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder){
|
||||
|
||||
case B_MODAL_APP_WINDOW_FEEL:{
|
||||
// add to ***app's*** list of Floating/Modal Windows.
|
||||
winBorder->Window()->GetApp()->GetFMWList()->AddItem(winBorder);
|
||||
winBorder->Window()->App()->fAppFMWList.AddItem(winBorder);
|
||||
|
||||
// determine in witch workspaces to add this winBorder.
|
||||
uint32 wks = 0;
|
||||
@@ -169,9 +196,9 @@ void RootLayer::AddWinBorder(WinBorder* winBorder){
|
||||
Workspace *ws = WorkspaceAt(i+1);
|
||||
for (WinBorder *wb = ws->GoToBottomItem(); wb!=NULL; wb = ws->GoToUpperItem()){
|
||||
if ( !(wb->IsHidden()) &&
|
||||
winBorder->Window()->GetClientTeamID() == wb->Window()->GetClientTeamID())
|
||||
winBorder->Window()->ClientTeamID() == wb->Window()->ClientTeamID())
|
||||
{
|
||||
wks = wks | winBorder->Window()->GetWorkspaces();
|
||||
wks = wks | winBorder->Window()->Workspaces();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -200,13 +227,13 @@ void RootLayer::AddWinBorder(WinBorder* winBorder){
|
||||
|
||||
case B_FLOATING_APP_WINDOW_FEEL:{
|
||||
// add to ***app's*** list of Floating/Modal Windows.
|
||||
winBorder->Window()->GetApp()->GetFMWList()->AddItem(winBorder);
|
||||
winBorder->Window()->App()->fAppFMWList.AddItem(winBorder);
|
||||
|
||||
for (int32 i=0; i<WorkspaceCount(); i++){
|
||||
Workspace *ws = WorkspaceAt(i+1);
|
||||
WinBorder *wb = ws->FrontLayer();
|
||||
if(wb && wb->Window()->GetClientTeamID() == winBorder->Window()->GetClientTeamID()
|
||||
&& wb->Window()->GetFeel() == B_NORMAL_WINDOW_FEEL)
|
||||
if(wb && wb->Window()->ClientTeamID() == winBorder->Window()->ClientTeamID()
|
||||
&& wb->Window()->Feel() == B_NORMAL_WINDOW_FEEL)
|
||||
{
|
||||
ws->AddLayerPtr(winBorder);
|
||||
}
|
||||
@@ -225,7 +252,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder){
|
||||
|
||||
case B_NORMAL_WINDOW_FEEL:{
|
||||
// add this winBorder to the specified workspaces
|
||||
AddWinBorderToWorkspaces(winBorder, winBorder->Window()->GetWorkspaces());
|
||||
AddWinBorderToWorkspaces(winBorder, winBorder->Window()->Workspaces());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -238,6 +265,11 @@ void RootLayer::AddWinBorder(WinBorder* winBorder){
|
||||
default:
|
||||
break;
|
||||
}
|
||||
fMainLock.Unlock();
|
||||
printf("*RootLayer::AddWinBorder(%s) - Main lock released\n", winBorder->GetName());
|
||||
desktop->fGeneralLock.Unlock();
|
||||
printf("*RootLayer::AddWinBorder(%s) - General lock released\n", winBorder->GetName());
|
||||
printf("#RootLayer::AddWinBorder(%s)\n", winBorder->GetName());
|
||||
}
|
||||
/* This method does 3 things:
|
||||
* 1) Removes MODAL/SUBSET windows from system/app/window subset list.
|
||||
@@ -246,8 +278,9 @@ void RootLayer::AddWinBorder(WinBorder* winBorder){
|
||||
*/
|
||||
//---------------------------------------------------------------------------
|
||||
void RootLayer::RemoveWinBorder(WinBorder* winBorder){
|
||||
|
||||
int32 feel = winBorder->Window()->GetFeel();
|
||||
desktop->fGeneralLock.Lock();
|
||||
fMainLock.Lock();
|
||||
int32 feel = winBorder->Window()->Feel();
|
||||
if(feel == B_MODAL_SUBSET_WINDOW_FEEL || feel == B_FLOATING_SUBSET_WINDOW_FEEL){
|
||||
desktop->RemoveSubsetWindow(winBorder);
|
||||
}
|
||||
@@ -265,14 +298,17 @@ void RootLayer::RemoveWinBorder(WinBorder* winBorder){
|
||||
WorkspaceAt(i+1)->RemoveLayerPtr(winBorder);
|
||||
}
|
||||
else{ // for B_NORMAL_WINDOW_FEEL
|
||||
uint32 workspaces = winBorder->Window()->GetWorkspaces();
|
||||
uint32 workspaces = winBorder->Window()->Workspaces();
|
||||
int32 count = WorkspaceCount();
|
||||
for( int32 i=0; i < 32 && i < count; i++)
|
||||
if( workspaces & (0x00000001 << i))
|
||||
if( workspaces & (0x00000001UL << i)){
|
||||
WorkspaceAt(i+1)->RemoveLayerPtr(winBorder);
|
||||
}
|
||||
}
|
||||
|
||||
RemoveChild(winBorder);
|
||||
fMainLock.Unlock();
|
||||
desktop->fGeneralLock.Unlock();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void RootLayer::ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces){
|
||||
@@ -280,7 +316,7 @@ void RootLayer::ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces){
|
||||
if(!winBorder->_level != B_NORMAL_FEEL)
|
||||
return;
|
||||
|
||||
uint32 oldWorkspaces = winBorder->Window()->GetWorkspaces();
|
||||
uint32 oldWorkspaces = winBorder->Window()->Workspaces();
|
||||
for(int32 i=0; i < WorkspaceCount(); i++){
|
||||
if ((oldWorkspaces & (0x00000001 << i)) && (newWorkspaces & (0x00000001 << i))){
|
||||
// do nothing.
|
||||
@@ -294,6 +330,49 @@ void RootLayer::ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces){
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
bool RootLayer::SetFrontWinBorder(WinBorder* winBorder){
|
||||
// TODO: watch out for a NULL value
|
||||
printf("*RootLayer::SetFrontWinBorder(%s)\n", winBorder? winBorder->GetName():"NULL");
|
||||
fMainLock.Lock();
|
||||
printf("*RootLayer::SetFrontWinBorder(%s) - main lock acquired\n", winBorder? winBorder->GetName():"NULL");
|
||||
if (!winBorder){
|
||||
ActiveWorkspace()->SetFrontLayer(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 workspaces = winBorder->Window()->Workspaces();
|
||||
int32 count = WorkspaceCount();
|
||||
int32 newWorkspace= 0;
|
||||
|
||||
if (workspaces & (0x00000001UL << (ActiveWorkspaceIndex()-1)) ){
|
||||
newWorkspace = ActiveWorkspaceIndex();
|
||||
}
|
||||
else{
|
||||
int32 i;
|
||||
for( i = 0; i < 32 && i < count; i++)
|
||||
if( workspaces & (0x00000001UL << i)){
|
||||
newWorkspace = i+1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == count || i == 32)
|
||||
newWorkspace = ActiveWorkspaceIndex();
|
||||
}
|
||||
|
||||
if(newWorkspace != ActiveWorkspaceIndex()){
|
||||
WorkspaceAt(newWorkspace)->SetFrontLayer(winBorder);
|
||||
SetActiveWorkspaceByIndex(newWorkspace);
|
||||
}
|
||||
else{
|
||||
ActiveWorkspace()->SetFrontLayer(winBorder);
|
||||
}
|
||||
|
||||
fMainLock.Unlock();
|
||||
printf("*RootLayer::SetFrontWinBorder(%s) - main lock released\n", winBorder? winBorder->GetName():"NULL");
|
||||
printf("#RootLayer::SetFrontWinBorder(%s)\n", winBorder? winBorder->GetName():"NULL");
|
||||
return true;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void RootLayer::SetScreens(Screen *screen[], int32 rows, int32 columns){
|
||||
// NOTE: *All* Screens *MUST* have the same resolution.
|
||||
fScreenPtrList.MakeEmpty();
|
||||
@@ -359,6 +438,7 @@ bool RootLayer::SetScreenResolution(int32 width, int32 height, uint32 colorspace
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void RootLayer::SetWorkspaceCount(const int32 count){
|
||||
printf("*RootLayer::SetWorkspaceCount(%ld)\n", count);
|
||||
if ((count < 1 && count > 32) || count == WorkspaceCount())
|
||||
return;
|
||||
|
||||
@@ -367,6 +447,8 @@ void RootLayer::SetWorkspaceCount(const int32 count){
|
||||
BList newWSPtrList;
|
||||
void *workspacePtr;
|
||||
|
||||
fMainLock.Lock();
|
||||
printf("*RootLayer::SetWorkspaceCount(%ld) - main lock acquired\n", count);
|
||||
for(int i=0; i < count; i++){
|
||||
workspacePtr = fWSPtrList.ItemAt(i);
|
||||
if (workspacePtr){
|
||||
@@ -374,7 +456,7 @@ void RootLayer::SetWorkspaceCount(const int32 count){
|
||||
}
|
||||
else{
|
||||
Workspace *ws;
|
||||
ws = new Workspace(fColorSpace, i+1, BGColor());
|
||||
ws = new Workspace(fColorSpace, i+1, BGColor(), this);
|
||||
newWSPtrList.AddItem(ws);
|
||||
}
|
||||
}
|
||||
@@ -393,12 +475,16 @@ void RootLayer::SetWorkspaceCount(const int32 count){
|
||||
}
|
||||
|
||||
fWSPtrList = newWSPtrList;
|
||||
|
||||
fMainLock.Unlock();
|
||||
printf("*RootLayer::SetWorkspaceCount(%ld) - main lock released\n", count);
|
||||
if (exActiveWorkspaceIndex > count)
|
||||
SetActiveWorkspaceByIndex(count);
|
||||
|
||||
// if true, this is the first time this method is called.
|
||||
if (exActiveWorkspaceIndex == -1)
|
||||
SetActiveWorkspaceByIndex(1);
|
||||
printf("#RootLayer::SetWorkspaceCount(%ld)\n", count);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int32 RootLayer::WorkspaceCount() const{
|
||||
@@ -453,7 +539,7 @@ RGBColor RootLayer::BGColor(void) const{
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void RootLayer::RemoveAppWindow(WinBorder *wb){
|
||||
wb->Window()->GetApp()->GetFMWList()->RemoveItem(wb);
|
||||
wb->Window()->App()->fAppFMWList.RemoveItem(wb);
|
||||
|
||||
int32 count = WorkspaceCount();
|
||||
for(int32 i=0; i < count; i++){
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#define _ROOTLAYER_H_
|
||||
|
||||
#include <List.h>
|
||||
#include <Locker.h>
|
||||
|
||||
#include "Layer.h"
|
||||
#include "FMWList.h"
|
||||
@@ -50,60 +51,63 @@ class Desktop;
|
||||
class RootLayer : public Layer
|
||||
{
|
||||
public:
|
||||
RootLayer(const char *layername, int32 workspaceCount, Desktop *desktop);
|
||||
virtual ~RootLayer();
|
||||
|
||||
virtual void Draw(const BRect &r);
|
||||
virtual void MoveBy(float x, float y);
|
||||
virtual void ResizeBy(float x, float y);
|
||||
RootLayer(const char *layername,
|
||||
int32 workspaceCount, Desktop *desktop);
|
||||
virtual ~RootLayer();
|
||||
|
||||
virtual Layer* VirtualTopChild() const; //
|
||||
virtual Layer* VirtualLowerSibling() const; // ... for the active workspace
|
||||
virtual Layer* VirtualUpperSibling() const; //
|
||||
virtual Layer* VirtualBottomChild() const; //
|
||||
virtual void Draw(const BRect &r);
|
||||
virtual void MoveBy(float x, float y);
|
||||
virtual void ResizeBy(float x, float y);
|
||||
|
||||
virtual Layer* VirtualTopChild() const; //
|
||||
virtual Layer* VirtualLowerSibling() const; // ... for the active workspace
|
||||
virtual Layer* VirtualUpperSibling() const; //
|
||||
virtual Layer* VirtualBottomChild() const; //
|
||||
|
||||
void AddWinBorder(WinBorder* winBorder);
|
||||
void RemoveWinBorder(WinBorder* winBorder);
|
||||
void ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces);
|
||||
|
||||
void SetScreens(Screen *screen[], int32 rows, int32 columns);
|
||||
Screen** Screens();
|
||||
bool SetScreenResolution(int32 width, int32 height, uint32 colorspace);
|
||||
int32 ScreenRows() const { return fRows; }
|
||||
int32 ScreenColumns() const { return fColumns; }
|
||||
|
||||
void SetWorkspaceCount(const int32 count);
|
||||
int32 WorkspaceCount(void) const;
|
||||
Workspace* WorkspaceAt(const int32 index) const;
|
||||
void SetActiveWorkspaceByIndex(const int32 index);
|
||||
void SetActiveWorkspace(Workspace *ws);
|
||||
int32 ActiveWorkspaceIndex(void) const;
|
||||
Workspace* ActiveWorkspace(void) const;
|
||||
|
||||
void SetBGColor(const RGBColor &col);
|
||||
RGBColor BGColor(void) const;
|
||||
|
||||
void AddWinBorderToWorkspaces(WinBorder* winBorder, uint32 wks);
|
||||
void AddWinBorder(WinBorder* winBorder);
|
||||
void RemoveWinBorder(WinBorder* winBorder);
|
||||
void ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces);
|
||||
bool SetFrontWinBorder(WinBorder* winBorder);
|
||||
|
||||
void SetScreens(Screen *screen[], int32 rows, int32 columns);
|
||||
Screen** Screens();
|
||||
bool SetScreenResolution(int32 width, int32 height, uint32 colorspace);
|
||||
int32 ScreenRows() const { return fRows; }
|
||||
int32 ScreenColumns() const { return fColumns; }
|
||||
|
||||
void SetWorkspaceCount(const int32 count);
|
||||
int32 WorkspaceCount(void) const;
|
||||
Workspace* WorkspaceAt(const int32 index) const;
|
||||
void SetActiveWorkspaceByIndex(const int32 index);
|
||||
void SetActiveWorkspace(Workspace *ws);
|
||||
int32 ActiveWorkspaceIndex(void) const;
|
||||
Workspace* ActiveWorkspace(void) const;
|
||||
|
||||
// ------- debugging methods -------
|
||||
void PrintToStream();
|
||||
|
||||
// "Private" to app_server :-) - they should not be used
|
||||
void RemoveAppWindow(WinBorder *wb);
|
||||
|
||||
FMWList fMainFMWList;
|
||||
void SetBGColor(const RGBColor &col);
|
||||
RGBColor BGColor(void) const;
|
||||
|
||||
void AddWinBorderToWorkspaces(WinBorder* winBorder,
|
||||
uint32 wks);
|
||||
|
||||
// ------- debugging methods -------
|
||||
void PrintToStream();
|
||||
// "Private" to app_server :-) - they should not be used
|
||||
void RemoveAppWindow(WinBorder *wb);
|
||||
|
||||
FMWList fMainFMWList;
|
||||
BLocker fMainLock;
|
||||
private:
|
||||
Desktop *fDesktop;
|
||||
|
||||
BList fScreenPtrList;
|
||||
int32 fRows;
|
||||
int32 fColumns;
|
||||
int32 fScreenXResolution;
|
||||
int32 fScreenYResolution;
|
||||
uint32 fColorSpace;
|
||||
|
||||
BList fWSPtrList;
|
||||
Workspace *fActiveWorkspace;
|
||||
Desktop *fDesktop;
|
||||
|
||||
BList fScreenPtrList;
|
||||
int32 fRows;
|
||||
int32 fColumns;
|
||||
int32 fScreenXResolution;
|
||||
int32 fScreenYResolution;
|
||||
uint32 fColorSpace;
|
||||
|
||||
BList fWSPtrList;
|
||||
Workspace *fActiveWorkspace;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
#include "LayerData.h"
|
||||
#include "Utils.h"
|
||||
|
||||
//#define DEBUG_SERVERAPP
|
||||
#define DEBUG_SERVERAPP
|
||||
|
||||
#ifdef DEBUG_SERVERAPP
|
||||
# include <stdio.h>
|
||||
@@ -70,8 +70,14 @@
|
||||
\param _signature NULL-terminated string which contains the BApplication's
|
||||
MIME _signature.
|
||||
*/
|
||||
ServerApp::ServerApp(port_id sendport, port_id rcvport, int32 handlerID, char *signature)
|
||||
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
|
||||
fClientTeamID = clientTeamID;
|
||||
// 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
|
||||
// owns the copy which we are passed as a parameter.
|
||||
_signature=(signature)?signature:"application/x-vnd.unregistered-application";
|
||||
@@ -85,9 +91,7 @@ ServerApp::ServerApp(port_id sendport, port_id rcvport, int32 handlerID, char *s
|
||||
_applink->SetPort(_sender);
|
||||
|
||||
// Gotta get the team ID so we can ping the application
|
||||
port_info pinfo;
|
||||
get_port_info(_sender,&pinfo);
|
||||
_target_id=pinfo.team;
|
||||
_target_id = clientTeamID;
|
||||
|
||||
// _receiver is the port we receive messages from our BApplication
|
||||
_receiver=rcvport;
|
||||
@@ -102,11 +106,12 @@ ServerApp::ServerApp(port_id sendport, port_id rcvport, int32 handlerID, char *s
|
||||
_appcursor=(defaultc)?new ServerCursor(defaultc):NULL;
|
||||
_lock=create_sem(1,"ServerApp sem");
|
||||
|
||||
// TODO: Fix
|
||||
//TODO: resolve
|
||||
// _driver=GetGfxDriver(ActiveScreen());
|
||||
|
||||
_cursorhidden=false;
|
||||
|
||||
Run();
|
||||
|
||||
STRACE(("ServerApp %s:\n",_signature.String()));
|
||||
STRACE(("\tBApp port: %ld\n",_sender));
|
||||
STRACE(("\tReceiver port: %ld\n",_receiver));
|
||||
@@ -115,9 +120,35 @@ ServerApp::ServerApp(port_id sendport, port_id rcvport, int32 handlerID, char *s
|
||||
//! Does all necessary teardown for application
|
||||
ServerApp::~ServerApp(void)
|
||||
{
|
||||
STRACE(("ServerApp %s:~ServerApp()\n",_signature.String()));
|
||||
STRACE(("*ServerApp %s:~ServerApp()\n",_signature.String()));
|
||||
int32 i;
|
||||
|
||||
|
||||
// wait for our ServerWindow threads
|
||||
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()){
|
||||
thread_id tid = sw->ThreadID();
|
||||
status_t temp;
|
||||
|
||||
desktop->fLayerLock.Unlock();
|
||||
printf("waiting for thread %s\n", sw->Title());
|
||||
wait_for_thread(tid, &temp);
|
||||
|
||||
desktop->fLayerLock.Lock();
|
||||
|
||||
ready = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}while(!ready);
|
||||
desktop->fLayerLock.Unlock();
|
||||
/*
|
||||
ServerWindow *tempwin;
|
||||
for(i=0;i<_winlist->CountItems();i++)
|
||||
{
|
||||
@@ -127,7 +158,7 @@ ServerApp::~ServerApp(void)
|
||||
}
|
||||
_winlist->MakeEmpty();
|
||||
delete _winlist;
|
||||
|
||||
*/
|
||||
ServerBitmap *tempbmp;
|
||||
for(i=0;i<_bmplist->CountItems();i++)
|
||||
{
|
||||
@@ -153,13 +184,17 @@ ServerApp::~ServerApp(void)
|
||||
if(_appcursor)
|
||||
delete _appcursor;
|
||||
|
||||
|
||||
cursormanager->RemoveAppCursors(_signature.String());
|
||||
delete_sem(_lock);
|
||||
|
||||
STRACE(("#ServerApp %s:~ServerApp()\n",_signature.String()));
|
||||
|
||||
// Kill the monitor thread if it exists
|
||||
thread_info info;
|
||||
if(get_thread_info(_monitor_thread,&info)==B_OK)
|
||||
kill_thread(_monitor_thread);
|
||||
|
||||
cursormanager->RemoveAppCursors(_signature.String());
|
||||
delete_sem(_lock);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -220,6 +255,21 @@ void ServerApp::PostMessage(int32 code, size_t size, int8 *buffer)
|
||||
write_port(_receiver,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);
|
||||
}
|
||||
else
|
||||
printf("PANIC: ServerApp: '%s': can't flatten message in 'SendMessageToClient()'\n", _signature.String());
|
||||
|
||||
delete buffer;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Sets the ServerApp's active status
|
||||
\param value The new status of the ServerApp.
|
||||
@@ -247,22 +297,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;
|
||||
ServerApp *app = (ServerApp *)data;
|
||||
PortQueue msgqueue(app->_receiver);
|
||||
PortMessage *msg;
|
||||
bool quiting = false;
|
||||
|
||||
for(;;)
|
||||
for( ; !quiting; )
|
||||
{
|
||||
if(!msgqueue.MessagesWaiting())
|
||||
msgqueue.GetMessagesFromPort(true);
|
||||
else
|
||||
msgqueue.GetMessagesFromPort(false);
|
||||
|
||||
msg=msgqueue.GetMessageFromQueue();
|
||||
msg = msgqueue.GetMessageFromQueue();
|
||||
if(!msg)
|
||||
continue;
|
||||
|
||||
@@ -271,6 +322,7 @@ int32 ServerApp::MonitorApp(void *data)
|
||||
case AS_QUIT_APP:
|
||||
{
|
||||
STRACE(("ServerApp %s:Server shutdown notification received\n",app->_signature.String()));
|
||||
/*
|
||||
// If we are using the real, accelerated version of the
|
||||
// DisplayDriver, we do NOT want the user to be able shut down
|
||||
// the server. The results would NOT be pretty
|
||||
@@ -281,18 +333,13 @@ int32 ServerApp::MonitorApp(void *data)
|
||||
// ask all apps to quit. This is NOT the same as system
|
||||
// shutdown and will happen only in testing
|
||||
|
||||
// For now, it seems that we can't seem to try to play nice and tell
|
||||
// an application to quit, so we'll just have to go postal. XD
|
||||
|
||||
// BMessage *shutdown=new BMessage(_QUIT_);
|
||||
// SendMessage(app->_sender,shutdown);
|
||||
|
||||
// DIE! DIE! DIE! :P
|
||||
port_info pi;
|
||||
get_port_info(app->_sender,&pi);
|
||||
kill_team(pi.team);
|
||||
app->PostMessage(B_QUIT_REQUESTED);
|
||||
BMessage pleaseQuit(_QUIT_);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -300,15 +347,19 @@ int32 ServerApp::MonitorApp(void *data)
|
||||
{
|
||||
// Our BApplication sent us this message when it quit.
|
||||
// We need to ask the app_server to delete our monitor
|
||||
port_id serverport=find_port(SERVER_PORT_NAME);
|
||||
if(serverport==B_NAME_NOT_FOUND)
|
||||
{
|
||||
// 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;
|
||||
// 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());
|
||||
break;
|
||||
}
|
||||
app->_applink->SetPort(serverport);
|
||||
app->_applink->SetOpCode(AS_DELETE_APP);
|
||||
app->_applink->Attach(&app->_monitor_thread,sizeof(thread_id));
|
||||
app->_applink->Attach(&app->_monitor_thread, sizeof(thread_id));
|
||||
app->_applink->Flush();
|
||||
break;
|
||||
}
|
||||
@@ -321,10 +372,8 @@ int32 ServerApp::MonitorApp(void *data)
|
||||
}
|
||||
|
||||
delete msg;
|
||||
|
||||
} // end for
|
||||
|
||||
exit_thread(0);
|
||||
// clean exit.
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -353,9 +402,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
}
|
||||
case AS_UPDATE_COLORS:
|
||||
{
|
||||
// TODO: move message def to ServerProtocol.h to allow for
|
||||
// complete build compatibility under R5
|
||||
/* ServerWindow *win;
|
||||
ServerWindow *win;
|
||||
BMessage msg(_COLORS_UPDATED);
|
||||
|
||||
for(int32 i=0; i<_winlist->CountItems(); i++)
|
||||
@@ -366,14 +413,11 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
win->SendMessageToClient(&msg);
|
||||
win->Unlock();
|
||||
}
|
||||
*/ break;
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_UPDATE_FONTS:
|
||||
{
|
||||
// TODO: move message def to ServerProtocol.h to allow for
|
||||
// complete build compatibility under R5
|
||||
/* ServerWindow *win;
|
||||
ServerWindow *win;
|
||||
BMessage msg(_FONTS_UPDATED);
|
||||
|
||||
for(int32 i=0; i<_winlist->CountItems(); i++)
|
||||
@@ -384,13 +428,11 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
win->SendMessageToClient(&msg);
|
||||
win->Unlock();
|
||||
}
|
||||
*/ break;
|
||||
break;
|
||||
}
|
||||
case AS_UPDATE_DECORATOR:
|
||||
{
|
||||
// TODO: move message def to ServerProtocol.h to allow for
|
||||
// complete build compatibility under R5
|
||||
/* ServerWindow *win;
|
||||
ServerWindow *win;
|
||||
|
||||
for(int32 i=0; i<_winlist->CountItems(); i++)
|
||||
{
|
||||
@@ -399,7 +441,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
win->_winborder->UpdateDecorator();
|
||||
win->Unlock();
|
||||
}
|
||||
*/ break;
|
||||
break;
|
||||
}
|
||||
case AS_CREATE_WINDOW:
|
||||
{
|
||||
@@ -425,7 +467,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
port_id looperPort;
|
||||
port_id replyport;
|
||||
char *title;
|
||||
|
||||
|
||||
msg->Read<BRect>(&frame);
|
||||
msg->Read<int32>((int32*)&look);
|
||||
msg->Read<int32>((int32*)&feel);
|
||||
@@ -441,41 +483,18 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
_signature.String()));
|
||||
|
||||
// ServerWindow constructor will reply with port_id of a newly created port
|
||||
ServerWindow *newwin = new ServerWindow(frame, title,
|
||||
look, feel, flags, this, sendPort, looperPort, replyport, wkspaces, token);
|
||||
|
||||
_winlist->AddItem(newwin);
|
||||
new ServerWindow(frame, title, look, feel, flags, this,
|
||||
sendPort, looperPort, replyport, wkspaces, token);
|
||||
// ServerWindow constructor has added 'newwin' to the Desktop.
|
||||
// We don't have to do anything here...
|
||||
|
||||
STRACE(("ServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n",
|
||||
STRACE(("\nServerApp %s: New Window %s (%.1f,%.1f,%.1f,%.1f)\n",
|
||||
_signature.String(),title,frame.left,frame.top,frame.right,frame.bottom));
|
||||
|
||||
delete title;
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_DELETE_WINDOW:
|
||||
{
|
||||
// Received from a ServerWindow when its window quits
|
||||
|
||||
// Attached data:
|
||||
// 1) uint32 ServerWindow ID token
|
||||
ServerWindow *w;
|
||||
uint32 winid;
|
||||
msg->Read<uint32>(&winid);
|
||||
|
||||
for(int32 i=0;i<_winlist->CountItems();i++)
|
||||
{
|
||||
w=(ServerWindow*)_winlist->ItemAt(i);
|
||||
if(w->_token==winid)
|
||||
{
|
||||
STRACE(("ServerApp %s: Deleting window %s\n",_signature.String(),w->GetTitle()));
|
||||
_winlist->RemoveItem(w);
|
||||
delete w;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case AS_CREATE_BITMAP:
|
||||
{
|
||||
// Allocate a bitmap for an application
|
||||
@@ -601,8 +620,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
msg->Read<int32>(&workspace);
|
||||
msg->Read<uint32>(&mode);
|
||||
msg->Read<bool>(&stick);
|
||||
|
||||
// TODO: Fix
|
||||
//TODO: Resolve
|
||||
// SetSpace(workspace,mode,ActiveScreen(),stick);
|
||||
|
||||
break;
|
||||
@@ -615,8 +633,7 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
// Error-checking is done in ActivateWorkspace, so this is a safe call
|
||||
int32 workspace;
|
||||
msg->Read<int32>(&workspace);
|
||||
|
||||
// TODO: Fix
|
||||
//TODO: Resolve
|
||||
// SetWorkspace(workspace);
|
||||
break;
|
||||
}
|
||||
@@ -735,13 +752,15 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
{
|
||||
// Attached data:
|
||||
// 1) port_id reply port - synchronous message
|
||||
scroll_bar_info sbi=desktop->ScrollBarInfo();
|
||||
//TODO: resolve
|
||||
// scroll_bar_info sbi=GetScrollBarInfo();
|
||||
|
||||
port_id replyport;
|
||||
msg->Read<int32>(&replyport);
|
||||
|
||||
PortLink link(replyport);
|
||||
link.Attach<scroll_bar_info>(sbi);
|
||||
//TODO: resolve
|
||||
// link.Attach<scroll_bar_info>(sbi);
|
||||
link.Flush();
|
||||
break;
|
||||
}
|
||||
@@ -751,7 +770,8 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
// 1) scroll_bar_info scroll bar info structure
|
||||
scroll_bar_info sbi;
|
||||
msg->Read<scroll_bar_info>(&sbi);
|
||||
desktop->SetScrollBarInfo(sbi);
|
||||
//TODO: resolve
|
||||
// SetScrollBarInfo(sbi);
|
||||
break;
|
||||
}
|
||||
case AS_FOCUS_FOLLOWS_MOUSE:
|
||||
@@ -763,7 +783,8 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
msg->Read<int32>(&replyport);
|
||||
|
||||
PortLink link(replyport);
|
||||
link.Attach<bool>(desktop->FFMouseInUse());
|
||||
//TODO: resolve
|
||||
// link.Attach<bool>(GetFFMouse());
|
||||
link.Flush();
|
||||
break;
|
||||
}
|
||||
@@ -773,7 +794,8 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
// 1) scroll_bar_info scroll bar info structure
|
||||
scroll_bar_info sbi;
|
||||
msg->Read<scroll_bar_info>(&sbi);
|
||||
desktop->SetScrollBarInfo(sbi);
|
||||
//TODO: resolve
|
||||
// SetScrollBarInfo(sbi);
|
||||
break;
|
||||
}
|
||||
case AS_SET_MOUSE_MODE:
|
||||
@@ -782,20 +804,23 @@ void ServerApp::_DispatchMessage(PortMessage *msg)
|
||||
// 1) enum mode_mouse FFM mouse mode
|
||||
mode_mouse mmode;
|
||||
msg->Read<mode_mouse>(&mmode);
|
||||
desktop->SetFFMouseMode(mmode);
|
||||
//TODO: resolve
|
||||
// SetFFMouseMode(mmode);
|
||||
break;
|
||||
}
|
||||
case AS_GET_MOUSE_MODE:
|
||||
{
|
||||
// Attached data:
|
||||
// 1) port_id reply port - synchronous message
|
||||
mode_mouse mmode=desktop->FFMouseMode();
|
||||
//TODO: resolve
|
||||
// mode_mouse mmode=GetFFMouseMode();
|
||||
|
||||
port_id replyport;
|
||||
msg->Read<int32>(&replyport);
|
||||
|
||||
PortLink link(replyport);
|
||||
link.Attach<mode_mouse>(mmode);
|
||||
//TODO: resolve
|
||||
// link.Attach<mode_mouse>(mmode);
|
||||
link.Flush();
|
||||
break;
|
||||
}
|
||||
@@ -831,3 +856,6 @@ ServerBitmap *ServerApp::_FindBitmap(int32 token)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
team_id ServerApp::ClientTeamID(){
|
||||
return fClientTeamID;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
#include <OS.h>
|
||||
#include <String.h>
|
||||
#include <ServerBitmap.h>
|
||||
#include "FMWList.h"
|
||||
|
||||
class AppServer;
|
||||
@@ -40,22 +39,6 @@ class BList;
|
||||
class DisplayDriver;
|
||||
class ServerCursor;
|
||||
|
||||
|
||||
/*
|
||||
class ServerApp{
|
||||
public:
|
||||
ServerApp(team_id clientTeamID){
|
||||
fClientTeamID = clientTeamID;
|
||||
}
|
||||
virtual ~ServerApp(){ }
|
||||
team_id ClientTeamID(){ return fClientTeamID; }
|
||||
|
||||
FMWList fAppFMWList;
|
||||
private:
|
||||
team_id fClientTeamID;
|
||||
};
|
||||
*/
|
||||
|
||||
/*!
|
||||
\class ServerApp ServerApp.h
|
||||
\brief Counterpart to BApplication within the app_server
|
||||
@@ -63,48 +46,60 @@ private:
|
||||
class ServerApp
|
||||
{
|
||||
public:
|
||||
ServerApp(port_id sendport, port_id rcvport, int32 handlerID, char *signature);
|
||||
~ServerApp(void);
|
||||
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; }
|
||||
bool IsActive(void) const { return _isactive; }
|
||||
|
||||
void Activate(bool value);
|
||||
bool PingTarget(void);
|
||||
void Activate(bool value);
|
||||
bool PingTarget(void);
|
||||
|
||||
void PostMessage(int32 code, size_t size=0, int8 *buffer=NULL);
|
||||
void PostMessage(int32 code, size_t size=0,
|
||||
int8 *buffer=NULL);
|
||||
void SendMessageToClient( const BMessage* msg ) const;
|
||||
|
||||
void SetAppCursor(void);
|
||||
FMWList *GetFMWList(void) { return &fAppFMWList; }
|
||||
|
||||
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;
|
||||
BString _signature;
|
||||
thread_id _monitor_thread;
|
||||
team_id _target_id;
|
||||
PortLink *_applink;
|
||||
BList *_winlist, *_bmplist, *_piclist;
|
||||
DisplayDriver *_driver;
|
||||
ServerCursor *_appcursor;
|
||||
sem_id _lock;
|
||||
bool _cursorhidden;
|
||||
bool _isactive;
|
||||
int32 _handlertoken;
|
||||
FMWList fAppFMWList;
|
||||
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;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -65,107 +65,113 @@ 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 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);
|
||||
|
||||
status_t Lock(void);
|
||||
void Unlock(void);
|
||||
bool IsLocked(void);
|
||||
thread_id ThreadID() const { return _monitorthread;}
|
||||
|
||||
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 ReplaceDecorator(void);
|
||||
void Quit(void);
|
||||
|
||||
const char *GetTitle(void);
|
||||
ServerApp *GetApp(void);
|
||||
int32 GetLook(void) const { return _look; }
|
||||
int32 GetFeel(void) const { return _feel; }
|
||||
int32 GetFlags(void) const { return _flags; }
|
||||
int32 GetHandlerID(void) const { return _handlertoken; }
|
||||
//! Returns the index of the workspaces to which it belongs
|
||||
uint32 GetWorkspaces(void) const { return _workspaces; }
|
||||
|
||||
team_id GetClientTeamID(void) const { return fClientTeamID; }
|
||||
FMWList *GetFMWList(void) { return &fWinFMWList; }
|
||||
int32 GetWorkspaceIndex(void) { return fWorkspaces; }
|
||||
Workspace* GetWorkspace(void);
|
||||
void SetWorkspace(Workspace *wkspc);
|
||||
|
||||
void SetLook(int32 look);
|
||||
void SetFeel(int32 feel);
|
||||
void SetFlags(int32 flags);
|
||||
void SetWorkspaces(int32 workspaces);
|
||||
|
||||
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 SetFrame(const BRect &rect);
|
||||
BRect Frame(void);
|
||||
|
||||
status_t Lock(void);
|
||||
void Unlock(void);
|
||||
bool IsLocked(void);
|
||||
|
||||
void DispatchMessage(PortMessage msg);
|
||||
void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer);
|
||||
|
||||
static int32 MonitorWin(void *data);
|
||||
static void HandleMouseEvent(PortMessage *msg);
|
||||
static void HandleKeyEvent(int32 code, int8 *buffer);
|
||||
|
||||
// Workspace* GetWorkspace(void);
|
||||
void SetWorkspace(Workspace *wkspc);
|
||||
|
||||
//! Returns the window's title
|
||||
const char *Title(void) { return _title->String(); }
|
||||
const char* Title(void) { return _title->String(); }
|
||||
|
||||
Layer* FindLayer(const Layer* start, int32 token) const;
|
||||
void SendMessageToClient( const BMessage* msg ) const;
|
||||
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; }
|
||||
|
||||
FMWList fWinFMWList;
|
||||
protected:
|
||||
friend class ServerApp;
|
||||
friend class WinBorder;
|
||||
friend class Screen;
|
||||
friend class Layer;
|
||||
|
||||
BString *_title;
|
||||
int32 _look,
|
||||
_feel,
|
||||
_flags;
|
||||
uint32 _workspaces;
|
||||
Workspace *_workspace;
|
||||
bool _active;
|
||||
BString *_title;
|
||||
int32 _look,
|
||||
_feel,
|
||||
_flags;
|
||||
uint32 fWorkspaces;
|
||||
Workspace *_workspace;
|
||||
bool _active;
|
||||
|
||||
ServerApp *_app;
|
||||
WinBorder *_winborder;
|
||||
ServerApp *_app;
|
||||
WinBorder *_winborder;
|
||||
|
||||
thread_id _monitorthread;
|
||||
team_id fClientTeamID;
|
||||
thread_id _monitorthread;
|
||||
port_id _receiver; // Messages from window
|
||||
port_id _sender; // Messages to window
|
||||
PortLink *_winlink;
|
||||
|
||||
port_id _receiver; // Messages from window
|
||||
port_id _sender; // Messages to window
|
||||
|
||||
PortLink *_winlink,
|
||||
*_applink;
|
||||
BLocker _locker;
|
||||
BRect _frame;
|
||||
uint32 _token;
|
||||
int32 _handlertoken;
|
||||
BLocker _locker;
|
||||
BRect _frame;
|
||||
uint32 _token;
|
||||
int32 _handlertoken;
|
||||
|
||||
port_id winLooperPort;
|
||||
Layer *top_layer;
|
||||
Layer *currentlayer;
|
||||
FMWList fWinFMWList;
|
||||
team_id fClientTeamID;
|
||||
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 :-)
|
||||
};
|
||||
|
||||
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,10 +27,8 @@
|
||||
#include <Region.h>
|
||||
#include <String.h>
|
||||
#include <Locker.h>
|
||||
#include <Region.h>
|
||||
#include <Debug.h>
|
||||
#include <TokenSpace.h>
|
||||
#include "Globals.h"
|
||||
#include "View.h" // for mouse button defines
|
||||
#include "ServerWindow.h"
|
||||
#include "Decorator.h"
|
||||
@@ -342,48 +340,9 @@ void WinBorder::SetFocus(const bool &active)
|
||||
_decorator->SetFocus(active);
|
||||
}
|
||||
|
||||
void WinBorder::SetServerFeel(int32 feel)
|
||||
{
|
||||
switch(_win->GetFeel())
|
||||
{
|
||||
case B_NORMAL_WINDOW_FEEL:
|
||||
_serverfeel = B_NORMAL_FEEL;
|
||||
break;
|
||||
case B_FLOATING_SUBSET_WINDOW_FEEL:
|
||||
_serverfeel = B_FLOATING_SUBSET_FEEL;
|
||||
break;
|
||||
case B_FLOATING_APP_WINDOW_FEEL:
|
||||
_serverfeel = B_FLOATING_APP_FEEL;
|
||||
break;
|
||||
case B_FLOATING_ALL_WINDOW_FEEL:
|
||||
_serverfeel = B_FLOATING_ALL_FEEL;
|
||||
break;
|
||||
case B_MODAL_SUBSET_WINDOW_FEEL:
|
||||
_serverfeel = B_MODAL_SUBSET_FEEL;
|
||||
break;
|
||||
case B_MODAL_APP_WINDOW_FEEL:
|
||||
_serverfeel = B_MODAL_APP_FEEL;
|
||||
break;
|
||||
case B_MODAL_ALL_WINDOW_FEEL:
|
||||
_serverfeel = B_MODAL_ALL_FEEL;
|
||||
break;
|
||||
case B_SYSTEM_LAST:
|
||||
case B_SYSTEM_FIRST:
|
||||
// if(_win->ServerTeamID() != _win->ClientTeamID())
|
||||
// _win->QuietlySetFeel(B_NORMAL_WINDOW_FEEL);
|
||||
// else
|
||||
// _serverfeel = _win->GetFeel();
|
||||
break;
|
||||
default:
|
||||
_win->SetFeel(B_NORMAL_WINDOW_FEEL);
|
||||
_serverfeel = B_NORMAL_FEEL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void WinBorder::RebuildRegions( const BRect& r ){
|
||||
/* WinBorder is a little bit special. It doesn't have a visible region
|
||||
in witch to do its drawings. Instead the hole visible region is split
|
||||
in which to do its drawings. Instead the whole visible region is split
|
||||
between decorator and top_layer.
|
||||
*/
|
||||
|
||||
|
||||
@@ -38,17 +38,17 @@ class DisplayDriver;
|
||||
class WinBorder : public Layer
|
||||
{
|
||||
public:
|
||||
WinBorder(const BRect &r, const char *name, const int32 look,
|
||||
const int32 feel, const int32 flags, ServerWindow *win);
|
||||
virtual ~WinBorder(void);
|
||||
|
||||
WinBorder(const BRect &r, const char *name, const int32 look,
|
||||
const int32 feel, const int32 flags, ServerWindow *win);
|
||||
virtual ~WinBorder(void);
|
||||
|
||||
virtual void RebuildRegions( const BRect& r );
|
||||
virtual void Draw(const BRect &r);
|
||||
|
||||
virtual void MoveBy(float x, float y);
|
||||
virtual void ResizeBy(float x, float y);
|
||||
bool HasPoint(BPoint pt) const;
|
||||
|
||||
|
||||
void MoveToBack();
|
||||
void MoveToFront();
|
||||
|
||||
@@ -80,7 +80,6 @@ public:
|
||||
void SetMainWinBorder(WinBorder *newMain);
|
||||
|
||||
protected:
|
||||
|
||||
ServerWindow *_win;
|
||||
//BString *_title;
|
||||
Decorator *_decorator;
|
||||
@@ -105,14 +104,14 @@ protected:
|
||||
*/
|
||||
};
|
||||
|
||||
bool is_moving_window(void);
|
||||
void set_is_moving_window(bool state);
|
||||
bool is_resizing_window(void);
|
||||
void set_is_resizing_window(bool state);
|
||||
void set_active_winborder(WinBorder *win);
|
||||
WinBorder *get_active_winborder(void);
|
||||
void set_is_resizing_window(bool state);
|
||||
void set_is_sliding_tab(bool state);
|
||||
bool is_sliding_tab(void);
|
||||
bool is_moving_window(void);
|
||||
void set_is_moving_window(bool state);
|
||||
bool is_resizing_window(void);
|
||||
void set_is_resizing_window(bool state);
|
||||
void set_active_winborder(WinBorder *win);
|
||||
WinBorder* get_active_winborder(void);
|
||||
void set_is_resizing_window(bool state);
|
||||
void set_is_sliding_tab(bool state);
|
||||
bool is_sliding_tab(void);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user