Finished up ServerApp
Implemented most of and documented all of ServerWindow Miscellaneous necessary tweaks to other classes git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2833 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -322,12 +322,12 @@ void AppServer::MainLoop(void)
|
||||
{
|
||||
switch(msgcode)
|
||||
{
|
||||
case CREATE_APP:
|
||||
case DELETE_APP:
|
||||
case GET_SCREEN_MODE:
|
||||
case AS_CREATE_APP:
|
||||
case AS_DELETE_APP:
|
||||
case AS_GET_SCREEN_MODE:
|
||||
case B_QUIT_REQUESTED:
|
||||
case UPDATED_CLIENT_FONTLIST:
|
||||
case QUERY_FONTS_CHANGED:
|
||||
case AS_UPDATED_CLIENT_FONTLIST:
|
||||
case AS_QUERY_FONTS_CHANGED:
|
||||
DispatchMessage(msgcode,msgbuffer);
|
||||
break;
|
||||
default:
|
||||
@@ -341,7 +341,7 @@ void AppServer::MainLoop(void)
|
||||
|
||||
if(buffersize>0)
|
||||
delete msgbuffer;
|
||||
if(msgcode==DELETE_APP || msgcode==B_QUIT_REQUESTED && DISPLAYDRIVER!=HWDRIVER)
|
||||
if(msgcode==AS_DELETE_APP || msgcode==B_QUIT_REQUESTED && DISPLAYDRIVER!=HWDRIVER)
|
||||
{
|
||||
if(_quitting_server==true && _applist->CountItems()==0)
|
||||
break;
|
||||
@@ -402,7 +402,7 @@ void AppServer::DispatchMessage(int32 code, int8 *buffer)
|
||||
int8 *index=buffer;
|
||||
switch(code)
|
||||
{
|
||||
case CREATE_APP:
|
||||
case AS_CREATE_APP:
|
||||
{
|
||||
// Create the ServerApp to node monitor a new BApplication
|
||||
|
||||
@@ -436,7 +436,7 @@ void AppServer::DispatchMessage(int32 code, int8 *buffer)
|
||||
_active_app=_applist->CountItems()-1;
|
||||
|
||||
PortLink *replylink=new PortLink(reply_port);
|
||||
replylink->SetOpCode(SET_SERVER_PORT);
|
||||
replylink->SetOpCode(AS_SET_SERVER_PORT);
|
||||
replylink->Attach((int32)newapp->_receiver);
|
||||
replylink->Flush();
|
||||
|
||||
@@ -447,7 +447,7 @@ void AppServer::DispatchMessage(int32 code, int8 *buffer)
|
||||
newapp->Run();
|
||||
break;
|
||||
}
|
||||
case DELETE_APP:
|
||||
case AS_DELETE_APP:
|
||||
{
|
||||
// Delete a ServerApp. Received only from the respective ServerApp when a
|
||||
// BApplication asks it to quit.
|
||||
@@ -497,7 +497,7 @@ void AppServer::DispatchMessage(int32 code, int8 *buffer)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case UPDATED_CLIENT_FONTLIST:
|
||||
case AS_UPDATED_CLIENT_FONTLIST:
|
||||
{
|
||||
// received when the client-side global font list has been
|
||||
// refreshed
|
||||
@@ -506,7 +506,7 @@ void AppServer::DispatchMessage(int32 code, int8 *buffer)
|
||||
fontserver->Unlock();
|
||||
break;
|
||||
}
|
||||
case QUERY_FONTS_CHANGED:
|
||||
case AS_QUERY_FONTS_CHANGED:
|
||||
{
|
||||
// Client application is asking if the font list has changed since
|
||||
// the last client-side refresh
|
||||
@@ -525,7 +525,7 @@ void AppServer::DispatchMessage(int32 code, int8 *buffer)
|
||||
|
||||
break;
|
||||
}
|
||||
case GET_SCREEN_MODE:
|
||||
case AS_GET_SCREEN_MODE:
|
||||
{
|
||||
// Synchronous message call to get the stats on the current screen mode
|
||||
// in the app_server. Simply a hack in place for the Input Server until
|
||||
@@ -540,7 +540,7 @@ void AppServer::DispatchMessage(int32 code, int8 *buffer)
|
||||
// 3) int depth
|
||||
|
||||
PortLink *replylink=new PortLink(*((port_id*)index));
|
||||
replylink->SetOpCode(GET_SCREEN_MODE);
|
||||
replylink->SetOpCode(AS_GET_SCREEN_MODE);
|
||||
replylink->Attach((int16)_driver->GetWidth());
|
||||
replylink->Attach((int16)_driver->GetHeight());
|
||||
replylink->Attach((int16)_driver->GetDepth());
|
||||
@@ -559,7 +559,7 @@ void AppServer::DispatchMessage(int32 code, int8 *buffer)
|
||||
if(DISPLAYDRIVER==HWDRIVER)
|
||||
break;
|
||||
|
||||
Broadcast(QUIT_APP);
|
||||
Broadcast(AS_QUIT_APP);
|
||||
|
||||
// So when we delete the last ServerApp, we can exit the server
|
||||
_quitting_server=true;
|
||||
|
||||
@@ -131,6 +131,7 @@ void InitDesktop(void)
|
||||
{
|
||||
s->Activate();
|
||||
desktop_private::activescreen=s;
|
||||
s->SetSpace(0,B_32_BIT_640x480,true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,6 +248,17 @@ int32 CurrentWorkspace(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the workspace object for the active screen at the given index
|
||||
*/
|
||||
Workspace *WorkspaceAt(int32 index)
|
||||
{
|
||||
if(desktop_private::activescreen)
|
||||
return desktop_private::activescreen->GetWorkspace(index);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Sets the active workspace
|
||||
\param workspace Index of the workspace to activate
|
||||
|
||||
@@ -38,13 +38,14 @@ TokenHandler screen_id_handler;
|
||||
\param fbinfo The frame buffer info
|
||||
\param gfxdriver DisplayDriver for the associated RootLayer
|
||||
*/
|
||||
Workspace::Workspace(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo, DisplayDriver *gfxdriver)
|
||||
Workspace::Workspace(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo, Screen *screen)
|
||||
{
|
||||
_gcinfo=gcinfo;
|
||||
_fbinfo=fbinfo;
|
||||
|
||||
_screen=screen;
|
||||
_rootlayer=new RootLayer(BRect(0,0,fbinfo.display_width-1,fbinfo.display_height-1),
|
||||
"Workspace Root",gfxdriver);
|
||||
"Workspace Root",_screen->GetGfxDriver());
|
||||
_rootlayer->SetColor(workspace_default_color);
|
||||
}
|
||||
|
||||
@@ -170,7 +171,7 @@ Screen::Screen(DisplayDriver *gfxmodule, uint8 workspaces)
|
||||
_workspacecount = workspaces;
|
||||
for (int i=0; i<workspaces; i++)
|
||||
{
|
||||
_workspacelist->AddItem(new Workspace(_gcinfo,_fbinfo,_driver));
|
||||
_workspacelist->AddItem(new Workspace(_gcinfo,_fbinfo,this));
|
||||
}
|
||||
_resolution=_driver->GetMode();
|
||||
_currentworkspace=0;
|
||||
@@ -203,7 +204,7 @@ Screen::~Screen(void)
|
||||
*/
|
||||
void Screen::AddWorkspace(int32 index)
|
||||
{
|
||||
Workspace *workspace = new Workspace(_gcinfo,_fbinfo,_driver);
|
||||
Workspace *workspace = new Workspace(_gcinfo,_fbinfo,this);
|
||||
if ( (index == -1) || !_workspacelist->AddItem(workspace,index) )
|
||||
_workspacelist->AddItem(workspace);
|
||||
}
|
||||
@@ -398,3 +399,14 @@ Workspace *Screen::GetActiveWorkspace(void)
|
||||
return _activeworkspace;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns a pointer to the Workspace at the specified index
|
||||
\return A pointer to the Workspace at the specified index
|
||||
*/
|
||||
Workspace *Screen::GetWorkspace(int32 index)
|
||||
{
|
||||
if(index==_currentworkspace)
|
||||
return _activeworkspace;
|
||||
|
||||
return (Workspace*)_workspacelist->ItemAt(index);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
class DisplayDriver;
|
||||
class ServerWindow;
|
||||
class RGBColor;
|
||||
class Screen;
|
||||
|
||||
/*!
|
||||
\class Workspace DesktopClasses.h
|
||||
@@ -47,7 +48,7 @@ class RGBColor;
|
||||
class Workspace
|
||||
{
|
||||
public:
|
||||
Workspace(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo, DisplayDriver *gfxdriver);
|
||||
Workspace(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo, Screen *screen);
|
||||
~Workspace(void);
|
||||
void SetBGColor(const RGBColor &c);
|
||||
RGBColor BGColor();
|
||||
@@ -55,10 +56,13 @@ public:
|
||||
void SetData(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo);
|
||||
void GetData(graphics_card_info *gcinfo, frame_buffer_info *fbinfo);
|
||||
void SetSpace(int32 res);
|
||||
//! Returns the screen to which the workspace belongs
|
||||
Screen *GetScreen(void) { return _screen; }
|
||||
protected:
|
||||
RootLayer *_rootlayer;
|
||||
graphics_card_info _gcinfo;
|
||||
frame_buffer_info _fbinfo;
|
||||
Screen *_screen;
|
||||
};
|
||||
|
||||
/*!
|
||||
@@ -88,6 +92,7 @@ public:
|
||||
void SetActiveWindow(ServerWindow *win);
|
||||
Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE);
|
||||
bool IsInitialized(void);
|
||||
Workspace *GetWorkspace(int32 index);
|
||||
Workspace *GetActiveWorkspace(void);
|
||||
//! Returns the unique identifier for the screen
|
||||
int32 GetID(void) { return _id; }
|
||||
|
||||
@@ -515,6 +515,15 @@ void Layer::Hide(void)
|
||||
child->Hide();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Determines whether the layer is hidden or not
|
||||
\return true if hidden, false if not.
|
||||
*/
|
||||
bool Layer::IsHidden(void)
|
||||
{
|
||||
return (_hidecount==0)?false:true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Counts the number of children the layer has
|
||||
\return the number of children the layer has, not including grandchildren
|
||||
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
|
||||
void Show(void);
|
||||
void Hide(void);
|
||||
bool IsHidden(void);
|
||||
|
||||
BRect Bounds(void);
|
||||
BRect Frame(void);
|
||||
|
||||
@@ -164,7 +164,7 @@ bool ServerApp::PingTarget(void)
|
||||
return false;
|
||||
}
|
||||
_applink->SetPort(serverport);
|
||||
_applink->SetOpCode(DELETE_APP);
|
||||
_applink->SetOpCode(AS_DELETE_APP);
|
||||
_applink->Attach(&_monitor_thread,sizeof(thread_id));
|
||||
_applink->Flush();
|
||||
return false;
|
||||
@@ -213,17 +213,7 @@ int32 ServerApp::MonitorApp(void *data)
|
||||
switch(msgcode)
|
||||
{
|
||||
// -------------- Messages received from the Server ------------------------
|
||||
// Mouse messages simply get passed onto the active app for now
|
||||
case B_MOUSE_UP:
|
||||
case B_MOUSE_DOWN:
|
||||
case B_MOUSE_MOVED:
|
||||
{
|
||||
// everything is formatted as it should be, so just call
|
||||
// write_port.
|
||||
write_port(app->_sender, msgcode, msgbuffer, buffersize);
|
||||
break;
|
||||
}
|
||||
case QUIT_APP:
|
||||
case AS_QUIT_APP:
|
||||
{
|
||||
// If we are using the real, accelerated version of the
|
||||
// DisplayDriver, we do NOT want the user to be able shut down
|
||||
@@ -251,7 +241,7 @@ int32 ServerApp::MonitorApp(void *data)
|
||||
break;
|
||||
}
|
||||
app->_applink->SetPort(serverport);
|
||||
app->_applink->SetOpCode(DELETE_APP);
|
||||
app->_applink->SetOpCode(AS_DELETE_APP);
|
||||
app->_applink->Attach(&app->_monitor_thread,sizeof(thread_id));
|
||||
app->_applink->Flush();
|
||||
break;
|
||||
@@ -292,7 +282,7 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
|
||||
|
||||
switch(code)
|
||||
{
|
||||
case UPDATED_CLIENT_FONTLIST:
|
||||
case AS_UPDATED_CLIENT_FONTLIST:
|
||||
{
|
||||
// received when the client-side global font list has been
|
||||
// refreshed
|
||||
@@ -301,7 +291,7 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
|
||||
fontserver->Unlock();
|
||||
break;
|
||||
}
|
||||
case CREATE_WINDOW:
|
||||
case AS_CREATE_WINDOW:
|
||||
{
|
||||
// Create the ServerWindow to node monitor a new OBWindow
|
||||
|
||||
@@ -332,25 +322,26 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
|
||||
// Window looper is waiting for our reply. Send back the
|
||||
// ServerWindow's message port
|
||||
PortLink *replylink=new PortLink(reply_port);
|
||||
replylink->SetOpCode(SET_SERVER_PORT);
|
||||
replylink->SetOpCode(AS_SET_SERVER_PORT);
|
||||
replylink->Attach((int32)newwin->_receiver);
|
||||
replylink->Flush();
|
||||
|
||||
delete replylink;
|
||||
break;
|
||||
}
|
||||
case DELETE_WINDOW:
|
||||
case AS_DELETE_WINDOW:
|
||||
{
|
||||
// Received from a ServerWindow when its window quits
|
||||
|
||||
// Attached data:
|
||||
// 1) thread_id ServerWindow ID
|
||||
thread_id winid;
|
||||
// 1) uint32 ServerWindow ID token
|
||||
ServerWindow *w;
|
||||
uint32 winid=*((uint32*)index);
|
||||
|
||||
for(int32 i=0;i<_winlist->CountItems();i++)
|
||||
{
|
||||
w=(ServerWindow*)_winlist->ItemAt(i);
|
||||
if(w->_monitorthread==winid)
|
||||
if(w->_token==winid)
|
||||
{
|
||||
_winlist->RemoveItem(w);
|
||||
delete w;
|
||||
@@ -359,7 +350,7 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GFX_SET_SCREEN_MODE:
|
||||
case AS_SET_SCREEN_MODE:
|
||||
{
|
||||
// Attached data
|
||||
// 1) int32 workspace #
|
||||
@@ -372,7 +363,7 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
|
||||
|
||||
break;
|
||||
}
|
||||
case GFX_ACTIVATE_WORKSPACE:
|
||||
case AS_ACTIVATE_WORKSPACE:
|
||||
{
|
||||
// Attached data
|
||||
// 1) int32 workspace index
|
||||
@@ -384,39 +375,34 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
|
||||
|
||||
// Theoretically, we could just call the driver directly, but we will
|
||||
// call the CursorManager's version to allow for future expansion
|
||||
case SHOW_CURSOR:
|
||||
case AS_SHOW_CURSOR:
|
||||
{
|
||||
cursormanager->ShowCursor();
|
||||
_cursorhidden=false;
|
||||
break;
|
||||
}
|
||||
case HIDE_CURSOR:
|
||||
case AS_HIDE_CURSOR:
|
||||
{
|
||||
cursormanager->HideCursor();
|
||||
_cursorhidden=true;
|
||||
break;
|
||||
}
|
||||
case OBSCURE_CURSOR:
|
||||
case AS_OBSCURE_CURSOR:
|
||||
{
|
||||
cursormanager->ObscureCursor();
|
||||
break;
|
||||
}
|
||||
case QUERY_CURSOR_HIDDEN:
|
||||
case AS_QUERY_CURSOR_HIDDEN:
|
||||
{
|
||||
// Attached data
|
||||
// 1) int32 port to reply to
|
||||
if(_cursorhidden)
|
||||
write_port(*((port_id*)index),SERVER_TRUE,NULL,0);
|
||||
else
|
||||
write_port(*((port_id*)index),SERVER_FALSE,NULL,0);
|
||||
write_port(*((port_id*)index),(_cursorhidden)?SERVER_TRUE:SERVER_FALSE,NULL,0);
|
||||
break;
|
||||
}
|
||||
case SET_CURSOR_DATA:
|
||||
case AS_SET_CURSOR_DATA:
|
||||
{
|
||||
// Attached data: 68 bytes of _appcursor data
|
||||
|
||||
// Get the data, update the app's _appcursor, and update the
|
||||
// app's _appcursor if active.
|
||||
int8 cdata[68];
|
||||
memcpy(cdata, buffer, 68);
|
||||
|
||||
@@ -428,13 +414,33 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
|
||||
cursormanager->DeleteCursor(_appcursor->ID());
|
||||
|
||||
_appcursor=new ServerCursor(cdata);
|
||||
_appcursor->SetAppSignature(_signature.String());
|
||||
cursormanager->AddCursor(_appcursor);
|
||||
cursormanager->SetCursor(_appcursor->ID());
|
||||
break;
|
||||
}
|
||||
case SET_CURSOR_BCURSOR:
|
||||
case AS_SET_CURSOR_BCURSOR:
|
||||
{
|
||||
// TODO: Implement
|
||||
// Attached data:
|
||||
// 1) port_id reply port
|
||||
// 2) 68 bytes of _appcursor data
|
||||
|
||||
port_id replyport=*((port_id*)index);
|
||||
index+=sizeof(port_id);
|
||||
|
||||
int8 cdata[68];
|
||||
memcpy(cdata, index, 68);
|
||||
|
||||
_appcursor=new ServerCursor(cdata);
|
||||
_appcursor->SetAppSignature(_signature.String());
|
||||
cursormanager->AddCursor(_appcursor);
|
||||
cursormanager->SetCursor(_appcursor->ID());
|
||||
|
||||
// Synchronous message - BApplication is waiting on the cursor's ID
|
||||
PortLink replylink(replyport);
|
||||
replylink.SetOpCode(AS_SET_CURSOR_BCURSOR);
|
||||
replylink.Attach(_appcursor->ID());
|
||||
replylink.Flush();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
#include "ServerCursor.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
/*!
|
||||
\brief Constructor
|
||||
\param r Size of the cursor
|
||||
@@ -92,9 +93,7 @@ ServerCursor::ServerCursor(int8 *data)
|
||||
cursorval=cursorflip & powval;
|
||||
maskval=maskflip & powval;
|
||||
bmppos[i]=((cursorval!=0)?black:white) & ((maskval>0)?0xFFFFFFFF:0x00FFFFFF);
|
||||
printf("%c",((cursorval!=0)?'*':'-'));
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -143,3 +142,15 @@ void ServerCursor::SetHotSpot(BPoint pt)
|
||||
_hotspot=pt;
|
||||
_hotspot.ConstrainTo(Bounds());
|
||||
}
|
||||
|
||||
void ServerCursor::SetAppSignature(const char *signature)
|
||||
{
|
||||
if(_app_signature)
|
||||
delete _app_signature;
|
||||
|
||||
if(signature)
|
||||
{
|
||||
_app_signature=new char[strlen(signature)];
|
||||
strcpy(_app_signature, signature);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,8 @@ public:
|
||||
BPoint GetHotSpot(void);
|
||||
void SetHotSpot(BPoint pt);
|
||||
const char *GetAppSignature(void) { return _app_signature; }
|
||||
|
||||
void SetAppSignature(const char *signature);
|
||||
|
||||
//! Returns the cursor's ID
|
||||
int32 ID(void) { return _token; }
|
||||
private:
|
||||
|
||||
@@ -7,114 +7,127 @@
|
||||
#define SERVER_PORT_NAME "OBappserver"
|
||||
#define SERVER_INPUT_PORT "OBinputport"
|
||||
|
||||
#define CREATE_APP 'drca'
|
||||
#define DELETE_APP 'drda'
|
||||
#define QUIT_APP 'srqa'
|
||||
|
||||
#define SET_SERVER_PORT 'srsp'
|
||||
|
||||
#define CREATE_WINDOW 'drcw'
|
||||
#define DELETE_WINDOW 'drdw'
|
||||
#define SHOW_WINDOW 'drsw'
|
||||
#define HIDE_WINDOW 'drhw'
|
||||
#define QUIT_WINDOW 'srqw'
|
||||
|
||||
enum
|
||||
{
|
||||
// Used for quick replies from the app_server
|
||||
#define SERVER_TRUE 'svtr'
|
||||
#define SERVER_FALSE 'svfl'
|
||||
SERVER_TRUE='_srt',
|
||||
SERVER_FALSE,
|
||||
|
||||
// Application definitions
|
||||
AS_CREATE_APP,
|
||||
AS_DELETE_APP,
|
||||
AS_QUIT_APP,
|
||||
|
||||
AS_SET_SERVER_PORT,
|
||||
|
||||
AS_CREATE_WINDOW,
|
||||
AS_DELETE_WINDOW,
|
||||
|
||||
AS_SET_CURSOR_DATA,
|
||||
AS_SET_CURSOR_BCURSOR,
|
||||
AS_SET_CURSOR_BBITMAP,
|
||||
AS_SHOW_CURSOR,
|
||||
AS_HIDE_CURSOR,
|
||||
AS_OBSCURE_CURSOR,
|
||||
AS_QUERY_CURSOR_HIDDEN,
|
||||
|
||||
AS_BEGIN_RECT_TRACKING,
|
||||
AS_END_RECT_TRACKING,
|
||||
|
||||
// Window definitions
|
||||
AS_SHOW_WINDOW,
|
||||
AS_HIDE_WINDOW,
|
||||
AS_QUIT_WINDOW,
|
||||
AS_SEND_BEHIND,
|
||||
AS_SET_LOOK,
|
||||
AS_SET_FEEL,
|
||||
AS_SET_FLAGS,
|
||||
|
||||
// Font-related server communications
|
||||
#define QUERY_FONTS_CHANGED 'qfch'
|
||||
#define UPDATED_CLIENT_FONTLIST 'ucfl'
|
||||
#define GET_FAMILY_ID 'fmid'
|
||||
#define GET_STYLE_ID 'stid'
|
||||
#define GET_STYLE_FOR_FACE 'stff'
|
||||
AS_QUERY_FONTS_CHANGED,
|
||||
AS_UPDATED_CLIENT_FONTLIST,
|
||||
AS_GET_FAMILY_ID,
|
||||
AS_GET_STYLE_ID,
|
||||
AS_GET_STYLE_FOR_FACE,
|
||||
|
||||
// This will be modified. Currently a kludge for the input server until
|
||||
// BScreens are implemented by the IK Taeam
|
||||
#define GET_SCREEN_MODE 'gsmd'
|
||||
AS_GET_SCREEN_MODE,
|
||||
|
||||
#define SET_UI_COLORS 'suic'
|
||||
#define GET_UI_COLOR 'guic'
|
||||
#define SET_DECORATOR 'sdec'
|
||||
#define GET_DECORATOR 'gdec'
|
||||
// Global function call defs
|
||||
AS_SET_UI_COLORS,
|
||||
AS_GET_UI_COLOR,
|
||||
AS_SET_DECORATOR,
|
||||
AS_GET_DECORATOR,
|
||||
|
||||
// Cursor-related communications
|
||||
#define SET_CURSOR_DATA 'sscd'
|
||||
#define SET_CURSOR_BCURSOR 'sscb'
|
||||
#define SET_CURSOR_BBITMAP 'sscB'
|
||||
#define SHOW_CURSOR 'srsc'
|
||||
#define HIDE_CURSOR 'srhc'
|
||||
#define OBSCURE_CURSOR 'sroc'
|
||||
#define QUERY_CURSOR_HIDDEN 'sqch'
|
||||
AS_COUNT_WORKSPACES,
|
||||
AS_SET_WORKSPACE_COUNT,
|
||||
AS_CURRENT_WORKSPACE,
|
||||
AS_ACTIVATE_WORKSPACE,
|
||||
AS_SET_SCREEN_MODE,
|
||||
AS_GET_SCROLLBAR_INFO,
|
||||
AS_SET_SCROLLBAR_INFO,
|
||||
AS_IDLE_TIME,
|
||||
AS_SELECT_PRINTER_PANEL,
|
||||
AS_ADD_PRINTER_PANEL,
|
||||
AS_RUN_BE_ABOUT,
|
||||
AS_SET_FOCUS_FOLLOWS_MOUSE,
|
||||
AS_FOCUS_FOLLOWS_MOUSE,
|
||||
|
||||
#define BEGIN_RECT_TRACKING 'sbrt'
|
||||
#define END_RECT_TRACKING 'sert'
|
||||
// Graphics calls
|
||||
AS_BEGIN_TRANSACTION,
|
||||
AS_END_TRANSACTION,
|
||||
AS_SET_HIGH_COLOR,
|
||||
AS_SET_LOW_COLOR,
|
||||
AS_SET_VIEW_COLOR,
|
||||
|
||||
#define GFX_COUNT_WORKSPACES 'gcws'
|
||||
#define GFX_SET_WORKSPACE_COUNT 'ggwc'
|
||||
#define GFX_CURRENT_WORKSPACE 'ggcw'
|
||||
#define GFX_ACTIVATE_WORKSPACE 'gaws'
|
||||
#define GFX_GET_SYSTEM_COLORS 'gsyc'
|
||||
#define GFX_SET_SYSTEM_COLORS 'gsyc'
|
||||
#define GFX_SET_SCREEN_MODE 'gssm'
|
||||
#define GFX_GET_SCROLLBAR_INFO 'ggsi'
|
||||
#define GFX_SET_SCROLLBAR_INFO 'gssi'
|
||||
#define GFX_IDLE_TIME 'gidt'
|
||||
#define GFX_SELECT_PRINTER_PANEL 'gspp'
|
||||
#define GFX_ADD_PRINTER_PANEL 'gapp'
|
||||
#define GFX_RUN_BE_ABOUT 'grba'
|
||||
#define GFX_SET_FOCUS_FOLLOWS_MOUSE 'gsfm'
|
||||
#define GFX_FOCUS_FOLLOWS_MOUSE 'gffm'
|
||||
AS_STROKE_ARC,
|
||||
AS_STROKE_BEZIER,
|
||||
AS_STROKE_ELLIPSE,
|
||||
AS_STROKE_LINE,
|
||||
AS_STROKE_LINEARRAY,
|
||||
AS_STROKE_POLYGON,
|
||||
AS_STROKE_RECT,
|
||||
AS_STROKE_ROUNDRECT,
|
||||
AS_STROKE_SHAPE,
|
||||
AS_STROKE_TRIANGLE,
|
||||
|
||||
#define GFX_SET_HIGH_COLOR 'gshc'
|
||||
#define GFX_SET_LOW_COLOR 'gslc'
|
||||
#define GFX_SET_VIEW_COLOR 'gsvc'
|
||||
AS_FILL_ARC,
|
||||
AS_FILL_BEZIER,
|
||||
AS_FILL_ELLIPSE,
|
||||
AS_FILL_POLYGON,
|
||||
AS_FILL_RECT,
|
||||
AS_FILL_REGION,
|
||||
AS_FILL_ROUNDRECT,
|
||||
AS_FILL_SHAPE,
|
||||
AS_FILL_TRIANGLE,
|
||||
|
||||
#define GFX_STROKE_ARC 'gsar'
|
||||
#define GFX_STROKE_BEZIER 'gsbz'
|
||||
#define GFX_STROKE_ELLIPSE 'gsel'
|
||||
#define GFX_STROKE_LINE 'gsln'
|
||||
#define GFX_STROKE_POLYGON 'gspy'
|
||||
#define GFX_STROKE_RECT 'gsrc'
|
||||
#define GFX_STROKE_ROUNDRECT 'gsrr'
|
||||
#define GFX_STROKE_SHAPE 'gssh'
|
||||
#define GFX_STROKE_TRIANGLE 'gstr'
|
||||
AS_MOVEPENBY,
|
||||
AS_MOVEPENTO,
|
||||
AS_SETPENSIZE,
|
||||
|
||||
#define GFX_FILL_ARC 'gfar'
|
||||
#define GFX_FILL_BEZIER 'gfbz'
|
||||
#define GFX_FILL_ELLIPSE 'gfel'
|
||||
#define GFX_FILL_POLYGON 'gfpy'
|
||||
#define GFX_FILL_RECT 'gfrc'
|
||||
#define GFX_FILL_REGION 'gfrg'
|
||||
#define GFX_FILL_ROUNDRECT 'gfrr'
|
||||
#define GFX_FILL_SHAPE 'gfsh'
|
||||
#define GFX_FILL_TRIANGLE 'gftr'
|
||||
AS_DRAW_STRING,
|
||||
AS_SET_FONT,
|
||||
AS_SET_FONT_SIZE,
|
||||
|
||||
#define GFX_MOVEPENBY 'gmpb'
|
||||
#define GFX_MOVEPENTO 'gmpt'
|
||||
#define GFX_SETPENSIZE 'gsps'
|
||||
AS_FLUSH,
|
||||
AS_SYNC,
|
||||
|
||||
#define GFX_DRAW_STRING 'gdst'
|
||||
#define GFX_SET_FONT 'gsft'
|
||||
#define GFX_SET_FONT_SIZE 'gsfs'
|
||||
AS_LAYER_CREATE,
|
||||
AS_LAYER_DELETE,
|
||||
AS_LAYER_ADD_CHILD,
|
||||
AS_LAYER_REMOVE_CHILD,
|
||||
AS_LAYER_REMOVE_SELF,
|
||||
AS_LAYER_SHOW,
|
||||
AS_LAYER_HIDE,
|
||||
AS_LAYER_MOVE,
|
||||
AS_LAYER_RESIZE,
|
||||
AS_LAYER_INVALIDATE,
|
||||
AS_LAYER_DRAW,
|
||||
|
||||
#define GFX_FLUSH 'gfsh'
|
||||
#define GFX_SYNC 'gsyn'
|
||||
AS_LAYER_GET_TOKEN,
|
||||
AS_LAYER_ADD,
|
||||
AS_LAYER_REMOVE
|
||||
};
|
||||
|
||||
#define LAYER_CREATE 'lycr'
|
||||
#define LAYER_DELETE 'lydl'
|
||||
#define LAYER_ADD_CHILD 'lyac'
|
||||
#define LAYER_REMOVE_CHILD 'lyrc'
|
||||
#define LAYER_REMOVE_SELF 'lyrs'
|
||||
#define LAYER_SHOW 'lysh'
|
||||
#define LAYER_HIDE 'lyhd'
|
||||
#define LAYER_MOVE 'lymv'
|
||||
#define LAYER_RESIZE 'lyre'
|
||||
#define LAYER_INVALIDATE 'lyin'
|
||||
#define LAYER_DRAW 'lydr'
|
||||
|
||||
#define VIEW_GET_TOKEN 'vgtk'
|
||||
#define VIEW_ADD 'vadd'
|
||||
#define VIEW_REMOVE 'vrem'
|
||||
#endif
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <Rect.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <Debug.h>
|
||||
#include <View.h> // for B_XXXXX_MOUSE_BUTTON defines
|
||||
#include "AppServer.h"
|
||||
#include "Layer.h"
|
||||
@@ -38,52 +37,40 @@
|
||||
#include "ServerProtocol.h"
|
||||
#include "WinBorder.h"
|
||||
#include "Desktop.h"
|
||||
#include "DesktopClasses.h"
|
||||
#include "TokenHandler.h"
|
||||
|
||||
//! Handler to get BWindow tokens from
|
||||
TokenHandler win_token_handler;
|
||||
|
||||
// defined in WinBorder.cpp. Locking is not necessary - the only
|
||||
// _monitorthread which accesses them is the Poller _monitorthread
|
||||
|
||||
//! Used in window focus management
|
||||
ServerWindow *active_serverwindow=NULL;
|
||||
|
||||
/*!
|
||||
\brief Contructor
|
||||
|
||||
Sets up a lot of the stuff
|
||||
Does a lot of stuff to set up for the window - new decorator, new winborder, spawn a
|
||||
monitor thread.
|
||||
*/
|
||||
ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
|
||||
uint32 wfeel, uint32 wflags, ServerApp *winapp, port_id winport, uint32 index)
|
||||
{
|
||||
_title=new BString;
|
||||
_title->SetTo( (string)?string:"Window" );
|
||||
|
||||
// This must happen before the WinBorder object - it needs this object's _frame
|
||||
// to be valid
|
||||
_frame=rect;
|
||||
|
||||
// set these early also - the _decorator will also need them
|
||||
_flags=wflags;
|
||||
_look=wlook;
|
||||
_feel=wfeel;
|
||||
|
||||
_decorator=new_decorator(_frame,_title->String(),_look,_feel,_flags,GetGfxDriver());
|
||||
|
||||
_winborder=new WinBorder(_frame,_title->String(),0,wflags,this);
|
||||
|
||||
// _sender is the monitored _app's event port
|
||||
// _sender is the monitored window's event port
|
||||
_sender=winport;
|
||||
_winlink=new PortLink(_sender);
|
||||
|
||||
_applink= (winapp)? new PortLink(winapp->_receiver) : NULL;
|
||||
|
||||
// _receiver is the port to which the _app sends messages for the server
|
||||
// _receiver is the port to which the app sends messages for the server
|
||||
_receiver=create_port(30,_title->String());
|
||||
|
||||
_active=false;
|
||||
_hidecount=0;
|
||||
|
||||
// Spawn our message monitoring _monitorthread
|
||||
_monitorthread=spawn_thread(MonitorWin,_title->String(),B_NORMAL_PRIORITY,this);
|
||||
@@ -96,6 +83,7 @@ ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook,
|
||||
AddWindowToDesktop(this,index);
|
||||
}
|
||||
|
||||
//!Tears down all connections with the user application, kills the monitoring thread.
|
||||
ServerWindow::~ServerWindow(void)
|
||||
{
|
||||
RemoveWindowFromDesktop(this);
|
||||
@@ -105,192 +93,299 @@ ServerWindow::~ServerWindow(void)
|
||||
_applink=NULL;
|
||||
delete _title;
|
||||
delete _winlink;
|
||||
delete _decorator;
|
||||
// TODO: uncomment this when we have WinBorder.h
|
||||
// delete _winborder;
|
||||
delete _winborder;
|
||||
}
|
||||
kill_thread(_monitorthread);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Requests an update of the specified rectangle
|
||||
\param rect The area to update, in the parent's coordinates
|
||||
|
||||
This could be considered equivalent to BView::Invalidate()
|
||||
*/
|
||||
void ServerWindow::RequestDraw(BRect rect)
|
||||
{
|
||||
_winlink->SetOpCode(LAYER_DRAW);
|
||||
_winlink->SetOpCode(AS_LAYER_DRAW);
|
||||
_winlink->Attach(&rect,sizeof(BRect));
|
||||
_winlink->Flush();
|
||||
}
|
||||
|
||||
//! Requests an update for the entire window
|
||||
void ServerWindow::RequestDraw(void)
|
||||
{
|
||||
RequestDraw(_frame);
|
||||
}
|
||||
|
||||
//! Forces the window border to update its decorator
|
||||
void ServerWindow::ReplaceDecorator(void)
|
||||
{
|
||||
_winborder->UpdateDecorator();
|
||||
}
|
||||
|
||||
//! Requests that the ServerWindow's BWindow quit
|
||||
void ServerWindow::Quit(void)
|
||||
{
|
||||
_winlink->SetOpCode(B_QUIT_REQUESTED);
|
||||
_winlink->Flush();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Gets the title for the window
|
||||
\return The title for the window
|
||||
*/
|
||||
const char *ServerWindow::GetTitle(void)
|
||||
{
|
||||
return _title->String();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Gets the window's ServerApp
|
||||
\return The ServerApp for the window
|
||||
*/
|
||||
ServerApp *ServerWindow::GetApp(void)
|
||||
{
|
||||
return _app;
|
||||
}
|
||||
|
||||
//! Shows the window's WinBorder
|
||||
void ServerWindow::Show(void)
|
||||
{
|
||||
/* if(_winborder)
|
||||
{
|
||||
_winborder->ShowLayer();
|
||||
ActivateWindow(this);
|
||||
}
|
||||
*/
|
||||
if(_winborder)
|
||||
_winborder->Show();
|
||||
}
|
||||
|
||||
//! Hides the window's WinBorder
|
||||
void ServerWindow::Hide(void)
|
||||
{
|
||||
// TODO: uncomment this when we have WinBorder.h
|
||||
// if(_winborder)
|
||||
// _winborder->HideLayer();
|
||||
if(_winborder)
|
||||
_winborder->Hide();
|
||||
}
|
||||
|
||||
/*
|
||||
\brief Determines whether the window is hidden or not
|
||||
\return true if hidden, false if not
|
||||
*/
|
||||
bool ServerWindow::IsHidden(void)
|
||||
{
|
||||
return (_hidecount==0)?true:false;
|
||||
if(_winborder)
|
||||
return _winborder->IsHidden();
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Handles focus and redrawing when changing focus states
|
||||
|
||||
The ServerWindow is set to (in)active and its decorator is redrawn based on its active status
|
||||
*/
|
||||
void ServerWindow::SetFocus(bool value)
|
||||
{
|
||||
if(_active!=value)
|
||||
{
|
||||
_active=value;
|
||||
_decorator->SetFocus(value);
|
||||
_decorator->Draw();
|
||||
_winborder->RequestDraw();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Determines whether or not the window is active
|
||||
\return true if active, false if not
|
||||
*/
|
||||
bool ServerWindow::HasFocus(void)
|
||||
{
|
||||
return _active;
|
||||
}
|
||||
|
||||
void ServerWindow::WorkspaceActivated(int32 newworkspace, const BPoint reso, color_space cspace)
|
||||
/*!
|
||||
\brief Notifies window of workspace (de)activation
|
||||
\param workspace Index of the workspace changed
|
||||
\param active New active status of the workspace
|
||||
*/
|
||||
void ServerWindow::WorkspaceActivated(int32 workspace, bool active)
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Notifies window of a workspace switch
|
||||
\param oldone index of the previous workspace
|
||||
\param newone index of the new workspace
|
||||
*/
|
||||
void ServerWindow::WorkspacesChanged(int32 oldone,int32 newone)
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Notifies window of a change in focus
|
||||
\param active New active status of the window
|
||||
*/
|
||||
void ServerWindow::WindowActivated(bool active)
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
void ServerWindow::ScreenModeChanged(const BPoint res, color_space cspace)
|
||||
/*!
|
||||
\brief Notifies window of a change in screen resolution
|
||||
\param frame Size of the new resolution
|
||||
\param color_space Color space of the new screen mode
|
||||
*/
|
||||
void ServerWindow::ScreenModeChanged(const BRect frame, const color_space cspace)
|
||||
{
|
||||
// TODO: implement
|
||||
}
|
||||
|
||||
/*
|
||||
\brief Sets the frame size of the window
|
||||
\rect New window size
|
||||
*/
|
||||
void ServerWindow::SetFrame(const BRect &rect)
|
||||
{
|
||||
_frame=rect;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the frame of the window in screen coordinates
|
||||
\return The frame of the window in screen coordinates
|
||||
*/
|
||||
BRect ServerWindow::Frame(void)
|
||||
{
|
||||
return _frame;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Locks the window
|
||||
\return B_OK if everything is ok, B_ERROR if something went wrong
|
||||
*/
|
||||
status_t ServerWindow::Lock(void)
|
||||
{
|
||||
#ifdef DEBUG_SERVERWIN
|
||||
printf("%s::Lock()\n",_title->String());
|
||||
#endif
|
||||
return _locker.Lock();
|
||||
return (_locker.Lock())?B_OK:B_ERROR;
|
||||
}
|
||||
|
||||
//! Unlocks the window
|
||||
void ServerWindow::Unlock(void)
|
||||
{
|
||||
#ifdef DEBUG_SERVERWIN
|
||||
printf("%s::Unlock()\n",_title->String());
|
||||
#endif
|
||||
_locker.Unlock();
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Determines whether or not the window is locked
|
||||
\return True if locked, false if not.
|
||||
*/
|
||||
bool ServerWindow::IsLocked(void)
|
||||
{
|
||||
return _locker.IsLocked();
|
||||
}
|
||||
|
||||
void ServerWindow::Loop(void)
|
||||
void ServerWindow::DispatchMessage(int32 code, int8 *msgbuffer)
|
||||
{
|
||||
// Message-dispatching loop for the ServerWindow
|
||||
switch(code)
|
||||
{
|
||||
case AS_LAYER_CREATE:
|
||||
{
|
||||
// Received when a view is attached to a window. This will require
|
||||
// us to attach a layer in the tree in the same manner and invalidate
|
||||
// the area in which the new layer resides assuming that it is
|
||||
// visible.
|
||||
|
||||
// Attached Data:
|
||||
// 1) (int32) id of the parent view
|
||||
// 2) (BRect) frame in parent's coordinates
|
||||
// 3) (int32) resize flags
|
||||
// 4) (int32) view flags
|
||||
// 5) (uint16) view's hide level
|
||||
|
||||
// This is a synchronous call, so reply immediately with the ID of the layer
|
||||
// so the BView can identify itself
|
||||
|
||||
// TODO: Implement
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_LAYER_DELETE:
|
||||
{
|
||||
// Received when a view is detached from a window. This is definitely
|
||||
// the less taxing operation - we call PruneTree() on the removed
|
||||
// layer, detach the layer itself, delete it, and invalidate the
|
||||
// area assuming that the view was visible when removed
|
||||
|
||||
// Attached Data:
|
||||
// 1) (int32) id of the removed view
|
||||
|
||||
// TODO: Implement
|
||||
|
||||
break;
|
||||
}
|
||||
case AS_SHOW_WINDOW:
|
||||
{
|
||||
Show();
|
||||
break;
|
||||
}
|
||||
case AS_HIDE_WINDOW:
|
||||
{
|
||||
Hide();
|
||||
break;
|
||||
}
|
||||
case B_MINIMIZE:
|
||||
case B_WINDOW_ACTIVATED:
|
||||
case B_ZOOM:
|
||||
case B_WINDOW_MOVE_TO:
|
||||
case B_WINDOW_MOVE_BY:
|
||||
case AS_SET_LOOK:
|
||||
case AS_SET_FEEL:
|
||||
case AS_SET_FLAGS:
|
||||
case AS_SEND_BEHIND:
|
||||
break;
|
||||
default:
|
||||
{
|
||||
printf("ServerWindow %s received unexpected code %lx",_title->String(),code);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Message-dispatching loop for the ServerWindow
|
||||
|
||||
MonitorWin() watches the ServerWindow's message port and dispatches as necessary
|
||||
\param data The thread's ServerWindow
|
||||
\return Throwaway code. Always 0.
|
||||
*/
|
||||
int32 ServerWindow::MonitorWin(void *data)
|
||||
{
|
||||
ServerWindow *win=(ServerWindow *)data;
|
||||
|
||||
int32 msgcode;
|
||||
int8 *msgbuffer=NULL;
|
||||
ssize_t buffersize,bytesread;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
buffersize=port_buffer_size(_receiver);
|
||||
buffersize=port_buffer_size(win->_receiver);
|
||||
|
||||
if(buffersize>0)
|
||||
{
|
||||
msgbuffer=new int8[buffersize];
|
||||
bytesread=read_port(_receiver,&msgcode,msgbuffer,buffersize);
|
||||
bytesread=read_port(win->_receiver,&msgcode,msgbuffer,buffersize);
|
||||
}
|
||||
else
|
||||
bytesread=read_port(_receiver,&msgcode,NULL,0);
|
||||
bytesread=read_port(win->_receiver,&msgcode,NULL,0);
|
||||
|
||||
if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK)
|
||||
{
|
||||
switch(msgcode)
|
||||
{
|
||||
case LAYER_CREATE:
|
||||
case B_QUIT_REQUESTED:
|
||||
{
|
||||
// Received when a view is attached to a window. This will require
|
||||
// us to attach a layer in the tree in the same manner and invalidate
|
||||
// the area in which the new layer resides assuming that it is
|
||||
// visible.
|
||||
|
||||
// Attached Data:
|
||||
// 1) (int32) id of the parent view
|
||||
// 2) (BRect) frame in parent's coordinates
|
||||
// 3) (int32) resize flags
|
||||
// 4) (int32) view flags
|
||||
// 5) (uint16) view's hide level
|
||||
|
||||
// This is a synchronous call, so reply immediately with the ID of the layer
|
||||
// so the BView can identify itself
|
||||
|
||||
break;
|
||||
}
|
||||
case LAYER_DELETE:
|
||||
{
|
||||
// Received when a view is detached from a window. This is definitely
|
||||
// the less taxing operation - we call PruneTree() on the removed
|
||||
// layer, detach the layer itself, delete it, and invalidate the
|
||||
// area assuming that the view was visible when removed
|
||||
|
||||
// Attached Data:
|
||||
// 1) (int32) id of the removed view
|
||||
break;
|
||||
}
|
||||
case SHOW_WINDOW:
|
||||
{
|
||||
Show();
|
||||
break;
|
||||
}
|
||||
case HIDE_WINDOW:
|
||||
{
|
||||
Hide();
|
||||
break;
|
||||
}
|
||||
case DELETE_WINDOW:
|
||||
{
|
||||
// Received from our window when it is told to quit, so tell our
|
||||
// application to delete this object
|
||||
_applink->SetOpCode(DELETE_WINDOW);
|
||||
_applink->Attach((int32)_monitorthread);
|
||||
_applink->Flush();
|
||||
// Our BWindow sent us this message when it quit.
|
||||
// We need to ask its ServerApp to delete our monitor
|
||||
win->_applink->SetOpCode(AS_DELETE_WINDOW);
|
||||
win->_applink->Attach((int32)win->_token);
|
||||
win->_applink->Flush();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
DispatchMessage(msgcode,msgbuffer);
|
||||
win->DispatchMessage(msgcode,msgbuffer);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -302,31 +397,16 @@ void ServerWindow::Loop(void)
|
||||
if(msgcode==B_QUIT_REQUESTED)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ServerWindow::DispatchMessage(int32 code, int8 *msgbuffer)
|
||||
{
|
||||
switch(code)
|
||||
{
|
||||
default:
|
||||
{
|
||||
#ifdef DEBUG_SERVERWIN
|
||||
printf("%s::ServerWindow(): Received unexpected code: ",_title->String());
|
||||
PrintMessageCode(code);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32 ServerWindow::MonitorWin(void *data)
|
||||
{
|
||||
ServerWindow *win=(ServerWindow *)data;
|
||||
win->Loop();
|
||||
exit_thread(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Passes mouse event messages to the appropriate window
|
||||
\param code Message code of the mouse message
|
||||
\param buffer Attachment buffer for the mouse message
|
||||
*/
|
||||
void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
|
||||
{
|
||||
/* ServerWindow *mousewin=NULL;
|
||||
@@ -445,22 +525,53 @@ void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer)
|
||||
*/
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Passes key event messages to the appropriate window
|
||||
\param code Message code of the key message
|
||||
\param buffer Attachment buffer for the key message
|
||||
*/
|
||||
void ServerWindow::HandleKeyEvent(int32 code, int8 *buffer)
|
||||
{
|
||||
}
|
||||
|
||||
void ServerWindow::SetWorkspace(Workspace *wkspc)
|
||||
{
|
||||
}
|
||||
|
||||
void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin)
|
||||
{
|
||||
/* if(active_serverwindow==win)
|
||||
return;
|
||||
if(active_serverwindow)
|
||||
active_serverwindow->SetFocus(false);
|
||||
active_serverwindow=win;
|
||||
if(win)
|
||||
win->SetFocus(true);
|
||||
/* ServerWindow *keywin=NULL;
|
||||
int8 *index=buffer;
|
||||
|
||||
// Dispatch the key event to the active window
|
||||
*/
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Returns the Workspace object to which the window belongs
|
||||
|
||||
If the window belongs to all workspaces, it returns the current workspace
|
||||
*/
|
||||
Workspace *ServerWindow::GetWorkspace(void)
|
||||
{
|
||||
if(_workspace_index==B_ALL_WORKSPACES)
|
||||
return _workspace->GetScreen()->GetActiveWorkspace();
|
||||
|
||||
return _workspace;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Assign the window to a particular workspace object
|
||||
\param The ServerWindow's new workspace
|
||||
*/
|
||||
void ServerWindow::SetWorkspace(Workspace *wkspc)
|
||||
{
|
||||
_workspace=wkspc;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Handles window activation stuff. Called by Desktop functions
|
||||
*/
|
||||
void ActivateWindow(ServerWindow *oldwin,ServerWindow *newwin)
|
||||
{
|
||||
if(oldwin==newwin)
|
||||
return;
|
||||
|
||||
if(oldwin)
|
||||
oldwin->SetFocus(false);
|
||||
|
||||
if(newwin)
|
||||
newwin->SetFocus(true);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <Locker.h>
|
||||
#include <Rect.h>
|
||||
#include <String.h>
|
||||
#include <Window.h>
|
||||
|
||||
class BString;
|
||||
class BMessenger;
|
||||
@@ -43,6 +44,15 @@ class PortLink;
|
||||
class WinBorder;
|
||||
class Workspace;
|
||||
|
||||
/*!
|
||||
\class ServerWindow ServerWindow.h
|
||||
\brief Shadow BWindow class
|
||||
|
||||
A ServerWindow handles all the intraserver tasks required of it by its BWindow. There are
|
||||
too many tasks to list as being done by them, but they include handling View transactions,
|
||||
coordinating and linking a window's WinBorder half with its messaging half, dispatching
|
||||
mouse and key events from the server to its window, and other such things.
|
||||
*/
|
||||
class ServerWindow
|
||||
{
|
||||
public:
|
||||
@@ -60,10 +70,12 @@ public:
|
||||
void SetFocus(bool value);
|
||||
bool HasFocus(void);
|
||||
void RequestDraw(BRect rect);
|
||||
void RequestDraw(void);
|
||||
|
||||
void WorkspaceActivated(int32 NewDesktop, const BPoint Resolution, color_space CSpace);
|
||||
void WindowActivated(bool Active);
|
||||
void ScreenModeChanged(const BPoint Resolution, color_space CSpace);
|
||||
void WorkspaceActivated(int32 workspace, bool active);
|
||||
void WorkspacesChanged(int32 oldone,int32 newone);
|
||||
void WindowActivated(bool active);
|
||||
void ScreenModeChanged(const BRect frame, const color_space cspace);
|
||||
|
||||
void SetFrame(const BRect &rect);
|
||||
BRect Frame(void);
|
||||
@@ -76,10 +88,10 @@ public:
|
||||
static int32 MonitorWin(void *data);
|
||||
static void HandleMouseEvent(int32 code, int8 *buffer);
|
||||
static void HandleKeyEvent(int32 code, int8 *buffer);
|
||||
void Loop(void);
|
||||
|
||||
//! Returns the index of the workspaces to which it belongs
|
||||
int32 GetWorkspaceIndex(void) { return _workspace_index; }
|
||||
Workspace *GetWorkspace(void) { return _workspace; }
|
||||
Workspace *GetWorkspace(void);
|
||||
void SetWorkspace(Workspace *wkspc);
|
||||
|
||||
protected:
|
||||
@@ -88,13 +100,11 @@ protected:
|
||||
|
||||
BString *_title;
|
||||
int32 _look, _feel, _flags;
|
||||
int32 _workspace_index;
|
||||
uint32 _workspace_index;
|
||||
Workspace *_workspace;
|
||||
bool _active;
|
||||
|
||||
ServerApp *_app;
|
||||
|
||||
Decorator *_decorator;
|
||||
WinBorder *_winborder;
|
||||
|
||||
thread_id _monitorthread;
|
||||
@@ -103,7 +113,6 @@ protected:
|
||||
PortLink *_winlink,*_applink;
|
||||
BLocker _locker;
|
||||
BRect _frame;
|
||||
bool _hidecount;
|
||||
uint32 _token;
|
||||
};
|
||||
|
||||
|
||||
@@ -328,3 +328,19 @@ void WinBorder::ResizeBy(BPoint pt)
|
||||
void WinBorder::ResizeBy(float x, float y)
|
||||
{
|
||||
}
|
||||
|
||||
void WinBorder::UpdateColors(void)
|
||||
{
|
||||
}
|
||||
|
||||
void WinBorder::UpdateDecorator(void)
|
||||
{
|
||||
}
|
||||
|
||||
void WinBorder::UpdateFont(void)
|
||||
{
|
||||
}
|
||||
|
||||
void WinBorder::UpdateScreen(void)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
void RebuildRegions(bool recursive=true);
|
||||
void Activate(bool active=false);
|
||||
ServerWindow *Window(void) { return _win; }
|
||||
Decorator *GetDecorator(void) { return _decorator; }
|
||||
protected:
|
||||
ServerWindow *_win;
|
||||
BString *_title;
|
||||
|
||||
Reference in New Issue
Block a user