Implemented Screen::SetMode

Added Workspace::SetSpace
Removal of old, commented-out server emu code in ScreenDriver
Tweaks to ServerProtocol and ServerConfig to have all BApplication messages, main server port name
AppServer now works fully at prototype #3 level - really cool with ScreenDriver!


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2814 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2003-02-23 21:40:44 +00:00
parent 16d1f45f81
commit c26d77e634
9 changed files with 74 additions and 246 deletions
+2 -2
View File
@@ -45,6 +45,7 @@ AppServer *app_server=NULL;
//! Default background color for workspaces //! Default background color for workspaces
RGBColor workspace_default_color(51,102,160); RGBColor workspace_default_color(51,102,160);
/*! /*!
\brief Constructor \brief Constructor
@@ -96,8 +97,7 @@ AppServer::AppServer(void)
// TODO: fix the cursor display // TODO: fix the cursor display
extern int8 default_cursor_data[]; extern int8 default_cursor_data[];
ServerCursor *sc=new ServerCursor(default_cursor_data); ServerCursor *sc=new ServerCursor(default_cursor_data);
// extern int8 cross_cursor[];
// ServerCursor *sc=new ServerCursor(cross_cursor);
cursormanager->AddCursor(sc); cursormanager->AddCursor(sc);
cursormanager->ChangeCursor(B_CURSOR_DEFAULT, sc->ID()); cursormanager->ChangeCursor(B_CURSOR_DEFAULT, sc->ID());
cursormanager->SetCursor(B_CURSOR_DEFAULT); cursormanager->SetCursor(B_CURSOR_DEFAULT);
+34 -2
View File
@@ -26,9 +26,11 @@
// //
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#include "DesktopClasses.h" #include "DesktopClasses.h"
#include "TokenHandler.h"
// Defined and initialized in AppServer.cpp // Defined and initialized in AppServer.cpp
extern RGBColor workspace_default_color; extern RGBColor workspace_default_color;
TokenHandler screen_id_handler;
/*! /*!
\brief Sets up internal variables needed by the Workspace \brief Sets up internal variables needed by the Workspace
@@ -116,6 +118,16 @@ void Workspace::GetData(graphics_card_info *gcinfo, frame_buffer_info *fbinfo)
*fbinfo=_fbinfo; *fbinfo=_fbinfo;
} }
/*!
\brief Changes the size and mode of the workspace
\param res The new resolution mode of the workspace
*/
void Workspace::SetSpace(int32 res)
{
// TODO: Implement
}
/*! /*!
\brief Sets up internal variables needed by Screen \brief Sets up internal variables needed by Screen
\param gfxmodule Pointer to the uninitialized display driver to use \param gfxmodule Pointer to the uninitialized display driver to use
@@ -132,6 +144,7 @@ Screen::Screen(DisplayDriver *gfxmodule, uint8 workspaces)
_workspacecount=0; _workspacecount=0;
_init=false; _init=false;
_active=false; _active=false;
_id=screen_id_handler.GetToken();
if (_driver) if (_driver)
{ {
@@ -143,8 +156,13 @@ Screen::Screen(DisplayDriver *gfxmodule, uint8 workspaces)
_fbinfo.height=_driver->GetHeight(); _fbinfo.height=_driver->GetHeight();
_fbinfo.display_width=_driver->GetWidth(); _fbinfo.display_width=_driver->GetWidth();
_fbinfo.display_height=_driver->GetHeight(); _fbinfo.display_height=_driver->GetHeight();
_fbinfo.display_x=_driver->GetWidth();; _fbinfo.display_x=_driver->GetWidth();
_fbinfo.display_y=_driver->GetHeight(); _fbinfo.display_y=_driver->GetHeight();
_gcinfo.width=_driver->GetWidth();
_gcinfo.height=_driver->GetHeight();
_gcinfo.bytes_per_row=_driver->GetBytesPerRow();
_gcinfo.bits_per_pixel=_driver->GetDepth();
// right now, we won't do anything with the gcinfo structure. ** LAZY PROGRAMMER ALERT ** :P // right now, we won't do anything with the gcinfo structure. ** LAZY PROGRAMMER ALERT ** :P
@@ -285,6 +303,18 @@ DisplayDriver *Screen::GetGfxDriver(void)
*/ */
status_t Screen::SetSpace(int32 index, int32 res,bool stick) status_t Screen::SetSpace(int32 index, int32 res,bool stick)
{ {
// the specified workspace isn't active, so this should be easy...
Workspace *wkspc=(Workspace*)_workspacelist->ItemAt(index);
if(!wkspc)
return B_ERROR;
wkspc->SetSpace(res);
if(index==_currentworkspace)
{
// change the statistics of the current workspace
if(_driver)
_driver->SetMode(res);
}
return B_OK; return B_OK;
} }
@@ -299,6 +329,7 @@ status_t Screen::SetSpace(int32 index, int32 res,bool stick)
*/ */
void Screen::AddWindow(ServerWindow *win, int32 workspace) void Screen::AddWindow(ServerWindow *win, int32 workspace)
{ {
//TODO: Implement
if(!win) if(!win)
return; return;
} }
@@ -312,6 +343,7 @@ void Screen::AddWindow(ServerWindow *win, int32 workspace)
*/ */
void Screen::RemoveWindow(ServerWindow *win) void Screen::RemoveWindow(ServerWindow *win)
{ {
//TODO: Implement
if(!win) if(!win)
return; return;
} }
@@ -335,7 +367,7 @@ ServerWindow *Screen::ActiveWindow(void)
*/ */
void Screen::SetActiveWindow(ServerWindow *win) void Screen::SetActiveWindow(ServerWindow *win)
{ {
//TODO: Implement
} }
/*! /*!
+4 -2
View File
@@ -54,7 +54,7 @@ public:
RootLayer *GetRoot(void); RootLayer *GetRoot(void);
void SetData(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo); void SetData(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo);
void GetData(graphics_card_info *gcinfo, frame_buffer_info *fbinfo); void GetData(graphics_card_info *gcinfo, frame_buffer_info *fbinfo);
void SetSpace(int32 res);
protected: protected:
RootLayer *_rootlayer; RootLayer *_rootlayer;
graphics_card_info _gcinfo; graphics_card_info _gcinfo;
@@ -89,7 +89,8 @@ public:
Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE); Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE);
bool IsInitialized(void); bool IsInitialized(void);
Workspace *GetActiveWorkspace(void); Workspace *GetActiveWorkspace(void);
//! Returns the unique identifier for the screen
int32 GetID(void) { return _id; }
protected: protected:
int32 _resolution; int32 _resolution;
ServerWindow *_activewin; ServerWindow *_activewin;
@@ -101,6 +102,7 @@ protected:
Workspace *_activeworkspace; Workspace *_activeworkspace;
graphics_card_info _gcinfo; graphics_card_info _gcinfo;
frame_buffer_info _fbinfo; frame_buffer_info _fbinfo;
int32 _id;
}; };
#endif #endif
+2 -228
View File
@@ -183,166 +183,7 @@ void FrameBuffer::MessageReceived(BMessage *msg)
write_port(serverport,B_QUIT_REQUESTED,NULL,0); write_port(serverport,B_QUIT_REQUESTED,NULL,0);
break; break;
} }
/* default:
#ifdef ENABLE_INPUT_SERVER_EMULATION
case 0x57: // up arrow
{
// Attach 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
if(mousepos.y<=0)
{
mousepos.y=0;
break;
}
uint32 clicks=1; // can't get the # of clicks without a *lot* of extra work :(
int64 time=(int64)real_time_clock();
if(modifiers & B_SHIFT_KEY)
mousepos.y--;
else
{
mousepos.y-=10;
if(mousepos.y<0)
mousepos.y=0;
}
serverlink->SetOpCode(B_MOUSE_MOVED);
serverlink->Attach(&time, sizeof(int64));
serverlink->Attach(&mousepos.x,sizeof(float));
serverlink->Attach(&mousepos.y,sizeof(float));
serverlink->Attach(&servermods, sizeof(int32));
serverlink->Attach(&buttons, sizeof(uint32));
serverlink->Attach(&clicks, sizeof(uint32));
serverlink->Flush();
break;
}
case 0x62: // down arrow
{
// Attach 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
if(mousepos.y>= (gcinfo.height-1))
{
mousepos.y=gcinfo.height-1;
break;
}
uint32 clicks=1; // can't get the # of clicks without a *lot* of extra work :(
int64 time=(int64)real_time_clock();
if(modifiers & B_SHIFT_KEY)
mousepos.y++;
else
{
mousepos.y+=10;
if(mousepos.y>gcinfo.height-1)
mousepos.y=gcinfo.height-1;
}
serverlink->SetOpCode(B_MOUSE_MOVED);
serverlink->Attach(&time, sizeof(int64));
serverlink->Attach(&mousepos.x,sizeof(float));
serverlink->Attach(&mousepos.y,sizeof(float));
serverlink->Attach(&servermods, sizeof(int32));
serverlink->Attach(&buttons, sizeof(uint32));
serverlink->Attach(&clicks, sizeof(uint32));
serverlink->Flush();
break;
}
case 0x61: // left arrow
{
// Attach 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
if(mousepos.x<=0)
{
mousepos.x=0;
break;
}
uint32 clicks=1; // can't get the # of clicks without a *lot* of extra work :(
int64 time=(int64)real_time_clock();
if(modifiers & B_SHIFT_KEY)
mousepos.x--;
else
{
mousepos.x-=10;
if(mousepos.x<0)
mousepos.x=0;
}
serverlink->SetOpCode(B_MOUSE_MOVED);
serverlink->Attach(&time, sizeof(int64));
serverlink->Attach(&mousepos.x,sizeof(float));
serverlink->Attach(&mousepos.y,sizeof(float));
serverlink->Attach(&servermods, sizeof(int32));
serverlink->Attach(&buttons, sizeof(uint32));
serverlink->Attach(&clicks, sizeof(uint32));
serverlink->Flush();
break;
}
case 0x63: // right arrow
{
// Attach 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
if(mousepos.x>= (gcinfo.width-1))
{
mousepos.x=gcinfo.width-1;
break;
}
uint32 clicks=1; // can't get the # of clicks without a *lot* of extra work :(
int64 time=(int64)real_time_clock();
if(modifiers & B_SHIFT_KEY)
mousepos.x++;
else
{
mousepos.x+=10;
if(mousepos.x>gcinfo.width-1)
mousepos.x=gcinfo.width-1;
}
serverlink->SetOpCode(B_MOUSE_MOVED);
serverlink->Attach(&time, sizeof(int64));
serverlink->Attach(&mousepos.x,sizeof(float));
serverlink->Attach(&mousepos.y,sizeof(float));
serverlink->Attach(&servermods, sizeof(int32));
serverlink->Attach(&buttons, sizeof(uint32));
serverlink->Attach(&clicks, sizeof(uint32));
serverlink->Flush();
break;
}
#endif // end server emu code
*/ default:
break; break;
} }
} }
@@ -362,74 +203,7 @@ void FrameBuffer::MessageReceived(BMessage *msg)
break; break;
} }
#endif #endif
default:
/* case B_MODIFIERS_CHANGED:
{
int32 modifiers;
if(msg->FindInt32("modifiers",&modifiers)==B_OK)
{
#ifdef ENABLE_INPUT_SERVER_EMULATION
uint32 clicks=1; // can't get the # of clicks without a *lot* of extra work :(
int64 time=(int64)real_time_clock();
// we need to be able to shift click & such, so we will construct
// a new modifiers value which excludes our mouse click keys
int32 servermods=0;
servermods|=modifiers & B_RIGHT_COMMAND_KEY;
servermods|=modifiers & B_RIGHT_OPTION_KEY;
servermods|=modifiers & B_RIGHT_CONTROL_KEY;
servermods|=modifiers & B_SHIFT_KEY;
if(modifiers & B_LEFT_OPTION_KEY)
{
buttons=B_PRIMARY_MOUSE_BUTTON;
serverlink->SetOpCode(B_MOUSE_DOWN);
serverlink->Attach(&time, sizeof(int64));
serverlink->Attach(&mousepos.x,sizeof(float));
serverlink->Attach(&mousepos.y,sizeof(float));
serverlink->Attach(&servermods, sizeof(uint32));
serverlink->Attach(&buttons, sizeof(uint32));
serverlink->Attach(&clicks, sizeof(uint32));
serverlink->Flush();
}
else
if(modifiers & B_LEFT_CONTROL_KEY)
{
buttons=B_SECONDARY_MOUSE_BUTTON;
serverlink->SetOpCode(B_MOUSE_DOWN);
serverlink->Attach(&time, sizeof(int64));
serverlink->Attach(&mousepos.x,sizeof(float));
serverlink->Attach(&mousepos.y,sizeof(float));
serverlink->Attach(&servermods, sizeof(uint32));
serverlink->Attach(&buttons, sizeof(uint32));
serverlink->Attach(&clicks, sizeof(uint32));
serverlink->Flush();
}
else
{
// well, we got this far so none of the buttons
// are down. set our mouse buttons to up and if this
// is a change, send a B_MOUSE_UP message
if(buttons>0)
{
serverlink->SetOpCode(B_MOUSE_UP);
serverlink->Attach(&time, sizeof(int64));
serverlink->Attach(&mousepos.x,sizeof(float));
serverlink->Attach(&mousepos.y,sizeof(float));
serverlink->Attach(&servermods, sizeof(uint32));
serverlink->Flush();
}
buttons=0;
}
#endif // end server emu code
}
break;
}
*/ default:
BWindowScreen::MessageReceived(msg); BWindowScreen::MessageReceived(msg);
} }
} }
+2
View File
@@ -92,7 +92,9 @@ public:
bool IsConnected(void) const { return is_connected; } bool IsConnected(void) const { return is_connected; }
bool QuitRequested(void); bool QuitRequested(void);
static int32 MouseMonitor(void *data); static int32 MouseMonitor(void *data);
graphics_card_info gcinfo; graphics_card_info gcinfo;
protected: protected:
friend ScreenDriver; friend ScreenDriver;
+13 -1
View File
@@ -81,6 +81,7 @@ ServerApp::ServerApp(port_id sendport, port_id rcvport, char *signature)
_lock=create_sem(1,"ServerApp sem"); _lock=create_sem(1,"ServerApp sem");
_driver=GetGfxDriver(); _driver=GetGfxDriver();
_cursorhidden=false;
} }
//! Does all necessary teardown for application //! Does all necessary teardown for application
@@ -386,11 +387,13 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
case SHOW_CURSOR: case SHOW_CURSOR:
{ {
cursormanager->ShowCursor(); cursormanager->ShowCursor();
_cursorhidden=false;
break; break;
} }
case HIDE_CURSOR: case HIDE_CURSOR:
{ {
cursormanager->HideCursor(); cursormanager->HideCursor();
_cursorhidden=true;
break; break;
} }
case OBSCURE_CURSOR: case OBSCURE_CURSOR:
@@ -398,7 +401,16 @@ void ServerApp::DispatchMessage(int32 code, int8 *buffer)
cursormanager->ObscureCursor(); cursormanager->ObscureCursor();
break; break;
} }
case 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);
break;
}
case SET_CURSOR_DATA: case SET_CURSOR_DATA:
{ {
// Attached data: 68 bytes of _appcursor data // Attached data: 68 bytes of _appcursor data
+1 -1
View File
@@ -82,7 +82,7 @@ protected:
DisplayDriver *_driver; DisplayDriver *_driver;
ServerCursor *_appcursor; ServerCursor *_appcursor;
sem_id _lock; sem_id _lock;
bool _cursorhidden;
bool _isactive; bool _isactive;
}; };
+5 -7
View File
@@ -21,7 +21,11 @@
#define HWDRIVER 3 #define HWDRIVER 3
// Display driver to be used by the server. // Display driver to be used by the server.
#define DISPLAYDRIVER VIEWDRIVER #define DISPLAYDRIVER SCREENDRIVER
// Uncomment this if the DisplayDriver should only rely on drawing functions implemented
// in software even though hardware-accelerated functions are available
//#define DISABLE_HARDWARE_ACCELERATION
// Define this for a quick hack to test some of the drawing functions // Define this for a quick hack to test some of the drawing functions
//#define DISPLAYDRIVER_TEST_HACK //#define DISPLAYDRIVER_TEST_HACK
@@ -34,12 +38,6 @@
// regular application. When running as the app_server, this is not used. // regular application. When running as the app_server, this is not used.
#define SERVER_SIGNATURE "application/x-vnd.obe-OBAppServer" #define SERVER_SIGNATURE "application/x-vnd.obe-OBAppServer"
// Server port names. The input port is the port which is used to receive
// input messages from the Input Server. The other is the "main" port for
// the server and is utilized mostly by BApplication objects.
#define SERVER_PORT_NAME "OBappserver"
#define SERVER_INPUT_PORT "OBinputport"
// Directory for all app_server-related settings. // Directory for all app_server-related settings.
#define SERVER_SETTINGS_DIR "/boot/home/config/settings/app_server/" #define SERVER_SETTINGS_DIR "/boot/home/config/settings/app_server/"
+11 -3
View File
@@ -1,6 +1,12 @@
#ifndef _APPSERVER_PROTOCOL_ #ifndef _APPSERVER_PROTOCOL_
#define _APPSERVER_PROTOCOL_ #define _APPSERVER_PROTOCOL_
// Server port names. The input port is the port which is used to receive
// input messages from the Input Server. The other is the "main" port for
// the server and is utilized mostly by BApplication objects.
#define SERVER_PORT_NAME "OBappserver"
#define SERVER_INPUT_PORT "OBinputport"
#define CREATE_APP 'drca' #define CREATE_APP 'drca'
#define DELETE_APP 'drda' #define DELETE_APP 'drda'
#define QUIT_APP 'srqa' #define QUIT_APP 'srqa'
@@ -33,12 +39,17 @@
#define SET_DECORATOR 'sdec' #define SET_DECORATOR 'sdec'
#define GET_DECORATOR 'gdec' #define GET_DECORATOR 'gdec'
// Cursor-related communications
#define SET_CURSOR_DATA 'sscd' #define SET_CURSOR_DATA 'sscd'
#define SET_CURSOR_BCURSOR 'sscb' #define SET_CURSOR_BCURSOR 'sscb'
#define SET_CURSOR_BBITMAP 'sscB' #define SET_CURSOR_BBITMAP 'sscB'
#define SHOW_CURSOR 'srsc' #define SHOW_CURSOR 'srsc'
#define HIDE_CURSOR 'srhc' #define HIDE_CURSOR 'srhc'
#define OBSCURE_CURSOR 'sroc' #define OBSCURE_CURSOR 'sroc'
#define QUERY_CURSOR_HIDDEN 'sqch'
#define BEGIN_RECT_TRACKING 'sbrt'
#define END_RECT_TRACKING 'sert'
#define GFX_COUNT_WORKSPACES 'gcws' #define GFX_COUNT_WORKSPACES 'gcws'
#define GFX_SET_WORKSPACE_COUNT 'ggwc' #define GFX_SET_WORKSPACE_COUNT 'ggwc'
@@ -103,9 +114,6 @@
#define LAYER_INVALIDATE 'lyin' #define LAYER_INVALIDATE 'lyin'
#define LAYER_DRAW 'lydr' #define LAYER_DRAW 'lydr'
#define BEGIN_RECT_TRACKING 'rtbg'
#define END_RECT_TRACKING 'rten'
#define VIEW_GET_TOKEN 'vgtk' #define VIEW_GET_TOKEN 'vgtk'
#define VIEW_ADD 'vadd' #define VIEW_ADD 'vadd'
#define VIEW_REMOVE 'vrem' #define VIEW_REMOVE 'vrem'