diff --git a/src/servers/app/Jamfile b/src/servers/app/Jamfile deleted file mode 100644 index 205e307696..0000000000 --- a/src/servers/app/Jamfile +++ /dev/null @@ -1,4 +0,0 @@ -SubDir OBOS_TOP src servers app ; - -SubInclude OBOS_TOP src servers app server ; - diff --git a/src/servers/app/proto1/AppServer.cpp b/src/servers/app/proto1/AppServer.cpp deleted file mode 100644 index 0ae116c257..0000000000 --- a/src/servers/app/proto1/AppServer.cpp +++ /dev/null @@ -1,84 +0,0 @@ -#include "scheduler.h" -#include -#include -#include "AppServer.h" -#include "Desktop.h" - -AppServer::AppServer(void) : BApplication("application/x-vnd.obe-OBAppServer") -{ - printf("AppServer()\n"); -} - -AppServer::~AppServer(void) -{ - printf("~AppServer()\n"); - -// kill_thread(PicassoID); -// kill_thread(InputID); - shutdown_desktop(); -} - -void AppServer::Initialize(void) -{ - printf("AppServer::Initialize()\n"); - mouseport=create_port(30,"OBpcreate"); - messageport=create_port(20,"OBpcreate"); - - // Set up the Desktop - init_desktop(3); -/* - // Start up the housekeeping threads - PicassoID = spawn_thread(Draw, "picasso", B_DISPLAY_PRIORITY, this); - if (PicassoID >= 0) - resume_thread(PicassoID); - - InputID = spawn_thread(Draw, "poller", B_DISPLAY_PRIORITY, this); - if (InputID >= 0) - resume_thread(InputID); - - MainLoop(); -*/ -} - -void AppServer::MainLoop(void) -{ - printf("AppServer::MainLoop()\n"); - // Main loop. Monitors the message queue and dispatches as appropriate - int32 msgcode; - uint8 *msgbuffer=new uint8[65536]; - - for(;;) - { - if (read_port(messageport,&msgcode,msgbuffer,65536)!=0) - { - printf("Message sent to OB App server: %ld\n",msgcode); - if(msgcode==B_QUIT_REQUESTED) - break; - } - } - delete msgbuffer; -} - -int32 AppServer::Picasso(void *data) -{ - return 1; -} - -int32 AppServer::Poller(void *data) -{ - return 1; -} - -void AppServer::DispatchMessage(BMessage *msg) -{ - printf("AppServer::DispatchMessage():"); msg->PrintToStream(); -} - -int main( int argc, char** argv ) -{ - AppServer *obas = new AppServer(); - obas->Initialize(); - obas->Run(); - return( 0 ); -} - diff --git a/src/servers/app/proto1/AppServer.h b/src/servers/app/proto1/AppServer.h deleted file mode 100644 index fdae9fa280..0000000000 --- a/src/servers/app/proto1/AppServer.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _OPENBEOS_APP_SERVER_H_ -#define _OPENBEOS_APP_SERVER_H_ - -#include -#include -#include "Globals.h" - -class BMessage; -class Desktop; - -class AppServer : public BApplication -{ -public: - AppServer(void); - ~AppServer(void); - void Initialize(void); - void MainLoop(void); - port_id messageport,mouseport; - static int32 Picasso(void *data); - static int32 Poller(void *data); -// void Run(void); - -private: - void DispatchMessage(BMessage *pcReq); - thread_id DrawID, InputID; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto1/Desktop.cpp b/src/servers/app/proto1/Desktop.cpp deleted file mode 100644 index 88a4c477b9..0000000000 --- a/src/servers/app/proto1/Desktop.cpp +++ /dev/null @@ -1,227 +0,0 @@ - -/* - Screen.cpp: - Function implementations of screen functions in InterfaceDefs.h -*/ -#include -#include -#include -#include -#include -#include "DisplayDriver.h" -#include "DirectDriver.h" -#include "Desktop.h" - -class ServerWindow; -class ServerBitmap; -class ServerLayer; -class Workspace; - -//--------------------GLOBALS------------------------- -int32 workspace_count, active_workspace; -BList desktop; -Workspace *pactive_workspace; -color_map system_palette; -DisplayDriver *gfxdriver; -//---------------------------------------------------- - - -//-------------------INTERNAL CLASS DEFS-------------- -class Workspace -{ -public: - Workspace(void); - Workspace(BPath imagepath); - ~Workspace(); - - BList layerlist; - BList focuslist; - rgb_color bgcolor; - screen_info screendata, - olddata; -}; - -DisplayDriver *get_gfxdriver(void) -{ - return gfxdriver; -} - -Workspace::Workspace(void) -{ - workspace_count++; - - // default values - layerlist.MakeEmpty(); - focuslist.MakeEmpty(); - bgcolor.red=51; - bgcolor.green=102; - bgcolor.blue=160; - screendata.mode=B_CMAP8; - screendata.spaces=B_8_BIT_640x480; - screendata.refresh_rate=60.0; - screendata.min_refresh_rate=60.0; - screendata.max_refresh_rate=60.0; - screendata.h_position=(uchar)50; - screendata.v_position=(uchar)50; - screendata.h_size=(uchar)50; - screendata.v_size=(uchar)50; - olddata=screendata; -} - -Workspace::~Workspace(void) -{ - workspace_count--; -} -//--------------------------------------------------- - - -//-----------------GLOBAL FUNCTION DEFS--------------- - -void init_desktop(int8 workspaces) -{ - printf("init_desktop()\n"); -/* - Create the screen bitmap - Get framebuffer area info - Call setup_screenmode - Create top layer for workspace - Set cursor - Turn mouse on in display driver -*/ - workspace_count=workspaces; - if(workspace_count==0) - workspace_count++; - - // Instantiate and initialize display driver - gfxdriver=new DirectDriver(); - gfxdriver->Initialize(); - if(gfxdriver->IsInitialized()) - printf("Driver initialized\n"); - else - printf("Driver NOT initialized\n"); - - // Create the workspaces we're supposed to have - for(int8 i=0; iSetScreen(pactive_workspace->screendata.spaces); -} - -void shutdown_desktop(void) -{ - printf("Shutdown desktop()\n"); - int32 i,count=desktop.CountItems(); - for(i=0;iworkspace_count || workspace<0) - return; - - Workspace *proposed=(Workspace *)desktop.ItemAt(workspace); - - if(proposed==NULL) - return; - - if(pactive_workspace->screendata.spaces != proposed->screendata.spaces) - { - gfxdriver->SetScreen(proposed->screendata.spaces); - } - - // What else needs to go here? --DW - -} - -const color_map *system_colors(void) -{ - return (const color_map *)&system_palette; -} - -status_t set_screen_space(int32 index, uint32 res, bool stick = true) -{ - printf("set_screen_space(%ld,%lu, %s)\n",index,res,(stick==true)?"true":"false"); - return B_ERROR; -} - -status_t get_scroll_bar_info(scroll_bar_info *info) -{ - return B_ERROR; -} - -status_t set_scroll_bar_info(scroll_bar_info *info) -{ - printf("set_scroll_bar_info()\n"); - return B_ERROR; -} - -bigtime_t idle_time() -{ - return 0; -} - -void run_select_printer_panel() -{ -} - -void run_add_printer_panel() -{ -} - -void run_be_about() -{ -} - -void set_focus_follows_mouse(bool follow) -{ - printf("set_focus_follows_mouse(%s)\n",(follow==true)?"true":"false"); -} - -bool focus_follows_mouse() -{ - return false; -} diff --git a/src/servers/app/proto1/Desktop.h b/src/servers/app/proto1/Desktop.h deleted file mode 100644 index 5b850d0f2d..0000000000 --- a/src/servers/app/proto1/Desktop.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _OBDESKTOP_H_ -#define _OBDESKTOP_H_ - -#include -#include -class DisplayDriver; - -typedef enum -{ PLACE_MANUAL=0, - PLACE_SCALE=1, - PLACE_TILE=2 -} wallpaper_placement; - -void init_desktop(int8 workspaces); -void shutdown_desktop(void); -DisplayDriver *get_gfxdriver(void); - -typedef struct -{ - color_space mode; - BRect frame; - uint32 spaces; - float min_refresh_rate; - float max_refresh_rate; - float refresh_rate; - uchar h_position; - uchar v_position; - uchar h_size; - uchar v_size; -} screen_info; - - -#endif \ No newline at end of file diff --git a/src/servers/app/proto1/DirectDriver.cpp b/src/servers/app/proto1/DirectDriver.cpp deleted file mode 100644 index 69c49e1bd8..0000000000 --- a/src/servers/app/proto1/DirectDriver.cpp +++ /dev/null @@ -1,117 +0,0 @@ -#include -#include "DirectDriver.h" - -OBAppServerScreen::OBAppServerScreen(status_t *error) - : BWindowScreen("DirectDriver",B_32_BIT_800x600,error,true) -{ - redraw=true; -} - -OBAppServerScreen::~OBAppServerScreen(void) -{ -} - -void OBAppServerScreen::MessageReceived(BMessage *msg) -{ - msg->PrintToStream(); - switch(msg->what) - { - case B_KEY_DOWN: - Disconnect(); - QuitRequested(); - break; - default: - BWindowScreen::MessageReceived(msg); - break; - } -} - -bool OBAppServerScreen::QuitRequested(void) -{ - be_app->PostMessage(B_QUIT_REQUESTED); - return true; -} - -int32 OBAppServerScreen::Draw(void *data) -{ - OBAppServerScreen *screen=(OBAppServerScreen *)data; - for(;;) - { - if(screen->connected && screen->redraw) - { - // Draw a sample background - screen->Clear(128,128,128); - screen->SimWin(BRect(100,100,250,250)); - screen->redraw=false; - } - } - return 1; -} - -void OBAppServerScreen::ScreenConnected(bool ok) -{ - if(ok==true) - connected=true; - else - connected=false; -} - -void OBAppServerScreen::Clear(uint8 red,uint8 green,uint8 blue) -{ - if(!connected) return; -} - -void OBAppServerScreen::SimWin(BRect rect) -{ - if(!connected) return; -} - -DirectDriver::DirectDriver(void) -{ - printf("DirectDriver()\n"); - old_space=B_32_BIT_800x600; -} - -DirectDriver::~DirectDriver(void) -{ - printf("~DirectDriver()\n"); - winscreen->Quit(); -} - -void DirectDriver::Initialize(void) -{ - printf("DirectDriver::Initialize()\n"); - status_t stat; - winscreen=new OBAppServerScreen(&stat); - if(stat==B_OK) - { - is_initialized=true; - winscreen->Show(); - } - else - delete winscreen; - - if(winscreen->connected==false) - return; - ginfo=winscreen->CardInfo(); - for(int8 i=0;i<48;i++) - ghooks[i]=winscreen->CardHookAt(i); -} - -void DirectDriver::SafeMode(void) -{ - printf("DirectDriver::SafeMode()\n"); - Reset(); -} - -void DirectDriver::Reset(void) -{ - printf("DirectDriver::Reset()\n"); - if(is_initialized) - winscreen->Clear(51,102,160); -} - -void DirectDriver::SetScreen(uint32 space) -{ - printf("DirectDriver::SetScreen(%lu)\n",space); -} \ No newline at end of file diff --git a/src/servers/app/proto1/DirectDriver.h b/src/servers/app/proto1/DirectDriver.h deleted file mode 100644 index 21920d049d..0000000000 --- a/src/servers/app/proto1/DirectDriver.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef _DIRECTDRIVER_H_ -#define _DIRECTDRIVER_H_ - -#include -#include -#include -#include -#include "DisplayDriver.h" - -class OBAppServerScreen : public BWindowScreen -{ -public: - OBAppServerScreen(status_t *error); - ~OBAppServerScreen(void); - virtual void MessageReceived(BMessage *msg); - virtual bool QuitRequested(void); - static int32 Draw(void *data); - virtual void ScreenConnected(bool connected); - - // Graphics stuff implemented here for the moment - void Clear(uint8 red,uint8 green,uint8 blue); - void SimWin(BRect rect); - - int32 DrawID; - bool redraw,connected; -}; - -class DirectDriver : public DisplayDriver -{ -public: - DirectDriver(void); - virtual ~DirectDriver(void); - - virtual void Initialize(void); // Sets the driver - virtual void SafeMode(void); // Easy-access functions for common tasks - virtual void Reset(void); - virtual void SetScreen(uint32 space); - OBAppServerScreen *winscreen; -protected: - // Original screen info - uint32 old_space; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto1/DisplayDriver.cpp b/src/servers/app/proto1/DisplayDriver.cpp deleted file mode 100644 index 43dc9647b6..0000000000 --- a/src/servers/app/proto1/DisplayDriver.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "DisplayDriver.h" - -DisplayDriver::DisplayDriver(void) -{ - is_initialized=false; - cursor_visible=false; -} - -DisplayDriver::~DisplayDriver(void) -{ -} - -void DisplayDriver::Initialize(void) -{ // Loading loop to find proper driver - -} - -bool DisplayDriver::IsInitialized(void) -{ // Let dev know whether things worked out ok - return is_initialized; -} - -void DisplayDriver::SafeMode(void) -{ // Set video mode to 640x480x256 mode -} - -void DisplayDriver::Reset(void) -{ // Reloads and restarts driver. Defaults to a safe mode - -} - -void DisplayDriver::SetScreen(uint32 space) -{ -} \ No newline at end of file diff --git a/src/servers/app/proto1/DisplayDriver.h b/src/servers/app/proto1/DisplayDriver.h deleted file mode 100644 index cafa3fd708..0000000000 --- a/src/servers/app/proto1/DisplayDriver.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef _GFX_DRIVER_H_ -#define _GFX_DRIVER_H_ - -#include -#include "Desktop.h" - -typedef struct -{ - uchar *xormask, *andmask; - int32 width, height; - int32 hotx, hoty; - -} cursor_data; - -#ifndef HOOK_DEFINE_CURSOR - -#define HOOK_DEFINE_CURSOR 0 -#define HOOK_MOVE_CURSOR 1 -#define HOOK_SHOW_CURSOR 2 -#define HOOK_DRAW_LINE_8BIT 3 -#define HOOK_DRAW_LINE_16BIT 12 -#define HOOK_DRAW_LINE_32BIT 4 -#define HOOK_DRAW_RECT_8BIT 5 -#define HOOK_DRAW_RECT_16BIT 13 -#define HOOK_DRAW_RECT_32BIT 6 -#define HOOK_BLIT 7 -#define HOOK_DRAW_ARRAY_8BIT 8 -#define HOOK_DRAW_ARRAY_16BIT 14 // Not implemented in current R5 drivers -#define HOOK_DRAW_ARRAY_32BIT 9 -#define HOOK_SYNC 10 -#define HOOK_INVERT_RECT 11 - -#endif - -class DisplayDriver -{ -public: - DisplayDriver(void); - virtual ~DisplayDriver(void); - - virtual void Initialize(void); // Sets the driver - virtual void SafeMode(void); // Easy-access functions for common tasks - virtual void Reset(void); - virtual void SetScreen(uint32 space); - - virtual bool IsInitialized(void); - graphics_card_hook ghooks[48]; - graphics_card_info *ginfo; - cursor_data current_cursor; - bool cursor_visible; - -protected: - bool is_initialized; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto1/Globals.h b/src/servers/app/proto1/Globals.h deleted file mode 100644 index 2753cad1aa..0000000000 --- a/src/servers/app/proto1/Globals.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _SERVER_GLOBALS_H_ -#define _SERVER_GLOBALS_H_ - -#include -BList *gBitmaplist, *gLayerlist; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto1/GraphicsHooks.cc b/src/servers/app/proto1/GraphicsHooks.cc deleted file mode 100644 index 2bd8e1c67e..0000000000 --- a/src/servers/app/proto1/GraphicsHooks.cc +++ /dev/null @@ -1,181 +0,0 @@ -#include -#include -#include "GraphicsHooks.h" -//#include "AppServer.h" // for the framebuffer pointer - -// Structs necessary for our hook functions -#include - -int32 define_cursor(uchar *xormask, uchar *andmask, int32 width, - int32 height, int32 hotx, int32 hoty) -{ - return 0; -} - -int32 move_cursor(int32 screenx, int32 screeny) -{ - return 0; -} - -int32 show_cursor(bool flag) -{ - return 0; -} - -int32 draw_line_with_8_bit_depth(int32 startx, int32 endx, - int32 starty, int32 endy, uint8 colorindex, bool cliptorect, - int16 clipleft, int16 cliptop, int16 clipright, int16 clipbottom) -{ - if(cliptorect) - { // Do clipping before we start if we're told to - BRect rect(clipleft,cliptop,clipright,clipbottom); - BPoint start(startx,starty),end(endx,endy); - start.ConstrainTo(rect); - end.ConstrainTo(rect); - } - - return B_OK; -} - -int32 draw_line_with_32_bit_depth(int32 startx, int32 endx, - int32 starty, int32 endy, uint32 color, bool cliptorect, - int16 clipleft, int16 cliptop, int16 clipright, int16 clipbottom) -{ - if(cliptorect) - { // Do clipping before we start if we're told to - BRect rect(clipleft,cliptop,clipright,clipbottom); - BPoint start(startx,starty),end(endx,endy); - start.ConstrainTo(rect); - end.ConstrainTo(rect); - } - - return 0; -} - -int32 draw_rect_with_8_bit_depth(int32 left, int32 top, int32 right, - int32 bottom, uint8 colorindex) -{ - return 0; -} - -int32 draw_rect_with_32_bit_depth(int32 left, int32 top, int32 right, - int32 bottom, uint32 color) -{ - return 0; -} - -int32 blit(int32 sourcex, int32 sourcey, int32 destinationx, - int32 destinationy, int32 width, int32 height) -{ - return 0; -} - -int32 draw_array_with_8_bit_depth(indexed_color_line *array, int32 numitems, - bool cliptorect, int16 clipleft, int16 cliptop, - int16 clipright, int16 clipbottom) -{ - return 0; -} - -int32 draw_array_with_32_bit_depth(rgb_color_line *array, int32 numitems, - bool cliptorect, int16 clipleft, int16 cliptop, - int16 clipright, int16 clipbottom) -{ - return 0; -} - -int32 sync(void) -{ - return 0; -} - -int32 invert_rect(int32 left, int32 top, int32 right, int32 bottom) -{ - return 0; -} - -int32 draw_line_with_16_bit_depth(int32 startx, int32 endx, - int32 starty, int32 endy, uint16 color, bool cliptorect, - int16 clipleft, int16 cliptop, int16 clipright, int16 clipbottom) -{ - return 0; -} - -int32 draw_rect_with_16_bit_depth(int32 left, int32 top, int32 right, - int32 bottom, uint16 color) -{ - return 0; -} - -// hook functions not officially-defined, but which should exist -int32 draw_array_with_16_bit_depth(high_color_line *array, int32 numitems, - bool cliptorect, int16 clipleft, int16 cliptop, - int16 clipright, int16 clipbottom) -{ - return 0; -} - -int32 draw_frect_with_8_bit_depth(int32 left, int32 top, int32 right, - int32 bottom, uint8 colorindex) -{ - return 0; -} - -int32 draw_frect_with_16_bit_depth(int32 left, int32 top, int32 right, - int32 bottom, uint16 color) -{ - return 0; -} - -int32 draw_frect_with_32_bit_depth(int32 left, int32 top, int32 right, - int32 bottom, uint32 color) -{ - return 0; -} - -/* -rgb_color GetPixel_32(BPoint pt) -{ -// pt.x = floor(pt.x / zoom); -// pt.y = floor(pt.y / zoom); - rgb_color color; - - uint32 pos_bits=uint32 ( (p_active_layer->bitmap->BytesPerRow()*pt.y) + (pt.x*4) ); - uint8 *s_bits=(uint8*) p_active_layer->bitmap->Bits() + pos_bits; - - color.blue=*s_bits; - s_bits++; - color.green=*s_bits; - s_bits++; - color.red=*s_bits; - s_bits++; - color.alpha=*s_bits; - return color; -} - -void SetPixel_32(BPoint where, rgb_color color) -{ - // Make some quick-access pointers - BBitmap *work_bmp; - work_bmp=p_active_layer->bitmap; - - uint8 *bmpdata=(uint8 *)work_bmp->Bits(); - - // Check bounds - where.ConstrainTo(work_bmp->Bounds()); - - // Calculate offset & jump - uint32 bitoffset; - bitoffset= uint32 ((where.x*4)+(work_bmp->BytesPerRow()*where.y)); //only counts there - it is similar on all lines - bmpdata += bitoffset; - - // Assign color data - *bmpdata=color.blue; - bmpdata++; - *bmpdata=color.green; - bmpdata++; - *bmpdata=color.red; - bmpdata++; - *bmpdata=color.alpha; -} -*/ \ No newline at end of file diff --git a/src/servers/app/proto1/GraphicsHooks.h b/src/servers/app/proto1/GraphicsHooks.h deleted file mode 100644 index 8b9c5b2f05..0000000000 --- a/src/servers/app/proto1/GraphicsHooks.h +++ /dev/null @@ -1,60 +0,0 @@ -// Structs necessary for our hook functions -#include - -typedef struct -{ int16 x1,y1,x2,y2; - uint8 color; -} indexed_color_line; - -typedef struct -{ int16 x1,y1,x2,y2; - rgb_color color; -} rgb_color_line; - -int32 define_cursor(uchar *xormask, uchar *andmask, int32 width, - int32 height, int32 hotx, int32 hoty); -int32 move_cursor(int32 screenx, int32 screeny); -int32 show_cursor(bool flag); -int32 draw_line_with_8_bit_depth(int32 startx, int32 endx, - int32 starty, int32 endy, uint8 colorindex, bool cliptorect, - int16 clipleft, int16 cliptop, int16 clipright, int16 clipbottom); -int32 draw_line_with_32_bit_depth(int32 startx, int32 endx, - int32 starty, int32 endy, uint32 color, bool cliptorect, - int16 clipleft, int16 cliptop, int16 clipright, int16 clipbottom); -int32 draw_rect_with_8_bit_depth(int32 left, int32 top, int32 right, - int32 bottom, uint8 colorindex); -int32 draw_rect_with_32_bit_depth(int32 left, int32 top, int32 right, - int32 bottom, uint32 color); -int32 blit(int32 sourcex, int32 sourcey, int32 destinationx, - int32 destinationy, int32 width, int32 height); -int32 draw_array_with_8_bit_depth(indexed_color_line *array, int32 numitems, - bool cliptorect, int16 clipleft, int16 cliptop, - int16 clipright, int16 clipbottom); -int32 draw_array_with_32_bit_depth(rgb_color_line *array, int32 numitems, - bool cliptorect, int16 clipleft, int16 cliptop, - int16 clipright, int16 clipbottom); -int32 sync(void); -int32 invert_rect(int32 left, int32 top, int32 right, int32 bottom); -int32 draw_line_with_16_bit_depth(int32 startx, int32 endx, - int32 starty, int32 endy, uint16 color, bool cliptorect, - int16 clipleft, int16 cliptop, int16 clipright, int16 clipbottom); -int32 draw_rect_with_16_bit_depth(int32 left, int32 top, int32 right, - int32 bottom, uint16 color); - - -// Not officially-defined hook functions which should be here -typedef struct -{ int16 x1,y1,x2,y2; - uint16 color; -} high_color_line; - -int32 draw_array_with_16_bit_depth(high_color_line *array, int32 numitems, - bool cliptorect, int16 clipleft, int16 cliptop, - int16 clipright, int16 clipbottom); - -int32 draw_frect_with_8_bit_depth(int32 left, int32 top, int32 right, - int32 bottom, uint8 colorindex); -int32 draw_frect_with_16_bit_depth(int32 left, int32 top, int32 right, - int32 bottom, uint16 color); -int32 draw_frect_with_32_bit_depth(int32 left, int32 top, int32 right, - int32 bottom, uint32 color); diff --git a/src/servers/app/proto1/Layer.cpp b/src/servers/app/proto1/Layer.cpp deleted file mode 100644 index 4130a02e2e..0000000000 --- a/src/servers/app/proto1/Layer.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "Layer.h" - -Layer::Layer(ServerWindow *Win, const char *Name, BRect &Frame, int32 Flags) -{ -} - -Layer::Layer(ServerBitmap *Bitmap) -{ -} - -Layer::~Layer(void) -{ -} - -void Layer::Initialize(void) -{ -} - -void Layer::Show(void) -{ -} - -void Layer::Hide(void) -{ -} - -bool Layer::IsVisible(void) -{ - return false; -} - -void Layer::Update(bool ForceUpdate) -{ -} - -bool Layer::IsBackground(void) -{ - return false; -} - -void Layer::SetFrame(const BRect &Rect) -{ -} - -BRect Layer::Frame(void) -{ - return BRect(0,0,0,0); -} - -BRect Layer::Bounds(void) -{ - return BRect(0,0,0,0); -} - -void Layer::Invalidate(const BRect &Rect) -{ -} - -void Layer::AddRegion(BRegion *Region) -{ -} - -void Layer::RemoveRegions(void) -{ -} - -void Layer::UpdateRegions(bool ForceUpdate=true, bool Root=true) -{ -} - -void Layer::Draw(const BRect &Rect) -{ -} - diff --git a/src/servers/app/proto1/Layer.h b/src/servers/app/proto1/Layer.h deleted file mode 100644 index 603d5642a3..0000000000 --- a/src/servers/app/proto1/Layer.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef _LAYER_H_ -#define _LAYER_H_ - -#include -#include -#include - -class ServerBitmap; -class ServerWindow; - -class Layer -{ -public: - Layer(ServerWindow *Win, const char *Name, BRect &Frame, int32 Flags); - Layer(ServerBitmap *Bitmap); - virtual ~Layer(void); - - void Initialize(void); - void Show(void); - void Hide(void); - bool IsVisible(void); - void Update(bool ForceUpdate); - - bool IsBackground(void); - - virtual void SetFrame(const BRect &Rect); - BRect Frame(void); - BRect Bounds(void); - - void Invalidate(const BRect &Rect); - void AddRegion(BRegion *Region); - void RemoveRegions(void); - void UpdateRegions(bool ForceUpdate=true, bool Root=true); - - // Render functions: - virtual void Draw(const BRect &Rect); - - const char *name; - int32 handle; - ServerWindow *window; // Window associated with this. NULL for background layer - ServerBitmap *bitmap; // Blasted to screen on redraw. We render to this - - BRect frame; - - BRegion *visible, // Everything currently visible - *full, // The complete region - *update; // Area to be updated at next redraw - - int32 flags; // Various flags for behavior - - // Render state: - BPoint penpos; - rgb_color high, low, erase; - - int32 drawingmode; -}; - - Layer *FindLayer(int32 Handle); - -#endif diff --git a/src/servers/app/proto1/ServerBitmap.cpp b/src/servers/app/proto1/ServerBitmap.cpp deleted file mode 100644 index 9c8748f802..0000000000 --- a/src/servers/app/proto1/ServerBitmap.cpp +++ /dev/null @@ -1,134 +0,0 @@ -#include "ServerBitmap.h" -#include "Desktop.h" - -ServerBitmap::ServerBitmap(BRect rect,color_space cspace,int32 BytesPerLine=0) -{ - width=rect.IntegerWidth()+1; - height=rect.IntegerHeight()+1; - colorspace=cspace; - is_vram=false; - - // Big convoluted mess just to handle every color space and dword align - // the buffer - switch(cspace) - { - // Buffer is dword-aligned, so nothing need be done - // aside from allocate the memory - case B_RGB32: - case B_RGBA32: - case B_RGB32_BIG: - case B_RGBA32_BIG: - case B_UVL32: - case B_UVLA32: - case B_LAB32: - case B_LABA32: - case B_HSI32: - case B_HSIA32: - case B_HSV32: - case B_HSVA32: - case B_HLS32: - case B_HLSA32: - case B_CMY32: - case B_CMYA32: - case B_CMYK32: - - // 24-bit=32bit with extra 8 bits ignored - case B_RGB24_BIG: - case B_RGB24: - case B_LAB24: - case B_UVL24: - case B_HSI24: - case B_HSV24: - case B_HLS24: - case B_CMY24: - { - if(BytesPerLine<(width*4)) - bytesperline=width*4; - else - bytesperline=BytesPerLine; - break; - } - // Calculate size and dword-align - - // 1-bit - case B_GRAY1: - { - int32 numbytes=width>>3; - if((width % 8) != 0) - numbytes++; - if(BytesPerLine -#include -#include "DisplayDriver.h" - -class ServerBitmap -{ -public: - ServerBitmap(BRect rect,color_space cspace,int32 BytesPerLine=0); - ~ServerBitmap(void); - - int32 width,height; - int32 bytesperline; - color_space colorspace; - uint8 *buffer; - DisplayDriver *driver; - bool is_vram; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto1/ServerWindow.cpp b/src/servers/app/proto1/ServerWindow.cpp deleted file mode 100644 index 25573409cf..0000000000 --- a/src/servers/app/proto1/ServerWindow.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include -#include "ServerWindow.h" - -ServerWindow::ServerWindow(const char *Title, uint32 Flags, uint32 Desktop, - const BRect &Rect, ServerApp *App, port_id SendPort) -{ -} - -ServerWindow::ServerWindow(ServerApp *App, ServerBitmap *Bitmap) -{ -} - -ServerWindow::~ServerWindow(void) -{ -} - -void ServerWindow::PostMessage(BMessage *msg) -{ -} - -void ServerWindow::ReplaceDecorator(void) -{ -} - -void ServerWindow::Quit(void) -{ -} - -const char *ServerWindow::GetTitle(void) -{ - return NULL; -} - -ServerApp *ServerWindow::GetApp(void) -{ - return NULL; -} - -BMessenger *ServerWindow::GetAppTarget(void) -{ - return NULL; -} - -void ServerWindow::Show(void) -{ -} - -void ServerWindow::Hide(void) -{ -} - -void ServerWindow::SetFocus(void) -{ -} - -bool ServerWindow::HasFocus(void) -{ - return false; -} - -void ServerWindow::DesktopActivated(int32 NewDesktop, const BPoint Resolution, color_space CSpace) -{ -} - -void ServerWindow::WindowActivated(bool Active) -{ -} - -void ServerWindow::ScreenModeChanged(const BPoint Resolustion, color_space CSpace) -{ -} - -void ServerWindow::SetFrame(const BRect &Frame) -{ -} - -BRect ServerWindow::Frame(void) -{ - return BRect(0,0,0,0); -} - -thread_id ServerWindow::Run(void) -{ - return -1; -} - -status_t ServerWindow::Lock(void) -{ - return B_ERROR; -} - -status_t ServerWindow::Unlock(void) -{ - return B_ERROR; -} - -bool ServerWindow::IsLocked(void) -{ - return false; -} - -bool ServerWindow::DispatchMessage(BMessage *msg) -{ - return false; -} - -bool ServerWindow::DispatchMessage(const void *msg, int nCode) -{ - return false; -} - -void ServerWindow::Loop(void) -{ -} diff --git a/src/servers/app/proto1/ServerWindow.h b/src/servers/app/proto1/ServerWindow.h deleted file mode 100644 index 4c97ab93bb..0000000000 --- a/src/servers/app/proto1/ServerWindow.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _SERVERWIN_H_ -#define _SERVERWIN_H_ - -#include -#include -#include -#include - -class BString; -class BMessenger; -class BRect; -class BPoint; -class ServerApp; -class ServerBitmap; -class WindowDecorator; - -class ServerWindow -{ -public: -ServerWindow(const char *Title, uint32 Flags, uint32 Desktop, - const BRect &Rect, ServerApp *App, port_id SendPort); -ServerWindow(ServerApp *App, ServerBitmap *Bitmap); -virtual ~ServerWindow(void); - -void PostMessage(BMessage *msg); -void ReplaceDecorator(void); -virtual void Quit(void); -const char *GetTitle(void); -ServerApp *GetApp(void); -BMessenger *GetAppTarget(void); -void Show(void); -void Hide(void); -void SetFocus(void); -bool HasFocus(void); - -void DesktopActivated(int32 NewDesktop, const BPoint Resolution, color_space CSpace); -void WindowActivated(bool Active); -void ScreenModeChanged(const BPoint Resolustion, color_space CSpace); - -void SetFrame(const BRect &Frame); -BRect Frame(void); - -thread_id Run(void); -status_t Lock(void); -status_t Unlock(void); -bool IsLocked(void); - -bool DispatchMessage(BMessage *msg); -bool DispatchMessage(const void *msg, int nCode); - -void Loop(void); - -const char *title; -int32 flags; -int32 desktop; - -ServerBitmap *userbitmap; -ServerApp *app; - -WindowDecorator *decorator; -bigtime_t lasthit; // Time of last mouse click - -thread_id thread; -port_id rcvport; // Messages from application -port_id sendport; // Messages to application -BLocker mutex; -BMessenger *apptarget; -}; - -#endif diff --git a/src/servers/app/proto2/AppServer.cpp b/src/servers/app/proto2/AppServer.cpp deleted file mode 100644 index 544512d659..0000000000 --- a/src/servers/app/proto2/AppServer.cpp +++ /dev/null @@ -1,177 +0,0 @@ -#include -#include -#include "ServerProtocol.h" - -#include "AppServer.h" -#include "ServerApp.h" -#include "PortLink.h" - -AppServer::AppServer(void) : BApplication("application/x-vnd.obe-OBAppServer") -{ - printf("AppServer()\n"); - - mouseport=create_port(30,"OBpcreate"); -// messageport=create_port(20,"OBpcreate"); - messageport=create_port(20,SERVER_PORT_NAME); - printf("Server message port: %ld\n",messageport); - applist=new BList(0); - quitting_server=false; -} - -AppServer::~AppServer(void) -{ - printf("~AppServer()\n"); - - ServerApp *temp; - for(int32 i=0;iCountItems();i++) - { - temp=(ServerApp *)applist->ItemAt(i); - if(temp!=NULL) - delete temp; - } - delete applist; -} - -thread_id AppServer::Run(void) -{ - printf("AppServer::Run()\n"); - - MainLoop(); - return 0; -} - -void AppServer::MainLoop(void) -{ - printf("AppServer::MainLoop()\n"); - - // Main loop. Monitors the message queue and dispatches as appropriate - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(messageport); - if(buffersize>0) - msgbuffer=new int8[buffersize]; - bytesread=read_port(messageport,&msgcode,msgbuffer,buffersize); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case CREATE_APP: - case DELETE_APP: - case B_QUIT_REQUESTED: - DispatchMessage(msgcode,msgbuffer); - break; - default: - printf("Server received unexpected code %ld\n",msgcode); - break; - } - - } - - if(buffersize>0) - delete msgbuffer; - if(msgcode==DELETE_APP) - { - if(quitting_server==true && applist->CountItems()==0) - break; - } - } - -} - - -void AppServer::DispatchMessage(int32 code, int8 *buffer) -{ - int8 *index=buffer; - switch(code) - { - case CREATE_APP: - { - printf("AppServer: Create App\n"); - - // Attached data: - // 1) port_id - receiver port of a regular app - // 2) char * - signature of the regular app - - // Find the necessary data - port_id app_port=*((port_id*)index); - index+=sizeof(port_id); - - char *app_signature=(char *)index; - - // Create the ServerApp subthread for this app - ServerApp *newapp=new ServerApp(app_port,app_signature); - applist->AddItem(newapp); - newapp->Run(); - break; - } - case DELETE_APP: - { - // Delete a ServerApp. Received only from the respective ServerApp - printf("AppServer: Delete App\n"); - - // Attached Data: - // 1) thread_id - thread ID of the ServerApp to be deleted - - int32 i, appnum=applist->CountItems(); - ServerApp *srvapp; - thread_id srvapp_id=*((thread_id*)buffer); - - // Run through the list of apps and nuke the proper one - for(i=0;iItemAt(i); - if(srvapp!=NULL && srvapp->monitor_thread==srvapp_id) - { - srvapp=(ServerApp *)applist->RemoveItem(i); - delete srvapp; - } - } - break; - } - case B_QUIT_REQUESTED: - { - printf("Shutdown sequence initiated.\n"); - // Attached Data: - // none - - // We've been asked to quit, so (for now) broadcast to all - // test apps to quit - PortLink *applink=new PortLink(0); - ServerApp *srvapp; - int32 i,appnum=applist->CountItems(); - - applink->SetOpCode(QUIT_APP); - for(i=0;iItemAt(i); - if(srvapp!=NULL) - { - applink->SetPort(srvapp->receiver); - applink->Flush(); - } - } - - delete applink; - // So when we delete the last ServerApp, we can exit the server - quitting_server=true; - break; - } - default: - printf("Unexpected message %ld (%lx) in AppServer::DispatchMessage()\n",code,code); - break; - } -} - -int main( int argc, char** argv ) -{ - AppServer *obas = new AppServer(); - obas->Run(); - delete obas; - return( 0 ); -} - diff --git a/src/servers/app/proto2/AppServer.h b/src/servers/app/proto2/AppServer.h deleted file mode 100644 index 0c781a735d..0000000000 --- a/src/servers/app/proto2/AppServer.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _OPENBEOS_APP_SERVER_H_ -#define _OPENBEOS_APP_SERVER_H_ - -#include -#include -#include - -class BMessage; -class ServerApp; - -class AppServer : public BApplication -{ -public: - AppServer(void); - ~AppServer(void); - thread_id Run(void); - void MainLoop(void); - port_id messageport,mouseport; - -private: - void DispatchMessage(int32 code, int8 *buffer); - thread_id DrawID, InputID; - bool quitting_server; - BList *applist; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto2/PortLink.cpp b/src/servers/app/proto2/PortLink.cpp deleted file mode 100644 index 8fba724569..0000000000 --- a/src/servers/app/proto2/PortLink.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/* - PortLink.cpp: - A helper class for port-based messaging - ------------------------------------------------------------------------- -How it works: - The class utilizes a fixed-size array of PortLinkData object pointers. When -data is attached, a new PortLinkData object is allocated and a copy of the -passed data is created inside it. When the time comes for the message to be sent, -the data is pieced together into a flattened array and written to the port. ------------------------------------------------------------------------- -Data members: - -*attachments[] - fixed-size array of pointers used to hold the attached data -opcode - message value which is sent along with any data -target - port to which the message is sent when Flush() is called -replyport - port used with synchronous messaging - FlushWithReply() -bufferlength - total bytes taken up by attachments -num_attachments - internal variable which is used to track which "slot" - will be the next one to receive an attachment object -*/ - -#include "PortLink.h" -#include -#include -#include - -//#define PLDEBUG - -// Internal data storage class for holding attached data whilst it is waiting -// to be Flattened() and then Flushed(). There is no need for this to be called outside -// the PortLink class. -class PortLinkData -{ -public: - PortLinkData(void); - ~PortLinkData(void); - bool Set(void *data, size_t size); - char *buffer; - size_t buffersize; -}; - -PortLink::PortLink(port_id port) -{ - // For this class to be useful (and to prevent a lot of init problems) - // we require a port in the constructor - target=port; - - // We start out without any data attached to the port message - num_attachments=0; - opcode=0; - bufferlength=0; - replyport=create_port(30,"PortLink reply port"); -} - -PortLink::~PortLink(void) -{ - // If, for some odd reason, this is deleted with something attached, - // free the memory used by the attachments. We do not flush the queue - // because the port may no longer be valid in cases such as the app - // is in the process of quitting - MakeEmpty(); -} - -void PortLink::SetOpCode(int32 code) -{ - // Sets the message code. This does not change once the message is sent. - // Another call to SetOpCode() is required for such things. - opcode=code; -} - -void PortLink::SetPort(port_id port) -{ - // Sets the target port. While not necessary in most uses, this exists - // mostly to prevent flexibility problems - target=port; -} - -port_id PortLink::GetPort(void) -{ - // Simply returns the port at which the object is pointed. - return target; -} - -void PortLink::Flush(bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message off to the target, complete with attachments. NOTE: - // the recipient must delete all attachments, being the PortLink object assumes - // no responsiblity for the attachments once the message is sent. - int8 *msgbuffer; - int32 size; - - if(num_attachments>0) - { - FlattenData(&msgbuffer,&size); - - // Dump message to port, reset attachments, and clean up - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,msgbuffer,size,B_TIMEOUT, timeout); - else - write_port(target,opcode,msgbuffer,size); - MakeEmpty(); - } - else - { - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,NULL,0,B_TIMEOUT, timeout); - else - write_port(target,opcode,NULL,0); - } -} - -int8* PortLink::FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message to the target and then waits for a reply. The target will - // receive a message with the first item being the port_id to reply to. - // NOTE: like Flush(), any attached data must be deleted. - - // Effectively, an Attach() call inlined for changes - - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - { - *status=B_ERROR; - return NULL; - } - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&replyport,sizeof(port_id))) - { - bufferlength+=sizeof(port_id); - } - else - { - delete pld; - *status=B_ERROR; - return NULL; - } - - // Flatten() inlined to make some necessary changes - int8 *buffer=new int8[bufferlength]; - int8 *bufferindex=buffer; - size_t size=0; - - // attach our port_id first - memcpy(bufferindex, pld->buffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - - // attach everything else - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - } - - // Flush the thing....FOOSH! :P - write_port(target,opcode,buffer,size); - MakeEmpty(); - delete buffer; - - // Now we wait for the reply - if(timeout==B_INFINITE_TIMEOUT) - { - *buffersize=port_buffer_size(replyport); - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - else - { - *buffersize=port_buffer_size_etc(replyport,0,timeout); - if(*buffersize==B_TIMED_OUT) - { - *status=*buffersize; - return NULL; - } - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - - // We got this far, so we apparently have some data - *status=B_OK; - return buffer; -} - -void PortLink::Attach(void *data, size_t size) -{ - // This is the member called to attach data to a message. Attachments are - // treated to be in 'Append' mode, tacking on each attached piece of data - // to the end of the list. - - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - if(size==0) - return; - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -// These functions were added for a major convenience in passing common types -// Eventually, I'd like to templatize these, but for now, this'll do - -void PortLink::Attach(int32 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int32); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int16 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int16); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int8 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int8); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(float data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(float); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(bool data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(bool); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BRect data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BRect); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BPoint data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BPoint); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::FlattenData(int8 **buffer,int32 *size) -{ - // This function is where all the magic happens, but it is strictly internal. - // It iterates through each PortLinkData object and copies it to the main buffer - // which ends up, ultimately, being written to the PortLink's target port. - - // skip if there aree no attachments - if(bufferlength<1) - return; - - *buffer=new int8[bufferlength]; - int8 *bufferindex=*buffer; - PortLinkData *pld; - *size=0; - - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - *size+=pld->buffersize; - } -} - -void PortLink::MakeEmpty(void) -{ - // Nukes all the attachments currently held by the PortLink class - if(num_attachments!=0) - { - for(int i=0; i0) - free(buffer); -} - -bool PortLinkData::Set(void *data, size_t size) -{ - // Function copies the passed to the internal buffers for storage - if(size>0 && buffersize==0 && data!=NULL) - { - buffer=(char *)malloc(size); - if(buffer==NULL) - return false; - memcpy(buffer, data, size); - buffersize=size; - return true; - } - return false; -} diff --git a/src/servers/app/proto2/PortLink.h b/src/servers/app/proto2/PortLink.h deleted file mode 100644 index 9f5432daab..0000000000 --- a/src/servers/app/proto2/PortLink.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _PORTLINK_H_ -#define _PORTLINK_H_ - -#include -#include -#include -#include - -#ifndef _PORTLINK_BUFFERSIZE -#define _PORTLINK_MAX_ATTACHMENTS 50 -#endif - -class PortLinkData; - -class PortLink -{ -public: - PortLink(port_id port); - ~PortLink(void); - void SetOpCode(int32 code); - void SetPort(port_id port); - port_id GetPort(void); - void Flush(bigtime_t timeout=B_INFINITE_TIMEOUT); - int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, - bigtime_t timeout=B_INFINITE_TIMEOUT); - void Attach(void *data, size_t size); - void Attach(int32 data); - void Attach(int16 data); - void Attach(int8 data); - void Attach(float data); - void Attach(bool data); - void Attach(BRect data); - void Attach(BPoint data); - void MakeEmpty(void); -protected: - void FlattenData(int8 **buffer,int32 *size); - port_id target, replyport; - int32 opcode, bufferlength; - int num_attachments; - PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS]; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto2/README b/src/servers/app/proto2/README deleted file mode 100644 index b9aaf0d60e..0000000000 --- a/src/servers/app/proto2/README +++ /dev/null @@ -1,31 +0,0 @@ -Prototype 2: Messaging - -This is the second proof-of-concept prototype for the OpenBeOS app_server. This demonstrates the use of the PortLink class to send messages quickly and how the server manages processes under normal circumstances (ie, not killing a team). Listed at the end of this file is the sequence of events for a particular task, utilizing only 3 types of components: the Server class, ServerApp application-monitoring nodes, and the application itself. All 3 have been built for R5. Although not formally documented, the code is relatively clean and mostly commented. - -Files Included - -OBAppServer: the actual server -OBApp: a skeleton of what's supposed to be an app. Implemented only for testing purposes but some concepts may eventually make their way into the real OBOS BApplication class -OBHey: Quick-and-dirty app which sends a message code (in decimal) to a specified port. For the sake of reference, B_QUIT_REQUESTED=1599165009. - -Application launch: -1) App constructor -2) App->server CREATE_APP -3) Server spawns ServerApp -4) ServerApp->App SET_PORT -5) App reinitializes serverlink to SET_PORT port - -Application quit (from app side): -1) ->App B_QUIT_REQUESTED -2) App -> ServerApp B_QUIT_REQUESTED and quits -3) ServerApp -> Server DELETE_APP and quits -4) Server removes ServerApp from list and deletes object - -App Server quit: -1) Right now: Server->all ServerApps (QUIT_APP) - Eventually: Server->Registrar(BROADCAST_QUIT) -1a) Right now: ServerApps->Apps(B_QUIT_REQUESTED) -2) Server sets internal flag quitting_server to true -3) When server receives DELETE_APP, checks to see if any ServerApps are left. -4) If no ServerApps are left after deleting the sender of the delete_app message, server checks to see if quitting_server is set to true -5) Server exits \ No newline at end of file diff --git a/src/servers/app/proto2/ServerApp.cpp b/src/servers/app/proto2/ServerApp.cpp deleted file mode 100644 index e549cf4801..0000000000 --- a/src/servers/app/proto2/ServerApp.cpp +++ /dev/null @@ -1,139 +0,0 @@ -#include -#include "ServerApp.h" -#include "ServerProtocol.h" -#include "PortLink.h" -#include -#include - -ServerApp::ServerApp(port_id msgport, char *signature) -{ - printf("New ServerApp %s for app at port %ld\n",signature,msgport); - - // need to copy the signature because the message buffer - // owns the copy which we are passed as a parameter. - if(signature) - { - app_sig=new char[strlen(signature)]; - sprintf(app_sig,signature); - } - else - { - app_sig=new char[strlen("Application")]; - sprintf(app_sig,"Application"); - } - - // sender is the monitored app's event port - sender=msgport; - applink=new PortLink(sender); - - // receiver is the port to which the app sends messages for the server - receiver=create_port(30,app_sig); - printf("ServerApp port for app %s is at %ld\n",app_sig,receiver); - if(receiver==B_NO_MORE_PORTS) - { - // uh-oh. We have a serious problem. Tell the app to quit - applink->SetOpCode(B_QUIT_REQUESTED); - applink->Flush(); - } - else - { - // Everything checks out, so tell the application - // where to send future messages - applink->SetOpCode(SET_SERVER_PORT); - applink->Attach(&receiver,sizeof(port_id)); - applink->Flush(); - } -} - -ServerApp::~ServerApp(void) -{ - printf("%s::~ServerApp()\n",app_sig); - delete app_sig; - delete applink; -} - -bool ServerApp::Run(void) -{ - monitor_thread=spawn_thread(MonitorApp,app_sig,B_NORMAL_PRIORITY,this); - if(monitor_thread==B_NO_MORE_THREADS || monitor_thread==B_NO_MEMORY) - return false; - resume_thread(monitor_thread); - return true; -} - -int32 ServerApp::MonitorApp(void *data) -{ - ServerApp *app=(ServerApp *)data; - app->Loop(); - exit_thread(0); - return 0; -} - -void ServerApp::Loop(void) -{ - printf("%s::MainLoop()\n",app_sig); - - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(receiver); - - if(buffersize>0) - { - // buffers are PortLink messages. Allocate necessary buffer and - // we'll cast it as a BMessage. - msgbuffer=new int8[buffersize]; - bytesread=read_port(receiver,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(receiver,&msgcode,NULL,0); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case B_QUIT_REQUESTED: - { - // We receive this message when the app we monitor quits - 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_sig); - break; - } - printf("ServerApp %s quitting\n",app_sig); - applink->SetPort(serverport); - applink->SetOpCode(DELETE_APP); - applink->Attach(&monitor_thread,sizeof(thread_id)); - applink->Flush(); - break; - } - case QUIT_APP: - { - printf("ServerApp asking %s to quit\n",app_sig); - applink->SetOpCode(B_QUIT_REQUESTED); - applink->Flush(); - break; - } - default: - printf("Server received unexpected code %ld\n",msgcode); - break; - } - - } - - if(buffersize>0) - delete msgbuffer; - - if(msgcode==B_QUIT_REQUESTED) - break; - } -} - -void ServerApp::DispatchMessage(BMessage *msg) -{ -} - diff --git a/src/servers/app/proto2/ServerApp.h b/src/servers/app/proto2/ServerApp.h deleted file mode 100644 index cf450ccc9c..0000000000 --- a/src/servers/app/proto2/ServerApp.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _SRVAPP_H_ -#define _SRVAPP_H_ - -#include -class BMessage; -class PortLink; - -class ServerApp -{ -public: - ServerApp(port_id msgport, char *signature); - ~ServerApp(void); - - bool Run(void); - static int32 MonitorApp(void *data); - void Loop(void); - void DispatchMessage(BMessage *msg); - - port_id sender,receiver; - char *app_sig; - thread_id monitor_thread; - PortLink *applink; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto2/ServerProtocol.h b/src/servers/app/proto2/ServerProtocol.h deleted file mode 100644 index 9cc7d7cf40..0000000000 --- a/src/servers/app/proto2/ServerProtocol.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _APPSERVER_PROTOCOL_ -#define _APPSERVER_PROTOCOL_ - -#define CREATE_APP 'drca' -#define DELETE_APP 'drda' - -#define SET_SERVER_PORT 'srsp' -#define QUIT_APP 'srqa' - -#define SERVER_PORT_NAME "OBappserver" - -#endif \ No newline at end of file diff --git a/src/servers/app/proto2/obhey/obhey.c b/src/servers/app/proto2/obhey/obhey.c deleted file mode 100644 index 8e6bfbd617..0000000000 --- a/src/servers/app/proto2/obhey/obhey.c +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include -#include -#include -/* - Sends a message to the OpenBeOS app_server's message port -*/ - -int main(int argc, char **argv) -{ - int32 msgcode; - - if(argc>2) - { - port_id serverport=atoi(argv[1]); - msgcode=atoi(argv[2]); - - write_port(serverport,msgcode,NULL,0); - printf("Sent %ld to port %ld\n",msgcode,serverport); - return 1; - } - - printf("obhey port \n"); - return 0; -} \ No newline at end of file diff --git a/src/servers/app/proto2/obtestapp/OBApp.cpp b/src/servers/app/proto2/obtestapp/OBApp.cpp deleted file mode 100644 index 7d22133a26..0000000000 --- a/src/servers/app/proto2/obtestapp/OBApp.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* - OBApp.cpp: App faker for OpenBeOS app_server prototype #2 -*/ - -#include -#include -#include -#include -#include -#include -#include "ServerProtocol.h" -#include "PortLink.h" - -class TestApp -{ -public: - TestApp(void); - virtual ~TestApp(void); - - void MainLoop(void); // Replaces BLooper message looping - - // Hmm... What's this do? ;^) - virtual void DispatchMessage(BMessage *msg, BHandler *handler); - virtual void MessageReceived(BMessage *msg); - bool Run(void); - - port_id messageport, serverport; - char *signature; - bool initialized; - PortLink *serverlink; -}; - - -TestApp::TestApp(void) -{ - printf("TestApp::TestApp()\n"); - initialized=true; - - // Receives messages from server and others - messageport=create_port(50,"msgport"); - if(messageport==B_BAD_VALUE || messageport==B_NO_MORE_PORTS) - { printf("TestApp: Couldn't create message port\n"); - initialized=false; - } - - // Find the port for the app_server - serverport=find_port("OBappserver"); - if(serverport==B_NAME_NOT_FOUND) - { printf("TestApp: Couldn't find server port\n"); - initialized=false; - - serverlink=new PortLink(create_port(50,"OBAppServer")); - } - else - { - serverlink=new PortLink(serverport); - } - -// signature=new char[255]; - signature=new char[strlen("application/x-vnd.wgp-OBTestApp")]; - sprintf(signature,"application/x-vnd.wgp-OBTestApp"); -} - -TestApp::~TestApp(void) -{ - printf("%s::~TestApp()\n",signature); - delete signature; - - if(initialized==true) - delete serverlink; -} - -void TestApp::MainLoop(void) -{ - printf("TestApp::MainLoop()\n"); - - // Notify server of app's existence -/* BMessage *createmsg=new BMessage(CREATE_APP); - createmsg->AddString("signature",signature); -// createmsg->AddInt32("PID",PID); - createmsg->AddInt32("messageport",messageport); - - printf("port id: %ld\n",messageport); - printf("signature: %s\n",signature); - - write_port(serverport,CREATE_APP,createmsg,sizeof(*createmsg)); -*/ - serverlink->SetOpCode(CREATE_APP); - serverlink->Attach(&messageport,sizeof(port_id)); -// serverlink.Attach(PID); - serverlink->Attach(signature,strlen(signature)); - serverlink->Flush(); - - int32 msgcode; - uint8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(messageport); - - if(buffersize>0) - { - // buffers are flattened messages. Allocate necessary buffer and - // we'll cast it as a BMessage. - msgbuffer=new uint8[buffersize]; - bytesread=read_port(messageport,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(messageport,&msgcode,NULL,0); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case B_QUIT_REQUESTED: - { - // Attached data: - // None - printf("%s: Quit requested\n",signature); - serverlink->SetOpCode(msgcode); - serverlink->Flush(); - break; - } - case SET_SERVER_PORT: - { - // Attached data: - // port_id - id of the port of the corresponding ServerApp - if(buffersize<1) - { - printf("%s: Set Server Port has no attached data\n",signature); - break; - } - printf("%s: Set Server Port to %ld\n",signature,*((port_id *)msgbuffer)); - serverport=*((port_id *)msgbuffer); - serverlink->SetPort(serverport); - break; - } - default: - printf("OBTestApp received unexpected code %ld\n",msgcode); - break; - } - - if(msgcode==B_QUIT_REQUESTED) - { - printf("Quitting %s\n",signature); - break; - } - } - - if(buffersize>0) - delete msgbuffer; - } -} - -void TestApp::DispatchMessage(BMessage *msg, BHandler *handler) -{ - printf("TestApp::DispatchMessage()\n"); -} - -void TestApp::MessageReceived(BMessage *msg) -{ - printf("TestApp::MessageReceived()\n"); -} - -bool TestApp::Run(void) -{ - printf("TestApp::Run()\n"); -// if(!initialized) -// return false; - - MainLoop(); - return true; -} - -int main(void) -{ - TestApp app; - app.Run(); -} \ No newline at end of file diff --git a/src/servers/app/proto2/obtestapp/PortLink.cpp b/src/servers/app/proto2/obtestapp/PortLink.cpp deleted file mode 100644 index 8fba724569..0000000000 --- a/src/servers/app/proto2/obtestapp/PortLink.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/* - PortLink.cpp: - A helper class for port-based messaging - ------------------------------------------------------------------------- -How it works: - The class utilizes a fixed-size array of PortLinkData object pointers. When -data is attached, a new PortLinkData object is allocated and a copy of the -passed data is created inside it. When the time comes for the message to be sent, -the data is pieced together into a flattened array and written to the port. ------------------------------------------------------------------------- -Data members: - -*attachments[] - fixed-size array of pointers used to hold the attached data -opcode - message value which is sent along with any data -target - port to which the message is sent when Flush() is called -replyport - port used with synchronous messaging - FlushWithReply() -bufferlength - total bytes taken up by attachments -num_attachments - internal variable which is used to track which "slot" - will be the next one to receive an attachment object -*/ - -#include "PortLink.h" -#include -#include -#include - -//#define PLDEBUG - -// Internal data storage class for holding attached data whilst it is waiting -// to be Flattened() and then Flushed(). There is no need for this to be called outside -// the PortLink class. -class PortLinkData -{ -public: - PortLinkData(void); - ~PortLinkData(void); - bool Set(void *data, size_t size); - char *buffer; - size_t buffersize; -}; - -PortLink::PortLink(port_id port) -{ - // For this class to be useful (and to prevent a lot of init problems) - // we require a port in the constructor - target=port; - - // We start out without any data attached to the port message - num_attachments=0; - opcode=0; - bufferlength=0; - replyport=create_port(30,"PortLink reply port"); -} - -PortLink::~PortLink(void) -{ - // If, for some odd reason, this is deleted with something attached, - // free the memory used by the attachments. We do not flush the queue - // because the port may no longer be valid in cases such as the app - // is in the process of quitting - MakeEmpty(); -} - -void PortLink::SetOpCode(int32 code) -{ - // Sets the message code. This does not change once the message is sent. - // Another call to SetOpCode() is required for such things. - opcode=code; -} - -void PortLink::SetPort(port_id port) -{ - // Sets the target port. While not necessary in most uses, this exists - // mostly to prevent flexibility problems - target=port; -} - -port_id PortLink::GetPort(void) -{ - // Simply returns the port at which the object is pointed. - return target; -} - -void PortLink::Flush(bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message off to the target, complete with attachments. NOTE: - // the recipient must delete all attachments, being the PortLink object assumes - // no responsiblity for the attachments once the message is sent. - int8 *msgbuffer; - int32 size; - - if(num_attachments>0) - { - FlattenData(&msgbuffer,&size); - - // Dump message to port, reset attachments, and clean up - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,msgbuffer,size,B_TIMEOUT, timeout); - else - write_port(target,opcode,msgbuffer,size); - MakeEmpty(); - } - else - { - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,NULL,0,B_TIMEOUT, timeout); - else - write_port(target,opcode,NULL,0); - } -} - -int8* PortLink::FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message to the target and then waits for a reply. The target will - // receive a message with the first item being the port_id to reply to. - // NOTE: like Flush(), any attached data must be deleted. - - // Effectively, an Attach() call inlined for changes - - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - { - *status=B_ERROR; - return NULL; - } - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&replyport,sizeof(port_id))) - { - bufferlength+=sizeof(port_id); - } - else - { - delete pld; - *status=B_ERROR; - return NULL; - } - - // Flatten() inlined to make some necessary changes - int8 *buffer=new int8[bufferlength]; - int8 *bufferindex=buffer; - size_t size=0; - - // attach our port_id first - memcpy(bufferindex, pld->buffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - - // attach everything else - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - } - - // Flush the thing....FOOSH! :P - write_port(target,opcode,buffer,size); - MakeEmpty(); - delete buffer; - - // Now we wait for the reply - if(timeout==B_INFINITE_TIMEOUT) - { - *buffersize=port_buffer_size(replyport); - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - else - { - *buffersize=port_buffer_size_etc(replyport,0,timeout); - if(*buffersize==B_TIMED_OUT) - { - *status=*buffersize; - return NULL; - } - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - - // We got this far, so we apparently have some data - *status=B_OK; - return buffer; -} - -void PortLink::Attach(void *data, size_t size) -{ - // This is the member called to attach data to a message. Attachments are - // treated to be in 'Append' mode, tacking on each attached piece of data - // to the end of the list. - - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - if(size==0) - return; - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -// These functions were added for a major convenience in passing common types -// Eventually, I'd like to templatize these, but for now, this'll do - -void PortLink::Attach(int32 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int32); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int16 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int16); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int8 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int8); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(float data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(float); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(bool data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(bool); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BRect data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BRect); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BPoint data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BPoint); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::FlattenData(int8 **buffer,int32 *size) -{ - // This function is where all the magic happens, but it is strictly internal. - // It iterates through each PortLinkData object and copies it to the main buffer - // which ends up, ultimately, being written to the PortLink's target port. - - // skip if there aree no attachments - if(bufferlength<1) - return; - - *buffer=new int8[bufferlength]; - int8 *bufferindex=*buffer; - PortLinkData *pld; - *size=0; - - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - *size+=pld->buffersize; - } -} - -void PortLink::MakeEmpty(void) -{ - // Nukes all the attachments currently held by the PortLink class - if(num_attachments!=0) - { - for(int i=0; i0) - free(buffer); -} - -bool PortLinkData::Set(void *data, size_t size) -{ - // Function copies the passed to the internal buffers for storage - if(size>0 && buffersize==0 && data!=NULL) - { - buffer=(char *)malloc(size); - if(buffer==NULL) - return false; - memcpy(buffer, data, size); - buffersize=size; - return true; - } - return false; -} diff --git a/src/servers/app/proto2/obtestapp/PortLink.h b/src/servers/app/proto2/obtestapp/PortLink.h deleted file mode 100644 index 9f5432daab..0000000000 --- a/src/servers/app/proto2/obtestapp/PortLink.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _PORTLINK_H_ -#define _PORTLINK_H_ - -#include -#include -#include -#include - -#ifndef _PORTLINK_BUFFERSIZE -#define _PORTLINK_MAX_ATTACHMENTS 50 -#endif - -class PortLinkData; - -class PortLink -{ -public: - PortLink(port_id port); - ~PortLink(void); - void SetOpCode(int32 code); - void SetPort(port_id port); - port_id GetPort(void); - void Flush(bigtime_t timeout=B_INFINITE_TIMEOUT); - int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, - bigtime_t timeout=B_INFINITE_TIMEOUT); - void Attach(void *data, size_t size); - void Attach(int32 data); - void Attach(int16 data); - void Attach(int8 data); - void Attach(float data); - void Attach(bool data); - void Attach(BRect data); - void Attach(BPoint data); - void MakeEmpty(void); -protected: - void FlattenData(int8 **buffer,int32 *size); - port_id target, replyport; - int32 opcode, bufferlength; - int num_attachments; - PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS]; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto2/obtestapp/ServerProtocol.h b/src/servers/app/proto2/obtestapp/ServerProtocol.h deleted file mode 100644 index 9cc7d7cf40..0000000000 --- a/src/servers/app/proto2/obtestapp/ServerProtocol.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _APPSERVER_PROTOCOL_ -#define _APPSERVER_PROTOCOL_ - -#define CREATE_APP 'drca' -#define DELETE_APP 'drda' - -#define SET_SERVER_PORT 'srsp' -#define QUIT_APP 'srqa' - -#define SERVER_PORT_NAME "OBappserver" - -#endif \ No newline at end of file diff --git a/src/servers/app/proto3/AppServer.cpp b/src/servers/app/proto3/AppServer.cpp deleted file mode 100644 index 8d1805eaa7..0000000000 --- a/src/servers/app/proto3/AppServer.cpp +++ /dev/null @@ -1,295 +0,0 @@ -#include -#include -#include "scheduler.h" -#include -#include "AppServer.h" -#include "ServerApp.h" -#include "Desktop.h" -#include "ServerProtocol.h" -#include "PortLink.h" -#include "DisplayDriver.h" - -AppServer::AppServer(void) : BApplication("application/x-vnd.obe-OBAppServer") -{ -// printf("AppServer()\n"); - - mouseport=create_port(30,SERVER_INPUT_PORT); - messageport=create_port(20,SERVER_PORT_NAME); -// printf("Server message port: %ld\n",messageport); -// printf("Server input port: %ld\n",mouseport); - applist=new BList(0); - quitting_server=false; - exit_poller=false; - - // Set up the Desktop - init_desktop(3); - - // Spawn our input-polling thread - poller_id = spawn_thread(PollerThread, "Poller", B_NORMAL_PRIORITY, this); - if (poller_id >= 0) - resume_thread(poller_id); - driver=get_gfxdriver(); -} - -AppServer::~AppServer(void) -{ - shutdown_desktop(); - - ServerApp *temp; - for(int32 i=0;iCountItems();i++) - { - temp=(ServerApp *)applist->ItemAt(i); - if(temp!=NULL) - delete temp; - } - delete applist; -} - -thread_id AppServer::Run(void) -{ - //printf("AppServer::Run()\n"); - - MainLoop(); - return 0; -} - -void AppServer::MainLoop(void) -{ - // Main loop (duh). Monitors the message queue and dispatches as appropriate. - // Input messages are handled by the poller, however. - - //printf("AppServer::MainLoop()\n"); - - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(messageport); - if(buffersize>0) - msgbuffer=new int8[buffersize]; - bytesread=read_port(messageport,&msgcode,msgbuffer,buffersize); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case CREATE_APP: - case DELETE_APP: - case B_QUIT_REQUESTED: - DispatchMessage(msgcode,msgbuffer); - break; - default: - //printf("Server received unexpected code %ld\n",msgcode); - break; - } - - } - - if(buffersize>0) - delete msgbuffer; - if(msgcode==DELETE_APP || msgcode==B_QUIT_REQUESTED) - { - 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); - -} - - -void AppServer::DispatchMessage(int32 code, int8 *buffer) -{ - int8 *index=buffer; - switch(code) - { - case CREATE_APP: - { - // Create the ServerApp to node monitor a new BApplication - - //printf("AppServer: Create App\n"); - - // Attached data: - // 1) port_id - receiver port of a regular app - // 2) char * - signature of the regular app - - // Find the necessary data - port_id app_port=*((port_id*)index); - index+=sizeof(port_id); - - char *app_signature=(char *)index; - - // Create the ServerApp subthread for this app - ServerApp *newapp=new ServerApp(app_port,app_signature); - applist->AddItem(newapp); - newapp->Run(); - break; - } - case DELETE_APP: - { - // Delete a ServerApp. Received only from the respective ServerApp when a - // BApplication asks it to quit. - - //printf("AppServer: Delete App\n"); - - // Attached Data: - // 1) thread_id - thread ID of the ServerApp to be deleted - - int32 i, appnum=applist->CountItems(); - ServerApp *srvapp; - thread_id srvapp_id=*((thread_id*)buffer); - - // Run through the list of apps and nuke the proper one - for(i=0;iItemAt(i); - if(srvapp!=NULL && srvapp->monitor_thread==srvapp_id) - { - srvapp=(ServerApp *)applist->RemoveItem(i); - delete srvapp; - } - } - break; - } - case B_QUIT_REQUESTED: - { - //printf("Shutdown sequence initiated.\n"); - - // Attached Data: - // none - - // 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. - PortLink *applink=new PortLink(0); - ServerApp *srvapp; - int32 i,appnum=applist->CountItems(); - - applink->SetOpCode(QUIT_APP); - for(i=0;iItemAt(i); - if(srvapp!=NULL) - { - applink->SetPort(srvapp->receiver); - applink->Flush(); - } - } - - delete applink; - // So when we delete the last ServerApp, we can exit the server - quitting_server=true; - exit_poller=true; - break; - } - default: - //printf("Unexpected message %ld (%lx) in AppServer::DispatchMessage()\n",code,code); - break; - } -} - -void AppServer::Poller(void) -{ - // This thread handles nothing but input messages for mouse and keyboard - int32 msgcode; - int8 *msgbuffer=NULL,*index; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(mouseport); - if(buffersize>0) - msgbuffer=new int8[buffersize]; - bytesread=read_port(mouseport,&msgcode,msgbuffer,buffersize); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case B_MOUSE_DOWN: - { - //printf("AppServer: Mouse Down\n"); - - // 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 during click - // 5) int32 - buttons down - // 6) int32 - number of clicks - 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 - - index=msgbuffer; - - // Throw away the time sent - for now - index += sizeof(int64); - - float tempx=0,tempy=0; - tempx=*((float*)index); - index+=sizeof(float); - tempy=*((float*)index); - index+=sizeof(float); - - driver->MoveCursorTo((int)tempx,(int)tempy); - break; - } - case B_MOUSE_UP: - { - //printf("AppServer: Mouse Up\n"); - - // 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; - } - default: - //printf("Server::Poller received unexpected code %ld\n",msgcode); - break; - } - - } - - if(buffersize>0) - delete msgbuffer; - - if(exit_poller) - break; - } -} - -int32 AppServer::PollerThread(void *data) -{ - //printf("Starting Poller thread...\n"); - AppServer *server=(AppServer *)data; - - server->Poller(); // This won't return until it's told to - - //printf("Exiting Poller thread...\n"); - exit_thread(B_OK); - return B_OK; -} - -int main( int argc, char** argv ) -{ - AppServer *obas = new AppServer(); - obas->Run(); - delete obas; - return 0; -} - - \ No newline at end of file diff --git a/src/servers/app/proto3/AppServer.h b/src/servers/app/proto3/AppServer.h deleted file mode 100644 index 4214ecdfc8..0000000000 --- a/src/servers/app/proto3/AppServer.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _OPENBEOS_APP_SERVER_H_ -#define _OPENBEOS_APP_SERVER_H_ - -#include -#include -#include - -class BMessage; -class ServerApp; -class DisplayDriver; - -class AppServer : public BApplication -{ -public: - AppServer(void); - ~AppServer(void); - thread_id Run(void); - void MainLoop(void); - port_id messageport,mouseport; - void Poller(void); - -private: - void DispatchMessage(int32 code, int8 *buffer); - static int32 PollerThread(void *data); - - bool quitting_server; - BList *applist; - thread_id poller_id; - bool exit_poller; - DisplayDriver *driver; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto3/DebugTools.cpp b/src/servers/app/proto3/DebugTools.cpp deleted file mode 100644 index 6e728d02c4..0000000000 --- a/src/servers/app/proto3/DebugTools.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include -#include -#include "DebugTools.h" - -void PrintStatusToStream(status_t value) -{ - // Function which simply translates a returned status code into a string - // and dumps it to stdout - BString outstr; - switch(value) - { - case B_OK: - outstr="B_OK "; - break; - case B_NAME_NOT_FOUND: - outstr="B_NAME_NOT_FOUND "; - break; - case B_BAD_VALUE: - outstr="B_BAD_VALUE "; - break; - case B_ERROR: - outstr="B_ERROR "; - break; - case B_TIMED_OUT: - outstr="B_TIMED_OUT "; - break; - case B_NO_MORE_PORTS: - outstr="B_NO_MORE_PORTS "; - break; - case B_WOULD_BLOCK: - outstr="B_WOULD_BLOCK "; - break; - case B_BAD_PORT_ID: - outstr="B_BAD_PORT_ID "; - break; - case B_BAD_TEAM_ID: - outstr="B_BAD_TEAM_ID "; - break; - default: - outstr="undefined status value in debugtools::PrintStatusToStream() "; - break; - } - cout << "Status: " << outstr.String(); -} diff --git a/src/servers/app/proto3/DebugTools.h b/src/servers/app/proto3/DebugTools.h deleted file mode 100644 index 8d3b01740b..0000000000 --- a/src/servers/app/proto3/DebugTools.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _DEBUGTOOLS_H_ -#define _DEBUGTOOLS_H_ - -#include - -void PrintStatusToStream(status_t value); - -#endif \ No newline at end of file diff --git a/src/servers/app/proto3/Desktop.cpp b/src/servers/app/proto3/Desktop.cpp deleted file mode 100644 index 8111068006..0000000000 --- a/src/servers/app/proto3/Desktop.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/* - Desktop.cpp: - Code necessary to handle the Desktop, defined as the collection of workspaces. -*/ -#include -#include -#include -#include -#include -#include "DisplayDriver.h" -#include "ViewDriver.h" -#include "Desktop.h" - -class ServerWindow; -class ServerBitmap; -class ServerLayer; -class Workspace; - -//--------------------GLOBALS------------------------- -int32 workspace_count, active_workspace; -BList desktop; -Workspace *pactive_workspace; -color_map system_palette; -ViewDriver *gfxdriver; -//---------------------------------------------------- - - -//-------------------INTERNAL CLASS DEFS-------------- -class Workspace -{ -public: - Workspace(void); - Workspace(BPath imagepath); - ~Workspace(); - - BList layerlist; - BList focuslist; - rgb_color bgcolor; - screen_info screendata, - olddata; -}; - -DisplayDriver *get_gfxdriver(void) -{ - return gfxdriver; -} - -Workspace::Workspace(void) -{ - workspace_count++; - - // default values - layerlist.MakeEmpty(); - focuslist.MakeEmpty(); - bgcolor.red=51; - bgcolor.green=102; - bgcolor.blue=160; - screendata.mode=B_CMAP8; - screendata.spaces=B_8_BIT_640x480; - screendata.refresh_rate=60.0; - screendata.min_refresh_rate=60.0; - screendata.max_refresh_rate=60.0; - screendata.h_position=(uchar)50; - screendata.v_position=(uchar)50; - screendata.h_size=(uchar)50; - screendata.v_size=(uchar)50; - olddata=screendata; -} - -Workspace::~Workspace(void) -{ - workspace_count--; -} -//--------------------------------------------------- - - -//-----------------GLOBAL FUNCTION DEFS--------------- - -void init_desktop(int8 workspaces) -{ - workspace_count=workspaces; - if(workspace_count==0) - workspace_count++; - - // Instantiate and initialize display driver - gfxdriver=new ViewDriver(); - gfxdriver->Initialize(); - if(gfxdriver->IsInitialized()) - printf("Driver initialized\n"); - else - printf("Driver NOT initialized\n"); - - // Create the workspaces we're supposed to have - for(int8 i=0; iSetScreen(pactive_workspace->screendata.spaces); - - // Clear the screen - gfxdriver->Clear(80,85,152); - - // Draw a couple primitives just so we can see something - rgb_color color; - color.red=255; - color.green=0; - color.blue=0; - color.alpha=255; - gfxdriver->FillRect(BRect(10,10,50,50),color); - color.green=255; - gfxdriver->FillEllipse(BRect(50,10,100,50),color); -} - -void shutdown_desktop(void) -{ - int32 i,count=desktop.CountItems(); - for(i=0;iShutdown(); - delete gfxdriver; -} - -int32 count_workspaces(void) -{ - return workspace_count; -} - -void set_workspace_count(int32 count) -{ - //printf("set_workspace_count(%ld)\n",count); - if(count<0) - return; - - if(countworkspace_count || workspace<0) - return; - - Workspace *proposed=(Workspace *)desktop.ItemAt(workspace); - - if(proposed==NULL) - return; - - if(pactive_workspace->screendata.spaces != proposed->screendata.spaces) - { - gfxdriver->SetScreen(proposed->screendata.spaces); - } - -} - -const color_map *system_colors(void) -{ - return (const color_map *)&system_palette; -} - -status_t set_screen_space(int32 index, uint32 res, bool stick = true) -{ - //printf("set_screen_space(%ld,%lu, %s)\n",index,res,(stick==true)?"true":"false"); - return B_ERROR; -} - -status_t get_scroll_bar_info(scroll_bar_info *info) -{ - return B_ERROR; -} - -status_t set_scroll_bar_info(scroll_bar_info *info) -{ - //printf("set_scroll_bar_info()\n"); - return B_ERROR; -} - -bigtime_t idle_time() -{ - return 0; -} - -void run_select_printer_panel() -{ -} - -void run_add_printer_panel() -{ -} - -void run_be_about() -{ -} - -void set_focus_follows_mouse(bool follow) -{ - //printf("set_focus_follows_mouse(%s)\n",(follow==true)?"true":"false"); -} - -bool focus_follows_mouse() -{ - return false; -} diff --git a/src/servers/app/proto3/Desktop.h b/src/servers/app/proto3/Desktop.h deleted file mode 100644 index 89cf4d2bff..0000000000 --- a/src/servers/app/proto3/Desktop.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _OBDESKTOP_H_ -#define _OBDESKTOP_H_ - -#include -#include -class DisplayDriver; - -void init_desktop(int8 workspaces); -void shutdown_desktop(void); -DisplayDriver *get_gfxdriver(void); - -typedef struct -{ - color_space mode; - BRect frame; - uint32 spaces; - float min_refresh_rate; - float max_refresh_rate; - float refresh_rate; - uchar h_position; - uchar v_position; - uchar h_size; - uchar v_size; -} screen_info; - - -#endif \ No newline at end of file diff --git a/src/servers/app/proto3/DirectDriver.cpp b/src/servers/app/proto3/DirectDriver.cpp deleted file mode 100644 index b451ae9b2e..0000000000 --- a/src/servers/app/proto3/DirectDriver.cpp +++ /dev/null @@ -1,251 +0,0 @@ -#include -#include "DirectDriver.h" -#include - -#ifndef ABS - #define ABS(a) (a<0)?a*-1:a -#endif - -OBAppServerScreen::OBAppServerScreen(status_t *error) - : BDirectWindow(BRect(100,60,740,540),"OBOS App Server, P3",B_TITLED_WINDOW, - B_NOT_RESIZABLE | B_NOT_ZOOMABLE) -{ - redraw=true; -} - -OBAppServerScreen::~OBAppServerScreen(void) -{ -} - -void OBAppServerScreen::MessageReceived(BMessage *msg) -{ - msg->PrintToStream(); - switch(msg->what) - { - case B_KEY_DOWN: -// Disconnect(); - QuitRequested(); - break; - default: - BDirectWindow::MessageReceived(msg); - break; - } -} - -bool OBAppServerScreen::QuitRequested(void) -{ - redraw=false; - be_app->PostMessage(B_QUIT_REQUESTED); - return true; -} - -int32 OBAppServerScreen::Draw(void *data) -{ - OBAppServerScreen *screen=(OBAppServerScreen *)data; - for(;;) - { - if(screen->connected && screen->redraw) - { - // Draw a sample background - screen->redraw=false; - } - } - return 1; -} - -void OBAppServerScreen::DirectConnected(direct_buffer_info *dbinfo) -{ -/* if(ok==true) - { - connected=true; - gcinfo=CardInfo(); - for(int8 i=0;i<48;i++) - gchooks[i]=CardHookAt(i); - } - else - connected=false; -*/ -} - -DirectDriver::DirectDriver(void) -{ -// printf("DirectDriver()\n"); -// old_space=B_32_BIT_800x600; -} - -DirectDriver::~DirectDriver(void) -{ - printf("~DirectDriver()\n"); - winscreen->Lock(); - winscreen->Close(); -} - -void DirectDriver::Initialize(void) -{ -/* printf("DirectDriver::Initialize()\n"); - status_t stat; - winscreen=new OBAppServerScreen(&stat); - if(stat==B_OK) - winscreen->Show(); - else - delete winscreen; -*/ -} - -void DirectDriver::SafeMode(void) -{ -/* printf("DirectDriver::SafeMode()\n"); -// SetScreen(B_8_BIT_640x480); - SetScreen(B_32_BIT_800x600); - Reset(); -*/ -} - -void DirectDriver::Reset(void) -{ -/* printf("DirectDriver::Reset()\n"); - if(winscreen->connected==true) - Clear(51,102,160); -*/ -} - -void DirectDriver::SetScreen(uint32 space) -{ -// printf("DirectDriver::SetScreen(%lu)\n",space); -// winscreen->SetSpace(space); -} - -void DirectDriver::Clear(uint8 red, uint8 green, uint8 blue) -{ -/* // This simply clears the entire screen, utilizing a string and - // memcpy to speed things up in a minor way - printf("DirectDriver::Clear(%d,%d,%d)\n",red,green,blue); - - if(winscreen->connected==false) - return; - - int i,imax, - length=winscreen->gcinfo->bytes_per_row; - int8 fillstring[length]; - - - switch(winscreen->gcinfo->bits_per_pixel) - { - case 32: - { - int32 color,*index32; - - // order is going to be BGRA or ARGB - if(winscreen->gcinfo->rgba_order[0]=='B') - { - // Create the number to quickly create the string - - // BBGG RRAA in RAM => 0xRRAA BBGG - color= (int32(red) << 24) + 0xFF0000L + (int32(blue) << 8) + green; - } - else - { - // Create the number to quickly create the string - - // AARR GGBB in RAM - color= 0xFF000000L + (int32(red) << 16) + (int32(green) << 8) + blue; - } - - // fill the string with the appropriate values - index32=(int32 *)fillstring; - imax=winscreen->gcinfo->width; - - for(i=0;igcinfo->rgba_order[0]=='B') - { - // Little-endian - // G[2:0],B[4:0] R[4:0],G[5:3] - - // Ick. Gotta love all that shifting and masking. :( - color= (int16((green & 7)) << 13) + - (int16((blue & 31)) << 8) + - (int16((red & 31)) << 4) + - (int16(green & 56)); - } - else - { - // Big-endian - // R[4:0],G[5:3] G[2:0],B[4:0] - color= (int16(red & 31) << 11) + - (int16(green & 56) << 8) + - (int16(green & 3) << 5) + - (blue & 31); - } - break; - } - case 15: - { - - // RGBA_15: - // G[2:0],B[4:0] A[0],R[4:0],G[4:3] - - // RGBA_15_BIG: - // A[0],R[4:0],G[4:3] G[2:0],B[4:0] - break; - } -*/ -/* case 8: - { - // This is both the easiest and hardest: - // We fill using memset(), but we have to find the closest match to the - // color we've been given. Yuck. - - // Find the closest match by comparing the differences in values for each - // color. This function was not intended to be called rapidly, so speed is - // not much of an issue at this point. - int8 closest=0; - int16 closest_delta=765, delta; // (255 * 3) - - // Get the current palette - rgb_color *list=winscreen->ColorList(); - for(i=0;i<256;i++) - { - delta=ABS(list->red-red)+ABS(list->green-green)+ABS(list->blue-blue); - if(deltagcinfo->frame_buffer,closest, - winscreen->gcinfo->bytes_per_row * winscreen->gcinfo->height); - - // Nothing left to do! - return; - break; - } - default: - { - printf("Unsupported bit depth %d in DirectDriver::Clear(r,g,b)!!\n",winscreen->gcinfo->bits_per_pixel); - return; - } - } - imax=winscreen->gcinfo->height; - - // a pointer to increment for the screen copy. Faster than doing a multiply - // each iteration - int8 *pbuffer=(int8*)winscreen->gcinfo->frame_buffer; - for(i=0;i -#include -#include -#include -#include "DisplayDriver.h" - -class OBAppServerScreen : public BDirectWindow -{ -public: - OBAppServerScreen(status_t *error); - ~OBAppServerScreen(void); - virtual void MessageReceived(BMessage *msg); - virtual bool QuitRequested(void); - static int32 Draw(void *data); - virtual void DirectConnected(direct_buffer_info *dbinfo); - - int32 DrawID; - bool redraw,connected; - graphics_card_info *gcinfo; - graphics_card_hook *gchooks; -}; - -class DirectDriver : public DisplayDriver -{ -public: - DirectDriver(void); - virtual ~DirectDriver(void); - - virtual void Initialize(void); // Sets the driver - virtual void SafeMode(void); // Easy-access functions for common tasks - virtual void Reset(void); - virtual void SetScreen(uint32 space); - virtual void Clear(uint8 red,uint8 green,uint8 blue); -// virtual void SetPixel(int x, int y, rgb_color color); -// virtual void StrokeEllipse(BRect rect, rgb_color color); - OBAppServerScreen *winscreen; - -protected: - // Original screen info - uint32 old_space; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto3/DisplayDriver.cpp b/src/servers/app/proto3/DisplayDriver.cpp deleted file mode 100644 index 671d64ef97..0000000000 --- a/src/servers/app/proto3/DisplayDriver.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* - DisplayDriver.cpp - Modular class to allow the server to not care what the ultimate output is - for graphics calls. -*/ -#include "DisplayDriver.h" -#include "ServerCursor.h" - -DisplayDriver::DisplayDriver(void) -{ - is_initialized=false; - cursor_visible=false; - show_on_move=false; - locker=new BLocker(); -} - -DisplayDriver::~DisplayDriver(void) -{ - delete locker; -} - -void DisplayDriver::Initialize(void) -{ // Loading loop to find proper driver or other setup for the driver -} - -void DisplayDriver::Shutdown(void) -{ // For use by subclasses -} - -bool DisplayDriver::IsInitialized(void) -{ // Let us know whether things worked out ok - return is_initialized; -} - -void DisplayDriver::SafeMode(void) -{ // Set video mode to 640x480x256 mode -} - -void DisplayDriver::Reset(void) -{ // Intended to reload and restart driver. Defaults to a safe mode -} - -void DisplayDriver::SetScreen(uint32 space) -{ // Set the screen to a particular mode -} - -int32 DisplayDriver::GetHeight(void) -{ // Gets the height of the current mode - return ginfo->height; -} - -int32 DisplayDriver::GetWidth(void) -{ // Gets the width of the current mode - return ginfo->width; -} - -int DisplayDriver::GetDepth(void) -{ // Gets the color depth of the current mode - return ginfo->bytes_per_row; -} - -void DisplayDriver::Clear(uint8 red,uint8 green,uint8 blue) -{ -} - -void DisplayDriver::StrokeRect(BRect rect, rgb_color color) -{ -} - -void DisplayDriver::FillRect(BRect rect, rgb_color color) -{ -} - -void DisplayDriver::StrokeEllipse(BRect rect, rgb_color color) -{ -} - -void DisplayDriver::FillEllipse(BRect rect,rgb_color color) -{ -} - -void DisplayDriver::SetPixel(int x, int y, rgb_color color) -{ // Internal function utilized by other functions to draw to the buffer - // Will eventually be an inline function -} - -void DisplayDriver::SetCursor(ServerCursor *cursor) -{ -} - -void DisplayDriver::SetCursor(int32 value) -{ // This is used just to provide an easy way of setting one of the default cursors - // Then again, I may just get rid of this thing. -} - -void DisplayDriver::ShowCursor(void) -{ -} - -void DisplayDriver::HideCursor(void) -{ -} - -void DisplayDriver::ObscureCursor(void) -{ // Hides cursor until mouse is moved -} - -bool DisplayDriver::IsCursorHidden(void) -{ - return false; -} - -void DisplayDriver::MoveCursorTo(int x, int y) -{ -} - -void DisplayDriver::Blit(BPoint dest, ServerBitmap *sourcebmp, ServerBitmap *destbmp) -{ // Screen-to-screen bitmap copying -} - -void DisplayDriver::DrawBitmap(ServerBitmap *bitmap) -{ -} - -void DisplayDriver::DrawChar(char c, int x, int y) -{ -} - -void DisplayDriver::DrawString(char *string, int length, int x, int y) -{ -} - -void DisplayDriver::StrokeArc(int centerx, int centery, int xradius, int yradius) -{ -} - -void DisplayDriver::FillArc(int centerx, int centery, int xradius, int yradius) -{ -} - -void DisplayDriver::StrokePolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void DisplayDriver::FillPolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void DisplayDriver::StrokeRegion(ServerRegion *region) -{ -} - -void DisplayDriver::FillRegion(ServerRegion *region) -{ -} - -void DisplayDriver::StrokeRoundRect(ServerRect *rect) -{ -} - -void DisplayDriver::FillRoundRect(ServerRect *rect) -{ -} - -void DisplayDriver::StrokeShape(ServerShape *shape) -{ -} - -void DisplayDriver::FillShape(ServerShape *shape) -{ -} - -void DisplayDriver::StrokeTriangle(int *x, int *y) -{ -} - -void DisplayDriver::FillTriangle(int *x, int *y) -{ -} - -void DisplayDriver::MoveTo(int x, int y) -{ // Moves the graphics pen to this position -} diff --git a/src/servers/app/proto3/DisplayDriver.h b/src/servers/app/proto3/DisplayDriver.h deleted file mode 100644 index 1d1c0b9a11..0000000000 --- a/src/servers/app/proto3/DisplayDriver.h +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef _GFX_DRIVER_H_ -#define _GFX_DRIVER_H_ - -#include -#include -#include -#include "Desktop.h" - -class ServerBitmap; -class ServerRegion; -class ServerShape; -class ServerRect; -class ServerCursor; - -#ifndef ROUND - #define ROUND(a) ( (a-long(a))>=.5)?(long(a)+1):(long(a)) -#endif - -typedef struct -{ - uchar *xormask, *andmask; - int32 width, height; - int32 hotx, hoty; - -} cursor_data; - -#ifndef HOOK_DEFINE_CURSOR - -#define HOOK_DEFINE_CURSOR 0 -#define HOOK_MOVE_CURSOR 1 -#define HOOK_SHOW_CURSOR 2 -#define HOOK_DRAW_LINE_8BIT 3 -#define HOOK_DRAW_LINE_16BIT 12 -#define HOOK_DRAW_LINE_32BIT 4 -#define HOOK_DRAW_RECT_8BIT 5 -#define HOOK_DRAW_RECT_16BIT 13 -#define HOOK_DRAW_RECT_32BIT 6 -#define HOOK_BLIT 7 -#define HOOK_DRAW_ARRAY_8BIT 8 -#define HOOK_DRAW_ARRAY_16BIT 14 // Not implemented in current R5 drivers -#define HOOK_DRAW_ARRAY_32BIT 9 -#define HOOK_SYNC 10 -#define HOOK_INVERT_RECT 11 - -#endif - -class ServerCursor; - -class DisplayDriver -{ -public: - DisplayDriver(void); - virtual ~DisplayDriver(void); - - virtual void Initialize(void); // Sets the driver - virtual void Shutdown(void); // You never know when you'll need this - - virtual void SafeMode(void); // Easy-access functions for common tasks - virtual void Reset(void); - virtual void Clear(uint8 red,uint8 green,uint8 blue); - - // Settings functions - virtual void SetScreen(uint32 space); - virtual int32 GetHeight(void); - virtual int32 GetWidth(void); - virtual int GetDepth(void); - - // Drawing functions - virtual void SetPixel(int x, int y, rgb_color color); - virtual void DrawBitmap(ServerBitmap *bitmap); - virtual void DrawChar(char c, int x, int y); - virtual void DrawString(char *string, int length, int x, int y); - virtual void StrokeRect(BRect rect,rgb_color color); - virtual void FillRect(BRect rect, rgb_color color); - virtual void StrokeEllipse(BRect rect,rgb_color color); - virtual void FillEllipse(BRect rect,rgb_color color); - virtual void StrokeArc(int centerx, int centery, int xradius, int yradius); - virtual void FillArc(int centerx, int centery, int xradius, int yradius); - virtual void StrokePolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void FillPolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void StrokeRegion(ServerRegion *region); - virtual void FillRegion(ServerRegion *region); - virtual void StrokeRoundRect(ServerRect *rect); - virtual void FillRoundRect(ServerRect *rect); - virtual void StrokeShape(ServerShape *shape); - virtual void FillShape(ServerShape *shape); - virtual void StrokeTriangle(int *x, int *y); - virtual void FillTriangle(int *x, int *y); - virtual void MoveTo(int x, int y); - virtual void Blit(BPoint dest, ServerBitmap *src, ServerBitmap *dest); - - virtual void SetCursor(int32 value); - virtual void SetCursor(ServerCursor *cursor); - virtual void ShowCursor(void); - virtual void MoveCursorTo(int x, int y); - virtual void HideCursor(void); - virtual void ObscureCursor(void); - virtual bool IsCursorHidden(void); - - - virtual bool IsInitialized(void); - graphics_card_hook ghooks[48]; - graphics_card_info *ginfo; - -protected: - bool is_initialized, cursor_visible, show_on_move; - ServerCursor *current_cursor; - BLocker *locker; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto3/Globals.h b/src/servers/app/proto3/Globals.h deleted file mode 100644 index 2753cad1aa..0000000000 --- a/src/servers/app/proto3/Globals.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _SERVER_GLOBALS_H_ -#define _SERVER_GLOBALS_H_ - -#include -BList *gBitmaplist, *gLayerlist; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto3/Layer.cpp b/src/servers/app/proto3/Layer.cpp deleted file mode 100644 index 4130a02e2e..0000000000 --- a/src/servers/app/proto3/Layer.cpp +++ /dev/null @@ -1,74 +0,0 @@ -#include "Layer.h" - -Layer::Layer(ServerWindow *Win, const char *Name, BRect &Frame, int32 Flags) -{ -} - -Layer::Layer(ServerBitmap *Bitmap) -{ -} - -Layer::~Layer(void) -{ -} - -void Layer::Initialize(void) -{ -} - -void Layer::Show(void) -{ -} - -void Layer::Hide(void) -{ -} - -bool Layer::IsVisible(void) -{ - return false; -} - -void Layer::Update(bool ForceUpdate) -{ -} - -bool Layer::IsBackground(void) -{ - return false; -} - -void Layer::SetFrame(const BRect &Rect) -{ -} - -BRect Layer::Frame(void) -{ - return BRect(0,0,0,0); -} - -BRect Layer::Bounds(void) -{ - return BRect(0,0,0,0); -} - -void Layer::Invalidate(const BRect &Rect) -{ -} - -void Layer::AddRegion(BRegion *Region) -{ -} - -void Layer::RemoveRegions(void) -{ -} - -void Layer::UpdateRegions(bool ForceUpdate=true, bool Root=true) -{ -} - -void Layer::Draw(const BRect &Rect) -{ -} - diff --git a/src/servers/app/proto3/Layer.h b/src/servers/app/proto3/Layer.h deleted file mode 100644 index 603d5642a3..0000000000 --- a/src/servers/app/proto3/Layer.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef _LAYER_H_ -#define _LAYER_H_ - -#include -#include -#include - -class ServerBitmap; -class ServerWindow; - -class Layer -{ -public: - Layer(ServerWindow *Win, const char *Name, BRect &Frame, int32 Flags); - Layer(ServerBitmap *Bitmap); - virtual ~Layer(void); - - void Initialize(void); - void Show(void); - void Hide(void); - bool IsVisible(void); - void Update(bool ForceUpdate); - - bool IsBackground(void); - - virtual void SetFrame(const BRect &Rect); - BRect Frame(void); - BRect Bounds(void); - - void Invalidate(const BRect &Rect); - void AddRegion(BRegion *Region); - void RemoveRegions(void); - void UpdateRegions(bool ForceUpdate=true, bool Root=true); - - // Render functions: - virtual void Draw(const BRect &Rect); - - const char *name; - int32 handle; - ServerWindow *window; // Window associated with this. NULL for background layer - ServerBitmap *bitmap; // Blasted to screen on redraw. We render to this - - BRect frame; - - BRegion *visible, // Everything currently visible - *full, // The complete region - *update; // Area to be updated at next redraw - - int32 flags; // Various flags for behavior - - // Render state: - BPoint penpos; - rgb_color high, low, erase; - - int32 drawingmode; -}; - - Layer *FindLayer(int32 Handle); - -#endif diff --git a/src/servers/app/proto3/PortLink.cpp b/src/servers/app/proto3/PortLink.cpp deleted file mode 100644 index 8fba724569..0000000000 --- a/src/servers/app/proto3/PortLink.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/* - PortLink.cpp: - A helper class for port-based messaging - ------------------------------------------------------------------------- -How it works: - The class utilizes a fixed-size array of PortLinkData object pointers. When -data is attached, a new PortLinkData object is allocated and a copy of the -passed data is created inside it. When the time comes for the message to be sent, -the data is pieced together into a flattened array and written to the port. ------------------------------------------------------------------------- -Data members: - -*attachments[] - fixed-size array of pointers used to hold the attached data -opcode - message value which is sent along with any data -target - port to which the message is sent when Flush() is called -replyport - port used with synchronous messaging - FlushWithReply() -bufferlength - total bytes taken up by attachments -num_attachments - internal variable which is used to track which "slot" - will be the next one to receive an attachment object -*/ - -#include "PortLink.h" -#include -#include -#include - -//#define PLDEBUG - -// Internal data storage class for holding attached data whilst it is waiting -// to be Flattened() and then Flushed(). There is no need for this to be called outside -// the PortLink class. -class PortLinkData -{ -public: - PortLinkData(void); - ~PortLinkData(void); - bool Set(void *data, size_t size); - char *buffer; - size_t buffersize; -}; - -PortLink::PortLink(port_id port) -{ - // For this class to be useful (and to prevent a lot of init problems) - // we require a port in the constructor - target=port; - - // We start out without any data attached to the port message - num_attachments=0; - opcode=0; - bufferlength=0; - replyport=create_port(30,"PortLink reply port"); -} - -PortLink::~PortLink(void) -{ - // If, for some odd reason, this is deleted with something attached, - // free the memory used by the attachments. We do not flush the queue - // because the port may no longer be valid in cases such as the app - // is in the process of quitting - MakeEmpty(); -} - -void PortLink::SetOpCode(int32 code) -{ - // Sets the message code. This does not change once the message is sent. - // Another call to SetOpCode() is required for such things. - opcode=code; -} - -void PortLink::SetPort(port_id port) -{ - // Sets the target port. While not necessary in most uses, this exists - // mostly to prevent flexibility problems - target=port; -} - -port_id PortLink::GetPort(void) -{ - // Simply returns the port at which the object is pointed. - return target; -} - -void PortLink::Flush(bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message off to the target, complete with attachments. NOTE: - // the recipient must delete all attachments, being the PortLink object assumes - // no responsiblity for the attachments once the message is sent. - int8 *msgbuffer; - int32 size; - - if(num_attachments>0) - { - FlattenData(&msgbuffer,&size); - - // Dump message to port, reset attachments, and clean up - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,msgbuffer,size,B_TIMEOUT, timeout); - else - write_port(target,opcode,msgbuffer,size); - MakeEmpty(); - } - else - { - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,NULL,0,B_TIMEOUT, timeout); - else - write_port(target,opcode,NULL,0); - } -} - -int8* PortLink::FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message to the target and then waits for a reply. The target will - // receive a message with the first item being the port_id to reply to. - // NOTE: like Flush(), any attached data must be deleted. - - // Effectively, an Attach() call inlined for changes - - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - { - *status=B_ERROR; - return NULL; - } - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&replyport,sizeof(port_id))) - { - bufferlength+=sizeof(port_id); - } - else - { - delete pld; - *status=B_ERROR; - return NULL; - } - - // Flatten() inlined to make some necessary changes - int8 *buffer=new int8[bufferlength]; - int8 *bufferindex=buffer; - size_t size=0; - - // attach our port_id first - memcpy(bufferindex, pld->buffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - - // attach everything else - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - } - - // Flush the thing....FOOSH! :P - write_port(target,opcode,buffer,size); - MakeEmpty(); - delete buffer; - - // Now we wait for the reply - if(timeout==B_INFINITE_TIMEOUT) - { - *buffersize=port_buffer_size(replyport); - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - else - { - *buffersize=port_buffer_size_etc(replyport,0,timeout); - if(*buffersize==B_TIMED_OUT) - { - *status=*buffersize; - return NULL; - } - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - - // We got this far, so we apparently have some data - *status=B_OK; - return buffer; -} - -void PortLink::Attach(void *data, size_t size) -{ - // This is the member called to attach data to a message. Attachments are - // treated to be in 'Append' mode, tacking on each attached piece of data - // to the end of the list. - - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - if(size==0) - return; - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -// These functions were added for a major convenience in passing common types -// Eventually, I'd like to templatize these, but for now, this'll do - -void PortLink::Attach(int32 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int32); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int16 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int16); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int8 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int8); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(float data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(float); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(bool data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(bool); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BRect data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BRect); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BPoint data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BPoint); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::FlattenData(int8 **buffer,int32 *size) -{ - // This function is where all the magic happens, but it is strictly internal. - // It iterates through each PortLinkData object and copies it to the main buffer - // which ends up, ultimately, being written to the PortLink's target port. - - // skip if there aree no attachments - if(bufferlength<1) - return; - - *buffer=new int8[bufferlength]; - int8 *bufferindex=*buffer; - PortLinkData *pld; - *size=0; - - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - *size+=pld->buffersize; - } -} - -void PortLink::MakeEmpty(void) -{ - // Nukes all the attachments currently held by the PortLink class - if(num_attachments!=0) - { - for(int i=0; i0) - free(buffer); -} - -bool PortLinkData::Set(void *data, size_t size) -{ - // Function copies the passed to the internal buffers for storage - if(size>0 && buffersize==0 && data!=NULL) - { - buffer=(char *)malloc(size); - if(buffer==NULL) - return false; - memcpy(buffer, data, size); - buffersize=size; - return true; - } - return false; -} diff --git a/src/servers/app/proto3/PortLink.h b/src/servers/app/proto3/PortLink.h deleted file mode 100644 index 9f5432daab..0000000000 --- a/src/servers/app/proto3/PortLink.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _PORTLINK_H_ -#define _PORTLINK_H_ - -#include -#include -#include -#include - -#ifndef _PORTLINK_BUFFERSIZE -#define _PORTLINK_MAX_ATTACHMENTS 50 -#endif - -class PortLinkData; - -class PortLink -{ -public: - PortLink(port_id port); - ~PortLink(void); - void SetOpCode(int32 code); - void SetPort(port_id port); - port_id GetPort(void); - void Flush(bigtime_t timeout=B_INFINITE_TIMEOUT); - int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, - bigtime_t timeout=B_INFINITE_TIMEOUT); - void Attach(void *data, size_t size); - void Attach(int32 data); - void Attach(int16 data); - void Attach(int8 data); - void Attach(float data); - void Attach(bool data); - void Attach(BRect data); - void Attach(BPoint data); - void MakeEmpty(void); -protected: - void FlattenData(int8 **buffer,int32 *size); - port_id target, replyport; - int32 opcode, bufferlength; - int num_attachments; - PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS]; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto3/README b/src/servers/app/proto3/README deleted file mode 100644 index 95e9d670c7..0000000000 --- a/src/servers/app/proto3/README +++ /dev/null @@ -1,9 +0,0 @@ -OpenBeOS App Server Test Prototype #3 - -This is an example of both a work in progress and a lot of research at the same time. Many of the concepts used in this prototype will be used in the real server. It doesn't do much, but the fact that it exists and does what it does is the result of a *lot* of work. - -This prototype does everything the second one did PLUS has much of the foundation for graphics in place. Graphics updates are slow and there is a lot of flicker, but this is expected - the driver-access module used also emulates the Input Server and utilizes BeOS' app_server to provide all the drawing. - -The code is reasonably (IMHO) well-commented and should be easy to understand at first glance. Also included are some extra files which I didn't feel like throwing out or are in place for future development. ;D Enjoy. - ---DarkWyrm \ No newline at end of file diff --git a/src/servers/app/proto3/ServerApp.cpp b/src/servers/app/proto3/ServerApp.cpp deleted file mode 100644 index 279ec17bc3..0000000000 --- a/src/servers/app/proto3/ServerApp.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - ServerApp.cpp - Class which works with a BApplication. Handles all messages coming - from and going to its application. -*/ - -#include -#include "ServerApp.h" -#include "ServerProtocol.h" -#include "PortLink.h" -#include -#include - -ServerApp::ServerApp(port_id msgport, char *signature) -{ - //printf("New ServerApp %s for app at port %ld\n",signature,msgport); - - // need to copy the signature because the message buffer - // owns the copy which we are passed as a parameter. - if(signature) - { - app_sig=new char[strlen(signature)]; - sprintf(app_sig,signature); - } - else - { - app_sig=new char[strlen("Application")]; - sprintf(app_sig,"Application"); - } - - // sender is the monitored app's event port - sender=msgport; - applink=new PortLink(sender); - - // receiver is the port to which the app sends messages for the server - receiver=create_port(30,app_sig); - //printf("ServerApp port for app %s is at %ld\n",app_sig,receiver); - if(receiver==B_NO_MORE_PORTS) - { - // uh-oh. We have a serious problem. Tell the app to quit - applink->SetOpCode(B_QUIT_REQUESTED); - applink->Flush(); - } - else - { - // Everything checks out, so tell the application - // where to send future messages - applink->SetOpCode(SET_SERVER_PORT); - applink->Attach(&receiver,sizeof(port_id)); - applink->Flush(); - } -} - -ServerApp::~ServerApp(void) -{ - //printf("%s::~ServerApp()\n",app_sig); - delete app_sig; - delete applink; -} - -bool ServerApp::Run(void) -{ - // Unlike a BApplication, a ServerApp is *supposed* to return immediately - // when its Run function is called. - monitor_thread=spawn_thread(MonitorApp,app_sig,B_NORMAL_PRIORITY,this); - if(monitor_thread==B_NO_MORE_THREADS || monitor_thread==B_NO_MEMORY) - return false; - resume_thread(monitor_thread); - return true; -} - -int32 ServerApp::MonitorApp(void *data) -{ - ServerApp *app=(ServerApp *)data; - app->Loop(); - exit_thread(0); - return 0; -} - -void ServerApp::Loop(void) -{ - // Message-dispatching loop for the ServerApp - - //printf("%s::MainLoop()\n",app_sig); - - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(receiver); - - if(buffersize>0) - { - // buffers are PortLink messages. Allocate necessary buffer and - // we'll cast it as a BMessage. - msgbuffer=new int8[buffersize]; - bytesread=read_port(receiver,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(receiver,&msgcode,NULL,0); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case B_QUIT_REQUESTED: - { - // 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) - { - //printf("PANIC: ServerApp %s could not find the app_server port!\n",app_sig); - break; - } - //printf("ServerApp %s quitting\n",app_sig); - applink->SetPort(serverport); - applink->SetOpCode(DELETE_APP); - applink->Attach(&monitor_thread,sizeof(thread_id)); - applink->Flush(); - break; - } - case QUIT_APP: - { - // This message is received from the app_server thread - // because the server was asked to quit. Thus, we - // ask all apps to quit. This is NOT the same as system - // shutdown - - //printf("ServerApp asking %s to quit\n",app_sig); - applink->SetOpCode(B_QUIT_REQUESTED); - applink->Flush(); - break; - } - default: - //printf("Server received unexpected code %ld\n",msgcode); - break; - } - - } - - if(buffersize>0) - delete msgbuffer; - - if(msgcode==B_QUIT_REQUESTED) - break; - } -} - -void ServerApp::DispatchMessage(BMessage *msg) -{ -} - diff --git a/src/servers/app/proto3/ServerApp.h b/src/servers/app/proto3/ServerApp.h deleted file mode 100644 index cf450ccc9c..0000000000 --- a/src/servers/app/proto3/ServerApp.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _SRVAPP_H_ -#define _SRVAPP_H_ - -#include -class BMessage; -class PortLink; - -class ServerApp -{ -public: - ServerApp(port_id msgport, char *signature); - ~ServerApp(void); - - bool Run(void); - static int32 MonitorApp(void *data); - void Loop(void); - void DispatchMessage(BMessage *msg); - - port_id sender,receiver; - char *app_sig; - thread_id monitor_thread; - PortLink *applink; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto3/ServerBitmap.cpp b/src/servers/app/proto3/ServerBitmap.cpp deleted file mode 100644 index 61cc689556..0000000000 --- a/src/servers/app/proto3/ServerBitmap.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* - ServerBitmap.cpp - Bitmap class which is intended to provide an easy way to package all the - data associated with a picture. It's very low-level, so there's still - plenty to do when coding with 'em. Also, they're used to access draw on the - frame buffer in a relatively easy way. -*/ - -// These three includes for ServerBitmap(const char *path_to_image_file) only -#include -#include -#include - -#include -#include "ServerBitmap.h" -#include "Desktop.h" - -ServerBitmap::ServerBitmap(BRect rect,color_space space,int32 BytesPerLine=0) -{ - width=rect.IntegerWidth()+1; - height=rect.IntegerHeight()+1; - cspace=space; - is_vram=false; - - HandleSpace(space, BytesPerLine); - buffer=new uint8[bytesperline*height]; - driver=get_gfxdriver(); -} - -ServerBitmap::ServerBitmap(int32 w,int32 h,color_space space,int32 BytesPerLine=0) -{ - width=w; - height=h; - cspace=space; - is_vram=false; - - HandleSpace(space, BytesPerLine); - buffer=new uint8[bytesperline*height]; - driver=get_gfxdriver(); -} - -ServerBitmap::ServerBitmap(void) -{ - is_vram=true; - UpdateSettings(); -} - -// This particular version is not intended for use except for testing purposes. -// It loads a BBitmap and copies it to the ServerBitmap. Probably will disappear -// when the *real* server is written -ServerBitmap::ServerBitmap(const char *path) -{ - BBitmap *bmp=BTranslationUtils::GetBitmap(path); - assert(bmp!=NULL); - - if(bmp==NULL) - { - width=0; - height=0; - cspace=B_NO_COLOR_SPACE; - bytesperline=0; - } - else - { - width=bmp->Bounds().IntegerWidth(); - height=bmp->Bounds().IntegerHeight(); - cspace=bmp->ColorSpace(); - bytesperline=bmp->BytesPerRow(); - buffer=new uint8[bmp->BitsLength()]; - memcpy(buffer,(void *)bmp->Bits(),bmp->BitsLength()); - } -} - -ServerBitmap::~ServerBitmap(void) -{ - if(!is_vram) - delete buffer; -} - -void ServerBitmap::UpdateSettings(void) -{ - // This is only used when the object is pointing to the frame buffer - driver=get_gfxdriver(); - bpp=driver->GetDepth(); - width=driver->GetWidth(); - height=driver->GetHeight(); -} - -void ServerBitmap::HandleSpace(color_space space, int32 BytesPerLine) -{ - // Function written to handle color space setup which is required - // by the two "normal" constructors - - // Big convoluted mess just to handle every color space and dword align - // the buffer - switch(space) - { - // Buffer is dword-aligned, so nothing need be done - // aside from allocate the memory - case B_RGB32: - case B_RGBA32: - case B_RGB32_BIG: - case B_RGBA32_BIG: - case B_UVL32: - case B_UVLA32: - case B_LAB32: - case B_LABA32: - case B_HSI32: - case B_HSIA32: - case B_HSV32: - case B_HSVA32: - case B_HLS32: - case B_HLSA32: - case B_CMY32: - case B_CMYA32: - case B_CMYK32: - - // 24-bit = 32-bit with extra 8 bits ignored - case B_RGB24_BIG: - case B_RGB24: - case B_LAB24: - case B_UVL24: - case B_HSI24: - case B_HSV24: - case B_HLS24: - case B_CMY24: - { - if(BytesPerLine<(width*4)) - bytesperline=width*4; - else - bytesperline=BytesPerLine; - bpp=32; - break; - } - // Calculate size and dword-align - - // 1-bit - case B_GRAY1: - { - int32 numbytes=width>>3; - if((width % 8) != 0) - numbytes++; - if(BytesPerLine -#include -#include "DisplayDriver.h" - -class ServerBitmap -{ -public: - ServerBitmap(BRect rect,color_space space,int32 BytesPerLine=0); - ServerBitmap(int32 w,int32 h,color_space space,int32 BytesPerLine=0); - ServerBitmap(void); - ServerBitmap(const char *path); - ~ServerBitmap(void); - void UpdateSettings(void); - - int32 width,height; - int32 bytesperline; - color_space cspace; - int bpp; - uint8 *buffer; - -protected: - void HandleSpace(color_space space, int32 BytesPerLine); - DisplayDriver *driver; - bool is_vram; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto3/ServerCursor.cpp b/src/servers/app/proto3/ServerCursor.cpp deleted file mode 100644 index 29fad12f0c..0000000000 --- a/src/servers/app/proto3/ServerCursor.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - ServerCursor.cpp - This is the server-side class used to handle cursors. Note that it - will handle the R5 cursors, but it will also handle taking a bitmap. - - This is new code, and there may be changes to the API before it settles - in. -*/ - -#include "ServerCursor.h" -#include "ServerBitmap.h" - -ServerCursor::ServerCursor(ServerBitmap *bmp) -{ - is_initialized=false; - position.Set(0,0); - SetCursor(bmp); -} - -ServerCursor::ServerCursor(int8 *data, color_space space) -{ - // For handling the idiot R5 API data format - - is_initialized=false; - position.Set(0,0); - SetCursor(data,space); -} - -ServerCursor::~ServerCursor(void) -{ - if(is_initialized) - { - delete bitmap; - delete mask; - } -} - -void ServerCursor::SetCursor(int8 *data, color_space space) -{ - // 68-byte array used in R5 for holding cursors. - // This API has serious problems and should be deprecated(but supported) - // in a future release, perhaps right after the first one - if(is_initialized) - { - delete bitmap; - delete mask; - } - cspace=space; - - bitmap=new ServerBitmap(16,16,B_GRAY1); - mask=new ServerBitmap(16,16,B_GRAY1); - width=16; - height=16; - bounds.Set(0,0,15,15); -} - -void ServerCursor::SetCursor(ServerBitmap *bmp) -{ - if(is_initialized) - { - delete bitmap; - delete mask; - } - cspace=bmp->cspace; - - bitmap=new ServerBitmap(16,16,B_GRAY1); - mask=new ServerBitmap(16,16,B_GRAY1); - width=bmp->width; - height=bmp->height; - bounds.Set(0,0,bmp->width-1,bmp->height-1); -} - -void ServerCursor::MoveTo(int32 x, int32 y) -{ - position.Set(x,y); -} diff --git a/src/servers/app/proto3/ServerCursor.h b/src/servers/app/proto3/ServerCursor.h deleted file mode 100644 index 17c23f661c..0000000000 --- a/src/servers/app/proto3/ServerCursor.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _SERVER_SPRITE_H -#define _SERVER_SPRITE_H - -#include -#include - -class ServerBitmap; - -class ServerCursor -{ -public: - ServerCursor(ServerBitmap *bmp); - ServerCursor(int8 *data,color_space space); - ~ServerCursor(void); - void MoveTo(int32 x, int32 y); - void SetCursor(int8 *data, color_space space); - void SetCursor(ServerBitmap *bmp); - - ServerBitmap *bitmap, - *mask; - - color_space cspace; - BRect bounds; - int width,height; - BPoint position; - bool is_initialized; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto3/ServerProtocol.h b/src/servers/app/proto3/ServerProtocol.h deleted file mode 100644 index e41135f1b6..0000000000 --- a/src/servers/app/proto3/ServerProtocol.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _APPSERVER_PROTOCOL_ -#define _APPSERVER_PROTOCOL_ - -#define CREATE_APP 'drca' -#define DELETE_APP 'drda' - -#define SET_SERVER_PORT 'srsp' -#define QUIT_APP 'srqa' - -#define SERVER_PORT_NAME "OBappserver" -#define SERVER_INPUT_PORT "OBinputport" - -#endif \ No newline at end of file diff --git a/src/servers/app/proto3/ServerRect.h b/src/servers/app/proto3/ServerRect.h deleted file mode 100644 index 2632cf3b46..0000000000 --- a/src/servers/app/proto3/ServerRect.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef _SERVER_RECT_H_ -#define _SERVER_RECT_H_ - -class ServerRect -{ -public: - ServerRect(int32 l, int32 t, int32 r, int32 b) - { left=l; top=t; right=r; bottom=b; } - ServerRect(void) - { left=top=0; right=bottom=0; } - ServerRect(const ServerRect &rect); - ServerRect Bounds(void) const - { return( ServerRect( 0, 0, right - left, bottom - top ) );} - - virtual ~ServerRect(void); - bool Intersect(const ServerRect &rect ) const - { return( !( rect.right < left || rect.left > right || rect.bottom < top || rect.top > bottom ) ); } - - - int32 left,top,right,bottom; -}; - -ServerRect::ServerRect( const ServerRect& rect ) -{ - left = rect.left; - top = rect.top; - right = rect.right; - bottom = rect.bottom; -} - -ServerRect::~ServerRect(void) -{ -} - -#endif \ No newline at end of file diff --git a/src/servers/app/proto3/ServerRegion.h b/src/servers/app/proto3/ServerRegion.h deleted file mode 100644 index d0da8cc79a..0000000000 --- a/src/servers/app/proto3/ServerRegion.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _SERVER_REGION_H_ -#define _SERVER_REGION_H_ - -#include "ServerRect.h" - -class ServerRegion -{ -public: - ServerRegion(void); - ServerRegion(const ServerRect rect); - ServerRegion(const ServerRegion ®); - virtual ~ServerRegion(void); - bool Intersects(ServerRect rect); - void Set(ServerRect rect); - void Include(ServerRect rect); - void Exclude(ServerRect rect); - void IntersectWith(ServerRect rect); - void MakeEmpty(void); - void Optimize(void); -}; -#endif \ No newline at end of file diff --git a/src/servers/app/proto3/ServerSprite.cpp b/src/servers/app/proto3/ServerSprite.cpp deleted file mode 100644 index 915e487dd3..0000000000 --- a/src/servers/app/proto3/ServerSprite.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "ServerCursor.h" -#include "ServerBitmap.h" - -ServerCursor::ServerCursor(ServerBitmap *bmp) -{ -} - -ServerCursor::~ServerCursor(void) -{ -} - -ServerCursor::SetCursor(int8 *data) -{ - // 68-byte array used in R5 for holding cursors. - // This API has serious problems and should be deprecated(but supported) - // in a future release, perhaps the first one(?) -} - -void ServerCursor::SaveClientData(void) -{ -} - -void ServerCursor::MoveTo(int32 x, int32 y) -{ -} - -void ServerCursor::SetClient(ServerBitmap *bmp) -{ -} \ No newline at end of file diff --git a/src/servers/app/proto3/ServerWindow.cpp b/src/servers/app/proto3/ServerWindow.cpp deleted file mode 100644 index 25573409cf..0000000000 --- a/src/servers/app/proto3/ServerWindow.cpp +++ /dev/null @@ -1,114 +0,0 @@ -#include -#include "ServerWindow.h" - -ServerWindow::ServerWindow(const char *Title, uint32 Flags, uint32 Desktop, - const BRect &Rect, ServerApp *App, port_id SendPort) -{ -} - -ServerWindow::ServerWindow(ServerApp *App, ServerBitmap *Bitmap) -{ -} - -ServerWindow::~ServerWindow(void) -{ -} - -void ServerWindow::PostMessage(BMessage *msg) -{ -} - -void ServerWindow::ReplaceDecorator(void) -{ -} - -void ServerWindow::Quit(void) -{ -} - -const char *ServerWindow::GetTitle(void) -{ - return NULL; -} - -ServerApp *ServerWindow::GetApp(void) -{ - return NULL; -} - -BMessenger *ServerWindow::GetAppTarget(void) -{ - return NULL; -} - -void ServerWindow::Show(void) -{ -} - -void ServerWindow::Hide(void) -{ -} - -void ServerWindow::SetFocus(void) -{ -} - -bool ServerWindow::HasFocus(void) -{ - return false; -} - -void ServerWindow::DesktopActivated(int32 NewDesktop, const BPoint Resolution, color_space CSpace) -{ -} - -void ServerWindow::WindowActivated(bool Active) -{ -} - -void ServerWindow::ScreenModeChanged(const BPoint Resolustion, color_space CSpace) -{ -} - -void ServerWindow::SetFrame(const BRect &Frame) -{ -} - -BRect ServerWindow::Frame(void) -{ - return BRect(0,0,0,0); -} - -thread_id ServerWindow::Run(void) -{ - return -1; -} - -status_t ServerWindow::Lock(void) -{ - return B_ERROR; -} - -status_t ServerWindow::Unlock(void) -{ - return B_ERROR; -} - -bool ServerWindow::IsLocked(void) -{ - return false; -} - -bool ServerWindow::DispatchMessage(BMessage *msg) -{ - return false; -} - -bool ServerWindow::DispatchMessage(const void *msg, int nCode) -{ - return false; -} - -void ServerWindow::Loop(void) -{ -} diff --git a/src/servers/app/proto3/ServerWindow.h b/src/servers/app/proto3/ServerWindow.h deleted file mode 100644 index 4c97ab93bb..0000000000 --- a/src/servers/app/proto3/ServerWindow.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _SERVERWIN_H_ -#define _SERVERWIN_H_ - -#include -#include -#include -#include - -class BString; -class BMessenger; -class BRect; -class BPoint; -class ServerApp; -class ServerBitmap; -class WindowDecorator; - -class ServerWindow -{ -public: -ServerWindow(const char *Title, uint32 Flags, uint32 Desktop, - const BRect &Rect, ServerApp *App, port_id SendPort); -ServerWindow(ServerApp *App, ServerBitmap *Bitmap); -virtual ~ServerWindow(void); - -void PostMessage(BMessage *msg); -void ReplaceDecorator(void); -virtual void Quit(void); -const char *GetTitle(void); -ServerApp *GetApp(void); -BMessenger *GetAppTarget(void); -void Show(void); -void Hide(void); -void SetFocus(void); -bool HasFocus(void); - -void DesktopActivated(int32 NewDesktop, const BPoint Resolution, color_space CSpace); -void WindowActivated(bool Active); -void ScreenModeChanged(const BPoint Resolustion, color_space CSpace); - -void SetFrame(const BRect &Frame); -BRect Frame(void); - -thread_id Run(void); -status_t Lock(void); -status_t Unlock(void); -bool IsLocked(void); - -bool DispatchMessage(BMessage *msg); -bool DispatchMessage(const void *msg, int nCode); - -void Loop(void); - -const char *title; -int32 flags; -int32 desktop; - -ServerBitmap *userbitmap; -ServerApp *app; - -WindowDecorator *decorator; -bigtime_t lasthit; // Time of last mouse click - -thread_id thread; -port_id rcvport; // Messages from application -port_id sendport; // Messages to application -BLocker mutex; -BMessenger *apptarget; -}; - -#endif diff --git a/src/servers/app/proto3/SystemPalette.cpp b/src/servers/app/proto3/SystemPalette.cpp deleted file mode 100644 index 3a388ed6b4..0000000000 --- a/src/servers/app/proto3/SystemPalette.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/* - SystemPalette.cpp - One global function to generate the palette which is the default BeOS - System palette and the variable to go with it -*/ - -#include "SystemPalette.h" - -rgb_color SystemPalette[256]; - -void GenerateSystemPalette(rgb_color *palette) -{ - int i,j,index=0; - int indexvals1[]={ 255,229,204,179,154,129,105,80,55,30 }, - indexvals2[]={ 255,203,152,102,51,0 }; - rgb_color *currentcol; - - // Grays 0,0,0 -> 248,248,248 by 8's - for(i=0; i<=248; i+=8,index++) - { - currentcol=&(palette[index]); - currentcol->red=i; - currentcol->green=i; - currentcol->blue=i; - currentcol->alpha=255; - } - - // Blues, following indexvals1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=0; - currentcol->blue=indexvals1[i]; - currentcol->alpha=255; - } - - // Reds, following indexvals1 - 1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals1[i] - 1; - currentcol->green=0; - currentcol->blue=0; - currentcol->alpha=255; - } - - // Greens, following indexvals1 - 1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=indexvals1[i] - 1; - currentcol->blue=0; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=152; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=255; - currentcol->blue=255; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=0;i<4;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=152; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=0; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=255; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=203; - index++; - - // Mostly array runs from here on out - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=203; - currentcol->green=203; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=152; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=102; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=51; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=152; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=102; - index++; - - // knocks out 4 assignment loops at once :) - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=152; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - currentcol+=sizeof(rgb_color); - currentcol->red=230; - currentcol->green=134; - currentcol->blue=0; - index++; - - for(i=1;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=0; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=102; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=175; - currentcol->blue=19; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=255; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=203; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=3;i>=0;i--,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - for(i=2;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - for(i=0;i<5;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=203; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=227; - currentcol->blue=70; - index++; - - for(j=2;j<6;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=0; - index++; - - for(i=5;i<=0;i--,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - -} diff --git a/src/servers/app/proto3/SystemPalette.h b/src/servers/app/proto3/SystemPalette.h deleted file mode 100644 index 0fb99d0fed..0000000000 --- a/src/servers/app/proto3/SystemPalette.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _SYSTEM_PALETTE_H_ -#define _SYSTEM_PALETTE_H_ - -#include - -void GenerateSystemPalette(rgb_color *palette); -extern rgb_color SystemPalette[]; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto3/ViewDriver.cpp b/src/servers/app/proto3/ViewDriver.cpp deleted file mode 100644 index 5f2a189691..0000000000 --- a/src/servers/app/proto3/ViewDriver.cpp +++ /dev/null @@ -1,555 +0,0 @@ -/* - ViewDriver: - First, slowest, and easiest driver class in the app_server which is designed - to utilize the BeOS graphics functions to cut out a lot of junk in getting the - drawing infrastructure in this server. - - The concept is to have VDView::Draw() draw a bitmap, which is a "frame buffer" - of sorts, utilize a second view to write to it. This cuts out - the most problems with having a crapload of code to get just right without - having to write a bunch of unit tests - - Components: 3 classes, VDView, VDWindow, and ViewDriver - - ViewDriver - a wrapper class which mostly posts messages to the VDWindow - VDWindow - does most of the work. - VDView - doesn't do all that much except display the rendered bitmap -*/ - -#include -#include -#include -#include -#include "PortLink.h" -#include "ServerProtocol.h" -#include "ServerBitmap.h" -#include "ViewDriver.h" -#include "ServerCursor.h" -#include "DebugTools.h" - -// Message defines for internal use only -#define VDWIN_CLEAR 'vwcl' -#define VDWIN_SAFEMODE 'vwsm' -#define VDWIN_RESET 'vwrs' -#define VDWIN_SETSCREEN 'vwss' -#define VDWIN_FILLRECT 'vwfr' -#define VDWIN_STROKERECT 'vwsr' -#define VDWIN_FILLELLIPSE 'vwfe' -#define VDWIN_STROKEELLIPSE 'vwse' -#define VDWIN_SHOWCURSOR 'vscr' -#define VDWIN_HIDECURSOR 'vhcr' -#define VDWIN_MOVECURSOR 'vmcr' - -static uint8 pickcursor[] = {16,1,2,1, -0,0,64,0,160,0,88,0,36,0,34,0,17,0,8,128, -4,88,2,60,1,120,0,240,1,248,1,220,0,140,0,0, -0,0,64,0,224,0,120,0,60,0,62,0,31,0,15,128, -7,216,3,252,1,248,0,240,1,248,1,220,0,140,0,0 -}; -static uint8 crosscursor[] = {16,1,5,5, -14,0,4,0,4,0,4,0,128,32,241,224,128,32,4,0, -4,0,4,0,14,0,0,0,0,0,0,0,0,0,0,0, -14,0,4,0,4,0,4,0,128,32,245,224,128,32,4,0, -4,0,4,0,14,0,0,0,0,0,0,0,0,0,0,0 -}; - -VDView::VDView(BRect bounds) - : BView(bounds,"viewdriver_view",B_FOLLOW_ALL, B_WILL_DRAW) -{ - viewbmp=new BBitmap(bounds,B_RGB32,true); - drawview=new BView(viewbmp->Bounds(),"drawview",B_FOLLOW_ALL, B_WILL_DRAW); - - // This link for sending mouse messages to the OBAppServer. - // This is only to take the place of the Input Server. I suppose I could write - // an addon filter to be more like the Input Server, but then I wouldn't be working - // on this thing! :P - serverlink=new PortLink(find_port(SERVER_INPUT_PORT)); -// printf("VDView: app_server input port: %ld\n",serverlink->GetPort()); - - hide_cursor=0; - - // Create a cursor which isn't just a box - cursor=new BBitmap(BRect(0,0,20,20),B_RGBA32,true); - BView *v=new BView(cursor->Bounds(),"v", B_FOLLOW_NONE, B_WILL_DRAW); - cursor->Lock(); - cursor->AddChild(v); - v->SetHighColor(255,255,255,0); - v->FillRect(cursor->Bounds()); - v->SetHighColor(255,0,0,255); - v->FillTriangle(cursor->Bounds().LeftTop(),cursor->Bounds().RightTop(),cursor->Bounds().LeftBottom()); - cursor->RemoveChild(v); - cursor->Unlock(); - - cursorframe=cursor->Bounds(); - oldcursorframe=cursor->Bounds(); -} - -VDView::~VDView(void) -{ - delete viewbmp; - delete serverlink; - delete cursor; -} - -void VDView::AttachedToWindow(void) -{ -// printf("VDView::AttachedToWindow()\n"); -} - -void VDView::Draw(BRect rect) -{ - DrawBitmapAsync(viewbmp,oldcursorframe,oldcursorframe); - DrawBitmapAsync(viewbmp,rect,rect); - SetDrawingMode(B_OP_ALPHA); - DrawBitmapAsync(cursor,cursor->Bounds(),cursorframe); - SetDrawingMode(B_OP_COPY); - Sync(); - -// oldcursorframe.PrintToStream(); -// cursorframe.PrintToStream(); -// printf("\n"); -} - -void VDView::MouseDown(BPoint pt) -{ -// printf("VDView::MouseDown()\n"); -// serverlink->SetOpCode(B_MOUSE_DOWN); -// serverlink->Flush(); -} - -void VDView::MouseMoved(BPoint pt, uint32 transit, const BMessage *msg) -{ - // This emulates an Input Server by sending the same kind of messages to the - // server's port. Being we're using a regular window, it would make little sense - // to do anything else. - - // Attach 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 - BPoint p; - uint32 buttons; - int64 time=(int64)real_time_clock(); - - serverlink->SetOpCode(B_MOUSE_MOVED); - serverlink->Attach(&time,sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - GetMouse(&p,&buttons); - serverlink->Attach(&buttons,sizeof(int32)); - serverlink->Flush(); -} - -void VDView::MouseUp(BPoint pt) -{ -// printf("VDView::MouseUp()\n"); -// serverlink->SetOpCode(B_MOUSE_UP); -// serverlink->Flush(); -} - -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- - -VDWindow::VDWindow(void) - : BWindow(BRect(100,60,740,540),"OBOS App Server, P3",B_TITLED_WINDOW, - B_NOT_ZOOMABLE | B_NOT_RESIZABLE) -{ - view=new VDView(Bounds()); - AddChild(view); - pick=new BCursor(pickcursor); - cross=new BCursor(crosscursor); -} - -VDWindow::~VDWindow(void) -{ - delete pick; - delete cross; -} - -void VDWindow::MessageReceived(BMessage *msg) -{ - switch(msg->what) - { - case VDWIN_CLEAR: - { -// printf("ViewDriver: Clear\n"); - int8 red=0,green=0,blue=0; - msg->FindInt8("red",&red); - msg->FindInt8("green",&green); - msg->FindInt8("blue",&blue); - Clear(red,green,blue); - break; - } - case VDWIN_SETSCREEN: - { - // debug printing done in SetScreen() - int32 space=0; - msg->FindInt32("screenmode",&space); - SetScreen(space); - break; - } - case VDWIN_RESET: - { -// printf("ViewDriver: Reset\n"); - Reset(); - break; - } - case VDWIN_SAFEMODE: - { -// printf("ViewDriver: Safemode\n"); - SafeMode(); - break; - } - case VDWIN_FILLRECT: - { -// printf("ViewDriver: FillRect\n"); - BRect rect(0,0,0,0); - rgb_color color; - - msg->FindRect("rect",&rect); - msg->FindInt8("red",(int8 *)&color.red); - msg->FindInt8("green",(int8 *)&color.green); - msg->FindInt8("blue",(int8 *)&color.blue); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->SetHighColor(color); - view->drawview->FillRect(rect); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - break; - } - case VDWIN_STROKERECT: - { -// printf("ViewDriver: StrokeRect\n"); - BRect rect(0,0,0,0); - rgb_color color; - - msg->FindRect("rect",&rect); - msg->FindInt8("red",(int8 *)&color.red); - msg->FindInt8("green",(int8 *)&color.green); - msg->FindInt8("blue",(int8 *)&color.blue); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->SetHighColor(color); - view->drawview->StrokeRect(rect); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - break; - } - case VDWIN_FILLELLIPSE: - { -// printf("ViewDriver: FillEllipse\n"); - BRect rect(0,0,0,0); - rgb_color color; - - msg->FindRect("rect",&rect); - msg->FindInt8("red",(int8 *)&color.red); - msg->FindInt8("green",(int8 *)&color.green); - msg->FindInt8("blue",(int8 *)&color.blue); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->SetHighColor(color); - view->drawview->FillEllipse(rect); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - break; - } - case VDWIN_STROKEELLIPSE: - { -// printf("ViewDriver: StrokeEllipse\n"); - BRect rect(0,0,0,0); - rgb_color color; - - msg->FindRect("rect",&rect); - msg->FindInt8("red",(int8 *)&color.red); - msg->FindInt8("green",(int8 *)&color.green); - msg->FindInt8("blue",(int8 *)&color.blue); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->SetHighColor(color); - view->drawview->StrokeEllipse(rect); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - break; - } - case VDWIN_SHOWCURSOR: - { - if(view->hide_cursor>0) - view->hide_cursor--; - break; - } - case VDWIN_HIDECURSOR: - { - view->hide_cursor++; - break; - } - case VDWIN_MOVECURSOR: - { - view->oldcursorframe=view->cursorframe; - - int16 x,y; - msg->FindInt16("x",&x); - msg->FindInt16("y",&y); - view->cursorframe.OffsetTo(x,y); - view->Invalidate(view->oldcursorframe); - break; - } - default: - BWindow::MessageReceived(msg); - break; - } -} - -void VDWindow::SafeMode(void) -{ - SetScreen(B_32_BIT_640x480); -} - -void VDWindow::Reset(void) -{ - SafeMode(); - Clear(255,255,255); -} - -void VDWindow::SetScreen(uint32 space) -{ - switch(space) - { - case B_32_BIT_640x480: - case B_16_BIT_640x480: - case B_8_BIT_640x480: - { - ResizeTo(640.0,480.0); -//printf("SetScreen(): 640x480\n"); - break; - } - case B_32_BIT_800x600: - case B_16_BIT_800x600: - case B_8_BIT_800x600: - { - ResizeTo(800.0,600.0); -//printf("SetScreen(): 800x600\n"); - break; - } - case B_32_BIT_1024x768: - case B_16_BIT_1024x768: - case B_8_BIT_1024x768: - { - ResizeTo(1024.0,768.0); -//printf("SetScreen(): 1024x768\n"); - break; - } - default: - break; - } -} - -void VDWindow::Clear(uint8 red,uint8 green,uint8 blue) -{ -//printf("Clear: (%d,%d,%d)\n",red,green,blue); - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->SetHighColor(red,green,blue); - view->drawview->FillRect(view->drawview->Bounds()); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(); -} - -bool VDWindow::QuitRequested(void) -{ - port_id serverport=find_port(SERVER_PORT_NAME); - if(serverport!=B_NAME_NOT_FOUND) - { - write_port(serverport,B_QUIT_REQUESTED,NULL,0); - } - return true; -} - -void VDWindow::WindowActivated(bool active) -{ - // This is just to hide the regular system cursor so we can see our own - if(active) - be_app->HideCursor(); - else - be_app->ShowCursor(); -} - -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- - -/* - Posting messages to the rendering window helps run right around a whole - migraine's worth of multithreaded code -*/ - -ViewDriver::ViewDriver(void) -{ - screenwin=new VDWindow(); - hide_cursor=0; -} - -ViewDriver::~ViewDriver(void) -{ - if(is_initialized) - { - screenwin->Lock(); - screenwin->Quit(); - } -} - -void ViewDriver::Initialize(void) -{ - locker->Lock(); - screenwin->Show(); - is_initialized=true; - locker->Unlock(); -} - -void ViewDriver::Shutdown(void) -{ - locker->Lock(); - screenwin->Lock(); - screenwin->Close(); - is_initialized=false; - locker->Unlock(); -} - -void ViewDriver::SafeMode(void) -{ - locker->Lock(); - screenwin->PostMessage(VDWIN_SAFEMODE); - locker->Unlock(); -} - -void ViewDriver::Reset(void) -{ - locker->Lock(); - screenwin->PostMessage(VDWIN_RESET); - locker->Unlock(); -} - -void ViewDriver::SetScreen(uint32 space) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_SETSCREEN); - msg->AddInt32("screenmode",space); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::Clear(uint8 red, uint8 green, uint8 blue) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_CLEAR); - msg->AddInt8("red",red); - msg->AddInt8("green",green); - msg->AddInt8("blue",blue); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokeRect(BRect rect,rgb_color color) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKERECT); - msg->AddRect("rect",rect); - msg->AddInt8("red",color.red); - msg->AddInt8("green",color.green); - msg->AddInt8("blue",color.blue); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::FillRect(BRect rect, rgb_color color) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_FILLRECT); - msg->AddRect("rect",rect); - msg->AddInt8("red",color.red); - msg->AddInt8("green",color.green); - msg->AddInt8("blue",color.blue); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokeEllipse(BRect rect,rgb_color color) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKEELLIPSE); - msg->AddRect("rect",rect); - msg->AddInt8("red",color.red); - msg->AddInt8("green",color.green); - msg->AddInt8("blue",color.blue); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::FillEllipse(BRect rect,rgb_color color) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_FILLELLIPSE); - msg->AddRect("rect",rect); - msg->AddInt8("red",color.red); - msg->AddInt8("green",color.green); - msg->AddInt8("blue",color.blue); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::Blit(BPoint dest, ServerBitmap *sourcebmp, ServerBitmap *destbmp) -{ -} - -void ViewDriver::SetCursor(int32 value) -{ -} - -void ViewDriver::SetCursor(ServerCursor *cursor) -{ -} - -void ViewDriver::ShowCursor(void) -{ - locker->Lock(); - if(hide_cursor>0) - { - hide_cursor--; - screenwin->PostMessage(VDWIN_SHOWCURSOR); - } - locker->Unlock(); -} - -void ViewDriver::HideCursor(void) -{ - locker->Lock(); - hide_cursor++; - screenwin->PostMessage(VDWIN_HIDECURSOR); - locker->Unlock(); -} - -bool ViewDriver::IsCursorHidden(void) -{ - locker->Lock(); - bool value=(hide_cursor>0)?true:false; - locker->Unlock(); - - return value; -} - -void ViewDriver::MoveCursorTo(int x, int y) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_MOVECURSOR); - msg->AddInt16("x",x); - msg->AddInt16("y",y); - screenwin->PostMessage(msg); - locker->Unlock(); -} diff --git a/src/servers/app/proto3/ViewDriver.h b/src/servers/app/proto3/ViewDriver.h deleted file mode 100644 index 38d4dd6ded..0000000000 --- a/src/servers/app/proto3/ViewDriver.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef _VIEWDRIVER_H_ -#define _VIEWDRIVER_H_ - -#include -#include -#include -#include -#include -#include -#include "DisplayDriver.h" - -class BBitmap; -class PortLink; -class VDWindow; -class ServerCursor; - -class VDView : public BView -{ -public: - VDView(BRect bounds); - ~VDView(void); - void AttachedToWindow(void); - void Draw(BRect rect); - void MouseDown(BPoint pt); - void MouseMoved(BPoint pt, uint32 transit, const BMessage *msg); - void MouseUp(BPoint pt); - - BBitmap *viewbmp; - BView *drawview; - PortLink *serverlink; - -protected: - friend VDWindow; - - int hide_cursor; - BBitmap *cursor; - - BRect cursorframe, oldcursorframe; -}; - -class VDWindow : public BWindow -{ -public: - VDWindow(void); - ~VDWindow(void); - void MessageReceived(BMessage *msg); - bool QuitRequested(void); - void WindowActivated(bool active); - - void SafeMode(void); - void Reset(void); - void SetScreen(uint32 space); - void Clear(uint8 red,uint8 green,uint8 blue); - - VDView *view; - BCursor *pick, *cross; -}; - -class ViewDriver : public DisplayDriver -{ -public: - ViewDriver(void); - virtual ~ViewDriver(void); - - virtual void Initialize(void); - virtual void Shutdown(void); - virtual void SafeMode(void); - virtual void Reset(void); - virtual void SetScreen(uint32 space); - virtual void Clear(uint8 red,uint8 green,uint8 blue); - - virtual void StrokeRect(BRect rect,rgb_color color); - virtual void FillRect(BRect rect, rgb_color color); - virtual void StrokeEllipse(BRect rect,rgb_color color); - virtual void FillEllipse(BRect rect,rgb_color color); - virtual void Blit(BPoint dest, ServerBitmap *sourcebmp, ServerBitmap *destbmp); - - virtual void SetCursor(int32 value); - virtual void SetCursor(ServerCursor *cursor); - virtual void ShowCursor(void); - virtual void HideCursor(void); - virtual bool IsCursorHidden(void); - virtual void MoveCursorTo(int x, int y); - VDWindow *screenwin; -protected: - int hide_cursor; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/AppServer.cpp b/src/servers/app/proto4/AppServer.cpp deleted file mode 100644 index f26e53ff69..0000000000 --- a/src/servers/app/proto4/AppServer.cpp +++ /dev/null @@ -1,323 +0,0 @@ -#include -#include -#include "scheduler.h" -#include -#include -#include "AppServer.h" -#include "ServerApp.h" -#include "Desktop.h" -#include "ServerProtocol.h" -#include "PortLink.h" -#include "DisplayDriver.h" -#include "DebugTools.h" - -AppServer::AppServer(void) : BApplication("application/x-vnd.obe-OBAppServer") -{ -// printf("AppServer()\n"); - - mouseport=create_port(30,SERVER_INPUT_PORT); - messageport=create_port(20,SERVER_PORT_NAME); -// printf("Server message port: %ld\n",messageport); -// printf("Server input port: %ld\n",mouseport); - applist=new BList(0); - quitting_server=false; - exit_poller=false; - - // Set up the Desktop - init_desktop(3); - - // Spawn our input-polling thread - poller_id = spawn_thread(PollerThread, "Poller", B_NORMAL_PRIORITY, this); - if (poller_id >= 0) - resume_thread(poller_id); - driver=get_gfxdriver(); - - active_app=-1; - p_active_app=NULL; - - // This is necessary to mediate access between the Poller and app_server threads - active_lock=new BLocker; -} - -AppServer::~AppServer(void) -{ - shutdown_desktop(); - - ServerApp *temp; - for(int32 i=0;iCountItems();i++) - { - temp=(ServerApp *)applist->ItemAt(i); - if(temp!=NULL) - delete temp; - } - delete applist; - delete active_lock; -} - -thread_id AppServer::Run(void) -{ - //printf("AppServer::Run()\n"); - - MainLoop(); - return 0; -} - -void AppServer::MainLoop(void) -{ - // Main loop (duh). Monitors the message queue and dispatches as appropriate. - // Input messages are handled by the poller, however. - - //printf("AppServer::MainLoop()\n"); - - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(messageport); - if(buffersize>0) - msgbuffer=new int8[buffersize]; - bytesread=read_port(messageport,&msgcode,msgbuffer,buffersize); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case CREATE_APP: - case DELETE_APP: - case B_QUIT_REQUESTED: - DispatchMessage(msgcode,msgbuffer); - break; - default: - //printf("Server received unexpected code %ld\n",msgcode); - break; - } - - } - - if(buffersize>0) - delete msgbuffer; - if(msgcode==DELETE_APP || msgcode==B_QUIT_REQUESTED) - { - 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); - -} - - -void AppServer::DispatchMessage(int32 code, int8 *buffer) -{ - int8 *index=buffer; - switch(code) - { - case CREATE_APP: - { - // Create the ServerApp to node monitor a new BApplication - - //printf("AppServer: Create App\n"); - - // Attached data: - // 1) port_id - receiver port of a regular app - // 2) char * - signature of the regular app - - // Find the necessary data - port_id app_port=*((port_id*)index); - index+=sizeof(port_id); - - char *app_signature=(char *)index; - - // Create the ServerApp subthread for this app - ServerApp *newapp=new ServerApp(app_port,app_signature); - applist->AddItem(newapp); - - active_lock->Lock(); - p_active_app=newapp; - active_app=applist->CountItems()-1; - active_lock->Unlock(); - - newapp->Run(); - - break; - } - case DELETE_APP: - { - // Delete a ServerApp. Received only from the respective ServerApp when a - // BApplication asks it to quit. - - //printf("AppServer: Delete App\n"); - - // Attached Data: - // 1) thread_id - thread ID of the ServerApp to be deleted - - int32 i, appnum=applist->CountItems(); - ServerApp *srvapp; - thread_id srvapp_id=*((thread_id*)buffer); - - // Run through the list of apps and nuke the proper one - for(i=0;iItemAt(i); - if(srvapp!=NULL && srvapp->monitor_thread==srvapp_id) - { - srvapp=(ServerApp *)applist->RemoveItem(i); - delete srvapp; - active_lock->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; - active_lock->Unlock(); - break; // jump out of the loop - } - } - break; - } - case B_QUIT_REQUESTED: - { - //printf("Shutdown sequence initiated.\n"); - - // Attached Data: - // none - - // 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. - PortLink *applink=new PortLink(0); - ServerApp *srvapp; - int32 i,appnum=applist->CountItems(); - - applink->SetOpCode(QUIT_APP); - for(i=0;iItemAt(i); - if(srvapp!=NULL) - { - applink->SetPort(srvapp->receiver); - applink->Flush(); - } - } - - delete applink; - // So when we delete the last ServerApp, we can exit the server - quitting_server=true; - exit_poller=true; - break; - } - default: - //printf("Unexpected message %ld (%lx) in AppServer::DispatchMessage()\n",code,code); - break; - } -} - -void AppServer::Poller(void) -{ - // This thread handles nothing but input messages for mouse and keyboard - int32 msgcode; - int8 *msgbuffer=NULL,*index; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(mouseport); - if(buffersize>0) - msgbuffer=new int8[buffersize]; - bytesread=read_port(mouseport,&msgcode,msgbuffer,buffersize); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - // We don't need to do anything with these two, so just pass them - // onto the active application. Eventually, we will pass them onto - // the window which is currently under the cursor. - case B_MOUSE_DOWN: - case B_MOUSE_UP: - { - active_lock->Lock(); - if(active_app>-1) - write_port(p_active_app->receiver, msgcode,msgbuffer,buffersize); - active_lock->Unlock(); - 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 - - index=msgbuffer; - - // Time sent is not necessary for cursor processing. - index += sizeof(int64); - - float tempx=0,tempy=0; - tempx=*((float*)index); - index+=sizeof(float); - tempy=*((float*)index); - index+=sizeof(float); - - driver->MoveCursorTo(tempx,tempy); - - active_lock->Lock(); - if(active_app>-1) - write_port(p_active_app->receiver, msgcode,msgbuffer,buffersize); - active_lock->Unlock(); - break; - } - default: - //printf("Server::Poller received unexpected code %ld\n",msgcode); - break; - } - - } - - if(buffersize>0) - delete msgbuffer; - - if(exit_poller) - break; - } -} - -int32 AppServer::PollerThread(void *data) -{ - //printf("Starting Poller thread...\n"); - AppServer *server=(AppServer *)data; - - server->Poller(); // This won't return until it's told to - - //printf("Exiting Poller thread...\n"); - exit_thread(B_OK); - return B_OK; -} - -int main( int argc, char** argv ) -{ - AppServer *obas = new AppServer(); - obas->Run(); - delete obas; - return 0; -} - - \ No newline at end of file diff --git a/src/servers/app/proto4/AppServer.h b/src/servers/app/proto4/AppServer.h deleted file mode 100644 index f24ec39a7c..0000000000 --- a/src/servers/app/proto4/AppServer.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _OPENBEOS_APP_SERVER_H_ -#define _OPENBEOS_APP_SERVER_H_ - -#include -#include -#include -#include - -class BMessage; -class ServerApp; -class DisplayDriver; - -class AppServer : public BApplication -{ -public: - AppServer(void); - ~AppServer(void); - thread_id Run(void); - void MainLoop(void); - port_id messageport,mouseport; - void Poller(void); - -private: - void DispatchMessage(int32 code, int8 *buffer); - static int32 PollerThread(void *data); - - bool quitting_server; - BList *applist; - int32 active_app; - ServerApp *p_active_app; - thread_id poller_id; - BLocker *active_lock; - bool exit_poller; - DisplayDriver *driver; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/BUGS b/src/servers/app/proto4/BUGS deleted file mode 100644 index 69d18cbea0..0000000000 --- a/src/servers/app/proto4/BUGS +++ /dev/null @@ -1 +0,0 @@ -Cursor display is just a little bit funky (try moving cursor by 1 pixel) \ No newline at end of file diff --git a/src/servers/app/proto4/CHANGES b/src/servers/app/proto4/CHANGES deleted file mode 100644 index 5cbff3e3e8..0000000000 --- a/src/servers/app/proto4/CHANGES +++ /dev/null @@ -1,19 +0,0 @@ -Prototype 4 - -Serious DisplayDriver API changes -Support of cursordata-based SetCursor calls by test app (ServerCursor translates them to 32-bit bitmaps) -TestApp has been modified to test the graphics access module -Implemented many, many BView graphics calls and appropriate protocols -BShape, BRegion, and BPolygon graphics calls not implemented. -BFont-based calls, save DrawString and SetFontSize, are unimplemented. -Partial foundation laid for BBitmap support - -Prototype 3 - -Added GUI and hardcoded cursor - - -Prototype 2 - -Adding and removing test applications -Quitting server causes all test apps to quit also \ No newline at end of file diff --git a/src/servers/app/proto4/DebugTools.cpp b/src/servers/app/proto4/DebugTools.cpp deleted file mode 100644 index 25f852f970..0000000000 --- a/src/servers/app/proto4/DebugTools.cpp +++ /dev/null @@ -1,205 +0,0 @@ -#include -#include -#include "DebugTools.h" - -void PrintStatusToStream(status_t value) -{ - // Function which simply translates a returned status code into a string - // and dumps it to stdout - BString outstr; - switch(value) - { - case B_OK: - outstr="B_OK "; - break; - case B_NAME_NOT_FOUND: - outstr="B_NAME_NOT_FOUND "; - break; - case B_BAD_VALUE: - outstr="B_BAD_VALUE "; - break; - case B_ERROR: - outstr="B_ERROR "; - break; - case B_TIMED_OUT: - outstr="B_TIMED_OUT "; - break; - case B_NO_MORE_PORTS: - outstr="B_NO_MORE_PORTS "; - break; - case B_WOULD_BLOCK: - outstr="B_WOULD_BLOCK "; - break; - case B_BAD_PORT_ID: - outstr="B_BAD_PORT_ID "; - break; - case B_BAD_TEAM_ID: - outstr="B_BAD_TEAM_ID "; - break; - default: - outstr="undefined status value in debugtools::PrintStatusToStream() "; - break; - } - cout << "Status: " << outstr.String() << endl << flush; - -} - -void PrintColorSpaceToStream(color_space value) -{ - // Dump a color space to cout - BString outstr; - switch(value) - { - case B_RGB32: - outstr="B_RGB32 "; - break; - case B_RGBA32: - outstr="B_RGBA32 "; - break; - case B_RGB32_BIG: - outstr="B_RGB32_BIG "; - break; - case B_RGBA32_BIG: - outstr=" "; - break; - case B_UVL32: - outstr="B_UVL32 "; - break; - case B_UVLA32: - outstr="B_UVLA32 "; - break; - case B_LAB32: - outstr="B_LAB32 "; - break; - case B_LABA32: - outstr="B_LABA32 "; - break; - case B_HSI32: - outstr="B_HSI32 "; - break; - case B_HSIA32: - outstr="B_HSIA32 "; - break; - case B_HSV32: - outstr="B_HSV32 "; - break; - case B_HSVA32: - outstr="B_HSVA32 "; - break; - case B_HLS32: - outstr="B_HLS32 "; - break; - case B_HLSA32: - outstr="B_HLSA32 "; - break; - case B_CMY32: - outstr="B_CMY32"; - break; - case B_CMYA32: - outstr="B_CMYA32 "; - break; - case B_CMYK32: - outstr="B_CMYK32 "; - break; - case B_RGB24_BIG: - outstr="B_RGB24_BIG "; - break; - case B_RGB24: - outstr="B_RGB24 "; - break; - case B_LAB24: - outstr="B_LAB24 "; - break; - case B_UVL24: - outstr="B_UVL24 "; - break; - case B_HSI24: - outstr="B_HSI24 "; - break; - case B_HSV24: - outstr="B_HSV24 "; - break; - case B_HLS24: - outstr="B_HLS24 "; - break; - case B_CMY24: - outstr="B_CMY24 "; - break; - case B_GRAY1: - outstr="B_GRAY1 "; - break; - case B_CMAP8: - outstr="B_CMAP8 "; - break; - case B_GRAY8: - outstr="B_GRAY8 "; - break; - case B_YUV411: - outstr="B_YUV411 "; - break; - case B_YUV420: - outstr="B_YUV420 "; - break; - case B_YCbCr422: - outstr="B_YCbCr422 "; - break; - case B_YCbCr411: - outstr="B_YCbCr411 "; - break; - case B_YCbCr420: - outstr="B_YCbCr420 "; - break; - case B_YUV422: - outstr="B_YUV422 "; - break; - case B_YUV9: - outstr="B_YUV9 "; - break; - case B_YUV12: - outstr="B_YUV12 "; - break; - case B_RGB15: - outstr="B_RGB15 "; - break; - case B_RGBA15: - outstr="B_RGBA15 "; - break; - case B_RGB16: - outstr="B_RGB16 "; - break; - case B_RGB16_BIG: - outstr="B_RGB16_BIG "; - break; - case B_RGB15_BIG: - outstr="B_RGB15_BIG "; - break; - case B_RGBA15_BIG: - outstr="B_RGBA15_BIG "; - break; - case B_YCbCr444: - outstr="B_YCbCr444 "; - break; - case B_YUV444: - outstr="B_YUV444 "; - break; - case B_NO_COLOR_SPACE: - outstr="B_NO_COLOR_SPACE "; - break; - default: - outstr="Undefined color space "; - break; - } - cout << "Color Space: " << outstr.String() << flush; -} - -void TranslateMessageCodeToStream(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - - cout << "'" - << (char)((code & 0xFF000000) >> 24) - << (char)((code & 0x00FF0000) >> 16) - << (char)((code & 0x0000FF00) >> 8) - << (char)((code & 0x000000FF)) << "' "; -} \ No newline at end of file diff --git a/src/servers/app/proto4/DebugTools.h b/src/servers/app/proto4/DebugTools.h deleted file mode 100644 index e629820577..0000000000 --- a/src/servers/app/proto4/DebugTools.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef _DEBUGTOOLS_H_ -#define _DEBUGTOOLS_H_ - -#include -#include - -void PrintStatusToStream(status_t value); -void PrintColorSpaceToStream(color_space value); -void TranslateMessageCodeToStream(int32 code); - -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/Desktop.cpp b/src/servers/app/proto4/Desktop.cpp deleted file mode 100644 index 125de6c6f4..0000000000 --- a/src/servers/app/proto4/Desktop.cpp +++ /dev/null @@ -1,338 +0,0 @@ -/* - Desktop.cpp: - Code necessary to handle the Desktop, defined as the collection of workspaces. -*/ - -//#define DEBUG_WORKSPACES - -#include -#include -#include -#include -#include "DisplayDriver.h" -#include "ViewDriver.h" -#include "Desktop.h" - -class ServerWindow; -class ServerBitmap; -class Workspace; - -// Quick hack to make setting rgb_colors much easier to live with -void set_rgb_color(rgb_color *col,uint8 red, uint8 green, uint8 blue, uint8 alpha=255) -{ - col->red=red; - col->green=green; - col->blue=blue; - col->alpha=alpha; -} - -//--------------------GLOBALS------------------------- -int32 workspace_count, active_workspace; -BList *desktop; -Workspace *pactive_workspace; -color_map system_palette; -ViewDriver *gfxdriver; -//---------------------------------------------------- - - -//-------------------INTERNAL CLASS DEFS-------------- -class Workspace -{ -public: - Workspace(void); - Workspace(BPath imagepath); - ~Workspace(); - - BList layerlist; - BList focuslist; - rgb_color bgcolor; - screen_info screendata, - olddata; -}; - -DisplayDriver *get_gfxdriver(void) -{ - return gfxdriver; -} - -Workspace::Workspace(void) -{ - workspace_count++; - - // default values - layerlist.MakeEmpty(); - focuslist.MakeEmpty(); - bgcolor.red=51; - bgcolor.green=102; - bgcolor.blue=160; - screendata.mode=B_CMAP8; - screendata.spaces=B_8_BIT_640x480; - screendata.refresh_rate=60.0; - screendata.min_refresh_rate=60.0; - screendata.max_refresh_rate=60.0; - screendata.h_position=(uchar)50; - screendata.v_position=(uchar)50; - screendata.h_size=(uchar)50; - screendata.v_size=(uchar)50; - olddata=screendata; -} - -Workspace::~Workspace(void) -{ - workspace_count--; -} -//--------------------------------------------------- - - -//-----------------GLOBAL FUNCTION DEFS--------------- - -void init_desktop(int8 workspaces) -{ -#ifdef DEBUG_WORKSPACES -printf("init_desktop(%d)\n",workspaces); -#endif - workspace_count=workspaces; - if(workspace_count==0) - workspace_count++; - - // Instantiate and initialize display driver - gfxdriver=new ViewDriver(); - gfxdriver->Initialize(); - -#ifdef DEBUG_WORKSPACES -printf("Driver %s\n", (gfxdriver->IsInitialized()==true)?"initialized":"NOT initialized"); -#endif - - desktop=new BList(0); - - // Create the workspaces we're supposed to have - for(int8 i=0; iAddItem(new Workspace()); - } - - // Load workspace preferences here - - // We're going to punch in some hardcoded settings for testing purposes. - // There are 3 workspaces hardcoded in for now, but we'll only use the - // second one. - Workspace *wksp=(Workspace*)desktop->ItemAt(1); - if(wksp!=NULL) // in case I forgot something - { - set_rgb_color(&(wksp->bgcolor),0,200,236); - screen_info *tempsd=&(wksp->screendata); - tempsd->mode=B_CMAP8; - tempsd->spaces=B_8_BIT_800x600; - tempsd->frame.Set(0,0,799,599); - } - else - printf("DW goofed on the workspace index :P\n"); - - - // Activate workspace 0 - pactive_workspace=(Workspace *)desktop->ItemAt(0); - gfxdriver->SetScreen(pactive_workspace->screendata.spaces); - - // Clear the screen - set_rgb_color(&(pactive_workspace->bgcolor),80,85,152); - gfxdriver->Clear(pactive_workspace->bgcolor); - -#ifdef DEBUG_WORKSPACES -printf("Desktop initialized\n"); -#endif -} - -void shutdown_desktop(void) -{ - int32 i,count=desktop->CountItems(); - for(i=0;iItemAt(i)!=NULL) - delete desktop->ItemAt(i); - } - desktop->MakeEmpty(); - delete desktop; - gfxdriver->Shutdown(); - delete gfxdriver; -} - - -int32 CountWorkspaces(void) -{ -#ifdef DEBUG_WORKSPACES -printf("CountWorkspaces() returned %ld\n",workspace_count); -#endif - return workspace_count; -} - -void SetWorkspaceCount(int32 count) -{ - if(count<0) - { -#ifdef DEBUG_WORKSPACES -printf("SetWorkspaceCount(value<0) - DOH!\n"); -#endif - return; - } - if(count==workspace_count) - return; - - // Activate last workspace in new set if we're using one to be nuked - if(countItemAt(i)!=NULL) - { - delete (Workspace*)desktop->ItemAt(i); - desktop->RemoveItem(i); - } - } - } - else - { - // count > workspace_count here - - // Once we have default workspace preferences which can be set by the - // user, we'll end up having to initialize newly-added workspaces to that - // data. In the mean time, the defaults in the constructor will do. :) - for(int32 i=count;iAddItem(new Workspace()); - } - } - - // don't forget to update our global! - workspace_count=desktop->CountItems(); - -#ifdef DEBUG_WORKSPACES -printf("SetWorkspaceCount(%ld)\n",workspace_count); -#endif - -} - -int32 CurrentWorkspace(void) -{ -#ifdef DEBUG_WORKSPACES -printf("CurrentWorkspace() returned %ld\n",active_workspace); -#endif - return active_workspace; -} - -void ActivateWorkspace(int32 workspace) -{ - // In order to change workspaces, we'll need to make all the necessary - // changes to the screen to fit the new one, such as resolution, - // background color, color depth, refresh rate, etc. - - if(workspace>workspace_count || workspace<0) - return; - - Workspace *proposed=(Workspace *)desktop->ItemAt(workspace); - - if(proposed==NULL) - return; - - // Here's where we update all the screen stuff - if(pactive_workspace->screendata.spaces != proposed->screendata.spaces) - { - gfxdriver->SetScreen(proposed->screendata.spaces); - gfxdriver->Clear(proposed->bgcolor); - } - // more if != then change code goes here. Currently, a lot of the code which - // uses this stuff is not implemented, so it's kind of moot. However, when we - // use the real graphics HW, it'll become important. - - // actually set our active workspace data to reflect the change in workspaces - pactive_workspace=proposed; - active_workspace=workspace; -#ifdef DEBUG_WORKSPACES -printf("ActivateWorkspace(%ld)\n",active_workspace); -#endif -} - -const color_map *SystemColors(void) -{ - return (const color_map *)&system_palette; -} - -status_t SetScreenSpace(int32 index, uint32 res, bool stick = true) -{ -#ifdef DEBUG_WORKSPACES -printf("SetScreenSpace(%ld,%lu, %s)\n",index,res,(stick==true)?"true":"false"); -#endif - - if(index>workspace_count-1) - { - printf("SetScreenSpace was passed invalid workspace value %ld\n",index); - return B_ERROR; - } - if(res>0x800000) // the last "normal" screen mode defined in GraphicsDefs.h - { - printf("SetScreenSpace was passed invalid screen value %lu\n",res); - return B_ERROR; - } - - // When we actually use app_server preferences, we'll save the screen mode to - // the preferences so that we use this mode next boot. For now, we treat stick==false - if(stick==true) - { - // save the screen data here - } - if(index==active_workspace) - { - gfxdriver->SetScreen(res); - gfxdriver->Clear(pactive_workspace->bgcolor); - } - else - { - // just set the workspace's data here. right now, do nothing. - } - return B_OK; -} - -status_t GetScrollBarInfo(scroll_bar_info *info) -{ - return B_ERROR; -} - -status_t SetScrollBarInfo(scroll_bar_info *info) -{ - //printf("set_scroll_bar_info()\n"); - return B_ERROR; -} - -bigtime_t IdleTime() -{ - return 0; -} - -void RunSelectPrinterPanel() -{ // Not sure what to do with this guy just yet -} - -void RunAddPrinterPanel() -{ // Not sure what to do with this guy just yet -} - -void RunBeAbout() -{ // the BeOS About Window belongs to Tracker.... -} - -void SetFocusFollowsMouse(bool follow) -{ - //printf("set_focus_follows_mouse(%s)\n",(follow==true)?"true":"false"); -} - -bool FocusFollowsMouse() -{ - return false; -} - -// Another "just in case DW screws up again" section -#ifdef DEBUG_WORKSPACES -#undef DEBUG_WORKSPACES -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/Desktop.h b/src/servers/app/proto4/Desktop.h deleted file mode 100644 index a4830a8c21..0000000000 --- a/src/servers/app/proto4/Desktop.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _OBDESKTOP_H_ -#define _OBDESKTOP_H_ - - -#include -#include -#include -class DisplayDriver; - -void init_desktop(int8 workspaces); -void shutdown_desktop(void); -DisplayDriver *get_gfxdriver(void); - -// Workspace access functions -int32 CountWorkspaces(void); -void SetWorkspaceCount(int32 count); -int32 CurrentWorkspace(void); -void ActivateWorkspace(int32 workspace); -const color_map *SystemColors(void); -status_t SetScreenSpace(int32 index, uint32 res, bool stick = true); - -typedef struct -{ - color_space mode; - BRect frame; - uint32 spaces; - float min_refresh_rate; - float max_refresh_rate; - float refresh_rate; - uchar h_position; - uchar v_position; - uchar h_size; - uchar v_size; -} screen_info; - - -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/DirectDriver.cpp b/src/servers/app/proto4/DirectDriver.cpp deleted file mode 100644 index b451ae9b2e..0000000000 --- a/src/servers/app/proto4/DirectDriver.cpp +++ /dev/null @@ -1,251 +0,0 @@ -#include -#include "DirectDriver.h" -#include - -#ifndef ABS - #define ABS(a) (a<0)?a*-1:a -#endif - -OBAppServerScreen::OBAppServerScreen(status_t *error) - : BDirectWindow(BRect(100,60,740,540),"OBOS App Server, P3",B_TITLED_WINDOW, - B_NOT_RESIZABLE | B_NOT_ZOOMABLE) -{ - redraw=true; -} - -OBAppServerScreen::~OBAppServerScreen(void) -{ -} - -void OBAppServerScreen::MessageReceived(BMessage *msg) -{ - msg->PrintToStream(); - switch(msg->what) - { - case B_KEY_DOWN: -// Disconnect(); - QuitRequested(); - break; - default: - BDirectWindow::MessageReceived(msg); - break; - } -} - -bool OBAppServerScreen::QuitRequested(void) -{ - redraw=false; - be_app->PostMessage(B_QUIT_REQUESTED); - return true; -} - -int32 OBAppServerScreen::Draw(void *data) -{ - OBAppServerScreen *screen=(OBAppServerScreen *)data; - for(;;) - { - if(screen->connected && screen->redraw) - { - // Draw a sample background - screen->redraw=false; - } - } - return 1; -} - -void OBAppServerScreen::DirectConnected(direct_buffer_info *dbinfo) -{ -/* if(ok==true) - { - connected=true; - gcinfo=CardInfo(); - for(int8 i=0;i<48;i++) - gchooks[i]=CardHookAt(i); - } - else - connected=false; -*/ -} - -DirectDriver::DirectDriver(void) -{ -// printf("DirectDriver()\n"); -// old_space=B_32_BIT_800x600; -} - -DirectDriver::~DirectDriver(void) -{ - printf("~DirectDriver()\n"); - winscreen->Lock(); - winscreen->Close(); -} - -void DirectDriver::Initialize(void) -{ -/* printf("DirectDriver::Initialize()\n"); - status_t stat; - winscreen=new OBAppServerScreen(&stat); - if(stat==B_OK) - winscreen->Show(); - else - delete winscreen; -*/ -} - -void DirectDriver::SafeMode(void) -{ -/* printf("DirectDriver::SafeMode()\n"); -// SetScreen(B_8_BIT_640x480); - SetScreen(B_32_BIT_800x600); - Reset(); -*/ -} - -void DirectDriver::Reset(void) -{ -/* printf("DirectDriver::Reset()\n"); - if(winscreen->connected==true) - Clear(51,102,160); -*/ -} - -void DirectDriver::SetScreen(uint32 space) -{ -// printf("DirectDriver::SetScreen(%lu)\n",space); -// winscreen->SetSpace(space); -} - -void DirectDriver::Clear(uint8 red, uint8 green, uint8 blue) -{ -/* // This simply clears the entire screen, utilizing a string and - // memcpy to speed things up in a minor way - printf("DirectDriver::Clear(%d,%d,%d)\n",red,green,blue); - - if(winscreen->connected==false) - return; - - int i,imax, - length=winscreen->gcinfo->bytes_per_row; - int8 fillstring[length]; - - - switch(winscreen->gcinfo->bits_per_pixel) - { - case 32: - { - int32 color,*index32; - - // order is going to be BGRA or ARGB - if(winscreen->gcinfo->rgba_order[0]=='B') - { - // Create the number to quickly create the string - - // BBGG RRAA in RAM => 0xRRAA BBGG - color= (int32(red) << 24) + 0xFF0000L + (int32(blue) << 8) + green; - } - else - { - // Create the number to quickly create the string - - // AARR GGBB in RAM - color= 0xFF000000L + (int32(red) << 16) + (int32(green) << 8) + blue; - } - - // fill the string with the appropriate values - index32=(int32 *)fillstring; - imax=winscreen->gcinfo->width; - - for(i=0;igcinfo->rgba_order[0]=='B') - { - // Little-endian - // G[2:0],B[4:0] R[4:0],G[5:3] - - // Ick. Gotta love all that shifting and masking. :( - color= (int16((green & 7)) << 13) + - (int16((blue & 31)) << 8) + - (int16((red & 31)) << 4) + - (int16(green & 56)); - } - else - { - // Big-endian - // R[4:0],G[5:3] G[2:0],B[4:0] - color= (int16(red & 31) << 11) + - (int16(green & 56) << 8) + - (int16(green & 3) << 5) + - (blue & 31); - } - break; - } - case 15: - { - - // RGBA_15: - // G[2:0],B[4:0] A[0],R[4:0],G[4:3] - - // RGBA_15_BIG: - // A[0],R[4:0],G[4:3] G[2:0],B[4:0] - break; - } -*/ -/* case 8: - { - // This is both the easiest and hardest: - // We fill using memset(), but we have to find the closest match to the - // color we've been given. Yuck. - - // Find the closest match by comparing the differences in values for each - // color. This function was not intended to be called rapidly, so speed is - // not much of an issue at this point. - int8 closest=0; - int16 closest_delta=765, delta; // (255 * 3) - - // Get the current palette - rgb_color *list=winscreen->ColorList(); - for(i=0;i<256;i++) - { - delta=ABS(list->red-red)+ABS(list->green-green)+ABS(list->blue-blue); - if(deltagcinfo->frame_buffer,closest, - winscreen->gcinfo->bytes_per_row * winscreen->gcinfo->height); - - // Nothing left to do! - return; - break; - } - default: - { - printf("Unsupported bit depth %d in DirectDriver::Clear(r,g,b)!!\n",winscreen->gcinfo->bits_per_pixel); - return; - } - } - imax=winscreen->gcinfo->height; - - // a pointer to increment for the screen copy. Faster than doing a multiply - // each iteration - int8 *pbuffer=(int8*)winscreen->gcinfo->frame_buffer; - for(i=0;i -#include -#include -#include -#include "DisplayDriver.h" - -class OBAppServerScreen : public BDirectWindow -{ -public: - OBAppServerScreen(status_t *error); - ~OBAppServerScreen(void); - virtual void MessageReceived(BMessage *msg); - virtual bool QuitRequested(void); - static int32 Draw(void *data); - virtual void DirectConnected(direct_buffer_info *dbinfo); - - int32 DrawID; - bool redraw,connected; - graphics_card_info *gcinfo; - graphics_card_hook *gchooks; -}; - -class DirectDriver : public DisplayDriver -{ -public: - DirectDriver(void); - virtual ~DirectDriver(void); - - virtual void Initialize(void); // Sets the driver - virtual void SafeMode(void); // Easy-access functions for common tasks - virtual void Reset(void); - virtual void SetScreen(uint32 space); - virtual void Clear(uint8 red,uint8 green,uint8 blue); -// virtual void SetPixel(int x, int y, rgb_color color); -// virtual void StrokeEllipse(BRect rect, rgb_color color); - OBAppServerScreen *winscreen; - -protected: - // Original screen info - uint32 old_space; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/DisplayDriver.cpp b/src/servers/app/proto4/DisplayDriver.cpp deleted file mode 100644 index 75e8f9bd60..0000000000 --- a/src/servers/app/proto4/DisplayDriver.cpp +++ /dev/null @@ -1,230 +0,0 @@ -/* - DisplayDriver.cpp - Modular class to allow the server to not care what the ultimate output is - for graphics calls. -*/ -#include "DisplayDriver.h" -#include "ServerCursor.h" - -DisplayDriver::DisplayDriver(void) -{ - is_initialized=false; - cursor_visible=false; - show_on_move=false; - locker=new BLocker(); - - penpos.Set(0,0); - pensize=0.0; - - // initialize to BView defaults - highcol.red=0; - highcol.green=0; - highcol.blue=0; - highcol.alpha=0; - lowcol.red=255; - lowcol.green=255; - lowcol.blue=255; - lowcol.alpha=255; -} - -DisplayDriver::~DisplayDriver(void) -{ - delete locker; -} - -void DisplayDriver::Initialize(void) -{ // Loading loop to find proper driver or other setup for the driver -} - -bool DisplayDriver::IsInitialized(void) -{ // Let us know whether things worked out ok - return is_initialized; -} - -void DisplayDriver::Shutdown(void) -{ // For use by subclasses -} - -void DisplayDriver::SafeMode(void) -{ // Set video mode to 640x480x256 mode -} - -void DisplayDriver::Reset(void) -{ // Intended to reload and restart driver. Defaults to a safe mode -} - -void DisplayDriver::Clear(uint8 red,uint8 green,uint8 blue) -{ -} - -void DisplayDriver::Clear(rgb_color col) -{ -} - -void DisplayDriver::SetScreen(uint32 space) -{ // Set the screen to a particular mode -} - -int32 DisplayDriver::GetHeight(void) -{ // Gets the height of the current mode - return ginfo->height; -} - -int32 DisplayDriver::GetWidth(void) -{ // Gets the width of the current mode - return ginfo->width; -} - -int DisplayDriver::GetDepth(void) -{ // Gets the color depth of the current mode - return ginfo->bytes_per_row; -} - -void DisplayDriver::Blit(BPoint dest, ServerBitmap *sourcebmp, ServerBitmap *destbmp) -{ // Screen-to-screen bitmap copying -} - -void DisplayDriver::DrawBitmap(ServerBitmap *bitmap) -{ -} - -void DisplayDriver::DrawChar(char c, BPoint point) -{ -} - -void DisplayDriver::DrawString(char *string, int length, BPoint point) -{ -} - -void DisplayDriver::FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern) -{ -} - -void DisplayDriver::FillBezier(BPoint *points, uint8 *pattern) -{ -} - -void DisplayDriver::FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern) -{ -} - -void DisplayDriver::FillPolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void DisplayDriver::FillRect(BRect rect, uint8 *pattern) -{ -} - -void DisplayDriver::FillRegion(BRegion *region) -{ -} - -void DisplayDriver::FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ -} - -void DisplayDriver::FillShape(BShape *shape) -{ -} - -void DisplayDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ -} - -void DisplayDriver::HideCursor(void) -{ -} - -bool DisplayDriver::IsCursorHidden(void) -{ - return false; -} - -void DisplayDriver::ObscureCursor(void) -{ // Hides cursor until mouse is moved -} - -void DisplayDriver::MoveCursorTo(float x, float y) -{ -} - -void DisplayDriver::MovePenTo(BPoint pt) -{ // Moves the graphics pen to this position -} - -BPoint DisplayDriver::PenPosition(void) -{ - return penpos; -} - -float DisplayDriver::PenSize(void) -{ - return pensize; -} - -void DisplayDriver::SetCursor(ServerCursor *cursor) -{ -} - -void DisplayDriver::SetCursor(int32 value) -{ // This is used just to provide an easy way of setting one of the default cursors - // Then again, I may just get rid of this thing. -} - -void DisplayDriver::SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ -} - -void DisplayDriver::SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ -} - -void DisplayDriver::SetPenSize(float size) -{ -} - -void DisplayDriver::SetPixel(int x, int y, uint8 *pattern) -{ // Internal function utilized by other functions to draw to the buffer - // Will eventually be an inline function -} - -void DisplayDriver::ShowCursor(void) -{ -} - -void DisplayDriver::StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeBezier(BPoint *points, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern) -{ -} - -void DisplayDriver::StrokeLine(BPoint point, uint8 *pattern) -{ -} - -void DisplayDriver::StrokePolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void DisplayDriver::StrokeRect(BRect rect, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeShape(BShape *shape) -{ -} - -void DisplayDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ -} diff --git a/src/servers/app/proto4/DisplayDriver.h b/src/servers/app/proto4/DisplayDriver.h deleted file mode 100644 index 3552e0a0d9..0000000000 --- a/src/servers/app/proto4/DisplayDriver.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef _GFX_DRIVER_H_ -#define _GFX_DRIVER_H_ - -#include -#include -#include -#include "Desktop.h" - -class ServerBitmap; -class ServerCursor; - -#ifndef ROUND - #define ROUND(a) ( (a-long(a))>=.5)?(long(a)+1):(long(a)) -#endif - -typedef struct -{ - uchar *xormask, *andmask; - int32 width, height; - int32 hotx, hoty; - -} cursor_data; - -#ifndef HOOK_DEFINE_CURSOR - -#define HOOK_DEFINE_CURSOR 0 -#define HOOK_MOVE_CURSOR 1 -#define HOOK_SHOW_CURSOR 2 -#define HOOK_DRAW_LINE_8BIT 3 -#define HOOK_DRAW_LINE_16BIT 12 -#define HOOK_DRAW_LINE_32BIT 4 -#define HOOK_DRAW_RECT_8BIT 5 -#define HOOK_DRAW_RECT_16BIT 13 -#define HOOK_DRAW_RECT_32BIT 6 -#define HOOK_BLIT 7 -#define HOOK_DRAW_ARRAY_8BIT 8 -#define HOOK_DRAW_ARRAY_16BIT 14 // Not implemented in current R5 drivers -#define HOOK_DRAW_ARRAY_32BIT 9 -#define HOOK_SYNC 10 -#define HOOK_INVERT_RECT 11 - -#endif - -class ServerCursor; - -class DisplayDriver -{ -public: - DisplayDriver(void); - virtual ~DisplayDriver(void); - - virtual void Initialize(void); // Sets the driver - virtual bool IsInitialized(void); - virtual void Shutdown(void); // You never know when you'll need this - - virtual void SafeMode(void); // Easy-access functions for common tasks - virtual void Reset(void); - virtual void Clear(uint8 red,uint8 green,uint8 blue); - virtual void Clear(rgb_color col); - - // Settings functions - virtual void SetScreen(uint32 space); - virtual int32 GetHeight(void); - virtual int32 GetWidth(void); - virtual int GetDepth(void); - - // Drawing functions - virtual void Blit(BPoint dest, ServerBitmap *src, ServerBitmap *dest); - virtual void DrawBitmap(ServerBitmap *bitmap); - virtual void DrawChar(char c, BPoint point); - virtual void DrawString(char *string, int length, BPoint point); - - virtual void FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void FillBezier(BPoint *points, uint8 *pattern); - virtual void FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void FillPolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void FillRect(BRect rect, uint8 *pattern); - virtual void FillRegion(BRegion *region); - virtual void FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void FillShape(BShape *shape); - virtual void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - -// virtual void GetBlendingMode(source_alpha *srcmode, alpha_function *funcmode); -// virtual drawing_mode GetDrawingMode(void); - virtual void HideCursor(void); - virtual bool IsCursorHidden(void); - virtual void MoveCursorTo(float x, float y); - virtual void MovePenTo(BPoint pt); - virtual void ObscureCursor(void); - virtual BPoint PenPosition(void); - virtual float PenSize(void); -// virtual void SetBlendingMode(source_alpha srcmode, alpha_function funcmode); - virtual void SetCursor(int32 value); - virtual void SetCursor(ServerCursor *cursor); -// virtual void SetDrawingMode(drawing_mode mode); - virtual void ShowCursor(void); - virtual void SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetPenSize(float size); - virtual void SetPixel(int x, int y, uint8 *pattern); - - virtual void StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void StrokeBezier(BPoint *points, uint8 *pattern); - virtual void StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void StrokeLine(BPoint point, uint8 *pattern); - virtual void StrokePolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void StrokeRect(BRect rect,uint8 *pattern); - virtual void StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void StrokeShape(BShape *shape); - virtual void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - - graphics_card_hook ghooks[48]; - graphics_card_info *ginfo; - -protected: - bool is_initialized, cursor_visible, show_on_move; - ServerCursor *current_cursor; - BLocker *locker; - rgb_color highcol, lowcol; - BPoint penpos; - float pensize; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/Globals.h b/src/servers/app/proto4/Globals.h deleted file mode 100644 index 2753cad1aa..0000000000 --- a/src/servers/app/proto4/Globals.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _SERVER_GLOBALS_H_ -#define _SERVER_GLOBALS_H_ - -#include -BList *gBitmaplist, *gLayerlist; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/Layer.cpp b/src/servers/app/proto4/Layer.cpp deleted file mode 100644 index 4be5bbfae2..0000000000 --- a/src/servers/app/proto4/Layer.cpp +++ /dev/null @@ -1,281 +0,0 @@ -/* - Layer.cpp: - -*/ -#include -#include -#include "ServerWindow.h" -#include "Layer.h" - -Layer::Layer(ServerWindow *Win, const char *Name, Layer *Parent, - BRect &Frame, int32 Flags) -{ - Initialize(); - flags=Flags; - frame=Frame; - if(Name!=NULL) - { - name=new char[strlen(Name)]; - cout << "Layer::Layer name=" << strcpy((char *)name, Name) << endl; - } - else - name=NULL; - if(Parent!=NULL) - Parent->AddChild(this); -} - -Layer::~Layer(void) -{ -} - -void Layer::Initialize(void) -{ - visible=NULL; - full=NULL; - update=NULL; - high.red=255; high.green=255; high.blue=255; high.alpha=255; - low.red=255; low.green=255; low.blue=255; low.alpha=255; - erase.red=255; erase.green=255; erase.blue=255; erase.alpha=255; - drawingmode=B_OP_COPY; - parent=NULL; - uppersibling=NULL; - lowersibling=NULL; - topchild=NULL; - bottomchild=NULL; - hidecount=0; -} - -void Layer::AddChild(Layer *child, bool topmost=true) -{ - // If we don't have any children, simply add the thing. - if (bottomchild==NULL && topchild==NULL) - { - bottomchild=child; - topchild=child; - child->lowersibling=NULL; - child->uppersibling=NULL; - } - else - { - if (topmost) - { - // "Move" the top child if there is one already and add to the - // top of the tree - if (topchild!=NULL) - topchild->uppersibling = child; - - topchild=child; - child->uppersibling= NULL; - child->lowersibling = topchild; - } - else - { - // Add layer to bottom of tree unless there are no other - // children - Layer *lay=bottomchild; - if (lay!=NULL) - { - child->uppersibling=lay; - child->lowersibling=lay->lowersibling; - lay->lowersibling=child; - - if(child->lowersibling!=NULL) - child->lowersibling->uppersibling=child; - else - bottomchild=child; - } - else - { - topchild=child; - topchild->uppersibling=child; - child->lowersibling=topchild; - child->uppersibling=NULL; - } - } - } - child->parent = this; - child->SetAddedData(hidecount); -} - -void Layer::RemoveChild(Layer *child) -{ - if(child->parent!=this) - { - cout << "DEBUG: attempt to remove a non-child layer\n" << endl; - return; - } - - if (child==bottomchild) - bottomchild=child->uppersibling; - - if (child==bottomchild) - bottomchild=child->uppersibling; - - if (child->lowersibling!=NULL) - child->lowersibling->uppersibling=child->uppersibling; - - if (child->uppersibling!=NULL) - child->uppersibling->lowersibling=child->lowersibling; - - child->parent=NULL; - child->lowersibling=NULL; - child->uppersibling=NULL; -} - -void Layer::RemoveSelf(void) -{ - if (parent!=NULL) - parent->RemoveChild(this); -} - -void Layer::SetAddedData(uint8 count) -{ - hidecount+=count; - Layer *lay; - for (lay=topchild; lay!=NULL; lay=lay->lowersibling) - lay->SetAddedData(count); -} - -void Layer::Show(void) -{ - hidecount--; - if(hidecount==0) - SetDirty(true); -} - -void Layer::Hide(void) -{ - if(parent==NULL) - { - cout << "DEBUG: attempt to hide an orphan layer" << endl; - return; - } - if(hidecount==0) - { - // Invalidate any sibling layers when this gets hidden so that - // we see what's left. This is a slower way to do things, but it - // works - Layer *sibling; - for (sibling=parent->bottomchild; sibling!=NULL; sibling=sibling->uppersibling) - { - if (sibling->frame.Intersects(frame)) - { - sibling->MarkModified(frame & sibling->frame); - } - } - - // Hide all child layers - Layer *child; - for (child=topchild; child!=NULL; child=child->lowersibling) - { - child->Hide(); - } - } - hidecount++; -} - -bool Layer::IsVisible(void) -{ - return (hidecount==0)?true:false; -} - -void Layer::Update(bool ForceUpdate) -{ -} - -void Layer::SetFrame(const BRect &Rect) -{ -} - -BRect Layer::Frame(void) -{ - return frame; -} - -BRect Layer::Bounds(void) -{ - BRect r=frame; - r.OffsetTo(0,0); - return r; -} - -void Layer::Invalidate(const BRect &rect) -{ - if (hidecount==0) - { - if (update==NULL) - update=new BRegion(rect); - else - update->Include(rect); - } -} - -// Invalidates the entire layer, possibly including the child layers -void Layer::Invalidate(bool recursive) -{ - if (hidecount==0) - { - delete update; - update = new BRegion(frame); - - if (recursive) - { - for (Layer *lay=bottomchild; lay!=NULL; lay=lay->uppersibling) - lay->Invalidate(true); - } - } -} - -// This invalidates the layer and all its child layers -void Layer::SetDirty(bool flag) -{ - isdirty=flag; - - Layer *lay; - for (lay=bottomchild; lay!=NULL; lay=lay->uppersibling ) - { - lay->SetDirty(flag); - } -} - -void Layer::AddRegion(BRegion *Region) -{ -} - -void Layer::RemoveRegions(void) -{ -/* delete visible; - delete full; - delete update; - - visible=NULL; - full=NULL; - update=NULL; - - Layer *lay; - for (lay=topchild; lay!=NULL; lay=lay->lowersibling ) - lay->DeleteRegions(); -*/ -} - -void Layer::UpdateRegions(bool ForceUpdate=true, bool Root=true) -{ -} - -void Layer::MarkModified(BRect rect) -{ - if (frame.Intersects(rect)) - { - BRect r=rect & frame; - isdirty=true; - - Layer* lay; - for (lay=bottomchild; lay!=NULL; lay=lay->uppersibling ) - lay->MarkModified(r); - } -} - -// virtual function to be defined by child classes -void Layer::Draw(const BRect &Rect) -{ -} diff --git a/src/servers/app/proto4/Layer.h b/src/servers/app/proto4/Layer.h deleted file mode 100644 index edcbd26eeb..0000000000 --- a/src/servers/app/proto4/Layer.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef _LAYER_H_ -#define _LAYER_H_ - -#include -#include -#include - -class ServerWindow; - -class Layer -{ -public: - Layer(ServerWindow *Win, const char *Name, Layer *Parent, BRect &Frame, int32 Flags); - virtual ~Layer(void); - - void Initialize(void); - void Show(void); - void Hide(void); - bool IsVisible(void); - void Update(bool ForceUpdate); - - void AddChild(Layer *child, bool topmost=true); - void RemoveChild(Layer *child); - void RemoveSelf(void); - void SetAddedData(uint8 count); - - virtual void SetFrame(const BRect &Rect); - BRect Frame(void); - BRect Bounds(void); - - void Invalidate(const BRect &rect); - void Invalidate(bool recursive); - void AddRegion(BRegion *Region); - void RemoveRegions(void); - void UpdateRegions(bool ForceUpdate=true, bool Root=true); - void SetDirty(bool flag); - void MarkModified(BRect rect); - - // Render functions: - virtual void Draw(const BRect &Rect); - - const char *name; - int32 handle; - ServerWindow *window; // Window associated with this. NULL for background layer - - BRect frame; - - BRegion *visible, // Everything currently visible - *full, // The complete region - *update; // Area to be updated at next redraw - - int32 flags; // Various flags for behavior - uint8 hidecount; // tracks the number of hide calls - bool isdirty; // has regions which are invalid - - // The whole set of layers is actually a tree - Layer *topchild, *bottomchild; - Layer *uppersibling, *lowersibling; - Layer *parent; - - // Render state: - BPoint penpos; - rgb_color high, low, erase; - - int32 drawingmode; -}; - -#endif diff --git a/src/servers/app/proto4/PortLink.cpp b/src/servers/app/proto4/PortLink.cpp deleted file mode 100644 index 8fba724569..0000000000 --- a/src/servers/app/proto4/PortLink.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/* - PortLink.cpp: - A helper class for port-based messaging - ------------------------------------------------------------------------- -How it works: - The class utilizes a fixed-size array of PortLinkData object pointers. When -data is attached, a new PortLinkData object is allocated and a copy of the -passed data is created inside it. When the time comes for the message to be sent, -the data is pieced together into a flattened array and written to the port. ------------------------------------------------------------------------- -Data members: - -*attachments[] - fixed-size array of pointers used to hold the attached data -opcode - message value which is sent along with any data -target - port to which the message is sent when Flush() is called -replyport - port used with synchronous messaging - FlushWithReply() -bufferlength - total bytes taken up by attachments -num_attachments - internal variable which is used to track which "slot" - will be the next one to receive an attachment object -*/ - -#include "PortLink.h" -#include -#include -#include - -//#define PLDEBUG - -// Internal data storage class for holding attached data whilst it is waiting -// to be Flattened() and then Flushed(). There is no need for this to be called outside -// the PortLink class. -class PortLinkData -{ -public: - PortLinkData(void); - ~PortLinkData(void); - bool Set(void *data, size_t size); - char *buffer; - size_t buffersize; -}; - -PortLink::PortLink(port_id port) -{ - // For this class to be useful (and to prevent a lot of init problems) - // we require a port in the constructor - target=port; - - // We start out without any data attached to the port message - num_attachments=0; - opcode=0; - bufferlength=0; - replyport=create_port(30,"PortLink reply port"); -} - -PortLink::~PortLink(void) -{ - // If, for some odd reason, this is deleted with something attached, - // free the memory used by the attachments. We do not flush the queue - // because the port may no longer be valid in cases such as the app - // is in the process of quitting - MakeEmpty(); -} - -void PortLink::SetOpCode(int32 code) -{ - // Sets the message code. This does not change once the message is sent. - // Another call to SetOpCode() is required for such things. - opcode=code; -} - -void PortLink::SetPort(port_id port) -{ - // Sets the target port. While not necessary in most uses, this exists - // mostly to prevent flexibility problems - target=port; -} - -port_id PortLink::GetPort(void) -{ - // Simply returns the port at which the object is pointed. - return target; -} - -void PortLink::Flush(bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message off to the target, complete with attachments. NOTE: - // the recipient must delete all attachments, being the PortLink object assumes - // no responsiblity for the attachments once the message is sent. - int8 *msgbuffer; - int32 size; - - if(num_attachments>0) - { - FlattenData(&msgbuffer,&size); - - // Dump message to port, reset attachments, and clean up - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,msgbuffer,size,B_TIMEOUT, timeout); - else - write_port(target,opcode,msgbuffer,size); - MakeEmpty(); - } - else - { - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,NULL,0,B_TIMEOUT, timeout); - else - write_port(target,opcode,NULL,0); - } -} - -int8* PortLink::FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message to the target and then waits for a reply. The target will - // receive a message with the first item being the port_id to reply to. - // NOTE: like Flush(), any attached data must be deleted. - - // Effectively, an Attach() call inlined for changes - - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - { - *status=B_ERROR; - return NULL; - } - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&replyport,sizeof(port_id))) - { - bufferlength+=sizeof(port_id); - } - else - { - delete pld; - *status=B_ERROR; - return NULL; - } - - // Flatten() inlined to make some necessary changes - int8 *buffer=new int8[bufferlength]; - int8 *bufferindex=buffer; - size_t size=0; - - // attach our port_id first - memcpy(bufferindex, pld->buffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - - // attach everything else - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - } - - // Flush the thing....FOOSH! :P - write_port(target,opcode,buffer,size); - MakeEmpty(); - delete buffer; - - // Now we wait for the reply - if(timeout==B_INFINITE_TIMEOUT) - { - *buffersize=port_buffer_size(replyport); - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - else - { - *buffersize=port_buffer_size_etc(replyport,0,timeout); - if(*buffersize==B_TIMED_OUT) - { - *status=*buffersize; - return NULL; - } - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - - // We got this far, so we apparently have some data - *status=B_OK; - return buffer; -} - -void PortLink::Attach(void *data, size_t size) -{ - // This is the member called to attach data to a message. Attachments are - // treated to be in 'Append' mode, tacking on each attached piece of data - // to the end of the list. - - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - if(size==0) - return; - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -// These functions were added for a major convenience in passing common types -// Eventually, I'd like to templatize these, but for now, this'll do - -void PortLink::Attach(int32 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int32); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int16 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int16); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int8 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int8); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(float data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(float); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(bool data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(bool); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BRect data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BRect); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BPoint data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BPoint); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::FlattenData(int8 **buffer,int32 *size) -{ - // This function is where all the magic happens, but it is strictly internal. - // It iterates through each PortLinkData object and copies it to the main buffer - // which ends up, ultimately, being written to the PortLink's target port. - - // skip if there aree no attachments - if(bufferlength<1) - return; - - *buffer=new int8[bufferlength]; - int8 *bufferindex=*buffer; - PortLinkData *pld; - *size=0; - - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - *size+=pld->buffersize; - } -} - -void PortLink::MakeEmpty(void) -{ - // Nukes all the attachments currently held by the PortLink class - if(num_attachments!=0) - { - for(int i=0; i0) - free(buffer); -} - -bool PortLinkData::Set(void *data, size_t size) -{ - // Function copies the passed to the internal buffers for storage - if(size>0 && buffersize==0 && data!=NULL) - { - buffer=(char *)malloc(size); - if(buffer==NULL) - return false; - memcpy(buffer, data, size); - buffersize=size; - return true; - } - return false; -} diff --git a/src/servers/app/proto4/PortLink.h b/src/servers/app/proto4/PortLink.h deleted file mode 100644 index 9f5432daab..0000000000 --- a/src/servers/app/proto4/PortLink.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _PORTLINK_H_ -#define _PORTLINK_H_ - -#include -#include -#include -#include - -#ifndef _PORTLINK_BUFFERSIZE -#define _PORTLINK_MAX_ATTACHMENTS 50 -#endif - -class PortLinkData; - -class PortLink -{ -public: - PortLink(port_id port); - ~PortLink(void); - void SetOpCode(int32 code); - void SetPort(port_id port); - port_id GetPort(void); - void Flush(bigtime_t timeout=B_INFINITE_TIMEOUT); - int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, - bigtime_t timeout=B_INFINITE_TIMEOUT); - void Attach(void *data, size_t size); - void Attach(int32 data); - void Attach(int16 data); - void Attach(int8 data); - void Attach(float data); - void Attach(bool data); - void Attach(BRect data); - void Attach(BPoint data); - void MakeEmpty(void); -protected: - void FlattenData(int8 **buffer,int32 *size); - port_id target, replyport; - int32 opcode, bufferlength; - int num_attachments; - PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS]; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/README b/src/servers/app/proto4/README deleted file mode 100644 index 0a1e3bb834..0000000000 --- a/src/servers/app/proto4/README +++ /dev/null @@ -1,9 +0,0 @@ -OpenBeOS App Server Test Prototype #4 - -This prototype is an extension of the third one, where the TestApp has become a test bed for graphics functions. The graphics-access object used, ViewDriver, has most of the useful BView calls implemented and tested. Such was necessary to proceed to the next steps. The functions not implemented were not done either because it was way too much work or simply not possible to do with the current test application. They will have to wait until BView is done. In any event, not bad for 2 weeks' work. - -This is an example of both a work in progress and a lot of research at the same time. Many of the concepts used in this prototype will be used in the real server. It doesn't do much, but the fact that it exists and does what it does is the result of a *lot* of work. - -The code is reasonably (IMHO) well-commented and should be easy to understand at first glance. Also included are some extra files which I didn't feel like throwing out or are in place for future development. ;D Enjoy. - ---DarkWyrm \ No newline at end of file diff --git a/src/servers/app/proto4/ServerApp.cpp b/src/servers/app/proto4/ServerApp.cpp deleted file mode 100644 index 87e9537b7c..0000000000 --- a/src/servers/app/proto4/ServerApp.cpp +++ /dev/null @@ -1,759 +0,0 @@ -/* - ServerApp.cpp - Class which works with a BApplication. Handles all messages coming - from and going to its application. -*/ -//#define DEBUG_SERVERAPP_MSGS -//#define DEBUG_SERVERAPP_CURSORS - -#include -#include -#include -#include "Desktop.h" -#include "DisplayDriver.h" -#include "ServerApp.h" -#include "ServerWindow.h" -#include "ServerBitmap.h" -#include "ServerProtocol.h" -#include "ServerCursor.h" -#include "PortLink.h" -#include -#include -#include -#include "DebugTools.h" - -ServerApp::ServerApp(port_id msgport, char *signature) -{ - // need to copy the signature because the message buffer - // owns the copy which we are passed as a parameter. - if(signature) - { - app_sig=new char[strlen(signature)]; - sprintf(app_sig,signature); - } - else - { - app_sig=new char[strlen("Application")]; - sprintf(app_sig,"Application"); - } - - // sender is the monitored app's event port - sender=msgport; - applink=new PortLink(sender); - - // receiver is the port to which the app sends messages for the server - receiver=create_port(30,app_sig); - //printf("ServerApp port for app %s is at %ld\n",app_sig,receiver); - if(receiver==B_NO_MORE_PORTS) - { - // uh-oh. We have a serious problem. Tell the app to quit - applink->SetOpCode(B_QUIT_REQUESTED); - applink->Flush(); - } - else - { - // Everything checks out, so tell the application - // where to send future messages - applink->SetOpCode(SET_SERVER_PORT); - applink->Attach(&receiver,sizeof(port_id)); - applink->Flush(); - } - winlist=new BList(0); - bmplist=new BList(0); - driver=get_gfxdriver(); - isactive=false; - cursor=new ServerCursor(); - - // This exists for testing the graphics access module and will disappear - // when layers are implemented - high.red=255; - high.green=255; - high.blue=255; - high.alpha=255; - low.red=0; - low.green=0; - low.blue=0; - low.alpha=255; -} - -ServerApp::~ServerApp(void) -{ - int32 i; - ServerWindow *tempwin; - for(i=0;iCountItems();i++) - { - tempwin=(ServerWindow*)winlist->ItemAt(i); - delete tempwin; - } - winlist->MakeEmpty(); - delete winlist; - - ServerBitmap *tempbmp; - for(i=0;iCountItems();i++) - { - tempbmp=(ServerBitmap*)bmplist->ItemAt(i); - delete tempbmp; - } - bmplist->MakeEmpty(); - delete bmplist; - - delete app_sig; - delete applink; - delete cursor; -} - -bool ServerApp::Run(void) -{ - // Unlike a BApplication, a ServerApp is *supposed* to return immediately - // when its Run function is called. - monitor_thread=spawn_thread(MonitorApp,app_sig,B_NORMAL_PRIORITY,this); - if(monitor_thread==B_NO_MORE_THREADS || monitor_thread==B_NO_MEMORY) - return false; - resume_thread(monitor_thread); - return true; -} - -int32 ServerApp::MonitorApp(void *data) -{ - ServerApp *app=(ServerApp *)data; - app->Loop(); - exit_thread(0); - return 0; -} - -void ServerApp::Loop(void) -{ - // Message-dispatching loop for the ServerApp - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(receiver); - - if(buffersize>0) - { - // buffers are PortLink messages. Allocate necessary buffer and - // we'll cast it as a BMessage. - msgbuffer=new int8[buffersize]; - bytesread=read_port(receiver,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(receiver,&msgcode,NULL,0); - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { -// -------------- Messages received from the Application ------------------ - case B_QUIT_REQUESTED: - { - // 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) - { - printf("PANIC: ServerApp %s could not find the app_server port!\n",app_sig); - break; - } - - applink->SetPort(serverport); - applink->SetOpCode(DELETE_APP); - applink->Attach(&monitor_thread,sizeof(thread_id)); - applink->Flush(); - break; - } - case CREATE_WINDOW: - case DELETE_WINDOW: - case SHOW_CURSOR: - case HIDE_CURSOR: - case OBSCURE_CURSOR: - case SET_CURSOR_BCURSOR: - case SET_CURSOR_DATA: - case SET_CURSOR_BBITMAP: - case GFX_MOVEPENBY: - case GFX_MOVEPENTO: - case GFX_SETPENSIZE: - case GFX_COUNT_WORKSPACES: - case GFX_SET_WORKSPACE_COUNT: - case GFX_CURRENT_WORKSPACE: - case GFX_ACTIVATE_WORKSPACE: - case GFX_SYSTEM_COLORS: - case GFX_SET_SCREEN_MODE: - case GFX_GET_SCROLLBAR_INFO: - case GFX_SET_SCROLLBAR_INFO: - case GFX_IDLE_TIME: - case GFX_SELECT_PRINTER_PANEL: - case GFX_ADD_PRINTER_PANEL: - case GFX_RUN_BE_ABOUT: - case GFX_SET_FOCUS_FOLLOWS_MOUSE: - case GFX_FOCUS_FOLLOWS_MOUSE: - - // Graphics messages - case GFX_SET_HIGH_COLOR: - case GFX_SET_LOW_COLOR: - case GFX_DRAW_STRING: - case GFX_SET_FONT_SIZE: - case GFX_STROKE_ARC: - case GFX_STROKE_BEZIER: - case GFX_STROKE_ELLIPSE: - case GFX_STROKE_LINE: - case GFX_STROKE_POLYGON: - case GFX_STROKE_RECT: - case GFX_STROKE_ROUNDRECT: - case GFX_STROKE_SHAPE: - case GFX_STROKE_TRIANGLE: - case GFX_FILL_ARC: - case GFX_FILL_BEZIER: - case GFX_FILL_ELLIPSE: - case GFX_FILL_POLYGON: - case GFX_FILL_RECT: - case GFX_FILL_REGION: - case GFX_FILL_ROUNDRECT: - case GFX_FILL_SHAPE: - case GFX_FILL_TRIANGLE: - DispatchMessage(msgcode, msgbuffer); - break; - -// -------------- 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. Eventually, this will be replaced by a - // BMessage - write_port(sender, msgcode, msgbuffer, buffersize); - break; - } - case QUIT_APP: - { - // This message is received from the app_server thread - // because the server was asked to quit. Thus, we - // ask all apps to quit. This is NOT the same as system - // shutdown and will happen only in testing - - //printf("ServerApp asking %s to quit\n",app_sig); - applink->SetOpCode(B_QUIT_REQUESTED); - applink->Flush(); - break; - } - default: - { -#ifdef DEBUG_SERVERAPP_MSGS -cout << "ServerApp received unrecognized code: "; -TranslateMessageCodeToStream(msgcode); -cout << endl << flush; -#endif - break; - } - } - - } - - if(buffersize>0) - delete msgbuffer; - - if(msgcode==B_QUIT_REQUESTED) - break; - } -} - -void ServerApp::DispatchMessage(int32 code, int8 *buffer) -{ -#ifdef DEBUG_SERVERAPP_MSGS -cout << "ServerApp Message: "; -TranslateMessageCodeToStream(code); -cout << endl << flush; -#endif - -int8 *index=buffer; - switch(code) - { - case CREATE_WINDOW: - { - // Attached data - // - break; - } - case DELETE_WINDOW: - { - // Attached data - break; - } - case GFX_SET_SCREEN_MODE: - { - // Attached data - // 1) int32 workspace # - // 2) uint32 screen mode - // 3) bool make default - int32 workspace=*((int32*)index); index+=sizeof(int32); - uint32 mode=*((uint32*)index); index+=sizeof(uint32); - - SetScreenSpace(workspace,mode,*((bool*)index)); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: SetScreenMode(%ld,%lu,%s)\n",workspace, - mode,(*((bool*)index)==true)?"true":"false"); -#endif - break; - } - case GFX_ACTIVATE_WORKSPACE: - { - // Attached data - // 1) int32 workspace index - ActivateWorkspace(*((int32*)index)); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: ActivateWorkspace(%ld)\n",*((int32*)index)); -#endif - break; - } - case SHOW_CURSOR: - { - driver->ShowCursor(); - break; - } - case HIDE_CURSOR: - { - driver->HideCursor(); - break; - } - case OBSCURE_CURSOR: - { - driver->ObscureCursor(); - break; - } - case SET_CURSOR_DATA: - { - // Attached data: 68 bytes of cursor data - - // Get the data, update the app's cursor, and update the - // app's cursor if active. - int8 cdata[68]; - memcpy(cdata, buffer, 68); - cursor->SetCursor(cdata); - driver->SetCursor(cursor); -#ifdef DEBUG_SERVERAPP_CURSOR -printf("ServerApp: SetCursor(%d,%d,%d,%d)\n",r,g,b,a); -#endif - break; - } - case SET_CURSOR_BCURSOR: - // Not yet implemented - break; - - case SET_CURSOR_BBITMAP: - // Not yet implemented - break; - - // Graphics messages - case GFX_SET_HIGH_COLOR: - { - // Attached data: - // 1) uint8 red - // 2) uint8 green - // 3) uint8 blue - // 4) uint8 alpha - - uint8 r,g,b,a; - r=*((uint8*)index); index+=sizeof(uint8); - g=*((uint8*)index); index+=sizeof(uint8); - b=*((uint8*)index); index+=sizeof(uint8); - a=*((uint8*)index); - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: SetHighColor(%d,%d,%d,%d)\n",r,g,b,a); -#endif - driver->SetHighColor(r,g,b,a); - break; - } - case GFX_SET_LOW_COLOR: - { - // Attached data: - // 1) uint8 red - // 2) uint8 green - // 3) uint8 blue - // 4) uint8 alpha - - uint8 r,g,b,a; - r=*((uint8*)index); index+=sizeof(uint8); - g=*((uint8*)index); index+=sizeof(uint8); - b=*((uint8*)index); index+=sizeof(uint8); - a=*((uint8*)index); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: SetHighColor(%d,%d,%d,%d)\n",r,g,b,a); -#endif - driver->SetLowColor(r,g,b,a); - break; - } - case GFX_MOVEPENBY: - { - // Attached data: - // 1) BPoint pt - - // Default functionality is MoveTo, so get the current position - // from the driver and compensate - BPoint *ptindex,passed_pt; - - ptindex=(BPoint*)index; - passed_pt=driver->PenPosition(); - passed_pt+=*ptindex; -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp MovePenBy: (%f,%f)\n",ptindex->x,ptindex->y); -printf("Pen moved to (%f,%f)\n",passed_pt.x,passed_pt.y); -#endif - driver->MovePenTo(passed_pt); - break; - } - case GFX_MOVEPENTO: - { - // Attached data: - // 1) BPoint pt - BPoint *pt; - pt=(BPoint*)index; -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp MovePenTo: (%f,%f)\n",pt->x,pt->y); -#endif - driver->MovePenTo(*pt); - break; - } - case GFX_SETPENSIZE: - { - // Attached data: - // 1) float pen size -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp SetPenSize(%f)\n",*((float*)index)); -#endif - driver->SetPenSize(*((float*)index)); - break; - } - case GFX_DRAW_STRING: - { - // Attached data: - // 1) uint16 string length - // 2) char * string - // 3) BPoint point - - uint16 length=*((uint16*)index); index+=sizeof(uint16); - char *string=new char[length]; - strcpy(string, (const char *)index); index+=length; - BPoint point=*((BPoint*)index); - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp DrawString(%s, %d, BPoint(%f,%f))\n",string,length,point.x,point.y); -#endif - driver->DrawString(string, length, point); - delete string; - break; - } - case GFX_SET_FONT_SIZE: - break; - case GFX_STROKE_ARC: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) float starting angle - // 6) float span (arc length in degrees) - // 7) uint8[8] pattern - float cx,cy,rx,ry,angle,span; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); - angle=*((float*)index); index+=sizeof(float); - span=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeArc: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("Angle, Span: %f,%f\n",angle, span); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeArc(cx,cy,rx,ry,angle,span,(uint8*)index); - break; - } - case GFX_STROKE_BEZIER: - { - // Attached data: - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BPoint #4 - // 5) uint8[8] pattern - -#ifdef DEBUG_SERVERAPP_MSGS -BPoint *pt=(BPoint*)index; -printf("ServerApp StrokeBezier:\n"); -printf("Point 1: "); pt[0].PrintToStream(); -printf("Point 2: "); pt[1].PrintToStream(); -printf("Point 3: "); pt[2].PrintToStream(); -printf("Point 4: "); pt[3].PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeBezier((BPoint*)index,(uint8*)(index+(sizeof(BPoint)*4))); - break; - } - case GFX_STROKE_ELLIPSE: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) uint8[8] pattern - float cx,cy,rx,ry; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeEllipse: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeEllipse(cx,cy,rx,ry,(uint8*)index); - break; - } - case GFX_STROKE_LINE: - { - // Attached data: - // 1) BPoint endpoint - // 2) uint8[8] pattern - BPoint *pt; - pt=(BPoint*)index; index+=sizeof(BPoint); - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeLineTo: (%f,%f)\n",pt->x,pt->y); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeLine(*pt,(uint8*)index); - break; - } - case GFX_STROKE_POLYGON: - break; - case GFX_STROKE_RECT: - { - // Attached data: - // 1) BRect rect - // 2) uint8[8] pattern - BRect rect; - rect=*((BRect*)index); index+=sizeof(BRect); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeRect: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeRect(rect, (uint8*)index); - break; - } - case GFX_STROKE_ROUNDRECT: - { - // Attached data: - // 1) BRect rect - // 2) float x_radius - // 3) float y_radius - // 4) uint8[8] pattern - BRect rect; - float x,y; - - rect=*((BRect*)index); index+=sizeof(BRect); - x=*((float*)index); index+=sizeof(float); - y=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeRoundRect: "); rect.PrintToStream(); -printf("Radii: %f,%f\n",x,y); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeRoundRect(rect, x,y,(uint8*)index); - break; - } - case GFX_STROKE_SHAPE: - break; - case GFX_STROKE_TRIANGLE: - { - // Attached data - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BRect invalid rect - // 5) uint8[8] pattern - BPoint pt1,pt2,pt3; - BRect rect; - pt1=*((BPoint*)index); index+=sizeof(BPoint); - pt2=*((BPoint*)index); index+=sizeof(BPoint); - pt3=*((BPoint*)index); index+=sizeof(BPoint); - rect=*((BRect*)index); index+=sizeof(BRect); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeTriangle: "); -printf("Point 1: "); pt1.PrintToStream(); -printf("Point 2: "); pt2.PrintToStream(); -printf("Point 3: "); pt3.PrintToStream(); -printf("Rectangle: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeTriangle(pt1,pt2,pt3,rect,(uint8*)index); - break; - } - case GFX_FILL_ARC: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) float starting angle - // 6) float span (arc length in degrees) - // 7) uint8[8] pattern - float cx,cy,rx,ry,angle,span; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); - angle=*((float*)index); index+=sizeof(float); - span=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillArc: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("Angle, Span: %f,%f\n",angle, span); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillArc(cx,cy,rx,ry,angle,span,(uint8*)index); - break; - } - case GFX_FILL_BEZIER: - { - // Attached data: - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BPoint #4 - // 5) uint8[8] pattern - -#ifdef DEBUG_SERVERAPP_MSGS -BPoint *pt=(BPoint*)index; -printf("ServerApp FillBezier:\n"); -printf("Point 1: "); pt[0].PrintToStream(); -printf("Point 2: "); pt[1].PrintToStream(); -printf("Point 3: "); pt[2].PrintToStream(); -printf("Point 4: "); pt[3].PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillBezier((BPoint*)index,(uint8*)(index+(sizeof(BPoint)*4))); - break; - } - case GFX_FILL_ELLIPSE: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) uint8[8] pattern - float cx,cy,rx,ry; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillEllipse: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillEllipse(cx,cy,rx,ry,(uint8*)index); - break; - } - case GFX_FILL_POLYGON: - break; - case GFX_FILL_RECT: - { - // Attached data: - // 1) BRect rect - // 2) uint8[8] pattern - BRect rect; - rect=*((BRect*)index); index+=sizeof(BRect); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillRect: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillRect(rect, (uint8*)index); - break; - } - case GFX_FILL_REGION: - break; - case GFX_FILL_ROUNDRECT: - { - // Attached data: - // 1) BRect rect - // 2) float x_radius - // 3) float y_radius - // 4) uint8[8] pattern - BRect rect; - float x,y; - - rect=*((BRect*)index); index+=sizeof(BRect); - x=*((float*)index); index+=sizeof(float); - y=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillRoundRect: "); rect.PrintToStream(); -printf("Radii: %f,%f\n",x,y); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillRoundRect(rect, x,y,(uint8*)index); - break; - } - case GFX_FILL_SHAPE: - break; - case GFX_FILL_TRIANGLE: - { - // Attached data - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BRect invalid rect - // 5) uint8[8] pattern - BPoint pt1,pt2,pt3; - BRect rect; - pt1=*((BPoint*)index); index+=sizeof(BPoint); - pt2=*((BPoint*)index); index+=sizeof(BPoint); - pt3=*((BPoint*)index); index+=sizeof(BPoint); - rect=*((BRect*)index); index+=sizeof(BRect); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillTriangle: "); -printf("Point 1: "); pt1.PrintToStream(); -printf("Point 2: "); pt2.PrintToStream(); -printf("Point 3: "); pt3.PrintToStream(); -printf("Rectangle: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillTriangle(pt1,pt2,pt3,rect,(uint8*)index); - break; - } - default: - { -#ifdef DEBUG_SERVERAPP_MSGS -cout << "DispatchMessage::Unrecognized code: "; -TranslateMessageCodeToStream(code); -cout << endl << flush; -#endif - break; - } - } -} - -// Prevent any preprocessor problems in case I screw something up -#ifdef DEBUG_SERVERAPP_MSGS -#undef DEBUG_SERVERAPP_MSGS -#endif - -#ifdef DEBUG_SERVERAPP_CURSORS -#undef DEBUG_SERVERAPP_CURSORS -#endif diff --git a/src/servers/app/proto4/ServerApp.h b/src/servers/app/proto4/ServerApp.h deleted file mode 100644 index 3265d9d050..0000000000 --- a/src/servers/app/proto4/ServerApp.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef _SRVAPP_H_ -#define _SRVAPP_H_ - -#include -class BMessage; -class PortLink; -class BList; -class ServerCursor; -class DisplayDriver; - -class ServerApp -{ -public: - ServerApp(port_id msgport, char *signature); - ~ServerApp(void); - - bool Run(void); - static int32 MonitorApp(void *data); - void Loop(void); - void DispatchMessage(int32 code, int8 *buffer); - bool IsActive(void) { return isactive; } - void Activate(bool value) { isactive=value; } - - port_id sender,receiver; - char *app_sig; - thread_id monitor_thread; - PortLink *applink; - BList *winlist, *bmplist; - ServerCursor *cursor; - DisplayDriver *driver; - bool isactive; - rgb_color high, low; // just for testing until layers are implemented -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/ServerBitmap.cpp b/src/servers/app/proto4/ServerBitmap.cpp deleted file mode 100644 index b210a31c96..0000000000 --- a/src/servers/app/proto4/ServerBitmap.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/* - ServerBitmap.cpp - Bitmap class which is intended to provide an easy way to package all the - data associated with a picture. It's very low-level, so there's still - plenty to do when coding with 'em. Also, they're used to access draw on the - frame buffer in a relatively easy way, although it is currently unclear - whether this functionality will even be necessary. -*/ - -// These three includes for ServerBitmap(const char *path_to_image_file) only -#include -#include -#include - -#include -#include "ServerBitmap.h" -#include "Desktop.h" - -ServerBitmap::ServerBitmap(BRect rect,color_space space,int32 BytesPerLine=0) -{ - width=rect.IntegerWidth()+1; - height=rect.IntegerHeight()+1; - cspace=space; - is_vram=false; - is_area=false; - areaid=B_ERROR; - - HandleSpace(space, BytesPerLine); - buffer=new uint8[bytesperline*height]; - driver=get_gfxdriver(); -} - -ServerBitmap::ServerBitmap(int32 w,int32 h,color_space space,int32 BytesPerLine=0) -{ - width=w; - height=h; - cspace=space; - is_vram=false; - is_area=false; - areaid=B_ERROR; - - HandleSpace(space, BytesPerLine); - buffer=new uint8[bytesperline*height]; - driver=get_gfxdriver(); -} - -ServerBitmap::ServerBitmap(int32 w,int32 h,color_space space, area_id areaID, int32 BytesPerLine=0) -{ - // This version is used for holding BBitmaps as one of the undocumented BBitmap - // constructors allows - it creates an area on the server's side. - width=w; - height=h; - cspace=space; - is_vram=false; - is_area=true; - - HandleSpace(space, BytesPerLine); - area_info ainfo; - areaid=areaID; - get_area_info(areaid, &ainfo); - buffer=(uint8*)ainfo.address; - driver=get_gfxdriver(); -} - -ServerBitmap::ServerBitmap(void) -{ - // This version is obviously intended for use as an easy-access class for the - // frame buffer. AtheOS does it and it's small, so why not? Worst case, this - // can disappear if not necessary. - is_vram=true; - is_area=false; - areaid=B_ERROR; - UpdateSettings(); -} - -// This particular version is not intended for use except for testing purposes. -// It loads a BBitmap and copies it to the ServerBitmap. Probably will disappear -// when the *real* server is written -ServerBitmap::ServerBitmap(const char *path) -{ - BBitmap *bmp=BTranslationUtils::GetBitmap(path); - assert(bmp!=NULL); - - if(bmp==NULL) - { - width=0; - height=0; - cspace=B_NO_COLOR_SPACE; - bytesperline=0; - } - else - { - width=bmp->Bounds().IntegerWidth(); - height=bmp->Bounds().IntegerHeight(); - cspace=bmp->ColorSpace(); - bytesperline=bmp->BytesPerRow(); - buffer=new uint8[bmp->BitsLength()]; - memcpy(buffer,(void *)bmp->Bits(),bmp->BitsLength()); - } -} - -ServerBitmap::~ServerBitmap(void) -{ - if(!is_vram) - delete buffer; -} - -void ServerBitmap::UpdateSettings(void) -{ - // This is only used when the object is pointing to the frame buffer - driver=get_gfxdriver(); - bpp=driver->GetDepth(); - width=driver->GetWidth(); - height=driver->GetHeight(); -} - -void ServerBitmap::SetBuffer(void *buffer) -{ - buffer=(uint8 *)buffer; -} - -uint8 *ServerBitmap::Buffer(void) -{ - return buffer; -} - -void ServerBitmap::HandleSpace(color_space space, int32 BytesPerLine) -{ - // Function written to handle color space setup which is required - // by the two "normal" constructors - - // Big convoluted mess just to handle every color space and dword align - // the buffer - switch(space) - { - // Buffer is dword-aligned, so nothing need be done - // aside from allocate the memory - case B_RGB32: - case B_RGBA32: - case B_RGB32_BIG: - case B_RGBA32_BIG: - case B_UVL32: - case B_UVLA32: - case B_LAB32: - case B_LABA32: - case B_HSI32: - case B_HSIA32: - case B_HSV32: - case B_HSVA32: - case B_HLS32: - case B_HLSA32: - case B_CMY32: - case B_CMYA32: - case B_CMYK32: - - // 24-bit = 32-bit with extra 8 bits ignored - case B_RGB24_BIG: - case B_RGB24: - case B_LAB24: - case B_UVL24: - case B_HSI24: - case B_HSV24: - case B_HLS24: - case B_CMY24: - { - if(BytesPerLine<(width*4)) - bytesperline=width*4; - else - bytesperline=BytesPerLine; - bpp=32; - break; - } - // Calculate size and dword-align - - // 1-bit - case B_GRAY1: - { - int32 numbytes=width>>3; - if((width % 8) != 0) - numbytes++; - if(BytesPerLine -#include -#include -#include "DisplayDriver.h" - -class ServerBitmap -{ -public: - ServerBitmap(BRect rect,color_space space,int32 BytesPerLine=0); - ServerBitmap(int32 w,int32 h,color_space space,int32 BytesPerLine=0); - ServerBitmap(int32 w,int32 h,color_space space, area_id areaID, int32 BytesPerLine=0); - ServerBitmap(void); - ServerBitmap(const char *path); - ~ServerBitmap(void); - void UpdateSettings(void); - void SetBuffer(void *buffer); - uint8 *Buffer(void); - void SetArea(area_id ID); - area_id Area(void); - - int32 width,height; - int32 bytesperline; - color_space cspace; - int bpp; - -protected: - void HandleSpace(color_space space, int32 BytesPerLine); - DisplayDriver *driver; - bool is_vram,is_area; - area_id areaid; - uint8 *buffer; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/ServerCursor.cpp b/src/servers/app/proto4/ServerCursor.cpp deleted file mode 100644 index 7ff11d1ac0..0000000000 --- a/src/servers/app/proto4/ServerCursor.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - ServerCursor.cpp - This is the server-side class used to handle cursors. Note that it - will handle the R5 cursor API, but it will also handle taking a bitmap. - - ServerCursors are 32-bit. Eventually, we will be mapping colors to fit - when the set is called. - - This is new code, and there may be changes to the API before it settles - in. -*/ - -#include "ServerCursor.h" -#include "ServerBitmap.h" -#include -#include - -long pow2(int power) -{ - if(power==0) - return 1; - return long(2 << (power-1)); -} - -ServerCursor::ServerCursor(void) -{ - // For when an application is started. This will probably disappear once I - // get the stuff for default cursors established - is_initialized=false; - position.Set(0,0); -} - -ServerCursor::ServerCursor(ServerBitmap *bmp, ServerBitmap *cmask=NULL) -{ - // The OpenBeOS R1 API uses Bitmaps to create cursors - more flexibility that way. - is_initialized=false; - position.Set(0,0); - SetCursor(bmp); -} - -ServerCursor::ServerCursor(int8 *data) -{ - // For handling the idiot R5 API data format - is_initialized=false; - position.Set(0,0); - SetCursor(data); -} - -ServerCursor::~ServerCursor(void) -{ - if(is_initialized) - delete bitmap; -} - -void ServerCursor::SetCursor(int8 *data) -{ - // 68-byte array used in R5 for holding cursors. - // This API has serious problems and should be deprecated(but supported) - // in a future release, perhaps right after the first one - - if(is_initialized) - { - delete bitmap; - } - cspace=B_RGBA32; - - bitmap=new ServerBitmap(16,16,B_RGBA32); - width=16; - height=16; - bounds.Set(0,0,15,15); - - // Now that we have all the setup, we're going to map (for now) the cursor - // to RGBA32. Eventually, there will be support for 16 and 8-bit depths - uint32 black=0xFF000000, - white=0xFFFFFFFF, - *bmppos; - uint16 *cursorpos, *maskpos,cursorflip, maskflip, - cursorval, maskval; - uint8 i,j; - - cursorpos=(uint16*)(data+4); - maskpos=(uint16*)(data+36); - - // for each row in the cursor data - for(j=0;j<16;j++) - { - bmppos=(uint32*)(bitmap->Buffer()+ (j*bitmap->bytesperline) ); - - // On intel, our bytes end up swapped, so we must swap them back - cursorflip=(cursorpos[j] & 0xFF) << 8; - cursorflip |= (cursorpos[j] & 0xFF00) >> 8; - maskflip=(maskpos[j] & 0xFF) << 8; - maskflip |= (maskpos[j] & 0xFF00) >> 8; - - // for each column in each row of cursor data - for(i=0;i<16;i++) - { - // Get the values and dump them to the bitmap - cursorval=cursorflip & pow2(15-i); - maskval=maskflip & pow2(15-i); - bmppos[i]=((cursorval!=0)?black:white) & ((maskval>0)?0xFFFFFFFF:0x00FFFFFF); - } - } -} - -// Currently unimplemented -void ServerCursor::SetCursor(ServerBitmap *bmp, ServerBitmap *cmask=NULL) -{ -/* if(is_initialized) - delete bitmap; - cspace=bmp->cspace; - - bitmap=new ServerBitmap(bmp->width,bmp->height,cspace); - - width=bmp->width; - height=bmp->height; - bounds.Set(0,0,bmp->width-1,bmp->height-1); -*/ -} - -void ServerCursor::MoveTo(int32 x, int32 y) -{ - position.Set(x,y); -} diff --git a/src/servers/app/proto4/ServerCursor.h b/src/servers/app/proto4/ServerCursor.h deleted file mode 100644 index c7e7b13972..0000000000 --- a/src/servers/app/proto4/ServerCursor.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef _SERVER_SPRITE_H -#define _SERVER_SPRITE_H - -#include -#include - -class ServerBitmap; - -class ServerCursor -{ -public: - ServerCursor(ServerBitmap *bmp,ServerBitmap *cmask=NULL); - ServerCursor(int8 *data); - ServerCursor(void); - ~ServerCursor(void); - void MoveTo(int32 x, int32 y); - void SetCursor(int8 *data); - void SetCursor(ServerBitmap *bmp, ServerBitmap *cmask=NULL); - - ServerBitmap *bitmap; - - color_space cspace; - BRect bounds; - int width,height; - BPoint position,hotspot; - bool is_initialized; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/ServerProtocol.h b/src/servers/app/proto4/ServerProtocol.h deleted file mode 100644 index ab23ca2d10..0000000000 --- a/src/servers/app/proto4/ServerProtocol.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef _APPSERVER_PROTOCOL_ -#define _APPSERVER_PROTOCOL_ - -#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 QUIT_WINDOW 'srqw' - -#define SERVER_PORT_NAME "OBappserver" -#define SERVER_INPUT_PORT "OBinputport" - -#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 GFX_COUNT_WORKSPACES 'gcws' -#define GFX_SET_WORKSPACE_COUNT 'ggwc' -#define GFX_CURRENT_WORKSPACE 'ggcw' -#define GFX_ACTIVATE_WORKSPACE 'gaws' -#define GFX_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' - -#define GFX_SET_HIGH_COLOR 'gshc' -#define GFX_SET_LOW_COLOR 'gslc' - -#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' - -#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' - -#define GFX_MOVEPENBY 'gmpb' -#define GFX_MOVEPENTO 'gmpt' -#define GFX_SETPENSIZE 'gsps' - -#define GFX_DRAW_STRING 'gdst' -#define GFX_SET_FONT 'gsft' -#define GFX_SET_FONT_SIZE 'gsfs' -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/ServerSprite.cpp b/src/servers/app/proto4/ServerSprite.cpp deleted file mode 100644 index 915e487dd3..0000000000 --- a/src/servers/app/proto4/ServerSprite.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "ServerCursor.h" -#include "ServerBitmap.h" - -ServerCursor::ServerCursor(ServerBitmap *bmp) -{ -} - -ServerCursor::~ServerCursor(void) -{ -} - -ServerCursor::SetCursor(int8 *data) -{ - // 68-byte array used in R5 for holding cursors. - // This API has serious problems and should be deprecated(but supported) - // in a future release, perhaps the first one(?) -} - -void ServerCursor::SaveClientData(void) -{ -} - -void ServerCursor::MoveTo(int32 x, int32 y) -{ -} - -void ServerCursor::SetClient(ServerBitmap *bmp) -{ -} \ No newline at end of file diff --git a/src/servers/app/proto4/ServerWindow.cpp b/src/servers/app/proto4/ServerWindow.cpp deleted file mode 100644 index f8921ed8a2..0000000000 --- a/src/servers/app/proto4/ServerWindow.cpp +++ /dev/null @@ -1,210 +0,0 @@ -#include -#include -#include -#include -#include "PortLink.h" -#include "ServerWindow.h" -#include "ServerApp.h" -#include "ServerProtocol.h" - -ServerWindow::ServerWindow(const char *Title, uint32 Flags, uint32 Desktop, - const BRect &Rect, ServerApp *App, port_id SendPort) -{ - cout << "ServerWindow " << Title << endl; - - if(Title) - { - title=new char[strlen(Title)]; - sprintf((char *)title,Title); - } - else - { - title=new char[strlen("Window")]; - sprintf((char *)title,"Window"); - } - - // sender is the monitored app's event port - sender=SendPort; - winlink=new PortLink(sender); - - if(App!=NULL) - applink=new PortLink(App->receiver); - else - applink=NULL; - - // receiver is the port to which the app sends messages for the server - receiver=create_port(30,title); - - cout << "ServerWin port for window " << title << "is at " << (int32)receiver << endl; - if(receiver==B_NO_MORE_PORTS) - { - // uh-oh. We have a serious problem. Tell the app to quit - if(applink!=NULL) - { - applink->SetOpCode(B_QUIT_REQUESTED); - applink->Flush(); - } - } - else - { - // Everything checks out, so tell the application - // where to send future messages - winlink->SetOpCode(SET_SERVER_PORT); - winlink->Attach(&receiver,sizeof(port_id)); - winlink->Flush(); - } - active=false; - frame.Set(0,0,0,0); - hidecount=0; - - // Spawn our message monitoring thread - thread=spawn_thread(MonitorWin,title,B_NORMAL_PRIORITY,this); - if(thread!=B_NO_MORE_THREADS && thread!=B_NO_MEMORY) - resume_thread(thread); - -} - -ServerWindow::~ServerWindow(void) -{ - if(applink!=NULL) - delete applink; - delete title; - delete winlink; -} - -void ServerWindow::PostMessage(BMessage *msg) -{ -} - -void ServerWindow::ReplaceDecorator(void) -{ -} - -void ServerWindow::Quit(void) -{ -} - -const char *ServerWindow::GetTitle(void) -{ - return title; -} - -ServerApp *ServerWindow::GetApp(void) -{ - return app; -} - -void ServerWindow::Show(void) -{ -} - -void ServerWindow::Hide(void) -{ -} - -bool ServerWindow::IsHidden(void) -{ - return (hidecount==0)?true:false; -} - -void ServerWindow::SetFocus(bool value) -{ - active=value; -} - -bool ServerWindow::HasFocus(void) -{ - return active; -} - -void ServerWindow::DesktopActivated(int32 NewDesktop, const BPoint Resolution, color_space CSpace) -{ -} - -void ServerWindow::WindowActivated(bool Active) -{ -} - -void ServerWindow::ScreenModeChanged(const BPoint Resolustion, color_space CSpace) -{ -} - -void ServerWindow::SetFrame(const BRect &rect) -{ - frame=rect; -} - -BRect ServerWindow::Frame(void) -{ - return frame; -} - -status_t ServerWindow::Lock(void) -{ - return locker.Lock(); -} - -void ServerWindow::Unlock(void) -{ - locker.Unlock(); -} - -bool ServerWindow::IsLocked(void) -{ - return locker.IsLocked(); -} - -void ServerWindow::DispatchMessage(const void *msg, int nCode) -{ -} - -void ServerWindow::Loop(void) -{ - // Message-dispatching loop for the ServerWindow - - cout << "Main message loop for " << title << endl; - - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(receiver); - - if(buffersize>0) - { - // buffers are PortLink messages. Allocate necessary buffer and - // we'll cast it as a BMessage. - msgbuffer=new int8[buffersize]; - bytesread=read_port(receiver,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(receiver,&msgcode,NULL,0); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - default: - cout << "ServerWin received unexpected code " << (int32)msgcode << endl; - break; - } - - } - - if(buffersize>0) - delete msgbuffer; - - if(msgcode==B_QUIT_REQUESTED) - break; - } -} - -int32 ServerWindow::MonitorWin(void *data) -{ - ServerWindow *win=(ServerWindow *)data; - win->Loop(); - exit_thread(0); - return 0; -} diff --git a/src/servers/app/proto4/ServerWindow.h b/src/servers/app/proto4/ServerWindow.h deleted file mode 100644 index 4230b9be91..0000000000 --- a/src/servers/app/proto4/ServerWindow.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef _SERVERWIN_H_ -#define _SERVERWIN_H_ - -#include -#include -#include -#include -#include - -class BString; -class BMessenger; -class BPoint; -class ServerApp; -class WindowDecorator; -class PortLink; - -class ServerWindow -{ -public: - ServerWindow(const char *Title, uint32 Flags, uint32 Desktop, - const BRect &Rect, ServerApp *App, port_id SendPort); - ~ServerWindow(void); - - void PostMessage(BMessage *msg); - void ReplaceDecorator(void); - void Quit(void); - const char *GetTitle(void); - ServerApp *GetApp(void); - void Show(void); - void Hide(void); - bool IsHidden(void); - void SetFocus(bool value); - bool HasFocus(void); - - void DesktopActivated(int32 NewDesktop, const BPoint Resolution, color_space CSpace); - void WindowActivated(bool Active); - void ScreenModeChanged(const BPoint Resolution, color_space CSpace); - - void SetFrame(const BRect &rect); - BRect Frame(void); - - status_t Lock(void); - void Unlock(void); - bool IsLocked(void); - - void DispatchMessage(const void *msg, int nCode); - static int32 MonitorWin(void *data); - void Loop(void); - - const char *title; - int32 flags; - int32 desktop; - bool active; - - ServerApp *app; - - WindowDecorator *decorator; - bigtime_t lasthit; // Time of last mouse click - - thread_id thread; - port_id receiver; // Messages from window - port_id sender; // Messages to window - PortLink *winlink,*applink; - BLocker locker; - BRect frame; - uint8 hidecount; -}; - -#endif diff --git a/src/servers/app/proto4/SystemPalette.cpp b/src/servers/app/proto4/SystemPalette.cpp deleted file mode 100644 index 3a388ed6b4..0000000000 --- a/src/servers/app/proto4/SystemPalette.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/* - SystemPalette.cpp - One global function to generate the palette which is the default BeOS - System palette and the variable to go with it -*/ - -#include "SystemPalette.h" - -rgb_color SystemPalette[256]; - -void GenerateSystemPalette(rgb_color *palette) -{ - int i,j,index=0; - int indexvals1[]={ 255,229,204,179,154,129,105,80,55,30 }, - indexvals2[]={ 255,203,152,102,51,0 }; - rgb_color *currentcol; - - // Grays 0,0,0 -> 248,248,248 by 8's - for(i=0; i<=248; i+=8,index++) - { - currentcol=&(palette[index]); - currentcol->red=i; - currentcol->green=i; - currentcol->blue=i; - currentcol->alpha=255; - } - - // Blues, following indexvals1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=0; - currentcol->blue=indexvals1[i]; - currentcol->alpha=255; - } - - // Reds, following indexvals1 - 1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals1[i] - 1; - currentcol->green=0; - currentcol->blue=0; - currentcol->alpha=255; - } - - // Greens, following indexvals1 - 1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=indexvals1[i] - 1; - currentcol->blue=0; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=152; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=255; - currentcol->blue=255; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=0;i<4;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=152; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=0; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=255; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=203; - index++; - - // Mostly array runs from here on out - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=203; - currentcol->green=203; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=152; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=102; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=51; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=152; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=102; - index++; - - // knocks out 4 assignment loops at once :) - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=152; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - currentcol+=sizeof(rgb_color); - currentcol->red=230; - currentcol->green=134; - currentcol->blue=0; - index++; - - for(i=1;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=0; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=102; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=175; - currentcol->blue=19; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=255; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=203; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=3;i>=0;i--,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - for(i=2;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - for(i=0;i<5;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=203; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=227; - currentcol->blue=70; - index++; - - for(j=2;j<6;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=0; - index++; - - for(i=5;i<=0;i--,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - -} diff --git a/src/servers/app/proto4/SystemPalette.h b/src/servers/app/proto4/SystemPalette.h deleted file mode 100644 index 0fb99d0fed..0000000000 --- a/src/servers/app/proto4/SystemPalette.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _SYSTEM_PALETTE_H_ -#define _SYSTEM_PALETTE_H_ - -#include - -void GenerateSystemPalette(rgb_color *palette); -extern rgb_color SystemPalette[]; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/ViewDriver.cpp b/src/servers/app/proto4/ViewDriver.cpp deleted file mode 100644 index 3ee50066ac..0000000000 --- a/src/servers/app/proto4/ViewDriver.cpp +++ /dev/null @@ -1,1385 +0,0 @@ -/* - ViewDriver: - First, slowest, and easiest driver class in the app_server which is designed - to utilize the BeOS graphics functions to cut out a lot of junk in getting the - drawing infrastructure in this server. - - The concept is to have VDView::Draw() draw a bitmap, which is a "frame buffer" - of sorts, utilize a second view to write to it. This cuts out - the most problems with having a crapload of code to get just right without - having to write a bunch of unit tests - - Components: 3 classes, VDView, VDWindow, and ViewDriver - - ViewDriver - a wrapper class which mostly posts messages to the VDWindow - VDWindow - does most of the work. - VDView - doesn't do all that much except display the rendered bitmap -*/ - -//#define DEBUG_DRIVER_MODULE - -#include -#include -#include -#include -#include -#include "PortLink.h" -#include "ServerProtocol.h" -#include "ServerBitmap.h" -#include "ViewDriver.h" -#include "ServerCursor.h" -#include "DebugTools.h" - -// Message defines for internal use only -enum -{ -VDWIN_CLEAR=100, -VDWIN_SAFEMODE, -VDWIN_RESET, -VDWIN_SETSCREEN, - -VDWIN_FILLARC, -VDWIN_STROKEARC, -VDWIN_FILLRECT, -VDWIN_STROKERECT, -VDWIN_FILLROUNDRECT, -VDWIN_STROKEROUNDRECT, -VDWIN_FILLELLIPSE, -VDWIN_STROKEELLIPSE, -VDWIN_FILLBEZIER, -VDWIN_STROKEBEZIER, -VDWIN_FILLTRIANGLE, -VDWIN_STROKETRIANGLE, -VDWIN_STROKELINE, -VDWIN_DRAWSTRING, - -VDWIN_SETPENSIZE, -VDWIN_MOVEPENTO, -VDWIN_SHOWCURSOR, -VDWIN_HIDECURSOR, -VDWIN_OBSCURECURSOR, -VDWIN_MOVECURSOR, -VDWIN_SETCURSOR, -VDWIN_SETHIGHCOLOR, -VDWIN_SETLOWCOLOR -}; - -VDView::VDView(BRect bounds) - : BView(bounds,"viewdriver_view",B_FOLLOW_ALL, B_WILL_DRAW) -{ - viewbmp=new BBitmap(bounds,B_RGB32,true); - drawview=new BView(viewbmp->Bounds(),"drawview",B_FOLLOW_ALL, B_WILL_DRAW); - - // This link for sending mouse messages to the OBAppServer. - // This is only to take the place of the Input Server. I suppose I could write - // an addon filter to be more like the Input Server, but then I wouldn't be working - // on this thing! :P - serverlink=new PortLink(find_port(SERVER_INPUT_PORT)); - -#ifdef DEBUG_DRIVER_MODULE - printf("VDView: app_server input port: %ld\n",serverlink->GetPort()); -#endif - - hide_cursor=0; - obscure_cursor=false; - - // Create a cursor which isn't just a box - cursor=new BBitmap(BRect(0,0,20,20),B_RGBA32,true); - BView *v=new BView(cursor->Bounds(),"v", B_FOLLOW_NONE, B_WILL_DRAW); - - cursor->Lock(); - cursor->AddChild(v); - - v->SetHighColor(255,255,255,0); - v->FillRect(cursor->Bounds()); - v->SetHighColor(255,0,0,255); - v->FillTriangle(cursor->Bounds().LeftTop(),cursor->Bounds().RightTop(),cursor->Bounds().LeftBottom()); - - cursor->RemoveChild(v); - cursor->Unlock(); - - cursorframe=cursor->Bounds(); - oldcursorframe=cursor->Bounds(); -} - -VDView::~VDView(void) -{ - delete viewbmp; - delete serverlink; - delete cursor; -} - -void VDView::AttachedToWindow(void) -{ -// printf("VDView::AttachedToWindow()\n"); -} - -void VDView::Draw(BRect rect) -{ - DrawBitmapAsync(viewbmp,oldcursorframe,oldcursorframe); - DrawBitmapAsync(viewbmp,rect,rect); - - if(hide_cursor==0 && obscure_cursor==false) - { - SetDrawingMode(B_OP_ALPHA); - DrawBitmapAsync(cursor,cursor->Bounds(),cursorframe); - SetDrawingMode(B_OP_COPY); - } - Sync(); -} - -// These functions emulate the Input Server by sending the *exact* same kind of messages -// to the server's port. Being we're using a regular window, it would make little sense -// to do anything else. - -void VDView::MouseDown(BPoint pt) -{ - // 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 - - BPoint p; - - uint32 buttons, - mod=modifiers(), - clicks=1; // can't get the # of clicks without a *lot* of extra work :( - - int64 time=(int64)real_time_clock(); - - GetMouse(&p,&buttons); - - serverlink->SetOpCode(B_MOUSE_DOWN); - serverlink->Attach(&time, sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - serverlink->Attach(&mod, sizeof(uint32)); - serverlink->Attach(&buttons, sizeof(uint32)); - serverlink->Attach(&clicks, sizeof(uint32)); - serverlink->Flush(); -} - -void VDView::MouseMoved(BPoint pt, uint32 transit, const BMessage *msg) -{ - // Attach 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 - BPoint p; - uint32 buttons; - int64 time=(int64)real_time_clock(); - - serverlink->SetOpCode(B_MOUSE_MOVED); - serverlink->Attach(&time,sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - GetMouse(&p,&buttons); - serverlink->Attach(&buttons,sizeof(int32)); - serverlink->Flush(); -} - -void VDView::MouseUp(BPoint pt) -{ - // 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 - BPoint p; - - uint32 buttons, - mod=modifiers(); - - int64 time=(int64)real_time_clock(); - - GetMouse(&p,&buttons); - - serverlink->SetOpCode(B_MOUSE_UP); - serverlink->Attach(&time, sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - serverlink->Attach(&mod, sizeof(uint32)); - serverlink->Flush(); -} - -void VDView::SetMode(int16 width, int16 height, uint8 bpp) -{ - // This function resets the emulated video buffer - color_space s; - - switch(bpp) - { - case 16: - s=B_RGBA15; - break; - case 8: - s=B_CMAP8; - break; - default: - s=B_RGBA32; - break; - } - delete viewbmp; - viewbmp=new BBitmap(BRect(0,0,width-1,height-1),s,true); - drawview->ResizeTo(width-1,height-1); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver::SetMode(%d x %d x %d)\n",width,height,bpp); -#endif -} - -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- - -VDWindow::VDWindow(void) - : BWindow(BRect(100,60,740,540),"OBOS App Server, P4",B_TITLED_WINDOW, - B_NOT_ZOOMABLE | B_NOT_RESIZABLE) -{ - view=new VDView(Bounds()); - AddChild(view); -} - -VDWindow::~VDWindow(void) -{ -} - -void VDWindow::MessageReceived(BMessage *msg) -{ - switch(msg->what) - { - case VDWIN_CLEAR: - { - int8 red=0,green=0,blue=0; - msg->FindInt8("red",&red); - msg->FindInt8("green",&green); - msg->FindInt8("blue",&blue); - Clear(red,green,blue); - break; - } - case VDWIN_SETSCREEN: - { - // debug printing done in SetScreen() - int32 space=0; - msg->FindInt32("screenmode",&space); - SetScreen(space); - break; - } - case VDWIN_RESET: - { - Reset(); - break; - } - case VDWIN_SAFEMODE: - { - SafeMode(); - break; - } - case VDWIN_DRAWSTRING: - { - char *string; - BPoint point; - uint16 length; - msg->FindString("string",(const char **)&string); - msg->FindInt16("length",(int16*)&length); - msg->FindPoint("point",&point); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->SetDrawingMode(B_OP_ALPHA); - view->drawview->DrawString(string,length,point); - view->drawview->SetDrawingMode(B_OP_COPY); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - - // Until I can figure out a better way, if I even bother... - view->Invalidate(); - } - case VDWIN_FILLARC: - { - float cx,cy,rx,ry,angle,span; - int64 temp64; - - msg->FindFloat("cx",&cx); - msg->FindFloat("cy",&cy); - msg->FindFloat("rx",&rx); - msg->FindFloat("ry",&ry); - msg->FindFloat("angle",&angle); - msg->FindFloat("span",&span); - msg->FindInt64("pattern",&temp64); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->FillArc(BPoint(cx,cy),rx,ry,angle,span,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(BRect(cx-rx,cy-ry,cx+rx,cy+ry)); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver::FillArc: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("Angle, Span: %f,%f\n",angle, span); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_STROKEARC: - { - float cx,cy,rx,ry,angle,span; - int64 temp64; - - msg->FindFloat("cx",&cx); - msg->FindFloat("cy",&cy); - msg->FindFloat("rx",&rx); - msg->FindFloat("ry",&ry); - msg->FindFloat("angle",&angle); - msg->FindFloat("span",&span); - msg->FindInt64("pattern",&temp64); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->StrokeArc(BPoint(cx,cy),rx,ry,angle,span,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(BRect(cx-rx,cy-ry,cx+rx,cy+ry)); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeArc: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("Angle, Span: %f,%f\n",angle, span); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_FILLBEZIER: - { - BPoint points[4]; - int64 temp64; - msg->FindPoint("p1",points); - msg->FindPoint("p2",&(points[1])); - msg->FindPoint("p3",&(points[2])); - msg->FindPoint("p4",&(points[3])); - msg->FindInt64("pattern",&temp64); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->FillBezier(points,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - - // Invalidate the whole view until I can figure out how to calculate - // a rect which encompasses the line - view->Invalidate(); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: FillBezier:\n"); -printf("Point 1: "); points[0].PrintToStream(); -printf("Point 2: "); points[1].PrintToStream(); -printf("Point 3: "); points[2].PrintToStream(); -printf("Point 4: "); points[3].PrintToStream(); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_STROKEBEZIER: - { - BPoint points[4]; - int64 temp64; - msg->FindPoint("p1",points); - msg->FindPoint("p2",&(points[1])); - msg->FindPoint("p3",&(points[2])); - msg->FindPoint("p4",&(points[3])); - msg->FindInt64("pattern",&temp64); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->StrokeBezier(points,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - - // Invalidate the whole view until I can figure out how to calculate - // a rect which encompasses the line - view->Invalidate(); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeBezier:\n"); -printf("Point 1: "); points[0].PrintToStream(); -printf("Point 2: "); points[1].PrintToStream(); -printf("Point 3: "); points[2].PrintToStream(); -printf("Point 4: "); points[3].PrintToStream(); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_FILLRECT: - { - BRect rect(0,0,0,0); - int64 temp64; - - msg->FindRect("rect",&rect); - msg->FindInt64("pattern",&temp64); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->FillRect(rect,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(rect); -#ifdef DEBUG_DRIVER_MODULE -printf("FillRect: "); rect.PrintToStream(); -printf("pattern: {%llxd}\n",temp64); -#endif - break; - } - case VDWIN_STROKERECT: - { - BRect rect(0,0,0,0); - int64 temp64; - - msg->FindRect("rect",&rect); - msg->FindInt64("pattern",&temp64); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->StrokeRect(rect,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(rect); -#ifdef DEBUG_DRIVER_MODULE -printf("StrokeRect: "); rect.PrintToStream(); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_FILLELLIPSE: - { - float cx,cy,rx,ry; - int64 temp64; - - msg->FindFloat("cx",&cx); - msg->FindFloat("cy",&cy); - msg->FindFloat("rx",&rx); - msg->FindFloat("ry",&ry); - msg->FindInt64("pattern",&temp64); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->FillEllipse(BPoint(cx,cy),rx,ry,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(BRect(cx-rx,cy-ry,cx+rx,cy+ry)); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: FillEllipse: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_STROKEELLIPSE: - { - float cx,cy,rx,ry; - int64 temp64; - - msg->FindFloat("cx",&cx); - msg->FindFloat("cy",&cy); - msg->FindFloat("rx",&rx); - msg->FindFloat("ry",&ry); - msg->FindInt64("pattern",&temp64); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->StrokeEllipse(BPoint(cx,cy),rx,ry,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(BRect(cx-rx,cy-ry,cx+rx,cy+ry)); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeEllipse: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_FILLROUNDRECT: - { - BRect rect(0,0,0,0); - int64 temp64; - float x,y; - - msg->FindRect("rect",&rect); - msg->FindFloat("x",&x); - msg->FindFloat("y",&y); - msg->FindInt64("pattern",&temp64); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->FillRoundRect(rect,x,y,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(rect); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: FillRoundRect: "); rect.PrintToStream(); -printf("Radii: %f,%f\n",x,y); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_STROKEROUNDRECT: - { - BRect rect(0,0,0,0); - int64 temp64; - float x,y; - - msg->FindRect("rect",&rect); - msg->FindFloat("x",&x); - msg->FindFloat("y",&y); - msg->FindInt64("pattern",&temp64); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->StrokeRoundRect(rect,x,y,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(rect); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeRoundRect: "); rect.PrintToStream(); -printf("Radii: %f,%f\n",x,y); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_FILLTRIANGLE: - { - BPoint pt1,pt2,pt3; - BRect invalid; - int64 temp64; - msg->FindPoint("first",&pt1); - msg->FindPoint("second",&pt2); - msg->FindPoint("third",&pt3); - msg->FindRect("rect",&invalid); - msg->FindInt64("pattern",&temp64); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->FillTriangle(pt1,pt2,pt3,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - - view->Invalidate(invalid); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: FillTriangle:\n"); -printf("Point 1: "); pt1.PrintToStream(); -printf("Point 2: "); pt2.PrintToStream(); -printf("Point 3: "); pt3.PrintToStream(); -printf("Rect: "); invalid.PrintToStream(); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_STROKETRIANGLE: - { - BPoint pt1,pt2,pt3; - BRect invalid; - int64 temp64; - msg->FindPoint("first",&pt1); - msg->FindPoint("second",&pt2); - msg->FindPoint("third",&pt3); - msg->FindRect("rect",&invalid); - msg->FindInt64("pattern",&temp64); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->StrokeTriangle(pt1,pt2,pt3,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - - view->Invalidate(invalid); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeTriangle:\n"); -printf("Point 1: "); pt1.PrintToStream(); -printf("Point 2: "); pt2.PrintToStream(); -printf("Point 3: "); pt3.PrintToStream(); -printf("Rect: "); invalid.PrintToStream(); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_STROKELINE: - { - BPoint pt(0,0),pt2(0,0); - int64 temp64; - - msg->FindPoint("from",&pt); - msg->FindPoint("to",&pt2); - msg->FindInt64("pattern",&temp64); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->StrokeLine(pt,pt2,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - - // Because BRect requires (pt1,pt2) where pt1=LeftTop(), - // we have to jump through some hoops - - BRect invalid(MIN(pt2.x,pt.x), MIN(pt2.y,pt.y), - MAX(pt2.x,pt.x), MAX(pt2.y,pt.y) ); - invalid.InsetBy((view->drawview->PenSize()/2)*-1,(view->drawview->PenSize()/2)*-1); - view->Invalidate(invalid); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeLine(%f,%f)\n",pt.x,pt.y); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_SHOWCURSOR: - { - if(view->hide_cursor>0) - { - view->hide_cursor--; -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: ShowCursor() - still hidden\n"); -#endif - } - if(view->hide_cursor==0) - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: ShowCursor() - cursor shown\n"); -#endif - view->Invalidate(view->cursorframe); - } - break; - } - case VDWIN_HIDECURSOR: - { - view->hide_cursor++; -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: HideCursor()\n"); -#endif - if(view->hide_cursor==1) - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: HideCursor() - cursor was hidden\n"); -#endif - view->Invalidate(view->cursorframe); - } - break; - } - case VDWIN_OBSCURECURSOR: - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: ObscureCursor()\n"); -#endif - view->obscure_cursor=true; - view->Invalidate(view->cursorframe); - break; - } - case VDWIN_MOVECURSOR: - { - float x,y; - msg->FindFloat("x",&x); - msg->FindFloat("y",&y); - - // this was changed because an extra message was - // sent even though the mouse was never moved - if(view->cursorframe.left!=x || view->cursorframe.top!=y) - { - if(view->obscure_cursor) - view->obscure_cursor=false; - - view->oldcursorframe=view->cursorframe; - view->cursorframe.OffsetTo(x,y); - } - - if(view->hide_cursor==0) - view->Invalidate(view->oldcursorframe); - break; - } - case VDWIN_SETCURSOR: - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: SetCursor()\n"); -#endif - ServerCursor *cdata; - msg->FindPointer("SCursor",(void**)&cdata); - - if(cdata!=NULL) - { - BBitmap *bmp=new BBitmap(BRect(0,0,cdata->width-1,cdata->height-1), - cdata->cspace); - - // Copy the server bitmap in the cursor to a BBitmap - uint8 *sbmppos=(uint8*)cdata->bitmap->Buffer(), - *bbmppos=(uint8*)bmp->Bits(); - - int32 bytes=cdata->bitmap->bytesperline, - bbytes=bmp->BytesPerRow(); - - for(int i=0;iheight;i++) - memcpy(bbmppos+(i*bbytes), sbmppos+(i*bytes), bytes); - - // Replace the bitmap - delete view->cursor; - view->cursor=bmp; - view->Invalidate(view->cursorframe); - break; - } - break; - } - case VDWIN_SETHIGHCOLOR: - { - uint8 r=0,g=0,b=0,a=0; - msg->FindInt8("red",(int8*)&r); - msg->FindInt8("green",(int8*)&g); - msg->FindInt8("blue",(int8*)&b); - msg->FindInt8("alpha",(int8*)&a); - view->drawview->SetHighColor(r,g,b,a); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: SetHighColor(%d,%d,%d,%d)\n",r,g,b,a); -#endif - break; - } - case VDWIN_SETLOWCOLOR: - { - uint8 r=0,g=0,b=0,a=0; - msg->FindInt8("red",(int8*)&r); - msg->FindInt8("green",(int8*)&g); - msg->FindInt8("blue",(int8*)&b); - msg->FindInt8("alpha",(int8*)&a); - view->drawview->SetLowColor(r,g,b,a); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: SetLowColor(%d,%d,%d,%d)\n",r,g,b,a); -#endif - break; - } - case VDWIN_SETPENSIZE: - { - float pensize; - msg->FindFloat("size",&pensize); - view->drawview->SetPenSize(pensize); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: SetPenSize(%f)\n",pensize); -#endif - break; - } - case VDWIN_MOVEPENTO: - { - BPoint pt; - msg->FindPoint("point",&pt); - view->drawview->MovePenTo(pt); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: MovePenTo(%f,%f)\n",pt.x,pt.y); -#endif - break; - } - default: - BWindow::MessageReceived(msg); - break; - } -} - -void VDWindow::SafeMode(void) -{ - SetScreen(B_8_BIT_640x480); -} - -void VDWindow::Reset(void) -{ - SafeMode(); - Clear(255,255,255); -} - -void VDWindow::SetScreen(uint32 space) -{ - int16 w=640,h=480; - uint8 bpp=0; - switch(space) - { - case B_32_BIT_800x600: - case B_16_BIT_800x600: - case B_8_BIT_800x600: - { - w=800; h=600; - break; - } - case B_32_BIT_1024x768: - case B_16_BIT_1024x768: - case B_8_BIT_1024x768: - { - w=1024; h=768; - break; - } - default: - break; - } - ResizeTo(w-1,h-1); - - switch(space) - { - case B_32_BIT_640x480: - case B_32_BIT_800x600: - case B_32_BIT_1024x768: - bpp=32; - break; - case B_16_BIT_640x480: - case B_16_BIT_800x600: - case B_16_BIT_1024x768: - bpp=16; - break; - case B_8_BIT_640x480: - case B_8_BIT_800x600: - case B_8_BIT_1024x768: - bpp=8; - break; - default: - break; - } - view->SetMode(w,h,bpp); -} - -void VDWindow::Clear(uint8 red,uint8 green,uint8 blue) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: Clear(%d,%d,%d)\n",red,green,blue); -#endif - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->SetHighColor(red,green,blue); - view->drawview->FillRect(view->drawview->Bounds()); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(); -} - -bool VDWindow::QuitRequested(void) -{ - port_id serverport=find_port(SERVER_PORT_NAME); - if(serverport!=B_NAME_NOT_FOUND) - { - write_port(serverport,B_QUIT_REQUESTED,NULL,0); - } - return true; -} - -void VDWindow::WindowActivated(bool active) -{ - // This is just to hide the regular system cursor so we can see our own - if(active) - be_app->HideCursor(); - else - be_app->ShowCursor(); -} - -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- - -/* - Posting messages to the rendering window helps run right around a whole - migraine's worth of multithreaded code -*/ - -ViewDriver::ViewDriver(void) -{ - screenwin=new VDWindow(); - hide_cursor=0; -} - -ViewDriver::~ViewDriver(void) -{ - if(is_initialized) - { - screenwin->Lock(); - screenwin->Quit(); - } -} - -void ViewDriver::Initialize(void) -{ - locker->Lock(); - screenwin->Show(); - is_initialized=true; - SetPenSize(1.0); - MovePenTo(BPoint(0,0)); - locker->Unlock(); -} - -void ViewDriver::Shutdown(void) -{ - locker->Lock(); - screenwin->Lock(); - screenwin->Close(); - is_initialized=false; - locker->Unlock(); -} - -bool ViewDriver::IsInitialized(void) -{ - return is_initialized; -} - -void ViewDriver::SafeMode(void) -{ - locker->Lock(); - screenwin->PostMessage(VDWIN_SAFEMODE); - locker->Unlock(); -} - -void ViewDriver::Reset(void) -{ - locker->Lock(); - screenwin->PostMessage(VDWIN_RESET); - locker->Unlock(); -} - -void ViewDriver::SetScreen(uint32 space) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_SETSCREEN); - msg->AddInt32("screenmode",space); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::Clear(uint8 red, uint8 green, uint8 blue) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_CLEAR); - msg->AddInt8("red",red); - msg->AddInt8("green",green); - msg->AddInt8("blue",blue); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::Clear(rgb_color col) -{ - Clear(col.red,col.green,col.blue); -} - -int32 ViewDriver::GetHeight(void) -{ // Gets the height of the current mode - return 0; -} - -int32 ViewDriver::GetWidth(void) -{ // Gets the width of the current mode - return 0; -} - -int ViewDriver::GetDepth(void) -{ // Gets the color depth of the current mode - return 0; -} - -void ViewDriver::Blit(BPoint dest, ServerBitmap *sourcebmp, ServerBitmap *destbmp) -{ -} - -void ViewDriver::DrawBitmap(ServerBitmap *bitmap) -{ -} - -void ViewDriver::DrawChar(char c, BPoint point) -{ - char string[2]; - string[0]=c; - string[1]='\0'; - DrawString(string,2,point); -} - -void ViewDriver::DrawString(char *string, int length, BPoint point) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_DRAWSTRING); - msg->AddString("string",string); - msg->AddInt16("length",length); - msg->AddPoint("point",point); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_FILLARC); - msg->AddFloat("cx",centerx); - msg->AddFloat("cy",centery); - msg->AddFloat("rx",xradius); - msg->AddFloat("ry",yradius); - msg->AddFloat("angle",angle); - msg->AddFloat("span",span); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::FillBezier(BPoint *points, uint8 *pattern) -{ - locker->Lock(); - int64 pat=*((int64*)pattern); - - BMessage *msg=new BMessage(VDWIN_FILLBEZIER); - msg->AddPoint("p1",points[0]); - msg->AddPoint("p2",points[1]); - msg->AddPoint("p3",points[2]); - msg->AddPoint("p4",points[3]); - msg->AddInt64("pattern",pat); - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_FILLELLIPSE); - msg->AddFloat("cx",centerx); - msg->AddFloat("cy",centery); - msg->AddFloat("rx",x_radius); - msg->AddFloat("ry",y_radius); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::FillPolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void ViewDriver::FillRect(BRect rect, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_FILLRECT); - msg->AddRect("rect",rect); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::FillRegion(BRegion *region) -{ -} - -void ViewDriver::FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_FILLROUNDRECT); - msg->AddRect("rect",rect); - msg->AddFloat("x",xradius); - msg->AddFloat("y",yradius); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::FillShape(BShape *shape) -{ -} - -void ViewDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_FILLTRIANGLE); - msg->AddPoint("first",first); - msg->AddPoint("second",second); - msg->AddPoint("third",third); - msg->AddRect("rect",rect); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::HideCursor(void) -{ - locker->Lock(); - hide_cursor++; - screenwin->PostMessage(VDWIN_HIDECURSOR); - locker->Unlock(); -} - -bool ViewDriver::IsCursorHidden(void) -{ - locker->Lock(); - bool value=(hide_cursor>0)?true:false; - locker->Unlock(); - return value; -} - -void ViewDriver::ObscureCursor(void) -{ // Hides cursor until mouse is moved - locker->Lock(); - screenwin->PostMessage(VDWIN_OBSCURECURSOR); - locker->Unlock(); -} - -void ViewDriver::MoveCursorTo(float x, float y) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_MOVECURSOR); - msg->AddFloat("x",x); - msg->AddFloat("y",y); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::MovePenTo(BPoint pt) -{ // Moves the graphics pen to this position - - locker->Lock(); - penpos=pt; - - BMessage *msg=new BMessage(VDWIN_MOVEPENTO); - msg->AddPoint("point",penpos); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -BPoint ViewDriver::PenPosition(void) -{ - return penpos; -} - -float ViewDriver::PenSize(void) -{ - return pensize; -} - -void ViewDriver::SetCursor(int32 value) -{ -} - -void ViewDriver::SetCursor(ServerCursor *cursor) -{ - // We are given a ServerCursor. Fire it off to the view driver's window for translation - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_SETCURSOR); - msg->AddPointer("SCursor",cursor); - screenwin->PostMessage(msg); // Much faster than copying data. :) - locker->Unlock(); -} - -void ViewDriver::SetPenSize(float size) -{ - locker->Lock(); - pensize=size; - - BMessage *msg=new BMessage(VDWIN_SETPENSIZE); - msg->AddFloat("size",pensize); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - locker->Lock(); - highcol.red=r; - highcol.green=g; - highcol.blue=b; - highcol.alpha=a; - - BMessage *msg=new BMessage(VDWIN_SETHIGHCOLOR); - msg->AddInt8("red",r); - msg->AddInt8("green",g); - msg->AddInt8("blue",b); - msg->AddInt8("alpha",a); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - locker->Lock(); - lowcol.red=r; - lowcol.green=g; - lowcol.blue=b; - lowcol.alpha=a; - - BMessage *msg=new BMessage(VDWIN_SETLOWCOLOR); - msg->AddInt8("red",r); - msg->AddInt8("green",g); - msg->AddInt8("blue",b); - msg->AddInt8("alpha",a); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::SetPixel(int x, int y, uint8 *pattern) -{ // Internal function utilized by other functions to draw to the buffer - // Will eventually be an inline function -} - -void ViewDriver::ShowCursor(void) -{ - locker->Lock(); - if(hide_cursor>0) - { - hide_cursor--; - screenwin->PostMessage(VDWIN_SHOWCURSOR); - } - locker->Unlock(); -} - -void ViewDriver::StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKEARC); - msg->AddFloat("cx",centerx); - msg->AddFloat("cy",centery); - msg->AddFloat("rx",xradius); - msg->AddFloat("ry",yradius); - msg->AddFloat("angle",angle); - msg->AddFloat("span",span); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokeBezier(BPoint *points, uint8 *pattern) -{ - locker->Lock(); - int64 pat=*((int64*)pattern); - - BMessage *msg=new BMessage(VDWIN_STROKEBEZIER); - msg->AddPoint("p1",points[0]); - msg->AddPoint("p2",points[1]); - msg->AddPoint("p3",points[2]); - msg->AddPoint("p4",points[3]); - msg->AddInt64("pattern",pat); - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKEELLIPSE); - msg->AddFloat("cx",centerx); - msg->AddFloat("cy",centery); - msg->AddFloat("rx",x_radius); - msg->AddFloat("ry",y_radius); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokeLine(BPoint point, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKELINE); - msg->AddPoint("from",penpos); - msg->AddPoint("to",point); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokePolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void ViewDriver::StrokeRect(BRect rect,uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKERECT); - msg->AddRect("rect",rect); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKEROUNDRECT); - msg->AddRect("rect",rect); - msg->AddFloat("x",xradius); - msg->AddFloat("y",yradius); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokeShape(BShape *shape) -{ -} - -void ViewDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKETRIANGLE); - msg->AddPoint("first",first); - msg->AddPoint("second",second); - msg->AddPoint("third",third); - msg->AddRect("rect",rect); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -#ifdef DEBUG_DRIVER_MODULE -#undef DEBUG_DRIVER_MODULE -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/ViewDriver.h b/src/servers/app/proto4/ViewDriver.h deleted file mode 100644 index 24358b2dac..0000000000 --- a/src/servers/app/proto4/ViewDriver.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef _VIEWDRIVER_H_ -#define _VIEWDRIVER_H_ - -#include -#include -#include -#include -#include // for pattern struct -#include -#include -#include "DisplayDriver.h" - -class BBitmap; -class PortLink; -class VDWindow; -class ServerCursor; - -class VDView : public BView -{ -public: - VDView(BRect bounds); - ~VDView(void); - void AttachedToWindow(void); - void Draw(BRect rect); - void MouseDown(BPoint pt); - void MouseMoved(BPoint pt, uint32 transit, const BMessage *msg); - void MouseUp(BPoint pt); - void SetMode(int16 width, int16 height, uint8 bpp); - - BBitmap *viewbmp; - BView *drawview; - PortLink *serverlink; - -protected: - friend VDWindow; - - int hide_cursor; - BBitmap *cursor; - - BRect cursorframe, oldcursorframe; - bool obscure_cursor; -}; - -class VDWindow : public BWindow -{ -public: - VDWindow(void); - ~VDWindow(void); - void MessageReceived(BMessage *msg); - bool QuitRequested(void); - void WindowActivated(bool active); - - void SafeMode(void); - void Reset(void); - void SetScreen(uint32 space); - void Clear(uint8 red,uint8 green,uint8 blue); - - VDView *view; -}; - -class ViewDriver : public DisplayDriver -{ -public: - ViewDriver(void); - virtual ~ViewDriver(void); - - virtual void Initialize(void); // Sets the driver - virtual bool IsInitialized(void); - virtual void Shutdown(void); // You never know when you'll need this - - virtual void SafeMode(void); // Easy-access functions for common tasks - virtual void Reset(void); - virtual void Clear(uint8 red,uint8 green,uint8 blue); - virtual void Clear(rgb_color col); - - // Settings functions - virtual void SetScreen(uint32 space); - virtual int32 GetHeight(void); - virtual int32 GetWidth(void); - virtual int GetDepth(void); - - // Drawing functions - virtual void Blit(BPoint dest, ServerBitmap *src, ServerBitmap *dest); - virtual void DrawBitmap(ServerBitmap *bitmap); - virtual void DrawChar(char c, BPoint point); - virtual void DrawString(char *string, int length, BPoint point); - - virtual void FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void FillBezier(BPoint *points, uint8 *pattern); - virtual void FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void FillPolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void FillRect(BRect rect, uint8 *pattern); - virtual void FillRegion(BRegion *region); - virtual void FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void FillShape(BShape *shape); - virtual void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - - virtual void HideCursor(void); - virtual bool IsCursorHidden(void); - virtual void MoveCursorTo(float x, float y); - virtual void MovePenTo(BPoint pt); - virtual void ObscureCursor(void); - virtual BPoint PenPosition(void); - virtual float PenSize(void); - virtual void SetCursor(int32 value); - virtual void SetCursor(ServerCursor *cursor); - virtual void SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetPenSize(float size); - virtual void SetPixel(int x, int y, uint8 *pattern); - virtual void ShowCursor(void); - - virtual void StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void StrokeBezier(BPoint *points, uint8 *pattern); - virtual void StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void StrokeLine(BPoint point, uint8 *pattern); - virtual void StrokePolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void StrokeRect(BRect rect,uint8 *pattern); - virtual void StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void StrokeShape(BShape *shape); - virtual void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - VDWindow *screenwin; -protected: - int hide_cursor; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/main.cpp b/src/servers/app/proto4/main.cpp deleted file mode 100644 index a237ea2468..0000000000 --- a/src/servers/app/proto4/main.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// main.cpp - - -const char app_sig[] = "application/x-vnd.myApp"; - -#include - -int main() -{ - if(is_computer_on()) - { - // TODO: start up the application! - } - - return 0; -} diff --git a/src/servers/app/proto4/obhey/obhey.c b/src/servers/app/proto4/obhey/obhey.c deleted file mode 100644 index 8e6bfbd617..0000000000 --- a/src/servers/app/proto4/obhey/obhey.c +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include -#include -#include -/* - Sends a message to the OpenBeOS app_server's message port -*/ - -int main(int argc, char **argv) -{ - int32 msgcode; - - if(argc>2) - { - port_id serverport=atoi(argv[1]); - msgcode=atoi(argv[2]); - - write_port(serverport,msgcode,NULL,0); - printf("Sent %ld to port %ld\n",msgcode,serverport); - return 1; - } - - printf("obhey port \n"); - return 0; -} \ No newline at end of file diff --git a/src/servers/app/proto4/obtestapp/OBApp.cpp b/src/servers/app/proto4/obtestapp/OBApp.cpp deleted file mode 100644 index 099b97b91d..0000000000 --- a/src/servers/app/proto4/obtestapp/OBApp.cpp +++ /dev/null @@ -1,639 +0,0 @@ -/* - OBApp.cpp: App faker for OpenBeOS app_server prototype #4 - - This one happens to be a graphics tester. - - ReadyToRun is set to spawn a thread to post all the messages. Posting from a - separate thread will be necessary once packetized graphics messaging is done. - - Because graphics message packetizing is not done, the code in each function to - test the graphics will obviously change even though the data format which the - server will ultimately receive will stay the same. -*/ - -#include -#include // for the pattern struct and screen mode defs -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ServerProtocol.h" -#include "PortLink.h" -#include "OBApp.h" - -TestApp::TestApp(void) -{ - initialized=true; - - // Receives messages from server and others - messageport=create_port(50,"msgport"); - if(messageport==B_BAD_VALUE || messageport==B_NO_MORE_PORTS) - { printf("TestApp: Couldn't create message port\n"); - initialized=false; - } - - // Find the port for the app_server - serverport=find_port("OBappserver"); - if(serverport==B_NAME_NOT_FOUND) - { printf("TestApp: Couldn't find server port\n"); - initialized=false; - - serverlink=new PortLink(create_port(50,"OBAppServer")); - } - else - { - serverlink=new PortLink(serverport); - } - -// signature=new char[255]; - signature=new char[strlen("application/x-vnd.wgp-OBTestApp")]; - sprintf(signature,"application/x-vnd.wgp-OBTestApp"); - -} - -TestApp::~TestApp(void) -{ -// printf("%s::~TestApp()\n",signature); - delete signature; - - if(initialized==true) - delete serverlink; -} - -void TestApp::MainLoop(void) -{ - printf("TestApp::MainLoop()\n"); - - // Notify server of app's existence - serverlink->SetOpCode(CREATE_APP); - serverlink->Attach(&messageport,sizeof(port_id)); -// serverlink.Attach(PID); - serverlink->Attach(signature,strlen(signature)); - serverlink->Flush(); - - int32 msgcode; - uint8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(messageport); - - if(buffersize>0) - { - // buffers are flattened messages. Allocate necessary buffer and - // we'll cast it as a BMessage. - msgbuffer=new uint8[buffersize]; - bytesread=read_port(messageport,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(messageport,&msgcode,NULL,0); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case B_QUIT_REQUESTED: - { - // Attached data: - // None - printf("%s: Quit requested\n",signature); - serverlink->SetOpCode(msgcode); - serverlink->Flush(); - break; - } - case SET_SERVER_PORT: - { - // This message is received when the server has created - // the ServerApp object to monitor our application. It is - // sending us the port to which we send future messages - - // Attached data: - // port_id - id of the port of the corresponding ServerApp - if(buffersize<1) - { - printf("%s: Set Server Port has no attached data\n",signature); - break; - } - printf("%s: Set Server Port to %ld\n",signature,*((port_id *)msgbuffer)); - serverport=*((port_id *)msgbuffer); - serverlink->SetPort(serverport); - ReadyToRun(); - break; - } - case B_MOUSE_MOVED: - case B_MOUSE_DOWN: - case B_MOUSE_UP: - DispatchMessage(msgcode, (int8*)msgbuffer); - break; - default: - printf("OBTestApp received unexpected code %ld\n",msgcode); - break; - } - - if(msgcode==B_QUIT_REQUESTED) - { - printf("Quitting %s\n",signature); - break; - } - } - - if(buffersize>0) - delete msgbuffer; - } -} - -void TestApp::DispatchMessage(BMessage *msg, BHandler *handler) -{ -// printf("TestApp::DispatchMessage()\n"); -} - -// For test application purposes only - will be replaced later -void TestApp::DispatchMessage(int32 code, int8 *buffer) -{ - switch(code) - { - case B_MOUSE_DOWN: - case B_MOUSE_UP: - case B_MOUSE_MOVED: - break; - default: - printf("TestApp %s received unknown code %ld\n",signature,code); - break; - } -} - -void TestApp::MessageReceived(BMessage *msg) -{ -// printf("TestApp::MessageReceived()\n"); -} - -void TestApp::ShowCursor(void) -{ - serverlink->SetOpCode(SHOW_CURSOR); - serverlink->Flush(); -} - -void TestApp::HideCursor(void) -{ - serverlink->SetOpCode(HIDE_CURSOR); - serverlink->Flush(); -} - -void TestApp::ObscureCursor(void) -{ - serverlink->SetOpCode(OBSCURE_CURSOR); - serverlink->Flush(); -} - -bool TestApp::IsCursorHidden(void) -{ - return false; -} - -void TestApp::SetCursor(const void *cursor) -{ -printf("TestApp::SetCursor()\n"); - // attach & send the 68-byte chunk - serverlink->SetOpCode(SET_CURSOR_DATA); - serverlink->Attach((void*)cursor, 68); - serverlink->Flush(); -} - -void TestApp::SetCursor(const BCursor *cursor, bool sync=true) -{ - // attach & send the BCursor - serverlink->SetOpCode(SET_CURSOR_BCURSOR); - serverlink->Attach((BCursor*)cursor, sizeof(BCursor)); - serverlink->Flush(); -} - -void TestApp::SetCursor(BBitmap *bmp) -{ - // This will be enabled once the BBitmap functionality is better nailed down - -/* // attach & send the TestBitmap's area_id - serverlink->SetOpCode(SET_CURSOR_BCURSOR); - serverlink->Attach(bmp, sizeof(BCursor)); - serverlink->Flush(); -*/ -} - -void TestApp::ReadyToRun(void) -{ - thread_id tid=spawn_thread(TestGraphics,"testthread",B_NORMAL_PRIORITY,this); - if(tid!=B_NO_MEMORY && tid!=B_NO_MORE_THREADS) - resume_thread(tid); -} - -int32 TestApp::TestGraphics(void *data) -{ - printf("TestGraphics Spawned\n"); - TestApp *app=(TestApp*)data; - - app->TestScreenStates(); - app->TestArcs(); - app->TestBeziers(); - app->TestEllipses(); - app->TestLines(); -// app->TestPolygon(); - app->TestRects(); -// app->TestRegions(); -// app->TestShape(); - app->TestTriangle(); - app->TestCursors(); - app->TestFonts(); - printf("TestGraphics Exited\n"); - exit_thread(0); - return 0; -} - -void TestApp::SetHighColor(uint8 r, uint8 g, uint8 b) -{ - // Server always expects an alpha value - uint8 a=255; - serverlink->SetOpCode(GFX_SET_HIGH_COLOR); - serverlink->Attach(&r,sizeof(uint8)); - serverlink->Attach(&g,sizeof(uint8)); - serverlink->Attach(&b,sizeof(uint8)); - serverlink->Attach(&a,sizeof(uint8)); - serverlink->Flush(); -} - -void TestApp::SetLowColor(uint8 r, uint8 g, uint8 b) -{ - // Server always expects an alpha value - uint8 a=255; - serverlink->SetOpCode(GFX_SET_LOW_COLOR); - serverlink->Attach(&r,sizeof(uint8)); - serverlink->Attach(&g,sizeof(uint8)); - serverlink->Attach(&b,sizeof(uint8)); - serverlink->Attach(&a,sizeof(uint8)); - serverlink->Flush(); -} - -void TestApp::TestScreenStates(void) -{ - // This function is here to test all the graphics state code, such as - // resolution, desktop switching, etc. - - // Protocol defined here will be used by the screen-related global functions - - int32 workspace=0; - uint32 mode=B_32_BIT_640x480; - bool sticky=false; - - // set_screen_space() - serverlink->SetOpCode(GFX_SET_SCREEN_MODE); - serverlink->Attach(&workspace,sizeof(int32)); - serverlink->Attach(&mode,sizeof(int32)); - serverlink->Attach(&sticky,sizeof(bool)); - serverlink->Flush(); - - // This code works, I just don't want to mess with it when I'm - // working on the other tests. -/* - // activate_workspace() - workspace=1; - serverlink->SetOpCode(GFX_ACTIVATE_WORKSPACE); - serverlink->Attach(&workspace,sizeof(int32)); - serverlink->Flush(); -*/ -} - -void TestApp::TestArcs(void) -{ - float centerx=275, centery=95, - radx=70, rady=45, - angle=40, - span=210; - - // Fill Arc - SetHighColor(0,0,255); - serverlink->SetOpCode(GFX_FILL_ARC); - serverlink->Attach(¢erx,sizeof(float)); - serverlink->Attach(¢ery,sizeof(float)); - serverlink->Attach(&radx,sizeof(float)); - serverlink->Attach(&rady,sizeof(float)); - serverlink->Attach(&angle,sizeof(float)); - serverlink->Attach(&span,sizeof(float)); - serverlink->Attach((pattern *)&B_SOLID_HIGH, sizeof(pattern)); - serverlink->Flush(); - - // Stroke Arc - for(int i=0; i<45; i+=5) - { - centerx=280+i; - centery=100+i; - radx=75+i; - rady=50+i; - angle=45+i; - span=215+i; - SetHighColor(128+(i*2),128+(i*2),128+(i*2)); - serverlink->SetOpCode(GFX_STROKE_ARC); - serverlink->Attach(¢erx,sizeof(float)); - serverlink->Attach(¢ery,sizeof(float)); - serverlink->Attach(&radx,sizeof(float)); - serverlink->Attach(&rady,sizeof(float)); - serverlink->Attach(&angle,sizeof(float)); - serverlink->Attach(&span,sizeof(float)); - serverlink->Attach((pattern *)&B_SOLID_HIGH, sizeof(pattern)); - serverlink->Flush(); - } -} - -void TestApp::TestBeziers(void) -{ - BPoint p1(500,300), - p2(350,450), - p3(350,300), - p4(500,450); - - // Stroke Bezier - SetHighColor(0,255,0); - serverlink->SetOpCode(GFX_STROKE_BEZIER); - serverlink->Attach(&p1,sizeof(BPoint)); - serverlink->Attach(&p2,sizeof(BPoint)); - serverlink->Attach(&p3,sizeof(BPoint)); - serverlink->Attach(&p4,sizeof(BPoint)); - serverlink->Attach((pattern *)&B_SOLID_HIGH, sizeof(pattern)); - serverlink->Flush(); - - // Fill Bezier - p1.Set(250,250); - p2.Set(300,300); - p3.Set(300,250); - p4.Set(300,250); - SetHighColor(255,0,0); - serverlink->SetOpCode(GFX_FILL_BEZIER); - serverlink->Attach(&p1,sizeof(BPoint)); - serverlink->Attach(&p2,sizeof(BPoint)); - serverlink->Attach(&p3,sizeof(BPoint)); - serverlink->Attach(&p4,sizeof(BPoint)); - serverlink->Attach((pattern *)&B_SOLID_HIGH, sizeof(pattern)); - serverlink->Flush(); - -} - -void TestApp::TestEllipses(void) -{ - float centerx=200, centery=200, - radx=10, rady=5; - - // Fill Ellipse - SetHighColor(0,0,0); - serverlink->SetOpCode(GFX_FILL_ELLIPSE); - serverlink->Attach(¢erx,sizeof(float)); - serverlink->Attach(¢ery,sizeof(float)); - serverlink->Attach(&radx,sizeof(float)); - serverlink->Attach(&rady,sizeof(float)); - serverlink->Attach((pattern *)&B_SOLID_HIGH, sizeof(pattern)); - serverlink->Flush(); - - // Stroke Ellipse - for(int i=5; i<255; i+=10) - { - SetHighColor(i,i,i); - radx=10+i; - rady=5+i; - serverlink->SetOpCode(GFX_STROKE_ELLIPSE); - serverlink->Attach(¢erx,sizeof(float)); - serverlink->Attach(¢ery,sizeof(float)); - serverlink->Attach(&radx,sizeof(float)); - serverlink->Attach(&rady,sizeof(float)); - serverlink->Attach((pattern *)&B_SOLID_HIGH, sizeof(pattern)); - serverlink->Flush(); - } -} - -void TestApp::TestFonts(void) -{ - - // Can't test SetFont() -- we don't have an active BApplication. :( - - // Draw String - BString string("OpenBeOS: The Future is Drawing Near..."); - uint16 length=string.Length(); - - // this will be set to a negative value in the case of not being passed - // a BPoint - BPoint pt(10,175); - - SetHighColor(0,0,0); - serverlink->SetOpCode(GFX_DRAW_STRING); - - // String passing protocol for PortLink/AppServer combination: - // uint16 length of string precedes each string - serverlink->Attach(&length,sizeof(uint16)); - serverlink->Attach((char *)string.String(),string.Length()); - serverlink->Attach(&pt,sizeof(BPoint)); - - // for now, passing escapements is disabled, so none are attached - serverlink->Flush(); -} - -void TestApp::TestLines(void) -{ - // Protocol for the usual line method (BPoint,BPoint) will simply - // result in a MovePenTo call followed by a StrokeLine(BPoint) call - - BPoint pt(100,100); - float x=50,y=50,size=1; - - // MovePenTo() - serverlink->SetOpCode(GFX_MOVEPENTO); - serverlink->Attach(&pt,sizeof(BPoint)); - serverlink->Flush(); - - // StrokeLine(BPoint) - pt.Set(10,10); - SetHighColor(255,0,255); - serverlink->SetOpCode(GFX_STROKE_LINE); - serverlink->Attach(&pt,sizeof(BPoint)); - serverlink->Attach((pattern *)&B_SOLID_HIGH, sizeof(pattern)); - serverlink->Flush(); - - // MovePenBy() - pt.Set(100,0); - serverlink->SetOpCode(GFX_MOVEPENBY); - serverlink->Attach(&x,sizeof(float)); - serverlink->Attach(&y,sizeof(float)); - serverlink->Flush(); - - // Eventually, this will become a LineArray test... - for(int i=0;i<256;i++) - { - // SetPenSize() - size=i/10; - serverlink->SetOpCode(GFX_SETPENSIZE); - serverlink->Attach(&size,sizeof(float)); - serverlink->Flush(); - - // StrokeLine(BPoint) - pt.Set(10,10+i); - SetHighColor(255,i,255); - serverlink->SetOpCode(GFX_STROKE_LINE); - serverlink->Attach(&pt,sizeof(BPoint)); - serverlink->Attach((pattern *)&B_SOLID_HIGH, sizeof(pattern)); - serverlink->Flush(); - } - // SetPenSize() - size=1; - serverlink->SetOpCode(GFX_SETPENSIZE); - serverlink->Attach(&size,sizeof(float)); - serverlink->Flush(); -} - -void TestApp::TestPolygon(void) -{ - // This one's going to REALLY be a pain. Can't be flattened like a BShape. - // Can't access any of its data like BRegion. I guess it'll have to wait until - // I've implemented the BView class. I'm starting to get a headache.... -} - -void TestApp::TestRects(void) -{ - BRect rect(10,270,75,335); - float xrad=10,yrad=30; - - SetHighColor(255,0,0); - - // Stroke Rect - serverlink->SetOpCode(GFX_STROKE_RECT); - serverlink->Attach(&rect,sizeof(BRect)); - serverlink->Attach((pattern *)&B_SOLID_HIGH, sizeof(pattern)); - serverlink->Flush(); - - // Fill Rect - rect.OffsetBy(100,10); - serverlink->SetOpCode(GFX_FILL_RECT); - serverlink->Attach(&rect,sizeof(BRect)); - serverlink->Attach((pattern *)&B_SOLID_LOW, sizeof(pattern)); - serverlink->Flush(); - - // Stroke Round Rect - rect.OffsetBy(100,10); - - SetHighColor(0,255,0); - serverlink->SetOpCode(GFX_STROKE_ROUNDRECT); - serverlink->Attach(&rect,sizeof(BRect)); - serverlink->Attach(&xrad,sizeof(float)); - serverlink->Attach(&yrad,sizeof(float)); - serverlink->Attach((pattern *)&B_SOLID_HIGH, sizeof(pattern)); - serverlink->Flush(); - - // Fill Round Rect - rect.OffsetBy(100,10); - SetHighColor(0,255,255); - serverlink->SetOpCode(GFX_FILL_ROUNDRECT); - serverlink->Attach(&rect,sizeof(BRect)); - serverlink->Attach(&xrad,sizeof(float)); - serverlink->Attach(&yrad,sizeof(float)); - serverlink->Attach((pattern *)&B_SOLID_HIGH, sizeof(pattern)); - serverlink->Flush(); - -} - -void TestApp::TestRegions(void) -{ -/* -Because of the varying size of BRegions, this will be a bit sticky. Size does -not change with added rectangles because the internally, it uses a BList. We -also must contend with the fact that they very well may not fit into the -port's buffer, which could have very nasty results. - -Possible Solutions: -1) Flatten it like a PortLink flattens data and pass the flattened region to - the server via an area. We' can simply clone it and pass the second - area_id to the server. -2) Attach it to a BMessage and fire it off. -3) Create an API which operates something like BeginRectArray() -*/ - -} - -void TestApp::TestShape(void) -{ - // BShapes are derived from BArchivable, so we'll flatten it, and fire it to - // the server via a BMessage. Thus, this will need to be done later... -} - -void TestApp::TestTriangle(void) -{ - // In either form of the function, we have to calculate the invaliated - // rect which contains the triangle unless the caller gives us one. Thus, - // the functions will always send a BRect to the server. - - BRect invalid; - - BPoint pt1(600,100), pt2(500,200), pt3(550,450); - - invalid.Set( MIN( MIN(pt1.x,pt2.x), pt3.x), - MIN( MIN(pt1.y,pt2.y), pt3.y), - MAX( MAX(pt1.x,pt2.x), pt3.x), - MAX( MAX(pt1.y,pt2.y), pt3.y) ); - - // Fill Triangle - SetHighColor(228,228,50); - serverlink->SetOpCode(GFX_FILL_TRIANGLE); - serverlink->Attach(&pt1,sizeof(BPoint)); - serverlink->Attach(&pt2,sizeof(BPoint)); - serverlink->Attach(&pt3,sizeof(BPoint)); - serverlink->Attach(&invalid,sizeof(BRect)); - serverlink->Attach((pattern *)&B_SOLID_HIGH, sizeof(pattern)); - serverlink->Flush(); - - - pt1.Set(50,50); - pt2.Set(200,475); - pt3.Set(400,400); - invalid.Set( MIN( MIN(pt1.x,pt2.x), pt3.x), - MIN( MIN(pt1.y,pt2.y), pt3.y), - MAX( MAX(pt1.x,pt2.x), pt3.x), - MAX( MAX(pt1.y,pt2.y), pt3.y) ); - // Stroke Triangle - SetHighColor(0,128,128); - serverlink->SetOpCode(GFX_STROKE_TRIANGLE); - serverlink->Attach(&pt1,sizeof(BPoint)); - serverlink->Attach(&pt2,sizeof(BPoint)); - serverlink->Attach(&pt3,sizeof(BPoint)); - serverlink->Attach(&invalid,sizeof(BRect)); - serverlink->Attach((pattern *)&B_SOLID_HIGH, sizeof(pattern)); - serverlink->Flush(); -} - -void TestApp::TestCursors(void) -{ -uint8 cross[] = {16,1,5,5, -14,0,4,0,4,0,4,0,128,32,241,224,128,32,4,0, -4,0,4,0,14,0,0,0,0,0,0,0,0,0,0,0, -14,0,4,0,4,0,4,0,128,32,245,224,128,32,4,0, -4,0,4,0,14,0,0,0,0,0,0,0,0,0,0,0 -}; - - SetCursor(cross); - HideCursor(); - ShowCursor(); - ObscureCursor(); -} - -bool TestApp::Run(void) -{ -// printf("TestApp::Run()\n"); - if(!initialized) - return false; - - MainLoop(); - return true; -} - -int main(void) -{ - TestApp app; - app.Run(); -} \ No newline at end of file diff --git a/src/servers/app/proto4/obtestapp/OBApp.h b/src/servers/app/proto4/obtestapp/OBApp.h deleted file mode 100644 index a1394c6a62..0000000000 --- a/src/servers/app/proto4/obtestapp/OBApp.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef _OBOS_APPLICATION_H_ -#define _OBOS_APPLICATION_H_ - -#include -#include - -class PortLink; - -class TestApp -{ -public: - TestApp(void); - virtual ~TestApp(void); - - // Replaces BLooper message looping - void MainLoop(void); - - // Hmm... What do these do? ;^) - void DispatchMessage(int32 code, int8 *buffer); - virtual void DispatchMessage(BMessage *msg, BHandler *handler); - virtual void MessageReceived(BMessage *msg); - virtual void ReadyToRun(void); - bool Run(void); - void ShowCursor(void); - void HideCursor(void); - void ObscureCursor(void); - bool IsCursorHidden(void); - void SetCursor(const void *cursor); - void SetCursor(const BCursor *cursor, bool sync=true); - void SetCursor(BBitmap *bmp); - - port_id messageport, serverport; - char *signature; - bool initialized; - PortLink *serverlink; - - static int32 TestGraphics(void *data); - - // Testing functions: - void SetLowColor(uint8 r, uint8 g, uint8 b); - void SetHighColor(uint8 r, uint8 g, uint8 b); - - void TestScreenStates(void); - void TestArcs(void); - void TestBeziers(void); - void TestEllipses(void); - void TestFonts(void); - void TestLines(void); - void TestPolygon(void); - void TestRects(void); - void TestRegions(void); - void TestShape(void); - void TestTriangle(void); - void TestCursors(void); -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/obtestapp/PortLink.cpp b/src/servers/app/proto4/obtestapp/PortLink.cpp deleted file mode 100644 index 8fba724569..0000000000 --- a/src/servers/app/proto4/obtestapp/PortLink.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/* - PortLink.cpp: - A helper class for port-based messaging - ------------------------------------------------------------------------- -How it works: - The class utilizes a fixed-size array of PortLinkData object pointers. When -data is attached, a new PortLinkData object is allocated and a copy of the -passed data is created inside it. When the time comes for the message to be sent, -the data is pieced together into a flattened array and written to the port. ------------------------------------------------------------------------- -Data members: - -*attachments[] - fixed-size array of pointers used to hold the attached data -opcode - message value which is sent along with any data -target - port to which the message is sent when Flush() is called -replyport - port used with synchronous messaging - FlushWithReply() -bufferlength - total bytes taken up by attachments -num_attachments - internal variable which is used to track which "slot" - will be the next one to receive an attachment object -*/ - -#include "PortLink.h" -#include -#include -#include - -//#define PLDEBUG - -// Internal data storage class for holding attached data whilst it is waiting -// to be Flattened() and then Flushed(). There is no need for this to be called outside -// the PortLink class. -class PortLinkData -{ -public: - PortLinkData(void); - ~PortLinkData(void); - bool Set(void *data, size_t size); - char *buffer; - size_t buffersize; -}; - -PortLink::PortLink(port_id port) -{ - // For this class to be useful (and to prevent a lot of init problems) - // we require a port in the constructor - target=port; - - // We start out without any data attached to the port message - num_attachments=0; - opcode=0; - bufferlength=0; - replyport=create_port(30,"PortLink reply port"); -} - -PortLink::~PortLink(void) -{ - // If, for some odd reason, this is deleted with something attached, - // free the memory used by the attachments. We do not flush the queue - // because the port may no longer be valid in cases such as the app - // is in the process of quitting - MakeEmpty(); -} - -void PortLink::SetOpCode(int32 code) -{ - // Sets the message code. This does not change once the message is sent. - // Another call to SetOpCode() is required for such things. - opcode=code; -} - -void PortLink::SetPort(port_id port) -{ - // Sets the target port. While not necessary in most uses, this exists - // mostly to prevent flexibility problems - target=port; -} - -port_id PortLink::GetPort(void) -{ - // Simply returns the port at which the object is pointed. - return target; -} - -void PortLink::Flush(bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message off to the target, complete with attachments. NOTE: - // the recipient must delete all attachments, being the PortLink object assumes - // no responsiblity for the attachments once the message is sent. - int8 *msgbuffer; - int32 size; - - if(num_attachments>0) - { - FlattenData(&msgbuffer,&size); - - // Dump message to port, reset attachments, and clean up - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,msgbuffer,size,B_TIMEOUT, timeout); - else - write_port(target,opcode,msgbuffer,size); - MakeEmpty(); - } - else - { - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,NULL,0,B_TIMEOUT, timeout); - else - write_port(target,opcode,NULL,0); - } -} - -int8* PortLink::FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message to the target and then waits for a reply. The target will - // receive a message with the first item being the port_id to reply to. - // NOTE: like Flush(), any attached data must be deleted. - - // Effectively, an Attach() call inlined for changes - - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - { - *status=B_ERROR; - return NULL; - } - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&replyport,sizeof(port_id))) - { - bufferlength+=sizeof(port_id); - } - else - { - delete pld; - *status=B_ERROR; - return NULL; - } - - // Flatten() inlined to make some necessary changes - int8 *buffer=new int8[bufferlength]; - int8 *bufferindex=buffer; - size_t size=0; - - // attach our port_id first - memcpy(bufferindex, pld->buffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - - // attach everything else - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - } - - // Flush the thing....FOOSH! :P - write_port(target,opcode,buffer,size); - MakeEmpty(); - delete buffer; - - // Now we wait for the reply - if(timeout==B_INFINITE_TIMEOUT) - { - *buffersize=port_buffer_size(replyport); - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - else - { - *buffersize=port_buffer_size_etc(replyport,0,timeout); - if(*buffersize==B_TIMED_OUT) - { - *status=*buffersize; - return NULL; - } - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - - // We got this far, so we apparently have some data - *status=B_OK; - return buffer; -} - -void PortLink::Attach(void *data, size_t size) -{ - // This is the member called to attach data to a message. Attachments are - // treated to be in 'Append' mode, tacking on each attached piece of data - // to the end of the list. - - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - if(size==0) - return; - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -// These functions were added for a major convenience in passing common types -// Eventually, I'd like to templatize these, but for now, this'll do - -void PortLink::Attach(int32 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int32); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int16 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int16); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int8 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int8); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(float data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(float); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(bool data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(bool); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BRect data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BRect); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BPoint data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BPoint); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::FlattenData(int8 **buffer,int32 *size) -{ - // This function is where all the magic happens, but it is strictly internal. - // It iterates through each PortLinkData object and copies it to the main buffer - // which ends up, ultimately, being written to the PortLink's target port. - - // skip if there aree no attachments - if(bufferlength<1) - return; - - *buffer=new int8[bufferlength]; - int8 *bufferindex=*buffer; - PortLinkData *pld; - *size=0; - - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - *size+=pld->buffersize; - } -} - -void PortLink::MakeEmpty(void) -{ - // Nukes all the attachments currently held by the PortLink class - if(num_attachments!=0) - { - for(int i=0; i0) - free(buffer); -} - -bool PortLinkData::Set(void *data, size_t size) -{ - // Function copies the passed to the internal buffers for storage - if(size>0 && buffersize==0 && data!=NULL) - { - buffer=(char *)malloc(size); - if(buffer==NULL) - return false; - memcpy(buffer, data, size); - buffersize=size; - return true; - } - return false; -} diff --git a/src/servers/app/proto4/obtestapp/PortLink.h b/src/servers/app/proto4/obtestapp/PortLink.h deleted file mode 100644 index 9f5432daab..0000000000 --- a/src/servers/app/proto4/obtestapp/PortLink.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _PORTLINK_H_ -#define _PORTLINK_H_ - -#include -#include -#include -#include - -#ifndef _PORTLINK_BUFFERSIZE -#define _PORTLINK_MAX_ATTACHMENTS 50 -#endif - -class PortLinkData; - -class PortLink -{ -public: - PortLink(port_id port); - ~PortLink(void); - void SetOpCode(int32 code); - void SetPort(port_id port); - port_id GetPort(void); - void Flush(bigtime_t timeout=B_INFINITE_TIMEOUT); - int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, - bigtime_t timeout=B_INFINITE_TIMEOUT); - void Attach(void *data, size_t size); - void Attach(int32 data); - void Attach(int16 data); - void Attach(int8 data); - void Attach(float data); - void Attach(bool data); - void Attach(BRect data); - void Attach(BPoint data); - void MakeEmpty(void); -protected: - void FlattenData(int8 **buffer,int32 *size); - port_id target, replyport; - int32 opcode, bufferlength; - int num_attachments; - PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS]; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/obtestapp/ServerProtocol.h b/src/servers/app/proto4/obtestapp/ServerProtocol.h deleted file mode 100644 index ab23ca2d10..0000000000 --- a/src/servers/app/proto4/obtestapp/ServerProtocol.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef _APPSERVER_PROTOCOL_ -#define _APPSERVER_PROTOCOL_ - -#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 QUIT_WINDOW 'srqw' - -#define SERVER_PORT_NAME "OBappserver" -#define SERVER_INPUT_PORT "OBinputport" - -#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 GFX_COUNT_WORKSPACES 'gcws' -#define GFX_SET_WORKSPACE_COUNT 'ggwc' -#define GFX_CURRENT_WORKSPACE 'ggcw' -#define GFX_ACTIVATE_WORKSPACE 'gaws' -#define GFX_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' - -#define GFX_SET_HIGH_COLOR 'gshc' -#define GFX_SET_LOW_COLOR 'gslc' - -#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' - -#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' - -#define GFX_MOVEPENBY 'gmpb' -#define GFX_MOVEPENTO 'gmpt' -#define GFX_SETPENSIZE 'gsps' - -#define GFX_DRAW_STRING 'gdst' -#define GFX_SET_FONT 'gsft' -#define GFX_SET_FONT_SIZE 'gsfs' -#endif \ No newline at end of file diff --git a/src/servers/app/proto4/obtestapp/TestBitmap.cpp b/src/servers/app/proto4/obtestapp/TestBitmap.cpp deleted file mode 100644 index 7da40d92fa..0000000000 --- a/src/servers/app/proto4/obtestapp/TestBitmap.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/* - TestBitmap.h - BBitmap faker used to test app_server prototypes -*/ - -#include -#include "TestBitmap.h" - -TestBitmap::TestBitmap(BRect bounds,color_space depth,bool accepts_views = false, - bool need_contiguous = false) -{ -} - -TestBitmap::TestBitmap(BRect bounds,uint32 flags,color_space depth, - int32 bytesPerRow=B_ANY_BYTES_PER_ROW,screen_id screenID=B_MAIN_SCREEN_ID) -{ -} - -TestBitmap::TestBitmap(const TestBitmap *source,bool accepts_views = false, - bool need_contiguous = false) -{ -} - -TestBitmap::~TestBitmap(void) -{ -} - -status_t TestBitmap::InitCheck() -{ - return B_ERROR; -} - -bool TestBitmap::IsValid() -{ - return false; -} - -area_id TestBitmap::Area() -{ - return B_ERROR; -} - -void * TestBitmap::Bits() -{ - return NULL; -} - -int32 TestBitmap::BitsLength() -{ - return 0; -} - -int32 TestBitmap::BytesPerRow() -{ - return 0; -} - -color_space TestBitmap::ColorSpace() -{ - return B_NO_COLOR_SPACE; -} - -BRect TestBitmap::Bounds() -{ - return BRect(0,0,0,0); -} - -void TestBitmap::HandleSpace(color_space space, int32 BytesPerLine) -{ - // Function written to handle color space setup which is required - // by the two "normal" constructors - - // Big convoluted mess just to handle every color space and dword align - // the buffer - switch(space) - { - // Buffer is dword-aligned, so nothing need be done - // aside from allocate the memory - case B_RGB32: - case B_RGBA32: - case B_RGB32_BIG: - case B_RGBA32_BIG: - case B_UVL32: - case B_UVLA32: - case B_LAB32: - case B_LABA32: - case B_HSI32: - case B_HSIA32: - case B_HSV32: - case B_HSVA32: - case B_HLS32: - case B_HLSA32: - case B_CMY32: - case B_CMYA32: - case B_CMYK32: - - // 24-bit = 32-bit with extra 8 bits ignored - case B_RGB24_BIG: - case B_RGB24: - case B_LAB24: - case B_UVL24: - case B_HSI24: - case B_HSV24: - case B_HLS24: - case B_CMY24: - { - if(BytesPerLine<(width*4)) - bytesperline=width*4; - else - bytesperline=BytesPerLine; - bpp=32; - break; - } - // Calculate size and dword-align - - // 1-bit - case B_GRAY1: - { - int32 numbytes=width>>3; - if((width % 8) != 0) - numbytes++; - if(BytesPerLine -#include - -enum { - B_BITMAP_CLEAR_TO_WHITE = 0x00000001, - B_BITMAP_ACCEPTS_VIEWS = 0x00000002, - B_BITMAP_IS_AREA = 0x00000004, - B_BITMAP_IS_LOCKED = 0x00000008 | B_BITMAP_IS_AREA, - B_BITMAP_IS_CONTIGUOUS = 0x00000010 | B_BITMAP_IS_LOCKED, - B_BITMAP_IS_OFFSCREEN = 0x00000020, - B_BITMAP_WILL_OVERLAY = 0x00000040 | B_BITMAP_IS_OFFSCREEN, - B_BITMAP_RESERVE_OVERLAY_CHANNEL = 0x00000080 -}; - -#ifndef B_ANY_BYTES_PER_ROW -#define B_ANY_BYTES_PER_ROW -1 -#endif - -class TestBitmap -{ -public: - TestBitmap(BRect bounds,color_space depth,bool accepts_views = false, - bool need_contiguous = false); - TestBitmap(BRect bounds,uint32 flags,color_space depth, - int32 bytesPerRow=B_ANY_BYTES_PER_ROW,screen_id screenID=B_MAIN_SCREEN_ID); - TestBitmap(const TestBitmap *source,bool accepts_views = false, - bool need_contiguous = false); - ~TestBitmap(void); - - status_t InitCheck(); - bool IsValid(); - -// status_t LockBits(uint32 *state=NULL); -// void UnlockBits(); - - area_id Area(); - void *Bits(); - int32 BitsLength(); - int32 BytesPerRow(); - color_space ColorSpace(); - BRect Bounds(); - - void SetBits(const void *data,int32 length,int32 offset,color_space cs); -/* virtual void AddChild(BView *view); - virtual bool RemoveChild(BView *view); - int32 CountChildren(); - BView *ChildAt(int32 index); - BView *FindView(const char *view_name); - BView *FindView(BPoint point); - bool Lock(); - void Unlock(); - bool IsLocked(); -*/ -protected: - void HandleSpace(color_space space, int32 BytesPerLine); - uint8 *buffer; - - int32 width,height; - int32 bytesperline; - color_space cspace; - int bpp; - area_id area; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/AppServer.cpp b/src/servers/app/proto5/AppServer.cpp deleted file mode 100644 index dba1639534..0000000000 --- a/src/servers/app/proto5/AppServer.cpp +++ /dev/null @@ -1,552 +0,0 @@ -/* - AppServer.cpp - File for the main app_server thread. This particular thread monitors for - application start and quit messages. It also starts the housekeeping threads - and initializes most of the server's globals. -*/ -#include -#include -#include "scheduler.h" -#include -#include -#include -#include -#include "AppServer.h" -#include "Layer.h" -#include "ServerApp.h" -#include "ServerWindow.h" -#include "Desktop.h" -#include "ServerProtocol.h" -#include "PortLink.h" -#include "DisplayDriver.h" -#include "DebugTools.h" -#include "BeDecorator.h" -//#include "YMakDecorator.h" - -//#define DEBUG_APPSERVER_THREAD - -// This bad boy holds only the top layer for each workspace -//BList *layerlist; - -// Used for mediating access to the layer lists -//BLocker *layerlock; - -// Used for access via instantiate_decorator -AppServer *app_server; - -AppServer::AppServer(void) : BApplication("application/x-vnd.obe-OBAppServer") -{ -#ifdef DEBUG_APPSERVER_THREAD - printf("AppServer()\n"); -#endif - - mouseport=create_port(30,SERVER_INPUT_PORT); - messageport=create_port(20,SERVER_PORT_NAME); -#ifdef DEBUG_APPSERVER_THREAD -printf("Server message port: %ld\n",messageport); -printf("Server input port: %ld\n",mouseport); -#endif - applist=new BList(0); - quitting_server=false; - exit_poller=false; - - // Set up the Desktop - init_desktop(3); - - // This is necessary to mediate access between the Poller and app_server threads - active_lock=new BLocker; - - // This locker is for app_server and Picasso to vy for control of the ServerApp list - applist_lock=new BLocker; - - // This locker is to mediate access to the make_decorator pointer - decor_lock=new BLocker; - - // Get the driver first - Poller thread utilizes the thing - driver=get_gfxdriver(); - - // Spawn our input-polling thread - 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); - if (picasso_id >= 0) - resume_thread(picasso_id); - - active_app=-1; - p_active_app=NULL; - -// layerlock=new BLocker; -// layerlist=new BList(1); -} - -AppServer::~AppServer(void) -{ - shutdown_desktop(); - - ServerApp *tempapp; -// Layer *templayer; - int32 i; - applist_lock->Lock(); - for(i=0;iCountItems();i++) - { - tempapp=(ServerApp *)applist->ItemAt(i); - if(tempapp!=NULL) - delete tempapp; - } - delete applist; - applist_lock->Unlock(); - -/* layerlock->Lock(); - for(i=0;iCountItems();i++) - { - templayer=(Layer *)layerlist->ItemAt(i); - - if(templayer!=NULL) - { - templayer->PruneTree(); - delete templayer; - } - } - delete layerlist; - layerlock->Unlock(); - - delete layerlock; -*/ delete active_lock; - delete applist_lock; - - // If these threads are still running, kill them - after this, if exit_poller - // is deleted, who knows what will happen... These things will just return an - // error and fail if the threads have already exited. - kill_thread(poller_id); - kill_thread(picasso_id); - - delete decor_lock; - - make_decorator=NULL; -} - -thread_id AppServer::Run(void) -{ -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer::Run()\n"); -#endif - - MainLoop(); - return 0; -} - -void AppServer::MainLoop(void) -{ - // Main loop (duh). Monitors the message queue and dispatches as appropriate. - // Input messages are handled by the poller, however. - -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer::MainLoop()\n"); -#endif - - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(messageport); - if(buffersize>0) - msgbuffer=new int8[buffersize]; - bytesread=read_port(messageport,&msgcode,msgbuffer,buffersize); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case CREATE_APP: - case DELETE_APP: - case B_QUIT_REQUESTED: - DispatchMessage(msgcode,msgbuffer); - break; - default: - { -#ifdef DEBUG_APPSERVER_THREAD -printf("Server received unexpected code %ld\n",msgcode); -#endif - break; - } - } - - } - - if(buffersize>0) - delete msgbuffer; - if(msgcode==DELETE_APP || msgcode==B_QUIT_REQUESTED) - { - 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); - -} - - -void AppServer::DispatchMessage(int32 code, int8 *buffer) -{ - int8 *index=buffer; - switch(code) - { - case CREATE_APP: - { - // Create the ServerApp to node monitor a new BApplication - -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer: Create App\n"); -#endif - - // Attached data: - // 1) port_id - port to reply to - // 2) port_id - receiver port of a regular app - // 3) char * - signature of the regular app - - // Find the necessary data - port_id reply_port=*((port_id*)index); index+=sizeof(port_id); - port_id app_port=*((port_id*)index); index+=sizeof(port_id); - - char *app_signature=(char *)index; - - // Create the ServerApp subthread for this app - applist_lock->Lock(); - ServerApp *newapp=new ServerApp(app_port,app_signature); - applist->AddItem(newapp); - applist_lock->Unlock(); - - active_lock->Lock(); - p_active_app=newapp; - active_app=applist->CountItems()-1; - - PortLink *replylink=new PortLink(reply_port); - replylink->SetOpCode(SET_SERVER_PORT); - replylink->Attach((int32)newapp->receiver); - replylink->Flush(); - - delete replylink; - - active_lock->Unlock(); - - newapp->Run(); - - break; - } - case DELETE_APP: - { - // Delete a ServerApp. Received only from the respective ServerApp when a - // BApplication asks it to quit. - -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer: Delete App\n"); -#endif - - // Attached Data: - // 1) thread_id - thread ID of the ServerApp to be deleted - - int32 i, appnum=applist->CountItems(); - ServerApp *srvapp; - thread_id srvapp_id=*((thread_id*)buffer); - - // Run through the list of apps and nuke the proper one - for(i=0;iItemAt(i); - - if(srvapp!=NULL && srvapp->monitor_thread==srvapp_id) - { - applist_lock->Lock(); - srvapp=(ServerApp *)applist->RemoveItem(i); - if(srvapp) - { - delete srvapp; - srvapp=NULL; - } - applist_lock->Unlock(); - active_lock->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; - active_lock->Unlock(); - break; // jump out of our for() loop - } - - } - break; - } - case B_QUIT_REQUESTED: - { -#ifdef DEBUG_APPSERVER_THREAD -printf("Shutdown sequence initiated.\n"); -#endif - - // Attached Data: - // none - - // 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. - PortLink *applink=new PortLink(0); - ServerApp *srvapp; - - applist_lock->Lock(); - int32 i,appnum=applist->CountItems(); - - applink->SetOpCode(QUIT_APP); - for(i=0;iItemAt(i); - if(srvapp!=NULL) - { - applink->SetPort(srvapp->receiver); - applink->Flush(); - } - } - applist_lock->Unlock(); - - delete applink; - // So when we delete the last ServerApp, we can exit the server - quitting_server=true; - exit_poller=true; - break; - } - default: - //printf("Unexpected message %ld (%lx) in AppServer::DispatchMessage()\n",code,code); - break; - } -} - -bool AppServer::LoadDecorator(BString path) -{ - // Loads a window decorator based on the supplied path and forces a decorator update. - // If it cannot load the specified decorator, it will retain the current one and - // return false. - - create_decorator *pcreatefunc=NULL; - get_decorator_version *pversionfunc=NULL; - status_t stat; - image_id addon; - - addon=load_add_on(path.String()); - - stat=get_image_symbol(addon, "get_decorator_version", B_SYMBOL_TYPE_TEXT, (void**)&pversionfunc); - if(stat!=B_OK) - { - printf("ERROR: Could not get version for Decorator %s\n", path.String()); - unload_add_on(addon); - return false; - } - - // As of now, we do nothing with decorator versions, but the possibility exists - // that the API will change even though I cannot forsee any reason to do so. If - // we *did* do anything with decorator versions, the assignment to a global would - // go here. - - stat=get_image_symbol(addon, "get_decorator_version", B_SYMBOL_TYPE_TEXT, (void**)&pversionfunc); - if(stat!=B_OK) - { - printf("ERROR: Could not get version for Decorator %s\n", path.String()); - unload_add_on(addon); - return false; - } - decor_lock->Lock(); - make_decorator=pcreatefunc; - decorator_id=addon; - decor_lock->Unlock(); - return true; -} - -void AppServer::LoadDefaultDecorator(void) -{ - // This function is called on server startup to provide a fallback decorator in - // case the decorator specified in the config file cannot be loaded. It just - // wouldn't do to have windows with no borders. ;) It also unloads any loaded - // decorator addons. We can specify that we want the default. It is no less - // functional - just internal. - -} - -Decorator *instantiate_decorator(Layer *lay, uint32 dflags, window_look wlook) -{ - Decorator *decor=NULL; - - app_server->decor_lock->Lock(); - if(app_server->make_decorator!=NULL) - decor=app_server->make_decorator(lay, dflags, wlook); - else - decor=new BeDecorator(lay, dflags, wlook); -// decor=new YMakDecorator(lay, dflags, wlook); - - app_server->decor_lock->Unlock(); - return decor; -} - -void AppServer::Poller(void) -{ - // This thread handles nothing but input messages for mouse and keyboard - int32 msgcode; - int8 *msgbuffer=NULL,*index; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(mouseport); - if(buffersize>0) - msgbuffer=new int8[buffersize]; - bytesread=read_port(mouseport,&msgcode,msgbuffer,buffersize); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - // We don't need to do anything with these two, so just pass them - // onto the active application. Eventually, we will pass them onto - // the window which is currently under the cursor. - case B_MOUSE_DOWN: - case B_MOUSE_UP: - { -/* - active_lock->Lock(); - if(active_app>-1 && p_active_app!=NULL) - write_port(p_active_app->receiver, msgcode,msgbuffer,buffersize); - active_lock->Unlock(); -*/ - ServerWindow::HandleMouseEvent(msgcode,msgbuffer); - 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 - - index=msgbuffer; - - // Time sent is not necessary for cursor processing. - index += sizeof(int64); - - float tempx=0,tempy=0; - tempx=*((float*)index); - index+=sizeof(float); - tempy=*((float*)index); - index+=sizeof(float); - - driver->MoveCursorTo(tempx,tempy); - -/* active_lock->Lock(); - if(active_app>-1 && p_active_app!=NULL) - write_port(p_active_app->receiver, msgcode,msgbuffer,buffersize); - active_lock->Unlock(); -*/ - ServerWindow::HandleMouseEvent(msgcode,msgbuffer); - break; - } - default: - //printf("Server::Poller received unexpected code %ld\n",msgcode); - break; - } - - } - - if(buffersize>0) - delete msgbuffer; - - if(exit_poller) - break; - } -} - -int32 AppServer::PollerThread(void *data) -{ -#ifdef DEBUG_APPSERVER_THREAD -printf("Starting Poller thread...\n"); -#endif - AppServer *server=(AppServer *)data; - - // This won't return until it's told to - server->Poller(); - -#ifdef DEBUG_APPSERVER_THREAD -printf("Exiting Poller thread...\n"); -#endif - exit_thread(B_OK); - return B_OK; -} - -void AppServer::Picasso(void) -{ - int32 i; - ServerApp *app; - for(;;) - { - applist_lock->Lock(); - for(i=0;iCountItems(); i++) - { - app=(ServerApp*)applist->ItemAt(i); - ASSERT(app!=NULL); - app->PingTarget(); - } - applist_lock->Unlock(); - - // if poller thread has to exit, so do we - I just was too lazy - // to rename the variable name. ;) - if(exit_poller) - break; - - // we do this every other second so as not to suck *too* many CPU cycles - snooze(2000000); - } -} - -int32 AppServer::PicassoThread(void *data) -{ -#ifdef DEBUG_APPSERVER_THREAD -printf("Starting Picasso thread...\n"); -#endif - AppServer *server=(AppServer *)data; - - // This won't return until it's told to - server->Picasso(); - -#ifdef DEBUG_APPSERVER_THREAD -printf("Exiting Picasso thread...\n"); -#endif - exit_thread(B_OK); - return B_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(); - app_server->Run(); - delete app_server; - return 0; -} diff --git a/src/servers/app/proto5/AppServer.h b/src/servers/app/proto5/AppServer.h deleted file mode 100644 index d7e352428d..0000000000 --- a/src/servers/app/proto5/AppServer.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _OPENBEOS_APP_SERVER_H_ -#define _OPENBEOS_APP_SERVER_H_ - -#include -#include -#include -#include -#include // for window_look -#include "Decorator.h" - -class Layer; -class BMessage; -class ServerApp; -class DisplayDriver; - -class AppServer : public BApplication -{ -public: - AppServer(void); - ~AppServer(void); - thread_id Run(void); - void MainLoop(void); - port_id messageport,mouseport; - void Poller(void); - void Picasso(void); - -private: - friend Decorator *instantiate_decorator(Layer *lay, uint32 dflags, window_look wlook); - - void DispatchMessage(int32 code, int8 *buffer); - static int32 PollerThread(void *data); - static int32 PicassoThread(void *data); - bool LoadDecorator(BString path); - void LoadDefaultDecorator(void); - - image_id decorator_id; - create_decorator *make_decorator; // global function pointer - bool quitting_server; - BList *applist; - int32 active_app; - ServerApp *p_active_app; - thread_id poller_id, picasso_id; - - BLocker *active_lock, *applist_lock, *decor_lock; - bool exit_poller; - DisplayDriver *driver; -}; - -Decorator *instantiate_decorator(Layer *lay, uint32 dflags, window_look wlook); -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/BUGS b/src/servers/app/proto5/BUGS deleted file mode 100644 index 71d92ac9b4..0000000000 --- a/src/servers/app/proto5/BUGS +++ /dev/null @@ -1,3 +0,0 @@ -Get a General OS Error followed by a segfault only when an application is started and the server is running under the debugger. - -Cursor display is just a little bit funky (try moving cursor by 1 pixel) when using the ViewDriver diff --git a/src/servers/app/proto5/BeDecorator.cpp b/src/servers/app/proto5/BeDecorator.cpp deleted file mode 100644 index 8cfaacc226..0000000000 --- a/src/servers/app/proto5/BeDecorator.cpp +++ /dev/null @@ -1,359 +0,0 @@ -#include "Layer.h" -#include "DisplayDriver.h" -#include -#include "BeDecorator.h" - -#define DEBUG_DECOR - -#ifdef DEBUG_DECOR -#include -#endif - -BeDecorator::BeDecorator(Layer *lay, uint32 dflags, window_look wlook) - : Decorator(lay, dflags, wlook) -{ -#ifdef DEBUG_DECOR -printf("BeDecorator()\n"); -#endif - zoomstate=false; - closestate=false; - taboffset=0; - - blue.red=100; - blue.green=100; - blue.blue=255; - - blue2.red=150; - blue2.green=150; - blue2.blue=255; - - black.red=0; - black.green=0; - black.blue=0; - - gray.red=224; - gray.green=224; - gray.blue=224; - - white.red=224; - white.green=224; - white.blue=224; - - yellow.red=255; - yellow.green=203; - yellow.blue=0; - - ltyellow.red=255; - ltyellow.green=236; - ltyellow.blue=33; - - mdyellow.red=255; - mdyellow.green=203; - mdyellow.blue=0; - - dkyellow.red=234; - dkyellow.green=181; - dkyellow.blue=0; - - Resize(lay->frame); -} - -BeDecorator::~BeDecorator(void) -{ -#ifdef DEBUG_DECOR -printf("~BeDecorator()\n"); -#endif -} - -click_type BeDecorator::Clicked(BPoint pt, uint32 buttons) -{ - // the case order is important - we go from smallest to largest - if(closerect.Contains(pt)) - { - -#ifdef DEBUG_DECOR -printf("BeDecorator():Clicked() - Close\n"); -#endif - - return CLICK_CLOSE; - } - - if(zoomrect.Contains(pt)) - { - -#ifdef DEBUG_DECOR -printf("BeDecorator():Clicked() - Zoom\n"); -#endif - - return CLICK_ZOOM; - } - - if(resizerect.Contains(pt)) - { - -#ifdef DEBUG_DECOR -printf("BeDecorator():Clicked() - Resize thumb\n"); -#endif - - return CLICK_RESIZE_RB; - } - - // Clicking in the tab? - if(tabrect.Contains(pt)) - { - // Here's part of our window management stuff - if(buttons==B_PRIMARY_MOUSE_BUTTON && !focused) - return CLICK_MOVETOFRONT; - if(buttons==B_SECONDARY_MOUSE_BUTTON) - return CLICK_MOVETOBACK; - return CLICK_TAB; - } - - // We got this far, so user is clicking on the border? - BRect borderrect(frame); - borderrect.top+=19; - BRect clientrect(borderrect.InsetByCopy(2,2)); - if(borderrect.Contains(pt) && !clientrect.Contains(pt)) - { -#ifdef DEBUG_DECOR -printf("BeDecorator():Clicked() - Drag\n"); -#endif - return CLICK_DRAG; - } - - // Guess user didn't click anything -#ifdef DEBUG_DECOR -printf("BeDecorator():Clicked()\n"); -#endif - return CLICK_NONE; -} - -void BeDecorator::Resize(BRect rect) -{ -#ifdef DEBUG_DECOR -printf("BeDecorator()::Resize()"); rect.PrintToStream(); -#endif - frame=rect; - closerect=frame; - tabrect=frame; - resizerect=frame; - borderrect=frame; - - closerect.left+=2; - closerect.top+=2; - closerect.right=closerect.left+10; - closerect.bottom=closerect.top+10; - - borderrect.top+=19; - - resizerect.top=resizerect.bottom-18; - resizerect.left=resizerect.right-18; - - tabrect.bottom=tabrect.top+18; - tabrect.right=tabrect.left+tabrect.Width()/2; - - zoomrect=tabrect; - zoomrect.top+=2; - zoomrect.right-=2; - zoomrect.bottom-=2; - zoomrect.left=zoomrect.right-10; - zoomrect.bottom=zoomrect.top+10; -} - -void BeDecorator::MoveBy(BPoint pt) -{ - frame.OffsetBy(pt); - closerect.OffsetBy(pt); - tabrect.OffsetBy(pt); - resizerect.OffsetBy(pt); - borderrect.OffsetBy(pt); - zoomrect.OffsetBy(pt); -} - -BRect BeDecorator::GetBorderSize(void) -{ - return bsize; -} - -BPoint BeDecorator::GetMinimumSize(void) -{ - return minsize; -} - -void BeDecorator::SetFlags(uint32 dflags) -{ - flags=dflags; -} - -void BeDecorator::UpdateFont(void) -{ -} - -void BeDecorator::UpdateTitle(const char *string) -{ -} - -void BeDecorator::SetFocus(bool bfocused) -{ - focused=bfocused; -} - -void BeDecorator::SetCloseButton(bool down) -{ - closestate=down; -} - -void BeDecorator::SetZoomButton(bool down) -{ - zoomstate=down; -} - -void BeDecorator::Draw(BRect update) -{ -#ifdef DEBUG_DECOR -printf("BeDecorator()::Draw():"); update.PrintToStream(); -#endif - // We need to draw a few things: the tab, the resize thumb, the borders, - // and the buttons - - DrawTab(); - - // Draw the top view's client area - just a hack :) - driver->FillRect(borderrect,blue); - - DrawFrame(); - -} - -void BeDecorator::DrawZoom(BRect r) -{ - BPoint pt1(r.left+2,r.bottom-2); - BPoint pt2(r.left+(r.Width()/2),r.top+2); - BPoint pt3(r.right-2,r.bottom-2); - if(zoomstate) - { - driver->FillRect(r,ltyellow); - driver->FillRect(r,(uint8*)&B_SOLID_LOW); - driver->FillTriangle(pt1,pt2,pt3,r,(uint8*)&B_SOLID_HIGH); - driver->StrokeLine(pt1,pt2,white); - driver->StrokeRect(r,black); - } - else - { - driver->FillRect(r,ltyellow); - driver->FillRect(r,(uint8*)&B_SOLID_HIGH); - driver->FillTriangle(pt1,pt2,pt3,r,(uint8*)&B_SOLID_LOW); - driver->StrokeLine(pt1,pt2,white); - driver->StrokeRect(r,black); - } -} - -void BeDecorator::DrawClose(BRect r) -{ - float w=r.Width()/2, h=r.Height()/2; - - if(closestate) - { - BPoint pt1(r.LeftTop()); - BPoint pt2(r.left+w,r.top); - BPoint pt3(r.left,r.top+h); - driver->FillTriangle(pt1,pt2,pt3,r,(uint8*)&B_SOLID_HIGH); - - pt1.Set(r.right-w,r.bottom); - pt2.Set(r.right,r.bottom-h); - pt3.Set(r.right,r.bottom); - driver->FillTriangle(pt1,pt2,pt3,r,(uint8*)&B_SOLID_LOW); - - driver->StrokeRect(r,black); - } - else - { - driver->FillRect(r,mdyellow); - - BPoint pt1(r.LeftTop()); - BPoint pt2(r.left+w,r.top); - BPoint pt3(r.left,r.top+h); - driver->FillTriangle(pt1,pt2,pt3,r,(uint8*)&B_SOLID_LOW); - - pt1.Set(r.right-w,r.bottom); - pt2.Set(r.right,r.bottom-h); - pt3.Set(r.right,r.bottom); - driver->FillTriangle(pt1,pt2,pt3,r,(uint8*)&B_SOLID_HIGH); - - driver->StrokeRect(r,black); - } -} - -void BeDecorator::Draw(void) -{ - // Easy way to draw everything - no worries about drawing only certain - // things - - DrawTab(); - - // Draw the top view's client area - just a hack :) - driver->FillRect(borderrect,blue); - - DrawFrame(); -} - -void BeDecorator::DrawTab(void) -{ - if(focused) - driver->FillRect(tabrect,yellow); - else - driver->FillRect(tabrect,gray); - driver->StrokeRect(tabrect,black); -} - -void BeDecorator::DrawFrame(void) -{ - driver->StrokeRect(borderrect,black); - - // Draw the resize thumb if we're supposed to - if(!(flags & B_NOT_RESIZABLE)) - { - driver->FillRect(resizerect,gray); - driver->StrokeRect(resizerect,black); - } - - // Draw the buttons if we're supposed to - if(!(flags & B_NOT_CLOSABLE)) - DrawClose(closerect); - if(!(flags & B_NOT_ZOOMABLE)) - DrawZoom(zoomrect); -} - -void BeDecorator::SetLook(window_look wlook) -{ - look=wlook; -} - -void BeDecorator::CalculateBorders(void) -{ - switch(look) - { - case B_NO_BORDER_WINDOW_LOOK: - { - bsize.Set(0,0,0,0); - break; - } - case B_TITLED_WINDOW_LOOK: - case B_DOCUMENT_WINDOW_LOOK: - case B_BORDERED_WINDOW_LOOK: - { - bsize.top=18; - break; - } - case B_MODAL_WINDOW_LOOK: - case B_FLOATING_WINDOW_LOOK: - { - bsize.top=15; - break; - } - default: - { - break; - } - } -} diff --git a/src/servers/app/proto5/BeDecorator.h b/src/servers/app/proto5/BeDecorator.h deleted file mode 100644 index 70ac8fe528..0000000000 --- a/src/servers/app/proto5/BeDecorator.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _BEOS_DECORATOR_H_ -#define _BEOS_DECORATOR_H_ - -#include "Decorator.h" - -class BeDecorator: public Decorator -{ -public: - BeDecorator(Layer *lay, uint32 dflags, window_look wlook); - ~BeDecorator(void); - - click_type Clicked(BPoint pt, uint32 buttons); - void Resize(BRect rect); - void MoveBy(BPoint pt); - BRect GetBorderSize(void); - BPoint GetMinimumSize(void); - void SetTitle(const char *newtitle); - void SetFlags(uint32 flags); - void SetLook(window_look wlook); - void UpdateFont(void); - void UpdateTitle(const char *string); - void SetFocus(bool focused); - void SetCloseButton(bool down); - void SetZoomButton(bool down); - void Draw(void); - void Draw(BRect update); - void DrawZoom(BRect r); - void DrawClose(BRect r); - void DrawTab(void); - void DrawFrame(void); - void CalculateBorders(void); - - uint32 taboffset; - rgb_color blue,blue2,black,gray,white,yellow; - rgb_color ltyellow,mdyellow, dkyellow; - BRect zoomrect,closerect,tabrect,frame, - resizerect,borderrect; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/DebugTools.cpp b/src/servers/app/proto5/DebugTools.cpp deleted file mode 100644 index 0a0c6aed1d..0000000000 --- a/src/servers/app/proto5/DebugTools.cpp +++ /dev/null @@ -1,219 +0,0 @@ -#include -#include -#include -#include "DebugTools.h" - -void PrintStatusToStream(status_t value) -{ - // Function which simply translates a returned status code into a string - // and dumps it to stdout - BString outstr; - switch(value) - { - case B_OK: - outstr="B_OK "; - break; - case B_NAME_NOT_FOUND: - outstr="B_NAME_NOT_FOUND "; - break; - case B_BAD_VALUE: - outstr="B_BAD_VALUE "; - break; - case B_ERROR: - outstr="B_ERROR "; - break; - case B_TIMED_OUT: - outstr="B_TIMED_OUT "; - break; - case B_NO_MORE_PORTS: - outstr="B_NO_MORE_PORTS "; - break; - case B_WOULD_BLOCK: - outstr="B_WOULD_BLOCK "; - break; - case B_BAD_PORT_ID: - outstr="B_BAD_PORT_ID "; - break; - case B_BAD_TEAM_ID: - outstr="B_BAD_TEAM_ID "; - break; - default: - outstr="undefined status value in debugtools::PrintStatusToStream() "; - break; - } - cout << "Status: " << outstr.String() << endl << flush; - -} - -void PrintColorSpaceToStream(color_space value) -{ - // Dump a color space to cout - BString outstr; - switch(value) - { - case B_RGB32: - outstr="B_RGB32 "; - break; - case B_RGBA32: - outstr="B_RGBA32 "; - break; - case B_RGB32_BIG: - outstr="B_RGB32_BIG "; - break; - case B_RGBA32_BIG: - outstr=" "; - break; - case B_UVL32: - outstr="B_UVL32 "; - break; - case B_UVLA32: - outstr="B_UVLA32 "; - break; - case B_LAB32: - outstr="B_LAB32 "; - break; - case B_LABA32: - outstr="B_LABA32 "; - break; - case B_HSI32: - outstr="B_HSI32 "; - break; - case B_HSIA32: - outstr="B_HSIA32 "; - break; - case B_HSV32: - outstr="B_HSV32 "; - break; - case B_HSVA32: - outstr="B_HSVA32 "; - break; - case B_HLS32: - outstr="B_HLS32 "; - break; - case B_HLSA32: - outstr="B_HLSA32 "; - break; - case B_CMY32: - outstr="B_CMY32"; - break; - case B_CMYA32: - outstr="B_CMYA32 "; - break; - case B_CMYK32: - outstr="B_CMYK32 "; - break; - case B_RGB24_BIG: - outstr="B_RGB24_BIG "; - break; - case B_RGB24: - outstr="B_RGB24 "; - break; - case B_LAB24: - outstr="B_LAB24 "; - break; - case B_UVL24: - outstr="B_UVL24 "; - break; - case B_HSI24: - outstr="B_HSI24 "; - break; - case B_HSV24: - outstr="B_HSV24 "; - break; - case B_HLS24: - outstr="B_HLS24 "; - break; - case B_CMY24: - outstr="B_CMY24 "; - break; - case B_GRAY1: - outstr="B_GRAY1 "; - break; - case B_CMAP8: - outstr="B_CMAP8 "; - break; - case B_GRAY8: - outstr="B_GRAY8 "; - break; - case B_YUV411: - outstr="B_YUV411 "; - break; - case B_YUV420: - outstr="B_YUV420 "; - break; - case B_YCbCr422: - outstr="B_YCbCr422 "; - break; - case B_YCbCr411: - outstr="B_YCbCr411 "; - break; - case B_YCbCr420: - outstr="B_YCbCr420 "; - break; - case B_YUV422: - outstr="B_YUV422 "; - break; - case B_YUV9: - outstr="B_YUV9 "; - break; - case B_YUV12: - outstr="B_YUV12 "; - break; - case B_RGB15: - outstr="B_RGB15 "; - break; - case B_RGBA15: - outstr="B_RGBA15 "; - break; - case B_RGB16: - outstr="B_RGB16 "; - break; - case B_RGB16_BIG: - outstr="B_RGB16_BIG "; - break; - case B_RGB15_BIG: - outstr="B_RGB15_BIG "; - break; - case B_RGBA15_BIG: - outstr="B_RGBA15_BIG "; - break; - case B_YCbCr444: - outstr="B_YCbCr444 "; - break; - case B_YUV444: - outstr="B_YUV444 "; - break; - case B_NO_COLOR_SPACE: - outstr="B_NO_COLOR_SPACE "; - break; - default: - outstr="Undefined color space "; - break; - } - cout << "Color Space: " << outstr.String() << flush; -} - -void TranslateMessageCodeToStream(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - - cout << "'" - << (char)((code & 0xFF000000) >> 24) - << (char)((code & 0x00FF0000) >> 16) - << (char)((code & 0x0000FF00) >> 8) - << (char)((code & 0x000000FF)) << "' "; -} - -void PrintMessageCode(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - - printf("Message code %c%c%c%c\n", - (char)((code & 0xFF000000) >> 24), - (char)((code & 0x00FF0000) >> 16), - (char)((code & 0x0000FF00) >> 8), - (char)((code & 0x000000FF)) ); -} - diff --git a/src/servers/app/proto5/DebugTools.h b/src/servers/app/proto5/DebugTools.h deleted file mode 100644 index 2f45b1ac6c..0000000000 --- a/src/servers/app/proto5/DebugTools.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _DEBUGTOOLS_H_ -#define _DEBUGTOOLS_H_ - -#include -#include - -void PrintStatusToStream(status_t value); -void PrintColorSpaceToStream(color_space value); -void TranslateMessageCodeToStream(int32 code); -void PrintMessageCode(int32 code); - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/Decorator.cpp b/src/servers/app/proto5/Decorator.cpp deleted file mode 100644 index 44349208ee..0000000000 --- a/src/servers/app/proto5/Decorator.cpp +++ /dev/null @@ -1,133 +0,0 @@ -#include "Decorator.h" - -Decorator::Decorator(Layer *lay, uint32 windowflags, window_look wlook) -{ - layer=lay; - flags=windowflags; - minsize.Set(0,0); - bsize.Set(1,1,1,1); - look=wlook; - focused=true; - driver=get_gfxdriver(); -} - -Decorator::~Decorator(void) -{ -} - -Layer* Decorator::GetLayer(void) -{ - return layer; -} - -click_type Decorator::Clicked(BPoint pt, uint32 buttons) -{ - return CLICK_NONE; -} - -void Decorator::Resize(BRect rect) -{ -} - -void Decorator::MoveBy(BPoint pt) -{ -} - -BRect Decorator::GetBorderSize(void) -{ - return BRect(0,0,0,0); -} - -BPoint Decorator::GetMinimumSize(void) -{ - return BPoint(0,0); -} - -void Decorator::SetFlags(uint32 flags) -{ -} - -uint32 Decorator::Flags(void) -{ - return flags; -} - -void Decorator::SetLook(window_look wlook) -{ -} - -uint32 Decorator::Look(void) -{ - return look; -} - -void Decorator::UpdateTitle(const char *string) -{ -} - -void Decorator::UpdateFont(void) -{ -} - -void Decorator::SetFocus(bool focused) -{ -} - -void Decorator::SetCloseButton(bool down) -{ -} - -void Decorator::SetZoomButton(bool down) -{ -} - -void Decorator::SetMinimizeButton(bool down) -{ -} - -bool Decorator::GetCloseButton(void) const -{ - return closestate; -} - -bool Decorator::GetZoomButton(void) const -{ - return zoomstate; -} - -bool Decorator::GetMinimizeButton(void) const -{ - return minstate; -} - -void Decorator::Draw(BRect update) -{ -} - -void Decorator::Draw(void) -{ -} - -void Decorator::DrawTab(void) -{ -} - -void Decorator::DrawFrame(void) -{ -} - -void Decorator::DrawZoom(BRect r) -{ -} - -void Decorator::DrawClose(BRect r) -{ -} - -void Decorator::DrawMinimize(BRect r) -{ -} - -void Decorator::CalculateBorders(void) -{ -} diff --git a/src/servers/app/proto5/Decorator.h b/src/servers/app/proto5/Decorator.h deleted file mode 100644 index 78ed26058d..0000000000 --- a/src/servers/app/proto5/Decorator.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef _DECORATOR_H_ -#define _DECORATOR_H_ - -#include -#include -#include -#include "Desktop.h" - -class Layer; -class DisplayDriver; - -typedef enum { CLICK_NONE=0, CLICK_ZOOM, CLICK_CLOSE, CLICK_MINIMIZE, - CLICK_TAB, CLICK_DRAG, CLICK_MOVETOBACK, CLICK_MOVETOFRONT, - - CLICK_RESIZE, CLICK_RESIZE_L, CLICK_RESIZE_T, - CLICK_RESIZE_R, CLICK_RESIZE_B, CLICK_RESIZE_LT, CLICK_RESIZE_RT, - CLICK_RESIZE_LB, CLICK_RESIZE_RB } click_type; - -class Decorator -{ -public: - Decorator(Layer *lay, uint32 windowflags, window_look wlook); - virtual ~Decorator(void); - - Layer* GetLayer(void); - - virtual click_type Clicked(BPoint pt, uint32 buttons); - virtual void Resize(BRect rect); - virtual void MoveBy(BPoint pt); - virtual BRect GetBorderSize(void); - virtual BPoint GetMinimumSize(void); - virtual void SetFlags(uint32 flags); - virtual uint32 Flags(void); - virtual void SetLook(window_look wlook); - virtual uint32 Look(void); - virtual void UpdateTitle(const char *string); - virtual void UpdateFont(void); - virtual void SetFocus(bool focused); - virtual void SetCloseButton(bool down); - virtual void SetZoomButton(bool down); - virtual void SetMinimizeButton(bool down); - bool GetCloseButton(void) const; - bool GetZoomButton(void) const; - bool GetMinimizeButton(void) const; - virtual void Draw(BRect update); - virtual void Draw(void); - virtual void DrawTab(void); - virtual void DrawFrame(void); - virtual void DrawZoom(BRect r); - virtual void DrawClose(BRect r); - virtual void DrawMinimize(BRect r); -protected: - virtual void CalculateBorders(void); - Layer *layer; - uint32 flags; - BPoint minsize; - BRect bsize; - uint32 look; - bool focused; - bool zoomstate, closestate, minstate; - DisplayDriver *driver; -}; - -// C exports to hide the class-related stuff from the rest of the -// server. Written for each decorator, but don't amount to much. -typedef uint16 get_decorator_version(void); -typedef Decorator *create_decorator(Layer *lay, uint32 dflags, window_look wlook); - -#endif diff --git a/src/servers/app/proto5/Desktop.cpp b/src/servers/app/proto5/Desktop.cpp deleted file mode 100644 index 148880ae80..0000000000 --- a/src/servers/app/proto5/Desktop.cpp +++ /dev/null @@ -1,403 +0,0 @@ -/* - Desktop.cpp: - Code necessary to handle the Desktop, defined as the collection of workspaces. -*/ - -#define DEBUG_WORKSPACES - -#include -#include -#include -#include -#include -#include "ServerWindow.h" -#include "ServerCursor.h" -#include "Layer.h" -#include "DisplayDriver.h" -#include "ViewDriver.h" -#include "SecondDriver.h" -#include "Desktop.h" -#include "WindowBorder.h" - -class ServerWindow; -class ServerBitmap; -class Workspace; - -// Quick hack to make setting rgb_colors much easier to live with -void set_rgb_color(rgb_color *col,uint8 red, uint8 green, uint8 blue, uint8 alpha=255) -{ - col->red=red; - col->green=green; - col->blue=blue; - col->alpha=alpha; -} - -//--------------------GLOBALS------------------------- -uint32 workspace_count, active_workspace; -BList *desktop; -ServerCursor *startup_cursor; -Workspace *pactive_workspace; -color_map system_palette; -DisplayDriver *gfxdriver; -int32 token_count=-1; -BLocker *workspacelock; -BLocker *layerlock; -UpdateNode *upnode; -//---------------------------------------------------- - - -//-------------------INTERNAL CLASS DEFS-------------- -class Workspace -{ -public: - Workspace(void); - Workspace(BPath imagepath); - ~Workspace(); - void SetBGColor(rgb_color col); - rgb_color BGColor(void); - thread_id tid; - - RootLayer *toplayer; - BList focuslist; - rgb_color bgcolor; - screen_info screendata, - olddata; -}; - -DisplayDriver *get_gfxdriver(void) -{ - return gfxdriver; -} - -Workspace::Workspace(void) -{ - workspace_count++; - - // default values - focuslist.MakeEmpty(); - bgcolor.red=51; - bgcolor.green=102; - bgcolor.blue=160; - screendata.mode=B_CMAP8; - screendata.spaces=B_8_BIT_640x480; - screendata.refresh_rate=60.0; - screendata.min_refresh_rate=60.0; - screendata.max_refresh_rate=60.0; - screendata.h_position=(uchar)50; - screendata.v_position=(uchar)50; - screendata.h_size=(uchar)50; - screendata.v_size=(uchar)50; - olddata=screendata; - - // We need one top layer for each workspace times the number of monitors - ick. - // Currently, we only have 1 monitor. *Whew* - char wspace_name[128]; - sprintf(wspace_name,"workspace %ld root",workspace_count); - toplayer=new RootLayer(BRect(0,0,639,439),wspace_name); -} - -Workspace::~Workspace(void) - { - workspace_count--; - toplayer->PruneTree(); -} - -void Workspace::SetBGColor(rgb_color col) -{ - bgcolor=col; - toplayer->SetColor(col); -#ifdef DEBUG_WORKSPACES -printf("Workspace::SetBGColor(%d,%d,%d,%d)\n",bgcolor.red,bgcolor.green, - bgcolor.blue,bgcolor.alpha); -#endif -} - -rgb_color Workspace::BGColor(void) -{ - return bgcolor; -} -//--------------------------------------------------- - - -//-----------------GLOBAL FUNCTION DEFS--------------- - -void init_desktop(int8 workspaces) -{ -#ifdef DEBUG_WORKSPACES -printf("init_desktop(%d)\n",workspaces); -#endif - workspace_count=workspaces; - if(workspace_count==0) - workspace_count++; - - // Instantiate and initialize display driver - gfxdriver=new ViewDriver(); -// gfxdriver=new SecondDriver(); - gfxdriver->Initialize(); - - workspacelock=new BLocker(); - layerlock=new BLocker(); - -#ifdef DEBUG_WORKSPACES -printf("Driver %s\n", (gfxdriver->IsInitialized()==true)?"initialized":"NOT initialized"); -#endif - - desktop=new BList(0); - - // Create the workspaces we're supposed to have - for(int8 i=0; iAddItem(new Workspace()); - } - - // Load workspace preferences here - - // We're going to punch in some hardcoded settings for testing purposes. - // There are 3 workspaces hardcoded in for now, but we'll only use the - // second one. - Workspace *wksp=(Workspace*)desktop->ItemAt(1); - if(wksp!=NULL) // in case I forgot something - { - rgb_color bcol; - set_rgb_color(&bcol,0,200,236); - -// set_rgb_color(&(wksp->bgcolor),0,200,236); - wksp->SetBGColor(bcol); - screen_info *tempsd=&(wksp->screendata); - tempsd->mode=B_CMAP8; - tempsd->spaces=B_8_BIT_800x600; - tempsd->frame.Set(0,0,799,599); - } - else - printf("DW goofed on the workspace index :P\n"); - - // Activate workspace 0 - pactive_workspace=(Workspace *)desktop->ItemAt(0); - gfxdriver->SetScreen(pactive_workspace->screendata.spaces); - - // Clear the screen - set_rgb_color(&(pactive_workspace->toplayer->bgcolor),80,85,152); - gfxdriver->Clear(pactive_workspace->toplayer->bgcolor); - startup_cursor=new ServerCursor(default_cursor); - gfxdriver->SetCursor(startup_cursor); - - pactive_workspace->toplayer->SetVisible(true); -#ifdef DEBUG_WORKSPACES -printf("Desktop initialized\n"); -#endif -} - -void shutdown_desktop(void) -{ - int32 i,count=desktop->CountItems(); - Workspace *w; - for(i=0;iItemAt(i); - if(w!=NULL) - delete w; - } - desktop->MakeEmpty(); - delete desktop; - gfxdriver->Shutdown(); - delete gfxdriver; - delete workspacelock; - delete layerlock; - delete startup_cursor; -} - - -int32 CountWorkspaces(void) -{ -#ifdef DEBUG_WORKSPACES -printf("CountWorkspaces() returned %ld\n",workspace_count); -#endif - return workspace_count; -} - -void SetWorkspaceCount(uint32 count) -{ - if(count<0) - { -#ifdef DEBUG_WORKSPACES -printf("SetWorkspaceCount(value<0) - DOH!\n"); -#endif - return; - } - if(count==workspace_count) - return; - - // Activate last workspace in new set if we're using one to be nuked - if(countItemAt(i)!=NULL) - { - delete (Workspace*)desktop->ItemAt(i); - desktop->RemoveItem(i); - } - } - } - else - { - // count > workspace_count here - - // Once we have default workspace preferences which can be set by the - // user, we'll end up having to initialize newly-added workspaces to that - // data. In the mean time, the defaults in the constructor will do. :) - for(uint32 i=count;iAddItem(new Workspace()); - } - } - - // don't forget to update our global! - workspace_count=desktop->CountItems(); - -#ifdef DEBUG_WORKSPACES -printf("SetWorkspaceCount(%ld)\n",workspace_count); -#endif - -} - -int32 CurrentWorkspace(void) -{ -#ifdef DEBUG_WORKSPACES -printf("CurrentWorkspace() returned %ld\n",active_workspace); -#endif - return active_workspace; -} - -void ActivateWorkspace(uint32 workspace) -{ - // In order to change workspaces, we'll need to make all the necessary - // changes to the screen to fit the new one, such as resolution, - // background color, color depth, refresh rate, etc. - - if(workspace>workspace_count || workspace<0) - return; - - Workspace *proposed=(Workspace *)desktop->ItemAt(workspace); - - if(proposed==NULL) - return; - - // Here's where we update all the screen stuff -// if(pactive_workspace->screendata.spaces != proposed->screendata.spaces) -// { - gfxdriver->SetScreen(proposed->screendata.spaces); - gfxdriver->Clear(proposed->bgcolor); - pactive_workspace->toplayer->SetVisible(false); - proposed->toplayer->SetVisible(true); -// } - // more if != then change code goes here. Currently, a lot of the code which - // uses this stuff is not implemented, so it's kind of moot. However, when we - // use the real graphics HW, it'll become important. - - // actually set our active workspace data to reflect the change in workspaces - pactive_workspace=proposed; - active_workspace=workspace; -#ifdef DEBUG_WORKSPACES -printf("ActivateWorkspace(%ld)\n",active_workspace); -#endif -} - -const color_map *SystemColors(void) -{ - return (const color_map *)&system_palette; -} - -status_t SetScreenSpace(uint32 index, uint32 res, bool stick = true) -{ -#ifdef DEBUG_WORKSPACES -printf("SetScreenSpace(%ld,%lu, %s)\n",index,res,(stick==true)?"true":"false"); -#endif - - if(index>workspace_count-1) - { - printf("SetScreenSpace was passed invalid workspace value %ld\n",index); - return B_ERROR; - } - if(res>0x800000) // the last "normal" screen mode defined in GraphicsDefs.h - { - printf("SetScreenSpace was passed invalid screen value %lu\n",res); - return B_ERROR; - } - - // When we actually use app_server preferences, we'll save the screen mode to - // the preferences so that we use this mode next boot. For now, we treat stick==false - if(stick==true) - { - // save the screen data here - } - if(index==active_workspace) - { - gfxdriver->SetScreen(res); - gfxdriver->Clear(pactive_workspace->bgcolor); - } - else - { - // just set the workspace's data here. right now, do nothing. - } - return B_OK; -} - -int32 GetViewToken(void) -{ - // Used to generate view and layer tokens - return ++token_count; -} - -void AddWindowToDesktop(ServerWindow *win,uint32 workspace) -{ - // Adds the top layer of each window to the root layer in the specified workspace. - // Note that in calling AddChild, a redraw is invoked - if(!win || workspace>workspace_count-1) - return; - - workspacelock->Lock(); - Workspace *w=(Workspace *)desktop->ItemAt(workspace); - if(w) - { - // a check for the B_CURRENT_WORKSPACE or B_ALL_WORKSPACES specifiers will - // go here later - - w->toplayer->AddChild(win->winborder); - } - workspacelock->Unlock(); -} - -void RemoveWindowFromDesktop(ServerWindow *win) -{ - // A little more time-consuming than AddWindow - if(!win) - return; - - workspacelock->Lock(); - - // a check for the B_CURRENT_WORKSPACE or B_ALL_WORKSPACES specifiers will - // go here later - - // If the window belongs on only 1 workspace, calling RemoveSelf is the most - // elegant solution. - win->winborder->RemoveSelf(); - workspacelock->Unlock(); -} - -Layer *GetRootLayer(void) -{ - layerlock->Lock(); - Layer *lay=(workspace_count>0)?pactive_workspace->toplayer:NULL; - layerlock->Unlock(); - - return lay; -} - -// Another "just in case DW screws up again" section -#ifdef DEBUG_WORKSPACES -#undef DEBUG_WORKSPACES -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/Desktop.h b/src/servers/app/proto5/Desktop.h deleted file mode 100644 index 54b5e1bf3f..0000000000 --- a/src/servers/app/proto5/Desktop.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef _OBDESKTOP_H_ -#define _OBDESKTOP_H_ - - -#include -#include -#include - -class DisplayDriver; -class ServerWindow; -class Layer; - -void init_desktop(int8 workspaces); -void shutdown_desktop(void); -DisplayDriver *get_gfxdriver(void); - -// Workspace access functions -int32 CountWorkspaces(void); -void SetWorkspaceCount(uint32 count); - -int32 CurrentWorkspace(void); -void ActivateWorkspace(uint32 workspace); - -const color_map *SystemColors(void); -status_t SetScreenSpace(uint32 index, uint32 res, bool stick=true); - -void AddWindowToDesktop(ServerWindow *win,uint32 workspace); -void RemoveWindowFromDesktop(ServerWindow *win); -Layer *GetRootLayer(void); -int32 GetViewToken(void); - -typedef struct -{ - color_space mode; - BRect frame; - uint32 spaces; - float min_refresh_rate; - float max_refresh_rate; - float refresh_rate; - uchar h_position; - uchar v_position; - uchar h_size; - uchar v_size; -} screen_info; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/DisplayDriver.cpp b/src/servers/app/proto5/DisplayDriver.cpp deleted file mode 100644 index a947061984..0000000000 --- a/src/servers/app/proto5/DisplayDriver.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/* - DisplayDriver.cpp - Modular class to allow the server to not care what the ultimate output is - for graphics calls. -*/ -#include "DisplayDriver.h" -#include "ServerCursor.h" - -DisplayDriver::DisplayDriver(void) -{ - is_initialized=false; - cursor_visible=false; - show_on_move=false; - locker=new BLocker(); - - penpos.Set(0,0); - pensize=0.0; - - // initialize to BView defaults - highcol.red=0; - highcol.green=0; - highcol.blue=0; - highcol.alpha=0; - lowcol.red=255; - lowcol.green=255; - lowcol.blue=255; - lowcol.alpha=255; -} - -DisplayDriver::~DisplayDriver(void) -{ - delete locker; -} - -void DisplayDriver::Initialize(void) -{ // Loading loop to find proper driver or other setup for the driver -} - -bool DisplayDriver::IsInitialized(void) -{ // Let us know whether things worked out ok - return is_initialized; -} - -void DisplayDriver::Shutdown(void) -{ // For use by subclasses -} - -void DisplayDriver::SafeMode(void) -{ // Set video mode to 640x480x256 mode -} - -void DisplayDriver::Reset(void) -{ // Intended to reload and restart driver. Defaults to a safe mode -} - -void DisplayDriver::Clear(uint8 red,uint8 green,uint8 blue) -{ -} - -void DisplayDriver::Clear(rgb_color col) -{ -} - -void DisplayDriver::SetScreen(uint32 space) -{ // Set the screen to a particular mode -} - -int32 DisplayDriver::GetHeight(void) -{ // Gets the height of the current mode - return ginfo->height; -} - -int32 DisplayDriver::GetWidth(void) -{ // Gets the width of the current mode - return ginfo->width; -} - -int DisplayDriver::GetDepth(void) -{ // Gets the color depth of the current mode - return ginfo->bytes_per_row; -} - -void DisplayDriver::Blit(BRect src, BRect dest) -{ // Screen-to-screen bitmap copying -} - -void DisplayDriver::DrawBitmap(ServerBitmap *bitmap) -{ -} - -void DisplayDriver::DrawChar(char c, BPoint point) -{ -} - -void DisplayDriver::DrawString(char *string, int length, BPoint point) -{ -} - -void DisplayDriver::FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern) -{ -} - -void DisplayDriver::FillBezier(BPoint *points, uint8 *pattern) -{ -} - -void DisplayDriver::FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern) -{ -} - -void DisplayDriver::FillPolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void DisplayDriver::FillRect(BRect rect, uint8 *pattern) -{ -} - -void DisplayDriver::FillRect(BRect rect, rgb_color col) -{ -} - -void DisplayDriver::FillRegion(BRegion *region) -{ -} - -void DisplayDriver::FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ -} - -void DisplayDriver::FillShape(BShape *shape) -{ -} - -void DisplayDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ -} - -void DisplayDriver::HideCursor(void) -{ -} - -bool DisplayDriver::IsCursorHidden(void) -{ - return false; -} - -void DisplayDriver::ObscureCursor(void) -{ // Hides cursor until mouse is moved -} - -void DisplayDriver::MoveCursorTo(float x, float y) -{ -} - -void DisplayDriver::MovePenTo(BPoint pt) -{ // Moves the graphics pen to this position -} - -BPoint DisplayDriver::PenPosition(void) -{ - return penpos; -} - -float DisplayDriver::PenSize(void) -{ - return pensize; -} - -void DisplayDriver::SetCursor(ServerCursor *cursor) -{ -} - -void DisplayDriver::SetCursor(int32 value) -{ // This is used just to provide an easy way of setting one of the default cursors - // Then again, I may just get rid of this thing. -} - -void DisplayDriver::SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ -} - -void DisplayDriver::SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ -} - -void DisplayDriver::SetPenSize(float size) -{ -} - -void DisplayDriver::SetPixel(int x, int y, uint8 *pattern) -{ // Internal function utilized by other functions to draw to the buffer - // Will eventually be an inline function -} - -void DisplayDriver::ShowCursor(void) -{ -} - -void DisplayDriver::StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeBezier(BPoint *points, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern) -{ -} - -void DisplayDriver::StrokeLine(BPoint point, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeLine(BPoint pt1, BPoint pt2, rgb_color col) -{ -} - -void DisplayDriver::StrokePolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void DisplayDriver::StrokeRect(BRect rect, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeRect(BRect rect, rgb_color col) -{ -} - -void DisplayDriver::StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeShape(BShape *shape) -{ -} - -void DisplayDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ -} diff --git a/src/servers/app/proto5/DisplayDriver.h b/src/servers/app/proto5/DisplayDriver.h deleted file mode 100644 index 77a6e707b9..0000000000 --- a/src/servers/app/proto5/DisplayDriver.h +++ /dev/null @@ -1,127 +0,0 @@ -#ifndef _GFX_DRIVER_H_ -#define _GFX_DRIVER_H_ - -#include -#include -#include -#include "Desktop.h" - -class ServerBitmap; -class ServerCursor; - -#ifndef ROUND - #define ROUND(a) ( (a-long(a))>=.5)?(long(a)+1):(long(a)) -#endif - -typedef struct -{ - uchar *xormask, *andmask; - int32 width, height; - int32 hotx, hoty; - -} cursor_data; - -#ifndef HOOK_DEFINE_CURSOR - -#define HOOK_DEFINE_CURSOR 0 -#define HOOK_MOVE_CURSOR 1 -#define HOOK_SHOW_CURSOR 2 -#define HOOK_DRAW_LINE_8BIT 3 -#define HOOK_DRAW_LINE_16BIT 12 -#define HOOK_DRAW_LINE_32BIT 4 -#define HOOK_DRAW_RECT_8BIT 5 -#define HOOK_DRAW_RECT_16BIT 13 -#define HOOK_DRAW_RECT_32BIT 6 -#define HOOK_BLIT 7 -#define HOOK_DRAW_ARRAY_8BIT 8 -#define HOOK_DRAW_ARRAY_16BIT 14 // Not implemented in current R5 drivers -#define HOOK_DRAW_ARRAY_32BIT 9 -#define HOOK_SYNC 10 -#define HOOK_INVERT_RECT 11 - -#endif - -class ServerCursor; - -class DisplayDriver -{ -public: - DisplayDriver(void); - virtual ~DisplayDriver(void); - - virtual void Initialize(void); // Sets the driver - virtual bool IsInitialized(void); - virtual void Shutdown(void); // You never know when you'll need this - - virtual void SafeMode(void); // Easy-access functions for common tasks - virtual void Reset(void); - virtual void Clear(uint8 red,uint8 green,uint8 blue); - virtual void Clear(rgb_color col); - - // Settings functions - virtual void SetScreen(uint32 space); - virtual int32 GetHeight(void); - virtual int32 GetWidth(void); - virtual int GetDepth(void); - - // Drawing functions - virtual void Blit(BRect src, BRect dest); - virtual void DrawBitmap(ServerBitmap *bitmap); - virtual void DrawChar(char c, BPoint point); - virtual void DrawString(char *string, int length, BPoint point); - - virtual void FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void FillBezier(BPoint *points, uint8 *pattern); - virtual void FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void FillPolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void FillRect(BRect rect, uint8 *pattern); - virtual void FillRect(BRect rect, rgb_color col); - virtual void FillRegion(BRegion *region); - virtual void FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void FillShape(BShape *shape); - virtual void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - -// virtual void GetBlendingMode(source_alpha *srcmode, alpha_function *funcmode); -// virtual drawing_mode GetDrawingMode(void); - virtual void HideCursor(void); - virtual bool IsCursorHidden(void); - virtual void MoveCursorTo(float x, float y); - virtual void MovePenTo(BPoint pt); - virtual void ObscureCursor(void); - virtual BPoint PenPosition(void); - virtual float PenSize(void); -// virtual void SetBlendingMode(source_alpha srcmode, alpha_function funcmode); - virtual void SetCursor(int32 value); - virtual void SetCursor(ServerCursor *cursor); -// virtual void SetDrawingMode(drawing_mode mode); - virtual void ShowCursor(void); - virtual void SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetPenSize(float size); - virtual void SetPixel(int x, int y, uint8 *pattern); - - virtual void StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void StrokeBezier(BPoint *points, uint8 *pattern); - virtual void StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void StrokeLine(BPoint point, uint8 *pattern); - virtual void StrokeLine(BPoint pt1, BPoint pt2, rgb_color col); - virtual void StrokePolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void StrokeRect(BRect rect,uint8 *pattern); - virtual void StrokeRect(BRect rect, rgb_color col); - virtual void StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void StrokeShape(BShape *shape); - virtual void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - - graphics_card_hook ghooks[48]; - graphics_card_info *ginfo; - -protected: - bool is_initialized, cursor_visible, show_on_move; - ServerCursor *current_cursor; - BLocker *locker; - rgb_color highcol, lowcol; - BPoint penpos; - float pensize; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/Globals.h b/src/servers/app/proto5/Globals.h deleted file mode 100644 index 2753cad1aa..0000000000 --- a/src/servers/app/proto5/Globals.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _SERVER_GLOBALS_H_ -#define _SERVER_GLOBALS_H_ - -#include -BList *gBitmaplist, *gLayerlist; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/Layer.cpp b/src/servers/app/proto5/Layer.cpp deleted file mode 100644 index 530966ddb4..0000000000 --- a/src/servers/app/proto5/Layer.cpp +++ /dev/null @@ -1,735 +0,0 @@ -/* - Layer.cpp - Class used for rendering to the frame buffer. One layer per view on screen and - also for window decorators -*/ -#include "Layer.h" -#include "ServerWindow.h" -#include "Desktop.h" -#include "PortLink.h" -#include "DisplayDriver.h" -#include -#include -#include -#include -#include - -#define DEBUG_LAYERS - -Layer::Layer(BRect rect, const char *layername, ServerWindow *srvwin, - int32 viewflags, int32 token) -{ - if(rect.IsValid()) - // frame is in parent layer's coordinates - frame=rect; - else - { -#ifdef DEBUG_LAYERS -printf("Invalid BRect: "); rect.PrintToStream(); -#endif - frame.Set(0,0,1,1); - } - - name=new BString(layername); - - // Layer does not start out as a part of the tree - parent=NULL; - uppersibling=NULL; - lowersibling=NULL; - topchild=NULL; - bottomchild=NULL; - - visible=new BRegion(Bounds()); - invalid=NULL; - - serverwin=srvwin; - - view_token=token; - - flags=viewflags; - - hidecount=0; - is_dirty=false; - is_updating=false; - - // Because this is not part of the tree, level is negative (thus, irrelevant) - level=0; -#ifdef DEBUG_LAYERS - PrintToStream(); -#endif -} - -Layer::Layer(BRect rect, const char *layername) -{ - // This constructor is used for the top layer in each workspace - if(rect.IsValid()) - frame=rect; - else - frame.Set(0,0,1,1); - - name=new BString(layername); - - // Layer is the root for the workspace - parent=NULL; - uppersibling=NULL; - lowersibling=NULL; - topchild=NULL; - bottomchild=NULL; - - visible=new BRegion(Bounds()); - invalid=NULL; - - serverwin=NULL; - flags=0; - hidecount=0; - is_dirty=false; - - level=0; - - view_token=-1; -#ifdef DEBUG_LAYERS - PrintToStream(); -#endif -} - -Layer::~Layer(void) -{ -#ifdef DEBUG_LAYERS - cout << "Layer Destructor for " << name->String() << endl << flush; -#endif - if(visible!=NULL) - delete visible; - if(invalid!=NULL) - delete invalid; - delete name; -} - -void Layer::AddChild(Layer *layer) -{ - // Adds a layer to the top of the layer's children -#ifdef DEBUG_LAYERS -printf("AddChild %s\n",layer->name->String()); -#endif - - if(layer->parent!=NULL) - { - printf("ERROR: AddChild(): View already has a parent\n"); - return; - } - layer->parent=this; - if(layer->visible && layer->hidecount==0 && visible) - { - // Technically, we could safely take the address of ConvertToParent(BRegion) - // but we don't just to avoid a compiler nag - - BRegion *reg=new BRegion(layer->ConvertToParent(layer->visible)); - visible->Exclude(reg); - delete reg; - } - - if(topchild!=NULL) - { - layer->lowersibling=topchild; - topchild->uppersibling=layer; - if(layer->frame.Intersects(layer->lowersibling->frame)) - { - if(layer->lowersibling->visible && layer->lowersibling->hidecount==0) - { - BRegion *reg=new BRegion(ConvertToParent(layer->visible)); - BRegion *reg2=new BRegion(layer->lowersibling->ConvertFromParent(reg)); - delete reg; - layer->lowersibling->visible->Exclude(reg2); - delete reg2; - } - } - } - else - bottomchild=layer; - topchild=layer; - layer->level=level+1; -} - -void Layer::RemoveChild(Layer *layer) -{ - // Remove a layer from the tree -#ifdef DEBUG_LAYERS - cout << "RemoveChild " << layer->name->String() << endl << flush; -#endif - - if(layer->parent==NULL) - { - cout << "ERROR: RemoveChild(): View doesn't have a parent\n" << flush; - return; - } - if(layer->parent!=this) - { - cout << "ERROR: RemoveChild(): View is not a child of this layer\n" << flush; - return; - } - - if(hidecount==0 && layer->visible && layer->parent->visible) - { - BRegion *reg=new BRegion(ConvertToParent(visible)); - layer->parent->visible->Include(reg); - delete reg; - } - - // Take care of parent - layer->parent=NULL; - if(topchild==layer) - topchild=layer->lowersibling; - if(bottomchild==layer) - bottomchild=layer->uppersibling; - - // Take care of siblings - if(layer->uppersibling!=NULL) - layer->uppersibling->lowersibling=layer->lowersibling; - if(layer->lowersibling!=NULL) - layer->lowersibling->lowersibling=layer->uppersibling; - layer->SetLevel(0); - layer->uppersibling=NULL; - layer->lowersibling=NULL; -} - -void Layer::RemoveSelf(void) -{ - // A Layer removes itself from the tree (duh) -#ifdef DEBUG_LAYERS - cout << "RemoveChild " << name->String() << endl; -#endif - if(parent==NULL) - { - cout << "ERROR: RemoveSelf(): View doesn't have a parent\n" << flush; - return; - } - parent->RemoveChild(this); -} - -Layer *Layer::GetChildAt(BPoint pt, bool recursive=false) -{ - // 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 *child; - if(recursive) - { - for(child=topchild; child!=NULL; child=child->lowersibling) - { - if(child->topchild!=NULL) - child->GetChildAt(pt,true); - - if(child->hidecount>0) - continue; - - if(child->frame.Contains(pt)) - return child; - } - } - else - { - for(child=topchild; child!=NULL; child=child->lowersibling) - { - if(child->hidecount>0) - continue; - - if(child->frame.Contains(pt)) - return child; - } - } - return NULL; -} - -BRect Layer::Bounds(void) -{ - return frame.OffsetToCopy(0,0); -} - -BRect Layer::Frame(void) -{ - return frame; -} - -void Layer::SetLevel(int32 value) -{ - // Sets hierarchy level of layer and all children -#ifdef DEBUG_LAYERS - printf("SetLevel %ld\n",value); -#endif - level=value; - - Layer *lay; - - lay=topchild; - - while(lay!=NULL) - { - if(lay->topchild!=NULL) - lay->topchild->SetLevel(value+1); - lay=lay->lowersibling; - } -} - -void Layer::PruneTree(void) -{ - // recursively deletes all children (and grandchildren, etc) of the passed layer - // This is mostly used for server shutdown or deleting a workspace -#ifdef DEBUG_LAYERS - printf("PruneTree() at level %ld\n", level); -#endif - Layer *lay,*nextlay; - - lay=topchild; - - while(lay!=NULL) - { - if(lay->topchild!=NULL) - lay->topchild->PruneTree(); - nextlay=lay->lowersibling; - delete lay; - lay=nextlay; - } - // Man, this thing is short. Elegant, ain't it? :P -} - -Layer *Layer::FindLayer(int32 token) -{ - // recursive search for a layer based on its view token - Layer *lay, *trylay; - - // Search child layers first - for(lay=topchild; lay!=NULL; lay=lay->lowersibling) - { - if(lay->view_token==token) - return lay; - } - - // Hmmm... not in this layer's children. Try lower descendants - for(lay=topchild; lay!=NULL; lay=lay->lowersibling) - { - trylay=lay->FindLayer(token); - if(trylay) - return trylay; - } - - // Well, we got this far in the function, so apparently there is no match to be found - return NULL; -} - -// Tested -void Layer::Invalidate(BRegion region) -{ - int32 i; - BRect r; - - // See if the region intersects with our current area - if(region.Intersects(Bounds()) && hidecount==0) - { - BRegion clippedreg(region); - clippedreg.IntersectWith(visible); - if(clippedreg.CountRects()>0) - { - is_dirty=true; - if(invalid) - invalid->Include(&clippedreg); - else - invalid=new BRegion(clippedreg); - } - } - - BRegion *reg; - for(Layer *lay=topchild;lay!=NULL; lay=lay->lowersibling) - { - if(lay->hidecount==0) - { - reg=new BRegion(lay->ConvertFromParent(®ion)); - - for(i=0;iCountRects();i++) - { - r=reg->RectAt(i); - if(frame.Intersects(r)) - lay->Invalidate(r); - } - - delete reg; - } - } -} - -// Tested -void Layer::Invalidate(BRect rect) -{ - // Make our own section dirty and pass it on to any children, if necessary.... - // YES, WE ARE SHARING DIRT! Mudpies anyone? :D - - if(Bounds().Intersects(rect)) - { - - // Clip the rectangle to the visible region of the layer - if(visible->Intersects(rect)) - { - BRegion reg(rect); - reg.IntersectWith(visible); - if(reg.CountRects()>0) - { - is_dirty=true; - if(invalid) - invalid->Include(®); - else - invalid=new BRegion(reg); - } - } - } - for(Layer *lay=topchild;lay!=NULL; lay=lay->lowersibling) - lay->Invalidate(lay->ConvertFromParent(rect)); -} - -void Layer::RequestDraw(void) -{ -/* if(visible==NULL || hidecount>0) - return; - - if(serverwin) - { - if(invalid==NULL) - invalid=new BRegion(*visible); - serverwin->RequestDraw(invalid->Frame()); - delete invalid; - invalid=NULL; - } - - is_dirty=false; - for(Layer *lay=topchild; lay!=NULL; lay=lay->lowersibling) - { - if(lay->IsDirty()) - lay->RequestDraw(); - } -*/ -} - -bool Layer::IsDirty(void) const -{ - return is_dirty; -} - -void Layer::ShowLayer(void) -{ - if(hidecount==0) - return; - - hidecount--; - if(hidecount==0) - { - BRegion *reg=new BRegion(ConvertToParent(visible)); - parent->visible->Exclude(reg); - delete reg; - is_dirty=true; - } - - Layer *child; - for(child=topchild; child!=NULL; child=child->lowersibling) - child->ShowLayer(); -} - -void Layer::HideLayer(void) -{ - if(hidecount==0) - { - BRegion *reg=new BRegion(ConvertToParent(visible)); - parent->visible->Include(reg); - delete reg; - parent->is_dirty=true; - is_dirty=true; - } - hidecount++; - - Layer *child; - for(child=topchild; child!=NULL; child=child->lowersibling) - child->HideLayer(); -} - -// Tested -uint32 Layer::CountChildren(void) -{ - uint32 i=0; - Layer *lay=topchild; - while(lay!=NULL) - { - lay=lay->lowersibling; - i++; - } - return i; -} - -void Layer::MoveBy(float x, float y) -{ - BRect oldframe(frame); - frame.OffsetBy(x,y); - - if(parent) - { - if(parent->invalid==NULL) - parent->invalid=new BRegion(oldframe); - else - parent->invalid->Include(oldframe); - } - -// for(Layer *lay=topchild; lay!=NULL; lay=lay->lowersibling) -// lay->MoveBy(x,y); - Invalidate(Bounds()); -} - -void Layer::PrintToStream(void) -{ - printf("-----------\nLayer %s\n",name->String()); - if(parent) - printf("Parent: %s (%p)\n",parent->name->String(), parent); - else - printf("Parent: NULL\n"); - if(uppersibling) - printf("Upper sibling: %s (%p)\n",uppersibling->name->String(), uppersibling); - else - printf("Upper sibling: NULL\n"); - if(lowersibling) - printf("Lower sibling: %s (%p)\n",lowersibling->name->String(), lowersibling); - else - printf("Lower sibling: NULL\n"); - if(topchild) - printf("Top child: %s (%p)\n",topchild->name->String(), topchild); - else - printf("Top child: NULL\n"); - if(bottomchild) - printf("Bottom child: %s (%p)\n",bottomchild->name->String(), bottomchild); - else - printf("Bottom child: NULL\n"); - printf("Frame: "); frame.PrintToStream(); - printf("Token: %ld\nLevel: %ld\n",view_token, level); - printf("Hide count: %u\n",hidecount); - if(invalid) - { - printf("Invalid Areas: "); invalid->PrintToStream(); - } - else - printf("Invalid Areas: NULL\n"); - if(visible) - { - printf("Visible Areas: "); visible->PrintToStream(); - } - else - printf("Visible Areas: NULL\n"); - printf("Is updating = %s\n",(is_updating)?"yes":"no"); -} - -// Tested -BRect Layer::ConvertToParent(BRect rect) -{ - return (rect.OffsetByCopy(frame.LeftTop())); -} - -// Tested -BPoint Layer::ConvertToParent(BPoint point) -{ - float x=point.x + frame.left, - y=point.y+frame.top; - return (BPoint(x,y)); -} - -// Tested -BRegion Layer::ConvertToParent(BRegion *reg) -{ - BRegion newreg; - for(int32 i=0; iCountRects();i++) - newreg.Include(ConvertToParent(reg->RectAt(i))); - return BRegion(newreg); -} - -// Tested -BRect Layer::ConvertFromParent(BRect rect) -{ - return (rect.OffsetByCopy(frame.left*-1,frame.top*-1)); -} - -// Tested -BPoint Layer::ConvertFromParent(BPoint point) -{ - return ( point-frame.LeftTop()); -} - -// Tested -BRegion Layer::ConvertFromParent(BRegion *reg) -{ - BRegion newreg; - for(int32 i=0; iCountRects();i++) - newreg.Include(ConvertFromParent(reg->RectAt(i))); - return BRegion(newreg); -} - -// Tested -BRegion Layer::ConvertToTop(BRegion *reg) -{ - BRegion newreg; - for(int32 i=0; iCountRects();i++) - newreg.Include(ConvertToTop(reg->RectAt(i))); - return BRegion(newreg); -} - -// Tested -BRect Layer::ConvertToTop(BRect rect) -{ - if (parent!=NULL) - return(parent->ConvertToTop(rect.OffsetByCopy(frame.LeftTop())) ); - else - return(rect); -} - -// Tested -BPoint Layer::ConvertToTop(BPoint point) -{ - if (parent!=NULL) - return(parent->ConvertToTop(point + frame.LeftTop()) ); - else - return(point); -} - -// Tested -BRegion Layer::ConvertFromTop(BRegion *reg) -{ - BRegion newreg; - for(int32 i=0; iCountRects();i++) - newreg.Include(ConvertFromTop(reg->RectAt(i))); - return BRegion(newreg); -} - -// Tested -BRect Layer::ConvertFromTop(BRect rect) -{ - if (parent!=NULL) - return(parent->ConvertFromTop(rect.OffsetByCopy(frame.LeftTop().x*-1, - frame.LeftTop().y*-1)) ); - else - return(rect); -} - -// Tested -BPoint Layer::ConvertFromTop(BPoint point) -{ - if (parent!=NULL) - return(parent->ConvertFromTop(point - frame.LeftTop()) ); - else - return(point); -} - -RootLayer::RootLayer(BRect rect, const char *layername, ServerWindow *srvwin, - int32 viewflags, int32 token) - : Layer(rect,layername,srvwin,viewflags,token) -{ - updater_id=-1; -} - -RootLayer::RootLayer(BRect rect, const char *layername) - : Layer(rect,layername) -{ - updater_id=-1; - driver=get_gfxdriver(); -} - -RootLayer::~RootLayer(void) -{ -} - -void RootLayer::SetVisible(bool is_visible) -{ - if(visible!=is_visible) - { - visible=is_visible; -/* if(visible) - { - updater_id=spawn_thread(UpdaterThread,name->String(),B_NORMAL_PRIORITY,this); - if(updater_id!=B_NO_MORE_THREADS && updater_id!=B_NO_MEMORY) - resume_thread(updater_id); - } -*/ - } -} - -bool RootLayer::IsVisible(void) const -{ - return visible; -} - -int32 RootLayer::UpdaterThread(void *data) -{ - // Updater thread which checks to see if its layer needs updating. If so, then - // call the recursive function RequestDraw. - - RootLayer *root=(RootLayer*)data; - - while(1) - { - if(!root->visible) - { - return 0; - exit_thread(1); - } - - if(root->IsDirty()) - { - layerlock->Lock(); - root->RequestDraw(); - layerlock->Unlock(); - } - } -} - -void RootLayer::RequestDraw(void) -{ - if(!invalid) - return; - - ASSERT(driver!=NULL); - -#ifdef DEBUG_LAYERS -printf("Root::RequestDraw: invalid rects: %ld\n",invalid->CountRects()); -#endif - - for(int32 i=0; invalid->CountRects();i++) - { - if(invalid->RectAt(i).IsValid()) - { -#ifdef DEBUG_LAYERS -printf("Root::RequestDraw:FillRect, color %u,%u,%u,%u\n",bgcolor.red,bgcolor.green, - bgcolor.blue,bgcolor.alpha); -#endif - driver->FillRect(invalid->RectAt(i),bgcolor); - } - else - break; - } - - delete invalid; - invalid=NULL; - is_dirty=false; - -/* for(Layer *lay=topchild; lay!=NULL; lay=lay->lowersibling) - { - if(lay->IsDirty()) - lay->RequestDraw(); - } -*/ -} - -void RootLayer::SetColor(rgb_color col) -{ - bgcolor=col; -#ifdef DEBUG_LAYERS -printf("Root::SetColor(%u,%u,%u,%u)\n",bgcolor.red,bgcolor.green, - bgcolor.blue,bgcolor.alpha); -#endif -} - -rgb_color RootLayer::GetColor(void) const -{ - return bgcolor; -} diff --git a/src/servers/app/proto5/Layer.h b/src/servers/app/proto5/Layer.h deleted file mode 100644 index 1fbcbc1ce4..0000000000 --- a/src/servers/app/proto5/Layer.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef _LAYER_H_ -#define _LAYER_H_ - -#include -#include -#include -#include -#include -#include - -class ServerWindow; -class UpdateNode; -class DisplayDriver; - -class Layer -{ -public: - Layer(BRect rect, const char *layername, ServerWindow *srvwin, - int32 viewflags, int32 token); - Layer(BRect rect, const char *layername); - virtual ~Layer(void); - - void ShowLayer(void); - void HideLayer(void); - Layer *FindLayer(int32 token); - void MoveLayer(BPoint delta, bool include_children=true); - void AddChild(Layer *child); - void RemoveChild(Layer *child); - void RemoveSelf(void); - uint32 CountChildren(void); - Layer *GetChildAt(BPoint pt, bool recursive=false); - BRect Bounds(void); - BRect Frame(void); - - void MoveBy(float x, float y); - void ResizeBy(float x, float y); - - void RebuildRegions(bool include_children=true); - bool IsDirty(void) const; - void PrintToStream(void); - void PruneTree(void); - void SetLevel(int32 value); - void Invalidate(BRect rect); - void Invalidate(BRegion region); - virtual void RequestDraw(void); - - BRect ConvertToParent(BRect rect); - BPoint ConvertToParent(BPoint point); - BRegion ConvertToParent(BRegion *reg); - BRect ConvertFromParent(BRect rect); - BPoint ConvertFromParent(BPoint point); - BRegion ConvertFromParent(BRegion *reg); - BRegion ConvertToTop(BRegion *reg); - BRect ConvertToTop(BRect rect); - BPoint ConvertToTop(BPoint point); - BRegion ConvertFromTop(BRegion *reg); - BRect ConvertFromTop(BRect rect); - BPoint ConvertFromTop(BPoint point); - - BRect frame; - - Layer *parent, - *uppersibling, - *lowersibling, - *topchild, - *bottomchild; - - BRegion *visible, - *invalid; - - ServerWindow *serverwin; - - BString *name; - int32 view_token; // identifier for the corresponding view - int32 level; // how far layer is from root - int32 flags; // view flags - uint8 hidecount; - bool is_dirty; // true if we need to redraw - bool is_updating; -}; - -class RootLayer : public Layer -{ -public: - RootLayer(BRect rect, const char *layername, ServerWindow *srvwin, - int32 viewflags, int32 token); - RootLayer(BRect rect, const char *layername); - ~RootLayer(void); - virtual void RequestDraw(void); - void SetVisible(bool is_visible); - bool IsVisible(void) const; - - void SetColor(rgb_color col); - rgb_color GetColor(void) const; - - static int32 UpdaterThread(void *data); - rgb_color bgcolor; -private: - thread_id updater_id; - bool visible; - DisplayDriver *driver; -}; - -extern BLocker *layerlock; -extern BList *layerlist; -extern Layer *rootlayer; -extern UpdateNode *updatenode; -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/PortLink.cpp b/src/servers/app/proto5/PortLink.cpp deleted file mode 100644 index 8fba724569..0000000000 --- a/src/servers/app/proto5/PortLink.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/* - PortLink.cpp: - A helper class for port-based messaging - ------------------------------------------------------------------------- -How it works: - The class utilizes a fixed-size array of PortLinkData object pointers. When -data is attached, a new PortLinkData object is allocated and a copy of the -passed data is created inside it. When the time comes for the message to be sent, -the data is pieced together into a flattened array and written to the port. ------------------------------------------------------------------------- -Data members: - -*attachments[] - fixed-size array of pointers used to hold the attached data -opcode - message value which is sent along with any data -target - port to which the message is sent when Flush() is called -replyport - port used with synchronous messaging - FlushWithReply() -bufferlength - total bytes taken up by attachments -num_attachments - internal variable which is used to track which "slot" - will be the next one to receive an attachment object -*/ - -#include "PortLink.h" -#include -#include -#include - -//#define PLDEBUG - -// Internal data storage class for holding attached data whilst it is waiting -// to be Flattened() and then Flushed(). There is no need for this to be called outside -// the PortLink class. -class PortLinkData -{ -public: - PortLinkData(void); - ~PortLinkData(void); - bool Set(void *data, size_t size); - char *buffer; - size_t buffersize; -}; - -PortLink::PortLink(port_id port) -{ - // For this class to be useful (and to prevent a lot of init problems) - // we require a port in the constructor - target=port; - - // We start out without any data attached to the port message - num_attachments=0; - opcode=0; - bufferlength=0; - replyport=create_port(30,"PortLink reply port"); -} - -PortLink::~PortLink(void) -{ - // If, for some odd reason, this is deleted with something attached, - // free the memory used by the attachments. We do not flush the queue - // because the port may no longer be valid in cases such as the app - // is in the process of quitting - MakeEmpty(); -} - -void PortLink::SetOpCode(int32 code) -{ - // Sets the message code. This does not change once the message is sent. - // Another call to SetOpCode() is required for such things. - opcode=code; -} - -void PortLink::SetPort(port_id port) -{ - // Sets the target port. While not necessary in most uses, this exists - // mostly to prevent flexibility problems - target=port; -} - -port_id PortLink::GetPort(void) -{ - // Simply returns the port at which the object is pointed. - return target; -} - -void PortLink::Flush(bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message off to the target, complete with attachments. NOTE: - // the recipient must delete all attachments, being the PortLink object assumes - // no responsiblity for the attachments once the message is sent. - int8 *msgbuffer; - int32 size; - - if(num_attachments>0) - { - FlattenData(&msgbuffer,&size); - - // Dump message to port, reset attachments, and clean up - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,msgbuffer,size,B_TIMEOUT, timeout); - else - write_port(target,opcode,msgbuffer,size); - MakeEmpty(); - } - else - { - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,NULL,0,B_TIMEOUT, timeout); - else - write_port(target,opcode,NULL,0); - } -} - -int8* PortLink::FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message to the target and then waits for a reply. The target will - // receive a message with the first item being the port_id to reply to. - // NOTE: like Flush(), any attached data must be deleted. - - // Effectively, an Attach() call inlined for changes - - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - { - *status=B_ERROR; - return NULL; - } - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&replyport,sizeof(port_id))) - { - bufferlength+=sizeof(port_id); - } - else - { - delete pld; - *status=B_ERROR; - return NULL; - } - - // Flatten() inlined to make some necessary changes - int8 *buffer=new int8[bufferlength]; - int8 *bufferindex=buffer; - size_t size=0; - - // attach our port_id first - memcpy(bufferindex, pld->buffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - - // attach everything else - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - } - - // Flush the thing....FOOSH! :P - write_port(target,opcode,buffer,size); - MakeEmpty(); - delete buffer; - - // Now we wait for the reply - if(timeout==B_INFINITE_TIMEOUT) - { - *buffersize=port_buffer_size(replyport); - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - else - { - *buffersize=port_buffer_size_etc(replyport,0,timeout); - if(*buffersize==B_TIMED_OUT) - { - *status=*buffersize; - return NULL; - } - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - - // We got this far, so we apparently have some data - *status=B_OK; - return buffer; -} - -void PortLink::Attach(void *data, size_t size) -{ - // This is the member called to attach data to a message. Attachments are - // treated to be in 'Append' mode, tacking on each attached piece of data - // to the end of the list. - - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - if(size==0) - return; - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -// These functions were added for a major convenience in passing common types -// Eventually, I'd like to templatize these, but for now, this'll do - -void PortLink::Attach(int32 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int32); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int16 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int16); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int8 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int8); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(float data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(float); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(bool data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(bool); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BRect data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BRect); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BPoint data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BPoint); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::FlattenData(int8 **buffer,int32 *size) -{ - // This function is where all the magic happens, but it is strictly internal. - // It iterates through each PortLinkData object and copies it to the main buffer - // which ends up, ultimately, being written to the PortLink's target port. - - // skip if there aree no attachments - if(bufferlength<1) - return; - - *buffer=new int8[bufferlength]; - int8 *bufferindex=*buffer; - PortLinkData *pld; - *size=0; - - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - *size+=pld->buffersize; - } -} - -void PortLink::MakeEmpty(void) -{ - // Nukes all the attachments currently held by the PortLink class - if(num_attachments!=0) - { - for(int i=0; i0) - free(buffer); -} - -bool PortLinkData::Set(void *data, size_t size) -{ - // Function copies the passed to the internal buffers for storage - if(size>0 && buffersize==0 && data!=NULL) - { - buffer=(char *)malloc(size); - if(buffer==NULL) - return false; - memcpy(buffer, data, size); - buffersize=size; - return true; - } - return false; -} diff --git a/src/servers/app/proto5/PortLink.h b/src/servers/app/proto5/PortLink.h deleted file mode 100644 index 9f5432daab..0000000000 --- a/src/servers/app/proto5/PortLink.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _PORTLINK_H_ -#define _PORTLINK_H_ - -#include -#include -#include -#include - -#ifndef _PORTLINK_BUFFERSIZE -#define _PORTLINK_MAX_ATTACHMENTS 50 -#endif - -class PortLinkData; - -class PortLink -{ -public: - PortLink(port_id port); - ~PortLink(void); - void SetOpCode(int32 code); - void SetPort(port_id port); - port_id GetPort(void); - void Flush(bigtime_t timeout=B_INFINITE_TIMEOUT); - int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, - bigtime_t timeout=B_INFINITE_TIMEOUT); - void Attach(void *data, size_t size); - void Attach(int32 data); - void Attach(int16 data); - void Attach(int8 data); - void Attach(float data); - void Attach(bool data); - void Attach(BRect data); - void Attach(BPoint data); - void MakeEmpty(void); -protected: - void FlattenData(int8 **buffer,int32 *size); - port_id target, replyport; - int32 opcode, bufferlength; - int num_attachments; - PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS]; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/SecondDriver.cpp b/src/servers/app/proto5/SecondDriver.cpp deleted file mode 100644 index 6a8523fb10..0000000000 --- a/src/servers/app/proto5/SecondDriver.cpp +++ /dev/null @@ -1,838 +0,0 @@ -/******************************************************* -* SecondDriver -* -* Second driver is a Drvier abstraction layer for the -* OBOS app_server. It provides access to the Graphic -* HW via the low level api calls. This provides a -* way to run the app_server on real HW. -* This driver also makes it easy for you to run the -* OBOS app_server in parallel with the Be app_server -* when two or more video cards are installed in your -* computer. -* -* @author YNOP (ynop@beunited.org) -* @version beta1 (p5) -* -* History: -* - Added Ellipse (Stroke & Fill) -* Ran though test app to make sure worked -* Fixed HorizLine to used fill_span instead of fill_rect :P -* Updated the Cursor code to work again. -* Made new cursor (Be-hand like) -* - Added StrokeBezir -* Added HorizLine for speed -* - Added HW acceleration methods -* - Brez Line added -* - Created by YNOP -* -* Todo: -* Clean up src and add more comments :P -* Redo StrokeLine to use PenSize -* Redo StrokeLine to use pattern -* Mouse Cursor seems to be broken in proto5 ? -* Add in a way to read app_server_settings file so we can get the real settings -* Make display mode settings more flexable -* Look into FreeType for DrawString :P fun fun fun -* -* Todo methods: -* Blit() DrawBitmap() DrawString() FillArc() FillBezier() FillPolygon() -* FillRegion() FillRoundRect() FillShape() FillTriangle() -* StrokeArc() StrokeRoundRect() StrokeShpae() -* -*******************************************************/ -#include -#include - -#include - -#include "PortLink.h" -#include "ServerProtocol.h" -#include "ServerBitmap.h" -#include "ServerCursor.h" -#include "DebugTools.h" -#include "SecondDriver.h" -#include "SecondDriverHelper.h" - -/******************************************************* -* @description -*******************************************************/ -SecondDriver::SecondDriver(void):DisplayDriver(){ - SetupBezier(); - hide_cursor = false; - fd = -1; - image = -1; - - gah = NULL; - bits = NULL; - bpr = -1; - - scs = NULL; - mc = NULL; - sc = NULL; - - et = NULL; - re = NULL; - - s2sb = NULL; - fr = NULL; - ir = NULL; - s2stb = NULL; - fs = NULL; - -} - -/******************************************************* -* @description -*******************************************************/ -SecondDriver::~SecondDriver(void){ - if(is_initialized){ - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::Initialize(void){ - et = NULL; - bits = NULL; - - // Find a driver - fd = get_device(); - if(fd < 0){ - printf("No Device settings found.\n"); - fd = find_device(); - }else{ - printf("Device read from settings file\n"); - } - if(fd < 0){ - printf("No device find, trying fallback stub\n"); - fd = fallback_device(); - } - if(fd < 0){ - printf("Didn't find device :(\n"); - is_initialized = false; - } - /* load the accelerant */ - image = load_accelerant(fd, &gah); - if (image >= 0){ - // Set up the display to a valid resolution - if(get_and_set_mode(gah,&dm) == B_OK){ - // Here we are all good - if(dm.space == B_CMAP8){ - set_palette(gah); - } - get_frame_buffer(gah, &fbc); - bits = (uint32*)fbc.frame_buffer/*_dma*/; - bpr = fbc.bytes_per_row/4; // sould be by depth - - if(dm.flags & B_HARDWARE_CURSOR){ - // Lets check out tha hardwar cursoer stuff :P - printf("Mode supports Hardware cursors\n"); - scs = (set_cursor_shape)gah(B_SET_CURSOR_SHAPE,NULL); - mc = (move_cursor)gah(B_MOVE_CURSOR,NULL); - sc = (show_cursor)gah(B_SHOW_CURSOR,NULL); - } - - // Ok. now lets see if we can add some spiffy - // 2D acceleration to this :) - accelerant_engine_count aec = (accelerant_engine_count)gah(B_ACCELERANT_ENGINE_COUNT,NULL); - uint32 count = aec(); - if(count > 0){ - acquire_engine ae = (acquire_engine)gah(B_ACQUIRE_ENGINE,NULL); - re = (release_engine)gah(B_RELEASE_ENGINE,NULL); - if(ae(B_2D_ACCELERATION,1000,&st,&et) == B_OK){ - // Now lets see if we have some functions - printf("You should be verry happy. You have 2D hardware Acceleration\n"); - s2sb = (screen_to_screen_blit)gah(B_SCREEN_TO_SCREEN_BLIT,NULL); - fr = (fill_rectangle)gah(B_FILL_RECTANGLE,NULL); - ir = (invert_rectangle)gah(B_INVERT_RECTANGLE,NULL); - s2stb = (screen_to_screen_transparent_blit)gah(B_SCREEN_TO_SCREEN_TRANSPARENT_BLIT,NULL); - fs = (fill_span)gah(B_FILL_SPAN,NULL); - } - } - is_initialized = true; - }else{ - // failed to set mode - is_initialized = false; - } - }else{ - // image failed to load - is_initialized = false; - } - - if(is_initialized){ - printf("\n\tSecond Driver by YNOP (ynop@beunited.org)\n"); - printf("\tSecond Driver is copyrigth YNOP 2002\n"); - printf("\tHave fun, its all set up :)\n\n"); - } - - SetCursor((ServerCursor*)NULL); - ShowCursor(); - int32 h = GetHeight(); - int32 w = GetWidth(); - MoveCursorTo(w/2,h/2); - -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::Shutdown(void){ - printf("\tShuting down SecondDriver\n"); - if(et){ - if(re(et,&st) != B_OK){ - printf("Failed to release engine\n"); - } - } - - uninit_accelerant ua = (uninit_accelerant)gah(B_UNINIT_ACCELERANT,NULL); - if(ua){ ua();} - - unload_add_on(image); - - // clsoe the file now... - close(fd); - - - is_initialized=false; -} - -/******************************************************* -* @description -*******************************************************/ -bool SecondDriver::IsInitialized(void){ - return is_initialized; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SafeMode(void){ -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::Reset(void){ -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetScreen(uint32 space){ - // Clear(51,102,152); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::Clear(uint8 red, uint8 green, uint8 blue){ - rgb_color r; - r.red = red; - r.blue = blue; - r.green = green; - Clear(r); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::Clear(rgb_color col){ - highcol = col; - FillRect(BRect(0,0,GetHeight()-1,GetWidth()-1),NULL); -} - -/******************************************************* -* @description -*******************************************************/ -int32 SecondDriver::GetHeight(void){ - // Gets the height of the current mode - return dm.virtual_height; -} - -/******************************************************* -* @description -*******************************************************/ -int32 SecondDriver::GetWidth(void){ - // Gets the width of the current mode - return dm.virtual_width; -} - -/******************************************************* -* @description -*******************************************************/ -int SecondDriver::GetDepth(void){ - // Gets the color depth of the current mode - return 0; -} - -/******************************************************* -* @description -*******************************************************/ -#ifdef PROTO_4 - void SecondDriver::Blit(BPoint loc, ServerBitmap *src, ServerBitmap *dest) -#else - void SecondDriver::Blit(BRect src, BRect dest) -#endif -{ - printf("Calling Blit (not wirten yet)\n"); - if(s2sb){ - printf("Accelerated Blit\n"); - }else{ - - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::DrawBitmap(ServerBitmap *bitmap){ - printf("Calling DrawBitmap (not writen yet)\n"); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::DrawChar(char c, BPoint point){ - char string[2]; - string[0]=c; - string[1]='\0'; - DrawString(string,2,point); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::DrawString(char *string, int length, BPoint point){ - printf("DrawString is not writen yet\n"); - - // i would say that libtruetype would do some good herer -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern){ - printf("FillArc is not writen yet\n"); - StrokeArc(centerx,centery,xradius,yradius,angle,span,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillBezier(BPoint *points, uint8 *pattern){ - printf("FillBezier is not writen yet\n"); - StrokeBezier(points,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern){ - MidpointEllipse(centerx,centery,x_radius,y_radius,true,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillPolygon(int *x, int *y, int numpoints, bool is_closed){ - printf("FillPolygon is not writen yet\n"); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillRect(BRect rect, uint8 *pattern){ - if(fr){ - // usieng accelertated 2d file - union{ - uint8 bytes[4]; - uint32 word; - }c1; - - //printf("Accelerated Fill\n"); - fill_rect_params frp; - frp.left =(uint16) rect.left; - frp.top =(uint16) rect.top; - frp.right =(uint16) rect.right; - frp.bottom =(uint16) rect.bottom; - c1.bytes[0] = highcol.blue; - c1.bytes[1] = highcol.green; - c1.bytes[2] = highcol.red; - fr(et,c1.word,&frp,1); - }else{ - for(int32 i = 0;i < rect.Height()-1;i++){ - MovePenTo(BPoint(rect.left,rect.top+i)); - StrokeLine(BPoint(rect.right,rect.top+i),pattern); - //HorizLine(rect.left,rect.right,rect.top+i); // uses accel :P - } - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillRect(BRect rect, rgb_color col){ - rgb_color tmpc = highcol; - highcol = col; - FillRect(rect, NULL); - highcol = tmpc; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillRegion(BRegion *region){ - printf("RillRegion is not writen yet\n"); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern){ - printf("FillRoundRect is not writen yet\n"); - StrokeRoundRect(rect,xradius,yradius,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillShape(BShape *shape){ - printf("FillShape is not writen yet\n"); - StrokeShape(shape); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern){ - printf("FillTriangle is not writen yet\n"); - StrokeTriangle(first,second,third,rect,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::HideCursor(void){ - if(sc){ - sc(false); - cursor_visible = false; - }else{ - printf("Shoftware Hide Cursor\n"); - } -} - -/******************************************************* -* @description -*******************************************************/ -bool SecondDriver::IsCursorHidden(void){ - return cursor_visible; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::ObscureCursor(void){ - // Hides cursor until mouse is moved - HideCursor(); - show_on_move = true; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::MoveCursorTo(float x, float y){ - if(show_on_move){ - ShowCursor(); - } - if(mc){ - mc((short unsigned int)x,(short unsigned int)y); - }else{ - printf("Software move Cursor\n"); - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::MovePenTo(BPoint pt){ - penpos = pt; -} - -/******************************************************* -* @description -*******************************************************/ -BPoint SecondDriver::PenPosition(void){ - return penpos; -} - -/******************************************************* -* @description -*******************************************************/ -float SecondDriver::PenSize(void){ - return pensize; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetCursor(int32 value){ - printf("Setcursoer value?\n"); - // Uh what is this all about? -} - - - - -//0 - 1 = black -//0 - 0 = what -//1 - 0 = trans -//1 - 1 = invert - -// Pointy cursor -/*uint8 andMask[] = { - 63,255,15,255,131,255,128,127,192,31,192,31,224,63,224,63, - 224,31,240,15,243,7,255,131,255,193,255,224,255,240,255,248 -}; -uint8 xorMask[] = { - 192,0,176,0,76,0,67,128,32,96,32,32,16,64,16,64, - 16,32,11,16,12,136,0,68,0,34,0,17,0,9,0,7 -};*/ -// BeOS like cursor -uint8 andMask[] = { - 255,255,255,255,199,255,195,255,195,255,224,31,224,3,240,1, - 240,0,192,0,128,0,128,0,192,0,240,0,252,1,254,7 -}; -uint8 xorMask[] = { - 0,0,0,0,56,0,36,0,36,0,19,224,18,92,9,42, - 8,1,60,0,76,0,66,0,48,0,12,0,2,0,1,0 -}; - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetCursor(ServerCursor *cursor){ - printf("Setting cursor\n"); - current_cursor = cursor; -// uint8 *andMask; - // uint8 *xorMask; - if(scs){ -// scs(cursor->width,cursor->height,(short unsigned int)cursor->hotspot.x,(short unsigned int)cursor->hotspot.y,andMask,xorMask); - scs(16,16,3,3,andMask,xorMask); - }else{ - printf("Setting software cursor\n"); - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetPenSize(float size){ - pensize = size; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255){ - highcol.red = r; - highcol.green = g; - highcol.blue = b; - highcol.alpha = a; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255){ - lowcol.red = r; - lowcol.green = g; - lowcol.blue = b; - lowcol.alpha = a; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetPixel(int x, int y, uint8 *pattern){ - union{ - uint8 bytes[4]; - uint32 word; - }c1; - - c1.bytes[0] = highcol.blue; - c1.bytes[1] = highcol.green; - c1.bytes[2] = highcol.red; - c1.bytes[3] = highcol.alpha; - - *(bits + x + y*bpr) = c1.word; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::ShowCursor(void){ - printf("\tShow Cursor\n"); - show_on_move = false; - cursor_visible = true; - if(sc){ - sc(true); - }else{ - printf("Software show cursor\n"); - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern){ - printf("StrokeArch is not writen yet\n"); -} - - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::StrokeBezier(BPoint *pts, uint8 *pattern){ - BPoint segment[SEGMENTS + 1]; - computeSegments(pts[0], pts[1],pts[2],pts[3], segment); - - MovePenTo(segment[0]); - - for(int32 s = 1 ; s <= SEGMENTS ; ++s ){ - if(segment[s].x != segment[s - 1].x || segment[s].y != segment[s - 1].y ) { - StrokeLine(segment[s],pattern); - } - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern){ - MidpointEllipse(centerx,centery,x_radius,y_radius,false,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::StrokeLine(BPoint point, uint8 *pattern){ - if(penpos.y == point.y){ - HorizLine(penpos.x,point.x,point.y,pattern); - return; - } - - int oct = 0; - int xoff = (int32)penpos.x; - int yoff = (int32)penpos.y; - int32 x2 = (int32)point.x-xoff; - int32 y2 = (int32)point.y-yoff; - int32 x1 = 0; - int32 y1 = 0; -// if(y2==0){ if (x1>x2){int t=x1;x1=x2;x2=t;}HorizLine(x1+xoff,x2+xoff,y1+yoff); return;} - if(y2<0){ y2 = -y2; oct+=4; }//bit2=1 - if(x2<0){ x2 = -x2; oct+=2;}//bit1=1 - if(x2 x2){ int32 t=x1;x1=x2;x2=t; } - if(fr){ - union{ - uint8 bytes[4]; - uint32 word; - }c1; - - //printf("Accelerated HorizLine\n"); - uint16 list[3]; - list[0] = y; - list[1] = x1; - list[2] = x2; - c1.bytes[0] = highcol.blue; - c1.bytes[1] = highcol.green; - c1.bytes[2] = highcol.red; - fs(et,c1.word,list,1); - }else{ - //software hline - printf("\t!!HorizLine without HWaccel is a waist\n"); - for(int32 i = x1; i <= x2;i++){ - SetPixel(i,y,pattern); - } - } - -} - -//void EllipsePoints(float cx,float cy,int32 x, int32 y){ -// view->StrokeLine(BPoint(x+cent.x,y+cent.y),BPoint(x+cent.x,y+cent.y)); -// view->StrokeLine(BPoint(-x+cent.x,y+cent.y),BPoint(-x+cent.x,y+cent.y)); -// view->StrokeLine(BPoint(x+cent.x,-y+cent.y),BPoint(x+cent.x,-y+cent.y)); -// view->StrokeLine(BPoint(-x+cent.x,-y+cent.y),BPoint(-x+cent.x,-y+cent.y)); -#define EllipsePoints(cx,cy,x,y,pattern){ \ - SetPixel( x+cx, y+cx,pattern); \ - SetPixel(-x+cx, y+cx,pattern); \ - SetPixel( x+cx,-y+cx,pattern); \ - SetPixel(-x+cx,-y+cx,pattern); \ -} - - -//void EllipsePointsFill(BPoint cent,int32 x, int32 y,pattern){ -// view->StrokeLine(BPoint(-x+cent.x,y+cent.y),BPoint(x+cent.x,y+cent.y)); -// view->StrokeLine(BPoint(-x+cent.x,-y+cent.y),BPoint(x+cent.x,-y+cent.y)); - - #define EllipsePointsFill(cx,cy,x,y,pattern){ \ - HorizLine(-x+cx,x+cx, y+cy, pattern); \ - HorizLine(-x+cx,x+cx, -y+cy, pattern); \ -} - - -/******************************************************* -* -*******************************************************/ -void SecondDriver::MidpointEllipse(float centx,float centy,int32 xrad, int32 yrad,bool fill,uint8 *pattern){ - if(xrad < 0){ xrad = -xrad; } - if(yrad < 0){ yrad = -yrad; } - double d2; - int32 x = 0; - int32 y = yrad; - - int32 xradSqr = xrad*xrad; - int32 yradSqr = yrad*yrad; - - double dl = yradSqr - (xradSqr*yrad) + (0.25 *xradSqr); - - if(fill){ EllipsePointsFill(centx,centy,x,y,pattern); }else{ EllipsePoints(centx,centy,x,y,pattern); } - - // Test gradient if still in region 1 - while((xradSqr*(y-.5)) > (yradSqr*(x+1))){ - if(dl < 0){ // Select E - dl += yradSqr*(2*x + 3); - }else{ // Select SE - dl += yradSqr*(2*x + 3) + xradSqr*(-2*y + 2); - y--; - } - x++; - if(fill){ EllipsePointsFill(centx,centy,x,y,pattern); }else{ EllipsePoints(centx,centy,x,y,pattern); } - } - - d2 = (yradSqr*(x + .5)*(x + .5)) + (xradSqr*(y-1)*(y-1)) - xradSqr*yradSqr; - while(y > 0){ - if(d2 < 0){ // Select SE - d2 += yradSqr*(2*x + 2) + xradSqr*(-2*y + 3); - x++; - }else{ // Select E - d2 += xradSqr*(-2*y + 3); - } - y--; - if(fill){ EllipsePointsFill(centx,centy,x,y,pattern); }else{ EllipsePoints(centx,centy,x,y,pattern); } - } -} - - - -#ifdef DEBUG_DRIVER_MODULE -#undef DEBUG_DRIVER_MODULE -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/SecondDriver.h b/src/servers/app/proto5/SecondDriver.h deleted file mode 100644 index e1b937b618..0000000000 --- a/src/servers/app/proto5/SecondDriver.h +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef _SECDRIVER_H_ -#define _SECDRIVER_H_ - -#include -#include -#include -#include -#include // for pattern struct -#include -#include -#include "DisplayDriver.h" - -#include -#include -#include - -class BBitmap; -class PortLink; -class VDWindow; -class ServerCursor; - - -class SecondDriver:public DisplayDriver{ -public: - SecondDriver(void); - virtual ~SecondDriver(void); - - virtual void Initialize(void); // Sets the driver - virtual bool IsInitialized(void); - virtual void Shutdown(void); // You never know when you'll need this - - virtual void SafeMode(void); // Easy-access functions for common tasks - virtual void Reset(void); - virtual void Clear(uint8 red,uint8 green,uint8 blue); - virtual void Clear(rgb_color col); - - // Settings functions - virtual void SetScreen(uint32 space); - virtual int32 GetHeight(void); - virtual int32 GetWidth(void); - virtual int GetDepth(void); - - // Drawing functions - #ifdef PROTO_4 - virtual void Blit(BPoint loc, ServerBitmap *src, ServerBitmap *dest); - #else - virtual void Blit(BRect src, BRect dest); - #endif - virtual void DrawBitmap(ServerBitmap *bitmap); - virtual void DrawChar(char c, BPoint point); - virtual void DrawString(char *string, int length, BPoint point); - - virtual void FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void FillBezier(BPoint *points, uint8 *pattern); - virtual void FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void FillPolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void FillRect(BRect rect, uint8 *pattern); - virtual void FillRect(BRect rect, rgb_color col); - virtual void FillRegion(BRegion *region); - virtual void FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void FillShape(BShape *shape); - virtual void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - - virtual void HideCursor(void); - virtual bool IsCursorHidden(void); - virtual void MoveCursorTo(float x, float y); - virtual void MovePenTo(BPoint pt); - virtual void ObscureCursor(void); - virtual BPoint PenPosition(void); - virtual float PenSize(void); - virtual void SetCursor(int32 value); - virtual void SetCursor(ServerCursor *cursor); - virtual void SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetPenSize(float size); - virtual void SetPixel(int x, int y, uint8 *pattern); - virtual void ShowCursor(void); - - virtual void StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void StrokeBezier(BPoint *points, uint8 *pattern); - virtual void StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void StrokeLine(BPoint point, uint8 *pattern); - virtual void StrokeLine(BPoint pt1, BPoint pt2, rgb_color col); - virtual void StrokePolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void StrokeRect(BRect rect,uint8 *pattern); - virtual void StrokeRect(BRect rect,rgb_color col); - virtual void StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void StrokeShape(BShape *shape); - virtual void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); -private: - void HorizLine(int32 x1,int32 x2,int32 y, uint8 *pattern); - void MidpointEllipse(float centerx, float centery,int32 xrad, int32 yrad,bool fill,uint8 *pattern); -protected: - int hide_cursor; - - int fd; - image_id image; - GetAccelerantHook gah; - display_mode dm; - - frame_buffer_config fbc; - - uint32 *bits; - int32 bpr; - - set_cursor_shape scs; - move_cursor mc; - show_cursor sc; - - sync_token st; - engine_token *et; - release_engine re; - - screen_to_screen_blit s2sb; - fill_rectangle fr; - invert_rectangle ir; - screen_to_screen_transparent_blit s2stb; - fill_span fs; - - -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/SecondDriverHelper.h b/src/servers/app/proto5/SecondDriverHelper.h deleted file mode 100644 index ff3ee288d7..0000000000 --- a/src/servers/app/proto5/SecondDriverHelper.h +++ /dev/null @@ -1,435 +0,0 @@ -/******************************************************* -* SecondDriver -* -* Helper methods for SecondDriver. This is where we -* put all the code that inits the real HW and -* seaches for the acceleration methods an all that -* other stuff. -* -* @author YNOP (ynop@beunited.org) -*******************************************************/ -#ifndef _SECDRIVER_HELPER_H_ -#define _SECDRIVER_HELPER_H_ - -//#include -#include -#include - -#include -#include -#include // has ioctl ?:P -//#include -#include - -#define DEV_GRAPHICS "/dev/graphics/" -#define ACCELERANTS_DIR "/accelerants/" -#define DEV_STUB "stub" - -/******************************************************* -* @description Loads the driver from settings ... -*******************************************************/ -int get_device(){ -// 102b_0519_001300 102b_051a_001400 stub - return open(DEV_GRAPHICS"102b_051a_001400", B_READ_WRITE); -// return -1; -} - -/******************************************************* -* @description Loads the stub driver - never fun -*******************************************************/ -int fallback_device(){ - return open(DEV_GRAPHICS DEV_STUB, B_READ_WRITE); -} - -/******************************************************* -* @description Find the first device that it can open -* in the /dev/graphics dir and returns it. -*******************************************************/ -int find_device(){ - DIR *d; - struct dirent *e; - char name_buf[1024]; - int fd = -1; - //bool foundfirst = false; // hacky way of finding second video card in your box - - printf("Probeing %s for device...\n",DEV_GRAPHICS); - - /* open directory apath */ - d = opendir(DEV_GRAPHICS); - if(!d){ return B_ERROR; } - while((e = readdir(d)) != NULL){ - if (!strcmp(e->d_name, ".") || !strcmp(e->d_name, "..") || !strcmp(e->d_name, "stub")){ - continue; - } - strcpy(name_buf, DEV_GRAPHICS); -// strcat(name_buf, "/"); - strcat(name_buf, e->d_name); - fd = open(name_buf, B_READ_WRITE); - ///printf("Opening device %s\n",name_buf); - if(fd >= 0){ - //printf("Open wend ok\n"); - /*if(!foundfirst){ - foundfirst = true; - printf("\tbut we are not going to use it as app_server is\n"); - }else{ - // found it :) - */ printf("\tOpened device %s\n",name_buf); - closedir(d); - return fd; - //} - }else{ - //foundfirst = true; // this is a proper find as the app_server should let us open the dev - printf("\tCouldn't open device %s\n",name_buf); - } - } - closedir(d); - return B_ERROR; -} - -/******************************************************* -* @description Finds and loads the Accelerant for -* this device -*******************************************************/ -image_id load_accelerant(int fd, GetAccelerantHook *hook) { - status_t result; - image_id image = -1; - char - signature[1024], - path[PATH_MAX]; - struct stat st; - const static directory_which vols[] = { - B_USER_ADDONS_DIRECTORY, - B_COMMON_ADDONS_DIRECTORY, - B_BEOS_ADDONS_DIRECTORY - }; - - /* get signature from driver */ - result = ioctl(fd, B_GET_ACCELERANT_SIGNATURE, &signature, sizeof(signature)); - if (result != B_OK){ - printf("Failed to get accelerant signature from drived!\n"); - return result; - } - - printf("Searching for Accelerant named \"%s\"\n",signature); - - // note failure by default - for(int32 i=0; i < (int32)(sizeof (vols) / sizeof (vols[0])); i++) { - //printf("attempting to get path for %ld (%d)\n", i, vols[i]); - if(find_directory(vols[i], -1, false, path, PATH_MAX) != B_OK) { - printf("warning: find directory failed (continueing)\n"); - continue; - } - - strcat (path, ACCELERANTS_DIR); - strcat (path, signature); - printf("\tTrying %s\n",path); - - // don't try to load non-existant files - if (stat(path, &st) != 0) continue; - - // try and load it up.. - image = load_add_on(path); - if (image >= 0) { - printf("\tAccelerant loaded - trying to init\n"); - // get entrypoint from accelerant - result = get_image_symbol(image, B_ACCELERANT_ENTRY_POINT, -#if defined(__INTEL__) - B_SYMBOL_TYPE_ANY, -#else - B_SYMBOL_TYPE_TEXT, -#endif - (void **)hook); - if (result == B_OK) { - init_accelerant ia; - ia = (init_accelerant)(*hook)(B_INIT_ACCELERANT, NULL); - if(ia && ((result = ia(fd)) == B_OK)) { - // we have a winner! - //printf("Accelerant %s \n", path); - printf("\tAccelerant Init() was B_OK\n"); - break; - } else { - printf("\tAccelerant Init() failed: %ld\n", result); - } - } else { - printf("\tCouldn't find the entry point :-(\n"); - } - // unload the accelerant, as we must be able to init! - unload_add_on(image); - } - if (image < 0) printf("\tLoad Image failure. ID: %.8lx (%s)\n", image, strerror(image)); - // mark failure to load image - image = -1; - } - - //printf("Add-on image id: %ld\n", image); - return image; -} - -/******************************************************* -* @description -*******************************************************/ -static const char *spaceToString(uint32 cs) { - const char *s; - switch (cs) { -#define s2s(a) case a: s = #a ; break - s2s(B_RGB32); - s2s(B_RGBA32); - s2s(B_RGB32_BIG); - s2s(B_RGBA32_BIG); - s2s(B_RGB16); - s2s(B_RGB16_BIG); - s2s(B_RGB15); - s2s(B_RGBA15); - s2s(B_RGB15_BIG); - s2s(B_RGBA15_BIG); - s2s(B_CMAP8); - s2s(B_GRAY8); - s2s(B_GRAY1); - s2s(B_YCbCr422); - s2s(B_YCbCr420); - s2s(B_YUV422); - s2s(B_YUV411); - s2s(B_YUV9); - s2s(B_YUV12); - default: - s = "unknown"; break; -#undef s2s - } - return s; -} - -/******************************************************* -* @description -*******************************************************/ -void dump_mode(display_mode *dm) { - display_timing *t = &(dm->timing); - printf(" pixel_clock: %ldKHz\n", t->pixel_clock); - printf(" H: %4d %4d %4d %4d\n", t->h_display, t->h_sync_start, t->h_sync_end, t->h_total); - printf(" V: %4d %4d %4d %4d\n", t->v_display, t->v_sync_start, t->v_sync_end, t->v_total); - printf(" timing flags:"); - if (t->flags & B_BLANK_PEDESTAL) printf(" B_BLANK_PEDESTAL"); - if (t->flags & B_TIMING_INTERLACED) printf(" B_TIMING_INTERLACED"); - if (t->flags & B_POSITIVE_HSYNC) printf(" B_POSITIVE_HSYNC"); - if (t->flags & B_POSITIVE_VSYNC) printf(" B_POSITIVE_VSYNC"); - if (t->flags & B_SYNC_ON_GREEN) printf(" B_SYNC_ON_GREEN"); - if (!t->flags) printf(" (none)\n"); - else printf("\n"); - printf(" refresh rate: %4.2f\n", ((double)t->pixel_clock * 1000) / ((double)t->h_total * (double)t->v_total)); - printf(" color space: %s\n", spaceToString(dm->space)); - printf(" virtual size: %dx%d\n", dm->virtual_width, dm->virtual_height); - printf("dispaly start: %d,%d\n", dm->h_display_start, dm->v_display_start); - - printf(" mode flags:"); - if (dm->flags & B_SCROLL) printf(" B_SCROLL"); - if (dm->flags & B_8_BIT_DAC) printf(" B_8_BIT_DAC"); - if (dm->flags & B_HARDWARE_CURSOR) printf(" B_HARDWARE_CURSOR"); - if (dm->flags & B_PARALLEL_ACCESS) printf(" B_PARALLEL_ACCESS"); -// if (dm->flags & B_SUPPORTS_OVERLAYS) printf(" B_SUPPORTS_OVERLAYS"); - if (!dm->flags) printf(" (none)\n"); - else printf("\n"); -} - -/******************************************************* -* @description -*******************************************************/ -void simple_dump_mode(display_mode *dm){ - //printf("H: %4d\n", t->h_display); - //printf("V: %4d\n", t->v_display); - display_timing *t = &(dm->timing); - printf("Virtual size: %d x %d\n", dm->virtual_width, dm->virtual_height); - printf("Color space: %s\n", spaceToString(dm->space)); - printf("Refresh rate: %4.2f\n", ((double)t->pixel_clock * 1000) / ((double)t->h_total * (double)t->v_total)); -} - -/******************************************************* -* @description -*******************************************************/ -void mode_from_settings(display_mode *dm){ - // display_timing *t = &(dm->timing); - dm->space = B_RGB32; - dm->virtual_width = 800; - dm->virtual_height = 600; - dm->h_display_start = 0; - dm->v_display_start = 0; -} - -/******************************************************* -* @description -*******************************************************/ -status_t get_and_set_mode(GetAccelerantHook gah, display_mode *dm) { - printf("Setting up display mode\n"); - accelerant_mode_count gmc; - uint32 mode_count; - get_mode_list gml; - display_mode *mode_list, target, high, low; - propose_display_mode pdm; - status_t result = B_ERROR; - set_display_mode sdm; - - /* find the propose mode hook */ - pdm = (propose_display_mode)gah(B_PROPOSE_DISPLAY_MODE, NULL); - if (!pdm) { - printf("No B_PROPOSE_DISPLAY_MODE\n"); - goto exit0; - } - /* and the set mode hook */ - sdm = (set_display_mode)gah(B_SET_DISPLAY_MODE, NULL); - if (!sdm) { - printf("No B_SET_DISPLAY_MODE\n"); - goto exit0; - } - - /* how many modes does the driver support */ - gmc = (accelerant_mode_count)gah(B_ACCELERANT_MODE_COUNT, NULL); - if (!gmc) { - printf("No B_ACCELERANT_MODE_COUNT\n"); - goto exit0; - } - mode_count = gmc(); - printf("\tDriver supports %lu differnat video modes\n", mode_count); - if (mode_count == 0) goto exit0; - - /* get a list of graphics modes from the driver */ - gml = (get_mode_list)gah(B_GET_MODE_LIST, NULL); - if (!gml) { - printf("No B_GET_MODE_LIST\n"); - goto exit0; - } - mode_list = (display_mode *)calloc(sizeof(display_mode), mode_count); - if (!mode_list) { - printf("Couldn't calloc() for mode list\n"); - goto exit0; - } - if (gml(mode_list) != B_OK) { - printf("mode list retrieval failed\n"); - goto free_mode_list; - } - - /* take the first mode in the list */ - //printf("\tPropose Display Mode\n------------------------\n"); - //simple_dump_mode(&mode_list[69]); - //mode_from_settings(&mode_list[69]); - target = mode_list[69]; - high = mode_list[69]; - low = mode_list[69]; - /* make as tall a virtual height as possible */ - //target.virtual_height = high.virtual_height = 0xffff; - // virtual hight should only be used if a res larger than - // the screen can handle - /* propose the display mode */ - if (pdm(&target, &low, &high) == B_ERROR) { - printf("propose_display_mode failed\n"); - goto free_mode_list; - } - printf("------Target display mode------\n"); - simple_dump_mode(&target); - printf("-------------------------------\n"); - /* we got a display mode, now set it */ - if (sdm(&target) == B_ERROR) { - printf("set display mode failed\n"); - goto free_mode_list; - } - /* note the mode and success */ - *dm = target; - result = B_OK; - -free_mode_list: - free(mode_list); -exit0: - return result; -} - - -/******************************************************* -* @description -*******************************************************/ -void get_frame_buffer(GetAccelerantHook gah, frame_buffer_config *fbc) { - get_frame_buffer_config gfbc; - gfbc = (get_frame_buffer_config)gah(B_GET_FRAME_BUFFER_CONFIG, NULL); - gfbc(fbc); -} - -/******************************************************* -* @description -*******************************************************/ -sem_id get_sem(GetAccelerantHook gah) { - accelerant_retrace_semaphore ars; - ars = (accelerant_retrace_semaphore)gah(B_ACCELERANT_RETRACE_SEMAPHORE, NULL); - return ars(); -} - -/******************************************************* -* @description -*******************************************************/ -void set_palette(GetAccelerantHook gah) { - set_indexed_colors sic; - sic = (set_indexed_colors)gah(B_SET_INDEXED_COLORS, NULL); - if (sic) { - /* booring grey ramp for now */ - uint8 map[3 * 256]; - uint8 *p = map; - int i; - for (i = 0; i < 256; i++) { - *p++ = i; - *p++ = i; - *p++ = i; - } - sic(256, 0, map, 0); - } -} - -// This is a ll the stuff needed to stroke a Bezier Curve.. -// Note that we should probably wait and alloc this data latter -// on when we stroke our first Curve. That way if no curve ever -// gets render (unlikely i know) then this space would be saved. -#define SEGMENTS 32 -#define Fixed float -static Fixed weight1[SEGMENTS + 1]; -static Fixed weight2[SEGMENTS + 1]; -#define w1(s) weight1[s] -#define w2(s) weight2[s] -#define w3(s) weight2[SEGMENTS - s] -#define w4(s) weight1[SEGMENTS - s] -#define FixMul(a,b) (a)*(b) -#define FixRound(a) ((a-int32(a))>=.5)?(int32(a)+1):(int32(a)) -#define FixRatio(a,b) ((a)/float(b)) - -/******************************************************* -* @description Creats the two Bernstien Pollynomials -* We only need to creat two becase the 1 & 4 are -* mirrors and the 2 & 3 are mirros. -*******************************************************/ -void SetupBezier(){ - Fixed t, zero, one; - int s; - zero = FixRatio(0, 1); - one = FixRatio(1, 1); - - weight1[0] = one; - weight2[0] = zero; - for(s = 1 ;s < SEGMENTS ;++s){ - t = FixRatio(s, SEGMENTS); - weight1[s] = FixMul(one - t, FixMul(one - t, one - t)); - weight2[s] = 3 * FixMul(t, FixMul(t - one, t - one)); - } - weight1[SEGMENTS] = zero; - weight2[SEGMENTS] = zero; -} - -/******************************************************* -* @description Useing the weights of the 4 bernstein -* pollynomials calc the segment endpoints. This is -* the real worker method -*******************************************************/ -static void computeSegments(BPoint p1,BPoint p2, BPoint p3, BPoint p4, BPoint *segment){ - int s; - segment[0] = p1; - for(s = 1;s < SEGMENTS;++s){ - segment[s].y = FixRound(w1(s) * p1.y + w2(s) * p2.y + w3(s) * p3.y + w4(s) * p4.y); - segment[s].x = FixRound(w1(s) * p1.x + w2(s) * p2.x + w3(s) * p3.x + w4(s) * p4.x); - } - segment[SEGMENTS] = p4; -} - -#endif - diff --git a/src/servers/app/proto5/ServerApp.cpp b/src/servers/app/proto5/ServerApp.cpp deleted file mode 100644 index 9cbc15c9e9..0000000000 --- a/src/servers/app/proto5/ServerApp.cpp +++ /dev/null @@ -1,883 +0,0 @@ -/* - ServerApp.cpp - Class which works with a BApplication. Handles all messages coming - from and going to its application. -*/ -//#define DEBUG_SERVERAPP_MSGS -//#define DEBUG_SERVERAPP_CURSORS -//#define DEBUG_SERVERAPP_MISC - -#include -#include -#include -#include -#include "Desktop.h" -#include "DisplayDriver.h" -//#include "Layer.h" -#include "ServerApp.h" -#include "ServerWindow.h" -#include "ServerBitmap.h" -#include "ServerProtocol.h" -#include "ServerCursor.h" -#include "PortLink.h" -#include -#include -#include -#include "DebugTools.h" - - -ServerApp::ServerApp(port_id msgport, char *signature) -{ - // need to copy the signature because the message buffer - // owns the copy which we are passed as a parameter. - app_sig=(signature)?signature:"Application"; - - // sender is the monitored app's event port - sender=msgport; - applink=new PortLink(sender); - - port_info pinfo; - get_port_info(sender,&pinfo); - target_id=pinfo.team; - - // receiver is the port to which the app sends messages for the server - receiver=create_port(30,app_sig.String()); - -#ifdef DEBUG_SERVERAPP_MISC -printf("ServerApp port for app %s is at %ld\n",app_sig.String(),receiver); -#endif - - if(receiver==B_NO_MORE_PORTS) - { - // uh-oh. We have a serious problem. Tell the app to quit - applink->SetOpCode(B_QUIT_REQUESTED); - applink->Flush(); - } - - // No longer necessary. This message is sent from the app_server thread - // now because of changes in the application structure from previous - // prototypes. -/* else - { - // Everything checks out, so tell the application - // where to send future messages - applink->SetOpCode(SET_SERVER_PORT); - applink->Attach(&receiver,sizeof(port_id)); - applink->Flush(); - } -*/ - applink->SetPort(sender); - winlist=new BList(0); - bmplist=new BList(0); - driver=get_gfxdriver(); - isactive=false; - cursor=new ServerCursor(); - - // This exists for testing the graphics access module and will disappear - // when layers are implemented - high.red=255; - high.green=255; - high.blue=255; - high.alpha=255; - low.red=0; - low.green=0; - low.blue=0; - low.alpha=255; -} - -ServerApp::~ServerApp(void) -{ -#ifdef DEBUG_SERVERAPP_MISC -printf("%s: ~ServerApp\n",app_sig.String()); -#endif - int32 i; - ServerWindow *tempwin; - for(i=0;iCountItems();i++) - { - tempwin=(ServerWindow*)winlist->ItemAt(i); - if(tempwin) - delete tempwin; - } - winlist->MakeEmpty(); - delete winlist; - - ServerBitmap *tempbmp; - for(i=0;iCountItems();i++) - { - tempbmp=(ServerBitmap*)bmplist->ItemAt(i); - if(tempbmp) - delete tempbmp; - } - bmplist->MakeEmpty(); - delete bmplist; - - delete applink; - applink=NULL; - delete cursor; - - // Kill the monitor thread if it exists - thread_info info; - if(get_thread_info(monitor_thread,&info)==B_OK) - kill_thread(monitor_thread); -} - -bool ServerApp::Run(void) -{ -#ifdef DEBUG_SERVERAPP_MISC -printf("%s: Run()\n",app_sig.String()); -#endif - // Unlike a BApplication, a ServerApp is *supposed* to return immediately - // when its Run function is called. - monitor_thread=spawn_thread(MonitorApp,app_sig.String(),B_NORMAL_PRIORITY,this); - if(monitor_thread==B_NO_MORE_THREADS || monitor_thread==B_NO_MEMORY) - return false; - resume_thread(monitor_thread); - return true; -} - -bool ServerApp::PingTarget(void) -{ - // This function is called by the app_server thread to ensure that - // the target app still exists. We do this not by sending a message - // but by calling get_port_info. We don't want to send ping messages - // just because the app might simply be hung. If this is the case, it - // should be up to the user to kill it. If the app has been killed, its - // ports will be invalid. Thus, if get_port_info returns an error, we - // tell the app_server to delete the respective ServerApp. - - team_info tinfo; - if(get_team_info(target_id,&tinfo)==B_BAD_TEAM_ID) - { - port_id serverport=find_port(SERVER_PORT_NAME); - if(serverport==B_NAME_NOT_FOUND) - { - printf("PANIC: ServerApp %s could not find the app_server port in PingTarget()!\n",app_sig.String()); - return false; - } - applink->SetPort(serverport); - applink->SetOpCode(DELETE_APP); - applink->Attach(&monitor_thread,sizeof(thread_id)); - applink->Flush(); -#ifdef DEBUG_SERVERAPP_MISC -printf("%s: target application is dead. ServerApp is quitting\n",app_sig.String()); -#endif - return false; - } - return true; -} - -int32 ServerApp::MonitorApp(void *data) -{ - ServerApp *app=(ServerApp *)data; - app->Loop(); - exit_thread(0); - return 0; -} - -void ServerApp::Loop(void) -{ -#ifdef DEBUG_SERVERAPP_MISC -printf("%s: Loop()\n",app_sig.String()); -#endif - // Message-dispatching loop for the ServerApp - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(receiver); - - if(buffersize>0) - { - // buffers are PortLink messages. Allocate necessary buffer and - // we'll cast it as a BMessage. - msgbuffer=new int8[buffersize]; - bytesread=read_port(receiver,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(receiver,&msgcode,NULL,0); - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { -// -------------- Messages received from the Application ------------------ - case B_QUIT_REQUESTED: - { - // 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) - { - printf("PANIC: ServerApp %s could not find the app_server port!\n",app_sig.String()); - break; - } - applink->SetPort(serverport); - applink->SetOpCode(DELETE_APP); - applink->Attach(&monitor_thread,sizeof(thread_id)); - applink->Flush(); - break; - } -/* case CREATE_WINDOW: - - case LAYER_CREATE: - case LAYER_DELETE: - case SHOW_CURSOR: - case HIDE_CURSOR: - case OBSCURE_CURSOR: - case SET_CURSOR_BCURSOR: - case SET_CURSOR_DATA: - case SET_CURSOR_BBITMAP: - - case GFX_MOVEPENBY: - case GFX_MOVEPENTO: - case GFX_SETPENSIZE: - case GFX_COUNT_WORKSPACES: - case GFX_SET_WORKSPACE_COUNT: - case GFX_CURRENT_WORKSPACE: - case GFX_ACTIVATE_WORKSPACE: - case GFX_SYSTEM_COLORS: - case GFX_SET_SCREEN_MODE: - case GFX_GET_SCROLLBAR_INFO: - case GFX_SET_SCROLLBAR_INFO: - case GFX_IDLE_TIME: - case GFX_SELECT_PRINTER_PANEL: - case GFX_ADD_PRINTER_PANEL: - case GFX_RUN_BE_ABOUT: - case GFX_SET_FOCUS_FOLLOWS_MOUSE: - case GFX_FOCUS_FOLLOWS_MOUSE: - - // Graphics messages - case GFX_SET_HIGH_COLOR: - case GFX_SET_LOW_COLOR: - case GFX_DRAW_STRING: - case GFX_SET_FONT_SIZE: - case GFX_STROKE_ARC: - case GFX_STROKE_BEZIER: - case GFX_STROKE_ELLIPSE: - case GFX_STROKE_LINE: - case GFX_STROKE_POLYGON: - case GFX_STROKE_RECT: - case GFX_STROKE_ROUNDRECT: - case GFX_STROKE_SHAPE: - case GFX_STROKE_TRIANGLE: - case GFX_FILL_ARC: - case GFX_FILL_BEZIER: - case GFX_FILL_ELLIPSE: - case GFX_FILL_POLYGON: - case GFX_FILL_RECT: - case GFX_FILL_REGION: - case GFX_FILL_ROUNDRECT: - case GFX_FILL_SHAPE: - case GFX_FILL_TRIANGLE: - DispatchMessage(msgcode, msgbuffer); - break; -*/ -// -------------- 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. Eventually, this will be replaced by a - // BMessage - write_port(sender, msgcode, msgbuffer, buffersize); - break; - } - case QUIT_APP: - { - // This message is received from the app_server thread - // because the server was asked to quit. Thus, we - // ask all apps to quit. This is NOT the same as system - // shutdown and will happen only in testing - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp asking %s to quit\n",app_sig); -#endif - applink->SetOpCode(B_QUIT_REQUESTED); - applink->Flush(); - break; - } - default: - { - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp received unrecognized code: "); -PrintMessageCodeToStream(msgcode); -#endif - - DispatchMessage(msgcode, msgbuffer); - break; - } - } - - } - - if(buffersize>0) - delete msgbuffer; - - if(msgcode==B_QUIT_REQUESTED) - break; - } -} - -void ServerApp::DispatchMessage(int32 code, int8 *buffer) -{ -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp "); -PrintMessageCode(code); -#endif - -int8 *index=buffer; - switch(code) - { - case CREATE_WINDOW: - { - // Create the ServerWindow to node monitor a new OBWindow - - // Attached data: - // 1) port_id reply port - // 2) BRect window frame - // 3) uint32 window flags - // 4) port_id window's message port - // 5) uint32 workspace index - // 6) const char * title - - // Find the necessary data - port_id reply_port=*((port_id*)index); index+=sizeof(port_id); - - BRect rect=*((BRect*)index); index+=sizeof(BRect); - - uint32 winflags=*((uint32*)index); index+=sizeof(uint32); - - port_id win_port=*((port_id*)index); index+=sizeof(port_id); - - uint32 workspace=*((uint32*)index); index+=sizeof(uint32); - - // Create the ServerWindow object for this window - ServerWindow *newwin=new ServerWindow(rect,(const char *)index, - winflags,this,win_port,workspace); - winlist->AddItem(newwin); - - // 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->Attach((int32)newwin->receiver); - replylink->Flush(); - - delete replylink; - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: Create Window()\n"); -printf("Frame: "); rect.PrintToStream(); -printf("Title: %s\n",(const char*)index); -printf("SenderPort: %ld\n",win_port); -printf("Flags: 0x%lx\n",winflags); -printf("Workspace: 0x%lx\n",workspace); -#endif - - break; - - } - case DELETE_WINDOW: - { - // Received from a ServerWindow when its window quits - - // Attached data: - // 1) thread_id ServerWindow ID - thread_id winid; - ServerWindow *w; - for(int32 i=0;iCountItems();i++) - { - w=(ServerWindow*)winlist->ItemAt(i); - if(w->thread==winid) - { - winlist->RemoveItem(w); - delete w; - break; - } - } -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: Delete Window()\n"); -printf("Thread ID: %ld",winid); -#endif - break; - } - case GFX_SET_SCREEN_MODE: - { - // Attached data - // 1) int32 workspace # - // 2) uint32 screen mode - // 3) bool make default - int32 workspace=*((int32*)index); index+=sizeof(int32); - uint32 mode=*((uint32*)index); index+=sizeof(uint32); - - SetScreenSpace(workspace,mode,*((bool*)index)); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: SetScreenMode(%ld,%lu,%s)\n",workspace, - mode,(*((bool*)index)==true)?"true":"false"); -#endif - break; - } - case GFX_ACTIVATE_WORKSPACE: - { - // Attached data - // 1) int32 workspace index - ActivateWorkspace(*((int32*)index)); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: ActivateWorkspace(%ld)\n",*((int32*)index)); -#endif - break; - } - case SHOW_CURSOR: - { - driver->ShowCursor(); - break; - } - case HIDE_CURSOR: - { - driver->HideCursor(); - break; - } - case OBSCURE_CURSOR: - { - driver->ObscureCursor(); - break; - } - case SET_CURSOR_DATA: - { - // Attached data: 68 bytes of cursor data - - // Get the data, update the app's cursor, and update the - // app's cursor if active. - int8 cdata[68]; - memcpy(cdata, buffer, 68); - cursor->SetCursor(cdata); - driver->SetCursor(cursor); -#ifdef DEBUG_SERVERAPP_CURSOR -printf("ServerApp: SetCursor(%d,%d,%d,%d)\n",r,g,b,a); -#endif - break; - } - case SET_CURSOR_BCURSOR: - // Not yet implemented - break; - - case SET_CURSOR_BBITMAP: - // Not yet implemented - break; - - // Graphics messages - case GFX_SET_HIGH_COLOR: - { - // Attached data: - // 1) uint8 red - // 2) uint8 green - // 3) uint8 blue - // 4) uint8 alpha - - uint8 r,g,b,a; - r=*((uint8*)index); index+=sizeof(uint8); - g=*((uint8*)index); index+=sizeof(uint8); - b=*((uint8*)index); index+=sizeof(uint8); - a=*((uint8*)index); - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: SetHighColor(%d,%d,%d,%d)\n",r,g,b,a); -#endif - driver->SetHighColor(r,g,b,a); - break; - } - case GFX_SET_LOW_COLOR: - { - // Attached data: - // 1) uint8 red - // 2) uint8 green - // 3) uint8 blue - // 4) uint8 alpha - - uint8 r,g,b,a; - r=*((uint8*)index); index+=sizeof(uint8); - g=*((uint8*)index); index+=sizeof(uint8); - b=*((uint8*)index); index+=sizeof(uint8); - a=*((uint8*)index); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: SetHighColor(%d,%d,%d,%d)\n",r,g,b,a); -#endif - driver->SetLowColor(r,g,b,a); - break; - } - case GFX_MOVEPENBY: - { - // Attached data: - // 1) BPoint pt - - // Default functionality is MoveTo, so get the current position - // from the driver and compensate - BPoint *ptindex,passed_pt; - - ptindex=(BPoint*)index; - passed_pt=driver->PenPosition(); - passed_pt+=*ptindex; -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp MovePenBy: (%f,%f)\n",ptindex->x,ptindex->y); -printf("Pen moved to (%f,%f)\n",passed_pt.x,passed_pt.y); -#endif - driver->MovePenTo(passed_pt); - break; - } - case GFX_MOVEPENTO: - { - // Attached data: - // 1) BPoint pt - BPoint *pt; - pt=(BPoint*)index; -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp MovePenTo: (%f,%f)\n",pt->x,pt->y); -#endif - driver->MovePenTo(*pt); - break; - } - case GFX_SETPENSIZE: - { - // Attached data: - // 1) float pen size -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp SetPenSize(%f)\n",*((float*)index)); -#endif - driver->SetPenSize(*((float*)index)); - break; - } - case GFX_DRAW_STRING: - { - // Attached data: - // 1) uint16 string length - // 2) char * string - // 3) BPoint point - - uint16 length=*((uint16*)index); index+=sizeof(uint16); -// char *string=new char[length]; -// strcpy(string, (const char *)index); index+=length; - BString string=(char *)index; index+=length; - BPoint point=*((BPoint*)index); - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp DrawString(%s, %d, BPoint(%f,%f))\n",string.String(),length,point.x,point.y); -#endif - driver->DrawString((char*)string.String(), length, point); -// delete string; - break; - } - case GFX_SET_FONT_SIZE: - break; - case GFX_STROKE_ARC: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) float starting angle - // 6) float span (arc length in degrees) - // 7) uint8[8] pattern - float cx,cy,rx,ry,angle,span; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); - angle=*((float*)index); index+=sizeof(float); - span=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeArc: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("Angle, Span: %f,%f\n",angle, span); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeArc(cx,cy,rx,ry,angle,span,(uint8*)index); - break; - } - case GFX_STROKE_BEZIER: - { - // Attached data: - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BPoint #4 - // 5) uint8[8] pattern - -#ifdef DEBUG_SERVERAPP_MSGS -BPoint *pt=(BPoint*)index; -printf("ServerApp StrokeBezier:\n"); -printf("Point 1: "); pt[0].PrintToStream(); -printf("Point 2: "); pt[1].PrintToStream(); -printf("Point 3: "); pt[2].PrintToStream(); -printf("Point 4: "); pt[3].PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeBezier((BPoint*)index,(uint8*)(index+(sizeof(BPoint)*4))); - break; - } - case GFX_STROKE_ELLIPSE: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) uint8[8] pattern - float cx,cy,rx,ry; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeEllipse: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeEllipse(cx,cy,rx,ry,(uint8*)index); - break; - } - case GFX_STROKE_LINE: - { - // Attached data: - // 1) BPoint endpoint - // 2) uint8[8] pattern - BPoint *pt; - pt=(BPoint*)index; index+=sizeof(BPoint); - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeLineTo: (%f,%f)\n",pt->x,pt->y); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeLine(*pt,(uint8*)index); - break; - } - case GFX_STROKE_POLYGON: - break; - case GFX_STROKE_RECT: - { - // Attached data: - // 1) BRect rect - // 2) uint8[8] pattern - BRect rect; - rect=*((BRect*)index); index+=sizeof(BRect); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeRect: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeRect(rect, (uint8*)index); - break; - } - case GFX_STROKE_ROUNDRECT: - { - // Attached data: - // 1) BRect rect - // 2) float x_radius - // 3) float y_radius - // 4) uint8[8] pattern - BRect rect; - float x,y; - - rect=*((BRect*)index); index+=sizeof(BRect); - x=*((float*)index); index+=sizeof(float); - y=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeRoundRect: "); rect.PrintToStream(); -printf("Radii: %f,%f\n",x,y); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeRoundRect(rect, x,y,(uint8*)index); - break; - } - case GFX_STROKE_SHAPE: - break; - case GFX_STROKE_TRIANGLE: - { - // Attached data - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BRect invalid rect - // 5) uint8[8] pattern - BPoint pt1,pt2,pt3; - BRect rect; - pt1=*((BPoint*)index); index+=sizeof(BPoint); - pt2=*((BPoint*)index); index+=sizeof(BPoint); - pt3=*((BPoint*)index); index+=sizeof(BPoint); - rect=*((BRect*)index); index+=sizeof(BRect); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeTriangle: "); -printf("Point 1: "); pt1.PrintToStream(); -printf("Point 2: "); pt2.PrintToStream(); -printf("Point 3: "); pt3.PrintToStream(); -printf("Rectangle: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeTriangle(pt1,pt2,pt3,rect,(uint8*)index); - break; - } - case GFX_FILL_ARC: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) float starting angle - // 6) float span (arc length in degrees) - // 7) uint8[8] pattern - float cx,cy,rx,ry,angle,span; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); - angle=*((float*)index); index+=sizeof(float); - span=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillArc: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("Angle, Span: %f,%f\n",angle, span); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillArc(cx,cy,rx,ry,angle,span,(uint8*)index); - break; - } - case GFX_FILL_BEZIER: - { - // Attached data: - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BPoint #4 - // 5) uint8[8] pattern - -#ifdef DEBUG_SERVERAPP_MSGS -BPoint *pt=(BPoint*)index; -printf("ServerApp FillBezier:\n"); -printf("Point 1: "); pt[0].PrintToStream(); -printf("Point 2: "); pt[1].PrintToStream(); -printf("Point 3: "); pt[2].PrintToStream(); -printf("Point 4: "); pt[3].PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillBezier((BPoint*)index,(uint8*)(index+(sizeof(BPoint)*4))); - break; - } - case GFX_FILL_ELLIPSE: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) uint8[8] pattern - float cx,cy,rx,ry; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillEllipse: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillEllipse(cx,cy,rx,ry,(uint8*)index); - break; - } - case GFX_FILL_POLYGON: - break; - case GFX_FILL_RECT: - { - // Attached data: - // 1) BRect rect - // 2) uint8[8] pattern - BRect rect; - rect=*((BRect*)index); index+=sizeof(BRect); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillRect: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillRect(rect, (uint8*)index); - break; - } - case GFX_FILL_REGION: - break; - case GFX_FILL_ROUNDRECT: - { - // Attached data: - // 1) BRect rect - // 2) float x_radius - // 3) float y_radius - // 4) uint8[8] pattern - BRect rect; - float x,y; - - rect=*((BRect*)index); index+=sizeof(BRect); - x=*((float*)index); index+=sizeof(float); - y=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillRoundRect: "); rect.PrintToStream(); -printf("Radii: %f,%f\n",x,y); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillRoundRect(rect, x,y,(uint8*)index); - break; - } - case GFX_FILL_SHAPE: - break; - case GFX_FILL_TRIANGLE: - { - // Attached data - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BRect invalid rect - // 5) uint8[8] pattern - BPoint pt1,pt2,pt3; - BRect rect; - pt1=*((BPoint*)index); index+=sizeof(BPoint); - pt2=*((BPoint*)index); index+=sizeof(BPoint); - pt3=*((BPoint*)index); index+=sizeof(BPoint); - rect=*((BRect*)index); index+=sizeof(BRect); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillTriangle: "); -printf("Point 1: "); pt1.PrintToStream(); -printf("Point 2: "); pt2.PrintToStream(); -printf("Point 3: "); pt3.PrintToStream(); -printf("Rectangle: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillTriangle(pt1,pt2,pt3,rect,(uint8*)index); - break; - } - default: - { -#ifdef DEBUG_SERVERAPP_MSGS -cout << "DispatchMessage::Unrecognized code: "; -TranslateMessageCodeToStream(code); -cout << endl << flush; -#endif - break; - } - } -} - -// Prevent any preprocessor problems in case I screw something up -#ifdef DEBUG_SERVERAPP_MSGS -#undef DEBUG_SERVERAPP_MSGS -#endif - -#ifdef DEBUG_SERVERAPP_CURSORS -#undef DEBUG_SERVERAPP_CURSORS -#endif diff --git a/src/servers/app/proto5/ServerApp.h b/src/servers/app/proto5/ServerApp.h deleted file mode 100644 index 6a53822cbf..0000000000 --- a/src/servers/app/proto5/ServerApp.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _SRVAPP_H_ -#define _SRVAPP_H_ - -#include -#include -class BMessage; -class PortLink; -class BList; -class ServerCursor; -class DisplayDriver; - -class ServerApp -{ -public: - ServerApp(port_id msgport, char *signature); - ~ServerApp(void); - - bool Run(void); - static int32 MonitorApp(void *data); - void Loop(void); - bool IsActive(void) const { return isactive; } - void Activate(bool value) { isactive=value; } - bool PingTarget(void); - -// char *app_sig; - port_id sender,receiver; - BString app_sig; - thread_id monitor_thread; - PortLink *applink; - BList *winlist, *bmplist; - ServerCursor *cursor; - DisplayDriver *driver; - rgb_color high, low; // just for testing until layers are implemented - -protected: - void DispatchMessage(int32 code, int8 *buffer); - - bool isactive; - team_id target_id; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/ServerBitmap.cpp b/src/servers/app/proto5/ServerBitmap.cpp deleted file mode 100644 index ee01f297f3..0000000000 --- a/src/servers/app/proto5/ServerBitmap.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* - ServerBitmap.cpp - Bitmap class which is intended to provide an easy way to package all the - data associated with a picture. It's very low-level, so there's still - plenty to do when coding with 'em. Also, they can be used to access draw on the - frame buffer in a relatively easy way, although it is currently unclear - whether this functionality will even be necessary. -*/ - -// These three includes for ServerBitmap(const char *path_to_image_file) only -#include -#include -#include - -#include -#include "ServerBitmap.h" -#include "Desktop.h" - -ServerBitmap::ServerBitmap(BRect rect,color_space space,int32 BytesPerLine=0) -{ - width=rect.IntegerWidth()+1; - height=rect.IntegerHeight()+1; - cspace=space; - is_vram=false; - is_area=false; - areaid=B_ERROR; - - HandleSpace(space, BytesPerLine); - buffer=new uint8[bytesperline*height]; - driver=get_gfxdriver(); -} - -ServerBitmap::ServerBitmap(int32 w,int32 h,color_space space,int32 BytesPerLine=0) -{ - width=w; - height=h; - cspace=space; - is_vram=false; - is_area=false; - areaid=B_ERROR; - - HandleSpace(space, BytesPerLine); - buffer=new uint8[bytesperline*height]; - driver=get_gfxdriver(); -} - -ServerBitmap::ServerBitmap(int32 w,int32 h,color_space space, area_id areaID, int32 BytesPerLine=0) -{ - // This version is used for holding BBitmaps as one of the undocumented BBitmap - // constructors allows - it creates an area on the server's side. - width=w; - height=h; - cspace=space; - is_vram=false; - is_area=true; - - HandleSpace(space, BytesPerLine); - area_info ainfo; - areaid=areaID; - get_area_info(areaid, &ainfo); - buffer=(uint8*)ainfo.address; - driver=get_gfxdriver(); -} - -ServerBitmap::ServerBitmap(void) -{ - // This version is obviously intended for use as an easy-access class for the - // frame buffer. AtheOS does it and it's small, so why not? Worst case, this - // can disappear if not necessary. - is_vram=true; - is_area=false; - areaid=B_ERROR; - UpdateSettings(); -} - -// This particular version is not intended for use except for testing purposes. -// It loads a BBitmap and copies it to the ServerBitmap. Probably will disappear -// when the *real* server is written -ServerBitmap::ServerBitmap(const char *path) -{ - BBitmap *bmp=BTranslationUtils::GetBitmap(path); - assert(bmp!=NULL); - - if(bmp==NULL) - { - width=0; - height=0; - cspace=B_NO_COLOR_SPACE; - bytesperline=0; - } - else - { - width=bmp->Bounds().IntegerWidth(); - height=bmp->Bounds().IntegerHeight(); - cspace=bmp->ColorSpace(); - bytesperline=bmp->BytesPerRow(); - buffer=new uint8[bmp->BitsLength()]; - memcpy(buffer,(void *)bmp->Bits(),bmp->BitsLength()); - } -} - -ServerBitmap::~ServerBitmap(void) -{ - if(!is_vram) - delete buffer; -} - -void ServerBitmap::UpdateSettings(void) -{ - // This is only used when the object is pointing to the frame buffer - driver=get_gfxdriver(); - bpp=driver->GetDepth(); - width=driver->GetWidth(); - height=driver->GetHeight(); -} - -void ServerBitmap::SetBuffer(void *buffer) -{ - buffer=(uint8 *)buffer; -} - -uint8 *ServerBitmap::Buffer(void) -{ - return buffer; -} - -uint32 ServerBitmap::BitsLength(void) -{ - return (uint32)(bytesperline*height); -} - -void ServerBitmap::HandleSpace(color_space space, int32 BytesPerLine) -{ - // Function written to handle color space setup which is required - // by the two "normal" constructors - - // Big convoluted mess just to handle every color space and dword align - // the buffer - switch(space) - { - // Buffer is dword-aligned, so nothing need be done - // aside from allocate the memory - case B_RGB32: - case B_RGBA32: - case B_RGB32_BIG: - case B_RGBA32_BIG: - case B_UVL32: - case B_UVLA32: - case B_LAB32: - case B_LABA32: - case B_HSI32: - case B_HSIA32: - case B_HSV32: - case B_HSVA32: - case B_HLS32: - case B_HLSA32: - case B_CMY32: - case B_CMYA32: - case B_CMYK32: - - // 24-bit = 32-bit with extra 8 bits ignored - case B_RGB24_BIG: - case B_RGB24: - case B_LAB24: - case B_UVL24: - case B_HSI24: - case B_HSV24: - case B_HLS24: - case B_CMY24: - { - if(BytesPerLine<(width*4)) - bytesperline=width*4; - else - bytesperline=BytesPerLine; - bpp=32; - break; - } - // Calculate size and dword-align - - // 1-bit - case B_GRAY1: - { - int32 numbytes=width>>3; - if((width % 8) != 0) - numbytes++; - if(BytesPerLine -#include -#include -#include "DisplayDriver.h" - -class ServerBitmap -{ -public: - ServerBitmap(BRect rect,color_space space,int32 BytesPerLine=0); - ServerBitmap(int32 w,int32 h,color_space space,int32 BytesPerLine=0); - ServerBitmap(int32 w,int32 h,color_space space, area_id areaID, int32 BytesPerLine=0); - ServerBitmap(void); - ServerBitmap(const char *path); - ~ServerBitmap(void); - void UpdateSettings(void); - void SetBuffer(void *buffer); - uint8 *Buffer(void); - void SetArea(area_id ID); - area_id Area(void); - uint32 BitsLength(void); - - int32 width,height; - int32 bytesperline; - color_space cspace; - int bpp; - -protected: - void HandleSpace(color_space space, int32 BytesPerLine); - DisplayDriver *driver; - bool is_vram,is_area; - area_id areaid; - uint8 *buffer; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/ServerCursor.cpp b/src/servers/app/proto5/ServerCursor.cpp deleted file mode 100644 index bb11e51760..0000000000 --- a/src/servers/app/proto5/ServerCursor.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - ServerCursor.cpp - This is the server-side class used to handle cursors. Note that it - will handle the R5 cursor API, but it will also handle taking a bitmap. - - ServerCursors are 32-bit. Eventually, we will be mapping colors to fit - when the set is called. - - This is new code, and there may be changes to the API before it settles - in. -*/ - -#include "ServerCursor.h" -#include "ServerBitmap.h" -#include -#include - -int8 default_cursor[]={ - 16,1,0,0, - - // data - 0xff, 0x80, 0x80, 0x80, 0x81, 0x00, 0x80, 0x80, 0x80, 0x40, 0x80, 0x80, 0x81, 0x00, 0xa2, 0x00, - 0xd4, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - - // mask - 0xff, 0x80, 0xff, 0x80, 0xff, 0x00, 0xff, 0x80, 0xff, 0xc0, 0xff, 0x80, 0xff, 0x00, 0xfe, 0x00, - 0xdc, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -long pow2(int power) -{ - if(power==0) - return 1; - return long(2 << (power-1)); -} - -ServerCursor::ServerCursor(void) -{ - // For when an application is started. This will probably disappear once I - // get the stuff for default cursors established - is_initialized=false; - position.Set(0,0); -} - -ServerCursor::ServerCursor(ServerBitmap *bmp, ServerBitmap *cmask=NULL) -{ - // The OpenBeOS R1 API uses Bitmaps to create cursors - more flexibility that way. - is_initialized=false; - position.Set(0,0); - SetCursor(bmp); -} - -ServerCursor::ServerCursor(int8 *data) -{ - // For handling the idiot R5 API data format - is_initialized=false; - position.Set(0,0); - SetCursor(data); -} - -ServerCursor::~ServerCursor(void) -{ - if(is_initialized) - delete bitmap; -} - -void ServerCursor::SetCursor(int8 *data) -{ - // 68-byte array used in R5 for holding cursors. - // This API has serious problems and should be deprecated(but supported) - // in a future release, perhaps right after the first one - - if(is_initialized) - { - delete bitmap; - } - cspace=B_RGBA32; - - bitmap=new ServerBitmap(16,16,B_RGBA32); - width=16; - height=16; - bounds.Set(0,0,15,15); - - // Now that we have all the setup, we're going to map (for now) the cursor - // to RGBA32. Eventually, there will be support for 16 and 8-bit depths - uint32 black=0xFF000000, - white=0xFFFFFFFF, - *bmppos; - uint16 *cursorpos, *maskpos,cursorflip, maskflip, - cursorval, maskval; - uint8 i,j; - - cursorpos=(uint16*)(data+4); - maskpos=(uint16*)(data+36); - - // for each row in the cursor data - for(j=0;j<16;j++) - { - bmppos=(uint32*)(bitmap->Buffer()+ (j*bitmap->bytesperline) ); - - // On intel, our bytes end up swapped, so we must swap them back - cursorflip=(cursorpos[j] & 0xFF) << 8; - cursorflip |= (cursorpos[j] & 0xFF00) >> 8; - maskflip=(maskpos[j] & 0xFF) << 8; - maskflip |= (maskpos[j] & 0xFF00) >> 8; - - // for each column in each row of cursor data - for(i=0;i<16;i++) - { - // Get the values and dump them to the bitmap - cursorval=cursorflip & pow2(15-i); - maskval=maskflip & pow2(15-i); - bmppos[i]=((cursorval!=0)?black:white) & ((maskval>0)?0xFFFFFFFF:0x00FFFFFF); - } - } -} - -// Currently unimplemented -void ServerCursor::SetCursor(ServerBitmap *bmp, ServerBitmap *cmask=NULL) -{ -/* if(is_initialized) - delete bitmap; - cspace=bmp->cspace; - - bitmap=new ServerBitmap(bmp->width,bmp->height,cspace); - - width=bmp->width; - height=bmp->height; - bounds.Set(0,0,bmp->width-1,bmp->height-1); -*/ -} - -void ServerCursor::MoveTo(int32 x, int32 y) -{ - position.Set(x,y); -} diff --git a/src/servers/app/proto5/ServerCursor.h b/src/servers/app/proto5/ServerCursor.h deleted file mode 100644 index b75b822acb..0000000000 --- a/src/servers/app/proto5/ServerCursor.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _SERVER_SPRITE_H -#define _SERVER_SPRITE_H - -#include -#include - -class ServerBitmap; - -class ServerCursor -{ -public: - ServerCursor(ServerBitmap *bmp,ServerBitmap *cmask=NULL); - ServerCursor(int8 *data); - ServerCursor(void); - ~ServerCursor(void); - void MoveTo(int32 x, int32 y); - void SetCursor(int8 *data); - void SetCursor(ServerBitmap *bmp, ServerBitmap *cmask=NULL); - - ServerBitmap *bitmap; - - color_space cspace; - BRect bounds; - int width,height; - BPoint position,hotspot; - bool is_initialized; -}; - -extern int8 default_cursor[]; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/ServerProtocol.h b/src/servers/app/proto5/ServerProtocol.h deleted file mode 100644 index d2138e2c1b..0000000000 --- a/src/servers/app/proto5/ServerProtocol.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef _APPSERVER_PROTOCOL_ -#define _APPSERVER_PROTOCOL_ - -#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' - -#define SERVER_PORT_NAME "OBappserver" -#define SERVER_INPUT_PORT "OBinputport" - -#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 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' - -#define GFX_SET_HIGH_COLOR 'gshc' -#define GFX_SET_LOW_COLOR 'gslc' -#define GFX_SET_VIEW_COLOR 'gsvc' - -#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' - -#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' - -#define GFX_MOVEPENBY 'gmpb' -#define GFX_MOVEPENTO 'gmpt' -#define GFX_SETPENSIZE 'gsps' - -#define GFX_DRAW_STRING 'gdst' -#define GFX_SET_FONT 'gsft' -#define GFX_SET_FONT_SIZE 'gsfs' - -#define GFX_FLUSH 'gfsh' -#define GFX_SYNC 'gsyn' - -#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 BEGIN_RECT_TRACKING 'rtbg' -#define END_RECT_TRACKING 'rten' - -#define VIEW_GET_TOKEN 'vgtk' -#define VIEW_ADD 'vadd' -#define VIEW_REMOVE 'vrem' -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/ServerSprite.cpp b/src/servers/app/proto5/ServerSprite.cpp deleted file mode 100644 index 915e487dd3..0000000000 --- a/src/servers/app/proto5/ServerSprite.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "ServerCursor.h" -#include "ServerBitmap.h" - -ServerCursor::ServerCursor(ServerBitmap *bmp) -{ -} - -ServerCursor::~ServerCursor(void) -{ -} - -ServerCursor::SetCursor(int8 *data) -{ - // 68-byte array used in R5 for holding cursors. - // This API has serious problems and should be deprecated(but supported) - // in a future release, perhaps the first one(?) -} - -void ServerCursor::SaveClientData(void) -{ -} - -void ServerCursor::MoveTo(int32 x, int32 y) -{ -} - -void ServerCursor::SetClient(ServerBitmap *bmp) -{ -} \ No newline at end of file diff --git a/src/servers/app/proto5/ServerWindow.cpp b/src/servers/app/proto5/ServerWindow.cpp deleted file mode 100644 index 25302fca52..0000000000 --- a/src/servers/app/proto5/ServerWindow.cpp +++ /dev/null @@ -1,462 +0,0 @@ -/* - ServerWindow.cpp - Class which works with a BWindow. Handles all messages coming from and - going to its window plus all drawing calls. -*/ -#include -#include -#include -#include -#include -#include // for B_XXXXX_MOUSE_BUTTON defines -#include "AppServer.h" -#include "Layer.h" -#include "PortLink.h" -#include "ServerWindow.h" -#include "ServerApp.h" -#include "ServerProtocol.h" -#include "WindowBorder.h" -#include "DebugTools.h" - -//#define DEBUG_SERVERWIN - -// Used for providing identifiers for views -int32 view_counter=0; -bool movewin=false; - -ServerWindow::ServerWindow(BRect rect, const char *string, uint32 winflags, - ServerApp *winapp, port_id winport, uint32 index) -{ - title=new BString; - if(string) - title->SetTo(string); - else - title->SetTo("Window"); -#ifdef DEBUG_SERVERWIN -printf("ServerWindow() %s\n",title->String()); -#endif - - // This must happen before the WindowBorder object - it needs this object's frame - // to be valid - frame=rect; - - winborder=new WindowBorder(this, title->String()); - - // hard code this for now - window look also needs to be attached and sent to - // server by BWindow constructor - decorator=instantiate_decorator(winborder, winflags, B_TITLED_WINDOW_LOOK); - winborder->SetDecorator(decorator); - - - // sender is the monitored app's event port - sender=winport; - winlink=new PortLink(sender); - - if(winapp!=NULL) - applink=new PortLink(winapp->receiver); - else - applink=NULL; - - // 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 thread - thread=spawn_thread(MonitorWin,title->String(),B_NORMAL_PRIORITY,this); - if(thread!=B_NO_MORE_THREADS && thread!=B_NO_MEMORY) - resume_thread(thread); - - workspace=index; - - AddWindowToDesktop(this,index); -} - -ServerWindow::~ServerWindow(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::~ServerWindow()\n",title->String()); -#endif - RemoveWindowFromDesktop(this); - if(applink!=NULL) - delete applink; - delete title; - delete winlink; - delete decorator; - delete winborder; - kill_thread(thread); -} - -void ServerWindow::RequestDraw(BRect rect) -{ - winlink->SetOpCode(LAYER_DRAW); - winlink->Attach(&rect,sizeof(BRect)); - winlink->Flush(); -} - -void ServerWindow::ReplaceDecorator(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::ReplaceDecorator()\n",title->String()); -#endif -} - -void ServerWindow::Quit(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::Quit()\n",title->String()); -#endif -} - -const char *ServerWindow::GetTitle(void) -{ - return title->String(); -} - -ServerApp *ServerWindow::GetApp(void) -{ - return app; -} - -void ServerWindow::Show(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::Show()\n",title->String()); -#endif - if(winborder) - { - winborder->ShowLayer(); - winborder->Draw(frame); - } -} - -void ServerWindow::Hide(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::Hide()\n",title->String()); -#endif - if(winborder) - winborder->HideLayer(); -} - -bool ServerWindow::IsHidden(void) -{ - return (hidecount==0)?true:false; -} - -void ServerWindow::SetFocus(bool value) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::SetFocus(%s)\n",title->String(),(value==true)?"true":"false"); -#endif - active=value; -} - -bool ServerWindow::HasFocus(void) -{ - return active; -} - -void ServerWindow::WorkspaceActivated(int32 NewWorkspace, const BPoint Resolution, color_space CSpace) -{ -} - -void ServerWindow::WindowActivated(bool Active) -{ -} - -void ServerWindow::ScreenModeChanged(const BPoint Resolustion, color_space CSpace) -{ -} - -void ServerWindow::SetFrame(const BRect &rect) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::SetFrame()",title->String()); rect.PrintToStream(); -#endif - frame=rect; -} - -BRect ServerWindow::Frame(void) -{ - return frame; -} - -status_t ServerWindow::Lock(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::Lock()\n",title->String()); -#endif - return locker.Lock(); -} - -void ServerWindow::Unlock(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::Unlock()\n",title->String()); -#endif - locker.Unlock(); -} - -bool ServerWindow::IsLocked(void) -{ - return locker.IsLocked(); -} - -void ServerWindow::Loop(void) -{ - // Message-dispatching loop for the ServerWindow - -#ifdef DEBUG_SERVERWIN -printf("%s::Loop()\n",title->String()); -#endif - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(receiver); - - if(buffersize>0) - { - msgbuffer=new int8[buffersize]; - bytesread=read_port(receiver,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(receiver,&msgcode,NULL,0); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case 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) (int32) id of the child view - // 3) (BRect) frame in parent's coordinates - // 4) (int32) resize flags - // 5) (int32) view flags - // 6) (uint16) view's hide level - - 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)thread); - applink->Flush(); - break; - } - case VIEW_GET_TOKEN: - { - // Request to get a view identifier - this is synchronous, so reply - // immediately - - // Attached data: - // 1) port_id reply port - port_id reply_port=*((port_id*)msgbuffer); - PortLink *link=new PortLink(reply_port); - link->Attach(view_counter++); - link->Flush(); - break; - } - default: - DispatchMessage(msgcode,msgbuffer); - break; - } - - } - - if(buffersize>0) - delete msgbuffer; - - 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; -} - -void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer) -{ - ServerWindow *mousewin=NULL; - int8 *index=buffer; - - // Find the window which will receive our mouse event. - Layer *root=GetRootLayer(); - WindowBorder *winborder; - ASSERT(root!=NULL); - - // Dispatch the mouse event to the proper window - switch(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 - -// int64 time=*((int64*)index); - index+=sizeof(int64); - float x=*((float*)index); - index+=sizeof(float); - float y=*((float*)index); - index+=sizeof(float); -// int32 modifiers=*((int32*)index); - index+=sizeof(uint32); - uint32 buttons=*((uint32*)index); - index+=sizeof(uint32); -// int32 clicks=*((int32*)index); - BPoint pt(x,y); - - // If we have clicked on a window, - winborder=(WindowBorder*)root->GetChildAt(pt); - if(winborder) - { - mousewin=winborder->Window(); - ASSERT(mousewin!=NULL); - - winborder->MouseDown(pt,buttons); - -#ifdef DEBUG_SERVERWIN -printf("ServerWindow() %s: MouseDown(%.1f,%.1f)\n",mousewin->title->String(),x,y); -#endif - } - 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 - -// int64 time=*((int64*)index); - index+=sizeof(int64); - float x=*((float*)index); - index+=sizeof(float); - float y=*((float*)index); - index+=sizeof(float); -// int32 modifiers=*((int32*)index); - BPoint pt(x,y); - - is_moving_window=false; - winborder=(WindowBorder*)root->GetChildAt(pt); - if(winborder) - { - mousewin=winborder->Window(); - ASSERT(mousewin!=NULL); - - // Eventually, we will build in MouseUp messages with buttons specified - // For now, we just "assume" no mouse specification with a 0. - winborder->MouseUp(pt,0); - - // Do cool mouse stuff here - -#ifdef DEBUG_SERVERWIN -printf("ServerWindow() %s: MouseUp(%.1f,%.1f)\n",mousewin->title->String(),x,y); -#endif - } - 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 -// int64 time=*((int64*)index); - index+=sizeof(int64); - float x=*((float*)index); - index+=sizeof(float); - float y=*((float*)index); - index+=sizeof(float); - uint32 buttons=*((uint32*)index); - BPoint pt(x,y); - - winborder=(WindowBorder*)root->GetChildAt(pt); - if(activeborder) - winborder=activeborder; - if(winborder) - { - mousewin=winborder->Window(); - ASSERT(mousewin!=NULL); - - winborder->MouseMoved(pt,buttons); - - // Do cool mouse stuff here - -#ifdef DEBUG_SERVERWIN -printf("ServerWindow() %s: MouseMoved(%.1f,%.1f)\n",mousewin->title->String(),x,y); -#endif - } - break; - } - default: - { -#ifdef DEBUG_SERVERWIN -printf("HandleMouseEvent() received an unrecognized mouse event"); -PrintMessageCode(code); -#endif - break; - } - } -} diff --git a/src/servers/app/proto5/ServerWindow.h b/src/servers/app/proto5/ServerWindow.h deleted file mode 100644 index 424256949b..0000000000 --- a/src/servers/app/proto5/ServerWindow.h +++ /dev/null @@ -1,73 +0,0 @@ -#ifndef _SERVERWIN_H_ -#define _SERVERWIN_H_ - -#include -#include -#include -#include -#include -#include - -class BString; -class BMessenger; -class BPoint; -class ServerApp; -class Decorator; -class PortLink; -class WindowBorder; - -class ServerWindow -{ -public: - ServerWindow(BRect rect, const char *string, uint32 winflags, - ServerApp *winapp, port_id winport, uint32 index); - ~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 SetFocus(bool value); - bool HasFocus(void); - void RequestDraw(BRect rect); - - void WorkspaceActivated(int32 NewDesktop, const BPoint Resolution, color_space CSpace); - void WindowActivated(bool Active); - void ScreenModeChanged(const BPoint Resolution, color_space CSpace); - - void SetFrame(const BRect &rect); - BRect Frame(void); - - status_t Lock(void); - void Unlock(void); - bool IsLocked(void); - - void DispatchMessage(int32 code, int8 *msgbuffer); - static int32 MonitorWin(void *data); - static void HandleMouseEvent(int32 code, int8 *buffer); - void Loop(void); - - BString *title; - int32 flags; - int32 workspace; - bool active; - - ServerApp *app; - - Decorator *decorator; - WindowBorder *winborder; - bigtime_t lasthit; // Time of last mouse click - - thread_id thread; - port_id receiver; // Messages from window - port_id sender; // Messages to window - PortLink *winlink,*applink; - BLocker locker; - BRect frame; - uint8 hidecount; -}; - -#endif diff --git a/src/servers/app/proto5/SystemPalette.cpp b/src/servers/app/proto5/SystemPalette.cpp deleted file mode 100644 index 3a388ed6b4..0000000000 --- a/src/servers/app/proto5/SystemPalette.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/* - SystemPalette.cpp - One global function to generate the palette which is the default BeOS - System palette and the variable to go with it -*/ - -#include "SystemPalette.h" - -rgb_color SystemPalette[256]; - -void GenerateSystemPalette(rgb_color *palette) -{ - int i,j,index=0; - int indexvals1[]={ 255,229,204,179,154,129,105,80,55,30 }, - indexvals2[]={ 255,203,152,102,51,0 }; - rgb_color *currentcol; - - // Grays 0,0,0 -> 248,248,248 by 8's - for(i=0; i<=248; i+=8,index++) - { - currentcol=&(palette[index]); - currentcol->red=i; - currentcol->green=i; - currentcol->blue=i; - currentcol->alpha=255; - } - - // Blues, following indexvals1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=0; - currentcol->blue=indexvals1[i]; - currentcol->alpha=255; - } - - // Reds, following indexvals1 - 1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals1[i] - 1; - currentcol->green=0; - currentcol->blue=0; - currentcol->alpha=255; - } - - // Greens, following indexvals1 - 1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=indexvals1[i] - 1; - currentcol->blue=0; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=152; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=255; - currentcol->blue=255; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=0;i<4;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=152; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=0; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=255; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=203; - index++; - - // Mostly array runs from here on out - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=203; - currentcol->green=203; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=152; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=102; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=51; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=152; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=102; - index++; - - // knocks out 4 assignment loops at once :) - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=152; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - currentcol+=sizeof(rgb_color); - currentcol->red=230; - currentcol->green=134; - currentcol->blue=0; - index++; - - for(i=1;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=0; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=102; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=175; - currentcol->blue=19; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=255; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=203; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=3;i>=0;i--,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - for(i=2;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - for(i=0;i<5;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=203; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=227; - currentcol->blue=70; - index++; - - for(j=2;j<6;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=0; - index++; - - for(i=5;i<=0;i--,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - -} diff --git a/src/servers/app/proto5/SystemPalette.h b/src/servers/app/proto5/SystemPalette.h deleted file mode 100644 index 0fb99d0fed..0000000000 --- a/src/servers/app/proto5/SystemPalette.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _SYSTEM_PALETTE_H_ -#define _SYSTEM_PALETTE_H_ - -#include - -void GenerateSystemPalette(rgb_color *palette); -extern rgb_color SystemPalette[]; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/TODO b/src/servers/app/proto5/TODO deleted file mode 100644 index 30d5887c1c..0000000000 --- a/src/servers/app/proto5/TODO +++ /dev/null @@ -1,3 +0,0 @@ -Finish Layers code which is declared in header but unimplemented - -Add Layer::Frame() \ No newline at end of file diff --git a/src/servers/app/proto5/ViewDriver.cpp b/src/servers/app/proto5/ViewDriver.cpp deleted file mode 100644 index 2979ee4b17..0000000000 --- a/src/servers/app/proto5/ViewDriver.cpp +++ /dev/null @@ -1,1558 +0,0 @@ -/* - ViewDriver: - First, slowest, and easiest driver class in the app_server which is designed - to utilize the BeOS graphics functions to cut out a lot of junk in getting the - drawing infrastructure in this server. - - The concept is to have VDView::Draw() draw a bitmap, which is a "frame buffer" - of sorts, utilize a second view to write to it. This cuts out - the most problems with having a crapload of code to get just right without - having to write a bunch of unit tests - - Components: 3 classes, VDView, VDWindow, and ViewDriver - - ViewDriver - a wrapper class which mostly posts messages to the VDWindow - VDWindow - does most of the work. - VDView - doesn't do all that much except display the rendered bitmap -*/ - -//#define DEBUG_DRIVER_MODULE -//#define DEBUG_SERVER_EMU - -//#define DISABLE_SERVER_EMU - -#include -#include -#include -#include -#include -#include "PortLink.h" -#include "ServerProtocol.h" -#include "ServerBitmap.h" -#include "ViewDriver.h" -#include "ServerCursor.h" -#include "DebugTools.h" - -// Message defines for internal use only -enum -{ -VDWIN_CLEAR=100, -VDWIN_SAFEMODE, -VDWIN_RESET, -VDWIN_SETSCREEN, - -VDWIN_FILLARC, -VDWIN_STROKEARC, -VDWIN_FILLRECT, -VDWIN_STROKERECT, -VDWIN_FILLROUNDRECT, -VDWIN_STROKEROUNDRECT, -VDWIN_FILLELLIPSE, -VDWIN_STROKEELLIPSE, -VDWIN_FILLBEZIER, -VDWIN_STROKEBEZIER, -VDWIN_FILLTRIANGLE, -VDWIN_STROKETRIANGLE, -VDWIN_STROKELINE, -VDWIN_DRAWSTRING, - -VDWIN_SETPENSIZE, -VDWIN_MOVEPENTO, -VDWIN_SHOWCURSOR, -VDWIN_HIDECURSOR, -VDWIN_OBSCURECURSOR, -VDWIN_MOVECURSOR, -VDWIN_SETCURSOR, -VDWIN_SETHIGHCOLOR, -VDWIN_SETLOWCOLOR -}; - -VDView::VDView(BRect bounds) - : BView(bounds,"viewdriver_view",B_FOLLOW_ALL, B_WILL_DRAW) -{ - viewbmp=new BBitmap(bounds,B_RGB32,true); - drawview=new BView(viewbmp->Bounds(),"drawview",B_FOLLOW_ALL, B_WILL_DRAW); - - // This link for sending mouse messages to the OBAppServer. - // This is only to take the place of the Input Server. I suppose I could write - // an addon filter to be more like the Input Server, but then I wouldn't be working - // on this thing! :P - serverlink=new PortLink(find_port(SERVER_INPUT_PORT)); - -#ifdef DEBUG_DRIVER_MODULE - printf("VDView: app_server input port: %ld\n",serverlink->GetPort()); -#endif - - hide_cursor=0; - obscure_cursor=false; - - // Create a cursor which isn't just a box - cursor=new BBitmap(BRect(0,0,20,20),B_RGBA32,true); - BView *v=new BView(cursor->Bounds(),"v", B_FOLLOW_NONE, B_WILL_DRAW); - - cursor->Lock(); - cursor->AddChild(v); - - v->SetHighColor(255,255,255,0); - v->FillRect(cursor->Bounds()); - v->SetHighColor(255,0,0,255); - v->FillTriangle(cursor->Bounds().LeftTop(),cursor->Bounds().RightTop(),cursor->Bounds().LeftBottom()); - - cursor->RemoveChild(v); - cursor->Unlock(); - - cursorframe=cursor->Bounds(); - oldcursorframe=cursor->Bounds(); -} - -VDView::~VDView(void) -{ - delete viewbmp; - delete serverlink; - delete cursor; -} - -void VDView::AttachedToWindow(void) -{ -// printf("VDView::AttachedToWindow()\n"); -} - -void VDView::Draw(BRect rect) -{ - DrawBitmapAsync(viewbmp,oldcursorframe,oldcursorframe); - DrawBitmapAsync(viewbmp,rect,rect); - - if(hide_cursor==0 && obscure_cursor==false) - { - SetDrawingMode(B_OP_ALPHA); - DrawBitmapAsync(cursor,cursor->Bounds(),cursorframe); - SetDrawingMode(B_OP_COPY); - } - Sync(); -} - -// These functions emulate the Input Server by sending the *exact* same kind of messages -// to the server's port. Being we're using a regular window, it would make little sense -// to do anything else. - -void VDView::MouseDown(BPoint pt) -{ -#ifdef DEBUG_SERVER_EMU -printf("ViewDriver::MouseDown\t"); -#endif - // 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 -#ifndef DISABLE_SERVER_EMU - BPoint p; - - uint32 buttons, - mod=modifiers(), - clicks=1; // can't get the # of clicks without a *lot* of extra work :( - - int64 time=(int64)real_time_clock(); - - GetMouse(&p,&buttons); - - serverlink->SetOpCode(B_MOUSE_DOWN); - serverlink->Attach(&time, sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - serverlink->Attach(&mod, sizeof(uint32)); - serverlink->Attach(&buttons, sizeof(uint32)); - serverlink->Attach(&clicks, sizeof(uint32)); - serverlink->Flush(); -#endif -} - -void VDView::MouseMoved(BPoint pt, uint32 transit, const BMessage *msg) -{ - // Attach 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 -#ifndef DISABLE_SERVER_EMU - BPoint p; - uint32 buttons; - int64 time=(int64)real_time_clock(); - - serverlink->SetOpCode(B_MOUSE_MOVED); - serverlink->Attach(&time,sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - GetMouse(&p,&buttons); - serverlink->Attach(&buttons,sizeof(int32)); - serverlink->Flush(); -#endif -} - -void VDView::MouseUp(BPoint pt) -{ -#ifdef DEBUG_SERVER_EMU -printf("ViewDriver::MouseUp\t"); -#endif - // 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 -#ifndef DISABLE_SERVER_EMU - BPoint p; - - uint32 buttons, - mod=modifiers(); - - int64 time=(int64)real_time_clock(); - - GetMouse(&p,&buttons); - - serverlink->SetOpCode(B_MOUSE_UP); - serverlink->Attach(&time, sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - serverlink->Attach(&mod, sizeof(uint32)); - serverlink->Flush(); -#endif -} - -void VDView::SetMode(int16 width, int16 height, uint8 bpp) -{ - // This function resets the emulated video buffer - color_space s; - - switch(bpp) - { - case 16: - s=B_RGBA15; - break; - case 8: - s=B_CMAP8; - break; - default: - s=B_RGBA32; - break; - } - delete viewbmp; - viewbmp=new BBitmap(BRect(0,0,width-1,height-1),s,true); - drawview->ResizeTo(width-1,height-1); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver::SetMode(%d x %d x %d)\n",width,height,bpp); -#endif -} - -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- - -VDWindow::VDWindow(void) - : BWindow(BRect(100,60,740,540),"OBOS App Server, P5",B_TITLED_WINDOW, - B_NOT_ZOOMABLE | B_NOT_RESIZABLE) -{ - view=new VDView(Bounds()); - AddChild(view); -} - -VDWindow::~VDWindow(void) -{ -} - -void VDWindow::MessageReceived(BMessage *msg) -{ - switch(msg->what) - { - case VDWIN_CLEAR: - { - int8 red=0,green=0,blue=0; - msg->FindInt8("red",&red); - msg->FindInt8("green",&green); - msg->FindInt8("blue",&blue); - Clear(red,green,blue); - break; - } - case VDWIN_SETSCREEN: - { - // debug printing done in SetScreen() - int32 space=0; - msg->FindInt32("screenmode",&space); - SetScreen(space); - break; - } - case VDWIN_RESET: - { - Reset(); - break; - } - case VDWIN_SAFEMODE: - { - SafeMode(); - break; - } - case VDWIN_DRAWSTRING: - { - char *string; - BPoint point; - uint16 length; - msg->FindString("string",(const char **)&string); - msg->FindInt16("length",(int16*)&length); - msg->FindPoint("point",&point); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->SetDrawingMode(B_OP_ALPHA); - view->drawview->DrawString(string,length,point); - view->drawview->SetDrawingMode(B_OP_COPY); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver::DrawString: "); -printf("String: %s\n",string); -printf("Length: %d\n",length); -printf("Point: "); point.PrintToStream(); -#endif - // Until I can figure out a better way, if I even bother... - view->Invalidate(); - } - case VDWIN_FILLARC: - { - float cx,cy,rx,ry,angle,span; - int64 temp64; - - msg->FindFloat("cx",&cx); - msg->FindFloat("cy",&cy); - msg->FindFloat("rx",&rx); - msg->FindFloat("ry",&ry); - msg->FindFloat("angle",&angle); - msg->FindFloat("span",&span); - if(msg->FindInt64("pattern",&temp64)!=B_OK) - temp64=*((int64*)&B_SOLID_HIGH); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->FillArc(BPoint(cx,cy),rx,ry,angle,span,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(BRect(cx-rx,cy-ry,cx+rx,cy+ry)); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver::FillArc: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("Angle, Span: %f,%f\n",angle, span); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_STROKEARC: - { - float cx,cy,rx,ry,angle,span; - int64 temp64; - - msg->FindFloat("cx",&cx); - msg->FindFloat("cy",&cy); - msg->FindFloat("rx",&rx); - msg->FindFloat("ry",&ry); - msg->FindFloat("angle",&angle); - msg->FindFloat("span",&span); - if(msg->FindInt64("pattern",&temp64)!=B_OK) - temp64=*((int64*)&B_SOLID_HIGH); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->StrokeArc(BPoint(cx,cy),rx,ry,angle,span,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(BRect(cx-rx,cy-ry,cx+rx,cy+ry)); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeArc: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("Angle, Span: %f,%f\n",angle, span); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_FILLBEZIER: - { - BPoint points[4]; - int64 temp64; - msg->FindPoint("p1",points); - msg->FindPoint("p2",&(points[1])); - msg->FindPoint("p3",&(points[2])); - msg->FindPoint("p4",&(points[3])); - if(msg->FindInt64("pattern",&temp64)!=B_OK) - temp64=*((int64*)&B_SOLID_HIGH); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->FillBezier(points,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - - // Invalidate the whole view until I can figure out how to calculate - // a rect which encompasses the line - view->Invalidate(); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: FillBezier:\n"); -printf("Point 1: "); points[0].PrintToStream(); -printf("Point 2: "); points[1].PrintToStream(); -printf("Point 3: "); points[2].PrintToStream(); -printf("Point 4: "); points[3].PrintToStream(); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_STROKEBEZIER: - { - BPoint points[4]; - int64 temp64; - msg->FindPoint("p1",points); - msg->FindPoint("p2",&(points[1])); - msg->FindPoint("p3",&(points[2])); - msg->FindPoint("p4",&(points[3])); - if(msg->FindInt64("pattern",&temp64)!=B_OK) - temp64=*((int64*)&B_SOLID_HIGH); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->StrokeBezier(points,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - - // Invalidate the whole view until I can figure out how to calculate - // a rect which encompasses the line - view->Invalidate(); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeBezier:\n"); -printf("Point 1: "); points[0].PrintToStream(); -printf("Point 2: "); points[1].PrintToStream(); -printf("Point 3: "); points[2].PrintToStream(); -printf("Point 4: "); points[3].PrintToStream(); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_FILLRECT: - { - BRect rect(0,0,0,0); - int64 temp64; - - msg->FindRect("rect",&rect); - if(msg->FindInt64("pattern",&temp64)==B_NAME_NOT_FOUND) - { - // Pattern will not exist if we are using the internal - // API which specifies a color and a rectangle - rgb_color highcolor=view->drawview->HighColor(); - rgb_color rectcolor; - msg->FindInt8("red",(int8*)&(rectcolor.red)); - msg->FindInt8("green",(int8*)&(rectcolor.green)); - msg->FindInt8("blue",(int8*)&(rectcolor.blue)); - msg->FindInt8("alpha",(int8*)&(rectcolor.alpha)); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->SetHighColor(rectcolor); - view->drawview->FillRect(rect,B_SOLID_HIGH); - view->drawview->SetHighColor(highcolor); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(rect); -#ifdef DEBUG_DRIVER_MODULE -printf("FillRect: "); rect.PrintToStream(); -printf("color (%d,%d,%d,%d)\n",rectcolor.red,rectcolor.green,rectcolor.blue,rectcolor.alpha); -#endif - break; - } - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->FillRect(rect,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(rect); -#ifdef DEBUG_DRIVER_MODULE -printf("FillRect: "); rect.PrintToStream(); -printf("pattern: {%llxd}\n",temp64); -#endif - break; - } - case VDWIN_STROKERECT: - { - BRect rect(0,0,0,0); - int64 temp64; - - msg->FindRect("rect",&rect); - - if(msg->FindInt64("pattern",&temp64)==B_NAME_NOT_FOUND) - { - // Pattern will not exist if we are using the internal - // API which specifies a color and a rectangle - rgb_color highcolor=view->drawview->HighColor(); - rgb_color rectcolor; - msg->FindInt8("red",(int8*)&(rectcolor.red)); - msg->FindInt8("green",(int8*)&(rectcolor.green)); - msg->FindInt8("blue",(int8*)&(rectcolor.blue)); - msg->FindInt8("alpha",(int8*)&(rectcolor.alpha)); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->SetHighColor(rectcolor); - view->drawview->StrokeRect(rect,B_SOLID_HIGH); - view->drawview->SetHighColor(highcolor); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(rect); -#ifdef DEBUG_DRIVER_MODULE -printf("StrokeRect: "); rect.PrintToStream(); -printf("color (%d,%d,%d,%d)\n",rectcolor.red,rectcolor.green,rectcolor.blue,rectcolor.alpha); -#endif - break; - } - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->StrokeRect(rect,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(rect); -#ifdef DEBUG_DRIVER_MODULE -printf("StrokeRect: "); rect.PrintToStream(); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_FILLELLIPSE: - { - float cx,cy,rx,ry; - int64 temp64; - - msg->FindFloat("cx",&cx); - msg->FindFloat("cy",&cy); - msg->FindFloat("rx",&rx); - msg->FindFloat("ry",&ry); - if(msg->FindInt64("pattern",&temp64)!=B_OK) - temp64=*((int64*)&B_SOLID_HIGH); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->FillEllipse(BPoint(cx,cy),rx,ry,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(BRect(cx-rx,cy-ry,cx+rx,cy+ry)); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: FillEllipse: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_STROKEELLIPSE: - { - float cx,cy,rx,ry; - int64 temp64; - - msg->FindFloat("cx",&cx); - msg->FindFloat("cy",&cy); - msg->FindFloat("rx",&rx); - msg->FindFloat("ry",&ry); - if(msg->FindInt64("pattern",&temp64)!=B_OK) - temp64=*((int64*)&B_SOLID_HIGH); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->StrokeEllipse(BPoint(cx,cy),rx,ry,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(BRect(cx-rx,cy-ry,cx+rx,cy+ry)); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeEllipse: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_FILLROUNDRECT: - { - BRect rect(0,0,0,0); - int64 temp64; - float x,y; - - msg->FindRect("rect",&rect); - msg->FindFloat("x",&x); - msg->FindFloat("y",&y); - if(msg->FindInt64("pattern",&temp64)!=B_OK) - temp64=*((int64*)&B_SOLID_HIGH); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->FillRoundRect(rect,x,y,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(rect); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: FillRoundRect: "); rect.PrintToStream(); -printf("Radii: %f,%f\n",x,y); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_STROKEROUNDRECT: - { - BRect rect(0,0,0,0); - int64 temp64; - float x,y; - - msg->FindRect("rect",&rect); - msg->FindFloat("x",&x); - msg->FindFloat("y",&y); - if(msg->FindInt64("pattern",&temp64)!=B_OK) - temp64=*((int64*)&B_SOLID_HIGH); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->StrokeRoundRect(rect,x,y,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(rect); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeRoundRect: "); rect.PrintToStream(); -printf("Radii: %f,%f\n",x,y); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_FILLTRIANGLE: - { - BPoint pt1,pt2,pt3; - BRect invalid; - int64 temp64; - msg->FindPoint("first",&pt1); - msg->FindPoint("second",&pt2); - msg->FindPoint("third",&pt3); - msg->FindRect("rect",&invalid); - if(msg->FindInt64("pattern",&temp64)!=B_OK) - temp64=*((int64*)&B_SOLID_HIGH); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->FillTriangle(pt1,pt2,pt3,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - - view->Invalidate(invalid); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: FillTriangle:\n"); -printf("Point 1: "); pt1.PrintToStream(); -printf("Point 2: "); pt2.PrintToStream(); -printf("Point 3: "); pt3.PrintToStream(); -printf("Rect: "); invalid.PrintToStream(); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_STROKETRIANGLE: - { - BPoint pt1,pt2,pt3; - BRect invalid; - int64 temp64; - msg->FindPoint("first",&pt1); - msg->FindPoint("second",&pt2); - msg->FindPoint("third",&pt3); - msg->FindRect("rect",&invalid); - if(msg->FindInt64("pattern",&temp64)!=B_OK) - temp64=*((int64*)&B_SOLID_HIGH); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->StrokeTriangle(pt1,pt2,pt3,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - - view->Invalidate(invalid); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeTriangle:\n"); -printf("Point 1: "); pt1.PrintToStream(); -printf("Point 2: "); pt2.PrintToStream(); -printf("Point 3: "); pt3.PrintToStream(); -printf("Rect: "); invalid.PrintToStream(); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_STROKELINE: - { - BPoint pt(0,0),pt2(0,0); - int64 temp64; - rgb_color tcol, oldcol; - - msg->FindPoint("from",&pt); - msg->FindPoint("to",&pt2); - if(msg->FindInt64("pattern",&temp64)!=B_OK) - temp64=*((int64*)&B_SOLID_HIGH); - - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - - if(msg->FindInt8("red",(int8*)&tcol.red)!=B_NAME_NOT_FOUND) - { - msg->FindInt8("green",(int8*)&tcol.green); - msg->FindInt8("blue",(int8*)&tcol.blue); - msg->FindInt8("alpha",(int8*)&tcol.alpha); - oldcol=view->drawview->HighColor(); - view->drawview->SetHighColor(tcol); - view->drawview->StrokeLine(pt,pt2,*((pattern *)&temp64)); - view->drawview->SetHighColor(oldcol); - } - else - view->drawview->StrokeLine(pt,pt2,*((pattern *)&temp64)); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - - // Because BRect requires (pt1,pt2) where pt1=LeftTop(), - // we have to jump through some hoops - - BRect invalid(MIN(pt2.x,pt.x), MIN(pt2.y,pt.y), - MAX(pt2.x,pt.x), MAX(pt2.y,pt.y) ); - invalid.InsetBy((view->drawview->PenSize()/2)*-1,(view->drawview->PenSize()/2)*-1); - view->Invalidate(invalid); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeLine(%f,%f)\n",pt.x,pt.y); -printf("pattern: {%llx}\n",temp64); -#endif - break; - } - case VDWIN_SHOWCURSOR: - { - if(view->hide_cursor>0) - { - view->hide_cursor--; -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: ShowCursor() - still hidden\n"); -#endif - } - if(view->hide_cursor==0) - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: ShowCursor() - cursor shown\n"); -#endif - view->Invalidate(view->cursorframe); - } - break; - } - case VDWIN_HIDECURSOR: - { - view->hide_cursor++; -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: HideCursor()\n"); -#endif - if(view->hide_cursor==1) - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: HideCursor() - cursor was hidden\n"); -#endif - view->Invalidate(view->cursorframe); - } - break; - } - case VDWIN_OBSCURECURSOR: - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: ObscureCursor()\n"); -#endif - view->obscure_cursor=true; - view->Invalidate(view->cursorframe); - break; - } - case VDWIN_MOVECURSOR: - { - float x,y; - msg->FindFloat("x",&x); - msg->FindFloat("y",&y); - - // this was changed because an extra message was - // sent even though the mouse was never moved - if(view->cursorframe.left!=x || view->cursorframe.top!=y) - { - if(view->obscure_cursor) - view->obscure_cursor=false; - - view->oldcursorframe=view->cursorframe; - view->cursorframe.OffsetTo(x,y); - } - - if(view->hide_cursor==0) - view->Invalidate(view->oldcursorframe); - break; - } - case VDWIN_SETCURSOR: - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: SetCursor()\n"); -#endif - ServerCursor *cdata; - msg->FindPointer("SCursor",(void**)&cdata); - - if(cdata!=NULL) - { - BBitmap *bmp=new BBitmap(BRect(0,0,cdata->width-1,cdata->height-1), - cdata->cspace); - - // Copy the server bitmap in the cursor to a BBitmap - uint8 *sbmppos=(uint8*)cdata->bitmap->Buffer(), - *bbmppos=(uint8*)bmp->Bits(); - - int32 bytes=cdata->bitmap->bytesperline, - bbytes=bmp->BytesPerRow(); - - for(int i=0;iheight;i++) - memcpy(bbmppos+(i*bbytes), sbmppos+(i*bytes), bytes); - - // Replace the bitmap - delete view->cursor; - view->cursor=bmp; - view->Invalidate(view->cursorframe); - break; - } - break; - } - case VDWIN_SETHIGHCOLOR: - { - uint8 r=0,g=0,b=0,a=0; - msg->FindInt8("red",(int8*)&r); - msg->FindInt8("green",(int8*)&g); - msg->FindInt8("blue",(int8*)&b); - msg->FindInt8("alpha",(int8*)&a); - view->drawview->SetHighColor(r,g,b,a); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: SetHighColor(%d,%d,%d,%d)\n",r,g,b,a); -#endif - break; - } - case VDWIN_SETLOWCOLOR: - { - uint8 r=0,g=0,b=0,a=0; - msg->FindInt8("red",(int8*)&r); - msg->FindInt8("green",(int8*)&g); - msg->FindInt8("blue",(int8*)&b); - msg->FindInt8("alpha",(int8*)&a); - view->drawview->SetLowColor(r,g,b,a); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: SetLowColor(%d,%d,%d,%d)\n",r,g,b,a); -#endif - break; - } - case VDWIN_SETPENSIZE: - { - float pensize; - msg->FindFloat("size",&pensize); - view->drawview->SetPenSize(pensize); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: SetPenSize(%f)\n",pensize); -#endif - break; - } - case VDWIN_MOVEPENTO: - { - BPoint pt; - msg->FindPoint("point",&pt); - view->drawview->MovePenTo(pt); -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: MovePenTo(%f,%f)\n",pt.x,pt.y); -#endif - break; - } - default: - BWindow::MessageReceived(msg); - break; - } -} - -void VDWindow::SafeMode(void) -{ - SetScreen(B_8_BIT_640x480); -} - -void VDWindow::Reset(void) -{ - SafeMode(); - Clear(255,255,255); -} - -void VDWindow::SetScreen(uint32 space) -{ - int16 w=640,h=480; - uint8 bpp=0; - switch(space) - { - case B_32_BIT_800x600: - case B_16_BIT_800x600: - case B_8_BIT_800x600: - { - w=800; h=600; - break; - } - case B_32_BIT_1024x768: - case B_16_BIT_1024x768: - case B_8_BIT_1024x768: - { - w=1024; h=768; - break; - } - default: - break; - } - ResizeTo(w-1,h-1); - - switch(space) - { - case B_32_BIT_640x480: - case B_32_BIT_800x600: - case B_32_BIT_1024x768: - bpp=32; - break; - case B_16_BIT_640x480: - case B_16_BIT_800x600: - case B_16_BIT_1024x768: - bpp=16; - break; - case B_8_BIT_640x480: - case B_8_BIT_800x600: - case B_8_BIT_1024x768: - bpp=8; - break; - default: - break; - } - view->SetMode(w,h,bpp); -} - -void VDWindow::Clear(uint8 red,uint8 green,uint8 blue) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: Clear(%d,%d,%d)\n",red,green,blue); -#endif - view->viewbmp->Lock(); - view->viewbmp->AddChild(view->drawview); - view->drawview->SetHighColor(red,green,blue); - view->drawview->FillRect(view->drawview->Bounds()); - view->viewbmp->RemoveChild(view->drawview); - view->viewbmp->Unlock(); - view->Invalidate(); -} - -bool VDWindow::QuitRequested(void) -{ - port_id serverport=find_port(SERVER_PORT_NAME); - if(serverport!=B_NAME_NOT_FOUND) - { - write_port(serverport,B_QUIT_REQUESTED,NULL,0); - } - return true; -} - -void VDWindow::WindowActivated(bool active) -{ - // This is just to hide the regular system cursor so we can see our own - if(active) - be_app->HideCursor(); - else - be_app->ShowCursor(); -} - -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- - -/* - Posting messages to the rendering window helps run right around a whole - migraine's worth of multithreaded code -*/ - -ViewDriver::ViewDriver(void) -{ - screenwin=new VDWindow(); - hide_cursor=0; -} - -ViewDriver::~ViewDriver(void) -{ - if(is_initialized) - { - screenwin->Lock(); - screenwin->Quit(); - } -} - -void ViewDriver::Initialize(void) -{ - locker->Lock(); - screenwin->Show(); - is_initialized=true; - SetPenSize(1.0); - MovePenTo(BPoint(0,0)); - locker->Unlock(); -} - -void ViewDriver::Shutdown(void) -{ - locker->Lock(); - is_initialized=false; - locker->Unlock(); -} - -bool ViewDriver::IsInitialized(void) -{ - return is_initialized; -} - -void ViewDriver::SafeMode(void) -{ - locker->Lock(); - screenwin->PostMessage(VDWIN_SAFEMODE); - locker->Unlock(); -} - -void ViewDriver::Reset(void) -{ - locker->Lock(); - screenwin->PostMessage(VDWIN_RESET); - locker->Unlock(); -} - -void ViewDriver::SetScreen(uint32 space) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_SETSCREEN); - msg->AddInt32("screenmode",space); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::Clear(uint8 red, uint8 green, uint8 blue) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_CLEAR); - msg->AddInt8("red",red); - msg->AddInt8("green",green); - msg->AddInt8("blue",blue); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::Clear(rgb_color col) -{ - Clear(col.red,col.green,col.blue); -} - -int32 ViewDriver::GetHeight(void) -{ // Gets the height of the current mode - return 0; -} - -int32 ViewDriver::GetWidth(void) -{ // Gets the width of the current mode - return 0; -} - -int ViewDriver::GetDepth(void) -{ // Gets the color depth of the current mode - return 0; -} - -void ViewDriver::Blit(BRect src, BRect dest) -{ -} - -void ViewDriver::DrawBitmap(ServerBitmap *bitmap) -{ -} - -void ViewDriver::DrawChar(char c, BPoint point) -{ - char string[2]; - string[0]=c; - string[1]='\0'; - DrawString(string,2,point); -} - -void ViewDriver::DrawString(char *string, int length, BPoint point) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_DRAWSTRING); - msg->AddString("string",string); - msg->AddInt16("length",length); - msg->AddPoint("point",point); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_FILLARC); - msg->AddFloat("cx",centerx); - msg->AddFloat("cy",centery); - msg->AddFloat("rx",xradius); - msg->AddFloat("ry",yradius); - msg->AddFloat("angle",angle); - msg->AddFloat("span",span); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - if(pattern) - { - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - } - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::FillBezier(BPoint *points, uint8 *pattern) -{ - locker->Lock(); - - BMessage *msg=new BMessage(VDWIN_FILLBEZIER); - msg->AddPoint("p1",points[0]); - msg->AddPoint("p2",points[1]); - msg->AddPoint("p3",points[2]); - msg->AddPoint("p4",points[3]); - if(pattern) - { - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - } - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_FILLELLIPSE); - msg->AddFloat("cx",centerx); - msg->AddFloat("cy",centery); - msg->AddFloat("rx",x_radius); - msg->AddFloat("ry",y_radius); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - if(pattern) - { - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - } - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::FillPolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void ViewDriver::FillRect(BRect rect, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_FILLRECT); - msg->AddRect("rect",rect); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - if(pattern) - { - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - } - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::FillRect(BRect rect, rgb_color col) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_FILLRECT); - msg->AddRect("rect",rect); - - msg->AddInt8("red",col.red); - msg->AddInt8("green",col.green); - msg->AddInt8("blue",col.blue); - msg->AddInt8("alpha",col.alpha); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::FillRegion(BRegion *region) -{ -} - -void ViewDriver::FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_FILLROUNDRECT); - msg->AddRect("rect",rect); - msg->AddFloat("x",xradius); - msg->AddFloat("y",yradius); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - if(pattern) - { - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - } - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::FillShape(BShape *shape) -{ -} - -void ViewDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_FILLTRIANGLE); - msg->AddPoint("first",first); - msg->AddPoint("second",second); - msg->AddPoint("third",third); - msg->AddRect("rect",rect); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - if(pattern) - { - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - } - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::HideCursor(void) -{ - locker->Lock(); - hide_cursor++; - screenwin->PostMessage(VDWIN_HIDECURSOR); - locker->Unlock(); -} - -bool ViewDriver::IsCursorHidden(void) -{ - locker->Lock(); - bool value=(hide_cursor>0)?true:false; - locker->Unlock(); - return value; -} - -void ViewDriver::ObscureCursor(void) -{ // Hides cursor until mouse is moved - locker->Lock(); - screenwin->PostMessage(VDWIN_OBSCURECURSOR); - locker->Unlock(); -} - -void ViewDriver::MoveCursorTo(float x, float y) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_MOVECURSOR); - msg->AddFloat("x",x); - msg->AddFloat("y",y); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::MovePenTo(BPoint pt) -{ // Moves the graphics pen to this position - - locker->Lock(); - penpos=pt; - - BMessage *msg=new BMessage(VDWIN_MOVEPENTO); - msg->AddPoint("point",penpos); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -BPoint ViewDriver::PenPosition(void) -{ - return penpos; -} - -float ViewDriver::PenSize(void) -{ - return pensize; -} - -void ViewDriver::SetCursor(int32 value) -{ -} - -void ViewDriver::SetCursor(ServerCursor *cursor) -{ - // We are given a ServerCursor, but the data is really a ServerBitmap. - // Copy it and fire it off to the view driver's window for translation - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_SETCURSOR); - msg->AddPointer("SCursor",cursor); - screenwin->PostMessage(msg); // Much faster than copying data. :) - locker->Unlock(); -} - -void ViewDriver::SetPenSize(float size) -{ - locker->Lock(); - pensize=size; - - BMessage *msg=new BMessage(VDWIN_SETPENSIZE); - msg->AddFloat("size",pensize); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - locker->Lock(); - highcol.red=r; - highcol.green=g; - highcol.blue=b; - highcol.alpha=a; - - BMessage *msg=new BMessage(VDWIN_SETHIGHCOLOR); - msg->AddInt8("red",r); - msg->AddInt8("green",g); - msg->AddInt8("blue",b); - msg->AddInt8("alpha",a); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - locker->Lock(); - lowcol.red=r; - lowcol.green=g; - lowcol.blue=b; - lowcol.alpha=a; - - BMessage *msg=new BMessage(VDWIN_SETLOWCOLOR); - msg->AddInt8("red",r); - msg->AddInt8("green",g); - msg->AddInt8("blue",b); - msg->AddInt8("alpha",a); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::SetPixel(int x, int y, uint8 *pattern) -{ // Internal function utilized by other functions to draw to the buffer - // Will eventually be an inline function -} - -void ViewDriver::ShowCursor(void) -{ - locker->Lock(); - if(hide_cursor>0) - { - hide_cursor--; - screenwin->PostMessage(VDWIN_SHOWCURSOR); - } - locker->Unlock(); -} - -void ViewDriver::StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKEARC); - msg->AddFloat("cx",centerx); - msg->AddFloat("cy",centery); - msg->AddFloat("rx",xradius); - msg->AddFloat("ry",yradius); - msg->AddFloat("angle",angle); - msg->AddFloat("span",span); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - if(pattern) - { - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - } - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokeBezier(BPoint *points, uint8 *pattern) -{ - locker->Lock(); - - BMessage *msg=new BMessage(VDWIN_STROKEBEZIER); - msg->AddPoint("p1",points[0]); - msg->AddPoint("p2",points[1]); - msg->AddPoint("p3",points[2]); - msg->AddPoint("p4",points[3]); - if(pattern) - { - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - } - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKEELLIPSE); - msg->AddFloat("cx",centerx); - msg->AddFloat("cy",centery); - msg->AddFloat("rx",x_radius); - msg->AddFloat("ry",y_radius); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - if(pattern) - { - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - } - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokeLine(BPoint point, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKELINE); - msg->AddPoint("from",penpos); - msg->AddPoint("to",point); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - if(pattern) - { - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - } - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokeLine(BPoint pt1, BPoint pt2, rgb_color col) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKELINE); - msg->AddPoint("from",pt1); - msg->AddPoint("to",pt2); - msg->AddInt8("red",col.red); - msg->AddInt8("green",col.green); - msg->AddInt8("blue",col.blue); - msg->AddInt8("alpha",col.alpha); - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokePolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void ViewDriver::StrokeRect(BRect rect,uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKERECT); - msg->AddRect("rect",rect); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - if(pattern) - { - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - } - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokeRect(BRect rect,rgb_color col) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKERECT); - msg->AddRect("rect",rect); - - msg->AddInt8("red",col.red); - msg->AddInt8("green",col.green); - msg->AddInt8("blue",col.blue); - msg->AddInt8("alpha",col.alpha); - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKEROUNDRECT); - msg->AddRect("rect",rect); - msg->AddFloat("x",xradius); - msg->AddFloat("y",yradius); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - if(pattern) - { - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - } - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -void ViewDriver::StrokeShape(BShape *shape) -{ -} - -void ViewDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ - locker->Lock(); - BMessage *msg=new BMessage(VDWIN_STROKETRIANGLE); - msg->AddPoint("first",first); - msg->AddPoint("second",second); - msg->AddPoint("third",third); - msg->AddRect("rect",rect); - - // Have to actually copy the pattern data because a sort of race condition - // Using an int64 to make for an easy copy. - if(pattern) - { - int64 pat=*((int64*)pattern); - msg->AddInt64("pattern",pat); - } - - screenwin->PostMessage(msg); - locker->Unlock(); -} - -#ifdef DEBUG_DRIVER_MODULE -#undef DEBUG_DRIVER_MODULE -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/ViewDriver.h b/src/servers/app/proto5/ViewDriver.h deleted file mode 100644 index 8c675a8daf..0000000000 --- a/src/servers/app/proto5/ViewDriver.h +++ /dev/null @@ -1,129 +0,0 @@ -#ifndef _VIEWDRIVER_H_ -#define _VIEWDRIVER_H_ - -#include -#include -#include -#include -#include // for pattern struct -#include -#include -#include "DisplayDriver.h" - -class BBitmap; -class PortLink; -class VDWindow; -class ServerCursor; - -class VDView : public BView -{ -public: - VDView(BRect bounds); - ~VDView(void); - void AttachedToWindow(void); - void Draw(BRect rect); - void MouseDown(BPoint pt); - void MouseMoved(BPoint pt, uint32 transit, const BMessage *msg); - void MouseUp(BPoint pt); - void SetMode(int16 width, int16 height, uint8 bpp); - - BBitmap *viewbmp; - BView *drawview; - PortLink *serverlink; - -protected: - friend VDWindow; - - int hide_cursor; - BBitmap *cursor; - - BRect cursorframe, oldcursorframe; - bool obscure_cursor; -}; - -class VDWindow : public BWindow -{ -public: - VDWindow(void); - ~VDWindow(void); - void MessageReceived(BMessage *msg); - bool QuitRequested(void); - void WindowActivated(bool active); - - void SafeMode(void); - void Reset(void); - void SetScreen(uint32 space); - void Clear(uint8 red,uint8 green,uint8 blue); - VDView *view; -}; - -class ViewDriver : public DisplayDriver -{ -public: - ViewDriver(void); - virtual ~ViewDriver(void); - - virtual void Initialize(void); // Sets the driver - virtual bool IsInitialized(void); - virtual void Shutdown(void); // You never know when you'll need this - - virtual void SafeMode(void); // Easy-access functions for common tasks - virtual void Reset(void); - virtual void Clear(uint8 red,uint8 green,uint8 blue); - virtual void Clear(rgb_color col); - - // Settings functions - virtual void SetScreen(uint32 space); - virtual int32 GetHeight(void); - virtual int32 GetWidth(void); - virtual int GetDepth(void); - - // Drawing functions - virtual void Blit(BRect src, BRect dest); - virtual void DrawBitmap(ServerBitmap *bitmap); - virtual void DrawChar(char c, BPoint point); - virtual void DrawString(char *string, int length, BPoint point); - - virtual void FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void FillBezier(BPoint *points, uint8 *pattern); - virtual void FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void FillPolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void FillRect(BRect rect, uint8 *pattern); - virtual void FillRect(BRect rect, rgb_color col); - virtual void FillRegion(BRegion *region); - virtual void FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void FillShape(BShape *shape); - virtual void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - - virtual void HideCursor(void); - virtual bool IsCursorHidden(void); - virtual void MoveCursorTo(float x, float y); - virtual void MovePenTo(BPoint pt); - virtual void ObscureCursor(void); - virtual BPoint PenPosition(void); - virtual float PenSize(void); - virtual void SetCursor(int32 value); - virtual void SetCursor(ServerCursor *cursor); - virtual void SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetPenSize(float size); - virtual void SetPixel(int x, int y, uint8 *pattern); - virtual void ShowCursor(void); - - virtual void StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void StrokeBezier(BPoint *points, uint8 *pattern); - virtual void StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void StrokeLine(BPoint point, uint8 *pattern); - virtual void StrokeLine(BPoint pt1, BPoint pt2, rgb_color col); - virtual void StrokePolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void StrokeRect(BRect rect,uint8 *pattern); - virtual void StrokeRect(BRect rect,rgb_color col); - virtual void StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void StrokeShape(BShape *shape); - virtual void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - VDWindow *screenwin; -protected: - int hide_cursor; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/WindowBorder.cpp b/src/servers/app/proto5/WindowBorder.cpp deleted file mode 100644 index c41014a5a7..0000000000 --- a/src/servers/app/proto5/WindowBorder.cpp +++ /dev/null @@ -1,253 +0,0 @@ -#include -#include -#include -#include -#include "View.h" // for mouse button defines -#include "ServerWindow.h" -#include "WindowBorder.h" -#include "Decorator.h" -#include "Desktop.h" - -#define DEBUG_WINBORDER - -#ifdef DEBUG_WINBORDER -#include -#endif - -bool is_moving_window=false; -WindowBorder *activeborder=NULL; - -WindowBorder::WindowBorder(ServerWindow *win, const char *bordertitle) - : Layer(win->frame,win->title->String()) -{ -#ifdef DEBUG_WINBORDER -printf("WindowBorder()\n"); -#endif - mbuttons=0; - swin=win; - title=new BString(bordertitle); - hresizewin=false; - vresizewin=false; -} - -WindowBorder::~WindowBorder(void) -{ -#ifdef DEBUG_WINBORDER -printf("~WindowBorder()\n"); -#endif - delete title; -} - -void WindowBorder::MouseDown(BPoint pt, uint32 buttons) -{ - mbuttons=buttons; - click_type click=decor->Clicked(pt, mbuttons); - - switch(click) - { - case CLICK_MOVETOBACK: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): MoveToBack\n"); -#endif - swin->SetFocus(false); - - // Move the window to the back (the top of the tree) - Layer *top=GetRootLayer(); - ASSERT(top!=NULL); - layerlock->Lock(); - top->RemoveChild(this); - top->AddChild(this); - swin->SetFocus(false); - decor->SetFocus(false); - decor->Draw(); - layerlock->Unlock(); - break; - } - case CLICK_MOVETOFRONT: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): MoveToFront\n"); -#endif - swin->SetFocus(true); - - // Move the window to the front by making it the bottom - // child of the root layer - Layer *top=GetRootLayer(); - layerlock->Lock(); - top->RemoveChild(this); - uppersibling=top->bottomchild; - lowersibling=NULL; - top->bottomchild=this; - if(top->topchild==NULL) - top->topchild=this; - parent=top; - swin->SetFocus(true); - decor->SetFocus(true); - decor->Draw(); - layerlock->Unlock(); - is_moving_window=true; - activeborder=this; - break; - } - case CLICK_CLOSE: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): SetCloseButton\n"); -#endif - decor->SetCloseButton(true); - swin->SetFocus(true); - decor->SetFocus(true); - decor->Draw(); - activeborder=this; - break; - } - case CLICK_ZOOM: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): SetZoomButton\n"); -#endif - decor->SetZoomButton(true); - swin->SetFocus(true); - decor->SetFocus(true); - decor->Draw(); - activeborder=this; - break; - } - case CLICK_MINIMIZE: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): SetMinimizeButton\n"); -#endif - decor->SetMinimizeButton(true); - break; - } - case CLICK_TAB: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): Click Tab\n"); -#endif - if(buttons==B_PRIMARY_MOUSE_BUTTON) - { - is_moving_window=true; - activeborder=this; - } - break; - } - case CLICK_NONE: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): Click None\n"); -#endif - break; - } - default: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder()::MouseDown: Undefined click type\n"); -#endif - break; - } - } -} - -void WindowBorder::MouseMoved(BPoint pt, uint32 buttons) -{ - click_type click=decor->Clicked(pt, mbuttons); - if(click!=CLICK_CLOSE && decor->GetCloseButton()) - { - decor->SetCloseButton(false); - decor->Draw(); - } - - if(click!=CLICK_ZOOM && decor->GetZoomButton()) - { - decor->SetZoomButton(false); - decor->Draw(); - } - - if(is_moving_window==true) - { - float dx=pt.x-mousepos.x, - dy=pt.y-mousepos.y; - if(dx!=0 || dy!=0) - { - clientframe.OffsetBy(pt); - - swin->Lock(); - swin->frame.OffsetBy(dx,dy); - swin->Unlock(); - - layerlock->Lock(); - MoveBy(dx,dy); - parent->RequestDraw(); - layerlock->Unlock(); - decor->MoveBy(BPoint(dx, dy)); - decor->Draw(); - } - } - mousepos=pt; -} - -void WindowBorder::MouseUp(BPoint pt, uint32 buttons) -{ -// mbuttons&= ~buttons; - mbuttons=buttons; - activeborder=NULL; - is_moving_window=false; - - click_type click=decor->Clicked(pt, mbuttons); - - switch(click) - { - case CLICK_CLOSE: - { - decor->SetCloseButton(false); - decor->Draw(); - break; - } - case CLICK_ZOOM: - { - decor->SetZoomButton(false); - decor->Draw(); - break; - } - default: - { - break; - } - } -} - -void WindowBorder::Draw(BRect update_rect) -{ - // Just a hard-coded placeholder for now - if(decor->Look()==B_NO_BORDER_WINDOW_LOOK) - return; - -#ifdef DEBUG_WINBORDER -printf("WindowBorder()::Draw():"); update_rect.PrintToStream(); -#endif - - if(update && visible!=NULL) - is_updating=true; - - decor->Draw(update_rect); - - if(update && visible!=NULL) - is_updating=false; -} - -void WindowBorder::SetDecorator(Decorator *newdecor) -{ - // AtheOS kills the decorator here. However, the decor - // under OBOS doesn't belong to the border - it belongs to the - // ServerWindow, so the ServerWindow will handle all (de)allocation - // tasks. We just need to update the pointer. - decor=newdecor; -} - -ServerWindow *WindowBorder::Window(void) const -{ - return swin; -} diff --git a/src/servers/app/proto5/WindowBorder.h b/src/servers/app/proto5/WindowBorder.h deleted file mode 100644 index b8d5c14f07..0000000000 --- a/src/servers/app/proto5/WindowBorder.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef _WINBORDER_H_ -#define _WINBORDER_H_ - -#include -#include -#include "Layer.h" - -class ServerWindow; -class Decorator; - -class WindowBorder : public Layer -{ -public: - WindowBorder(ServerWindow *win, const char *bordertitle); - ~WindowBorder(void); - void MouseDown(BPoint pt, uint32 buttons); - void MouseMoved(BPoint pt, uint32 buttons); - void MouseUp(BPoint pt, uint32 buttons); - void Draw(BRect update); - void SystemColorsUpdated(void); - void SetDecorator(Decorator *newdecor); - ServerWindow *Window(void) const; - - ServerWindow *swin; - BString *title; - Decorator *decor; - int32 flags; - BRect frame, clientframe; - uint32 mbuttons; - BPoint mousepos; - bool update; - bool hresizewin,vresizewin; -}; - -extern bool is_moving_window; -extern WindowBorder *activeborder; -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/YMakDecorator.cpp b/src/servers/app/proto5/YMakDecorator.cpp deleted file mode 100644 index a660e4a857..0000000000 --- a/src/servers/app/proto5/YMakDecorator.cpp +++ /dev/null @@ -1,656 +0,0 @@ -/******************************************************* -* YMakDecorator -* -* Writen by YNOP. -* used BeOS Magnify and decor to try to figure out -* how it looks. -* Originaly writen on AtheOS as MakDadddy Decor. -* Hacked around several times, and then ported -* (by me again) to OBOS app_server Decorator API -* -* TODO -* Fix title issuse (We need a Font width to center by) -* Fix any issuse that came about via porting -* These may have to do with the fact that the origin is -* differnat for the two API's and also with the fact -* that we can test anything yet :P -* Border size should change with Font Height -* -* @author YNOP (ynop@beunited.org) -* @version 1 (p5) -*******************************************************/ - - -#include "Layer.h" -#include "DisplayDriver.h" -#include "YMakDecorator.h" - -//#define DEBUG_DECOR - -#ifdef DEBUG_DECOR -#include -#endif - -// Hardcoded sized .. TOP should be Font based... -#define TOP 22 -#define FRAME 6 - -/******************************************************* -* @description -*******************************************************/ -YMakDecorator::YMakDecorator(Layer *lay, uint32 dflags, window_look wlook):Decorator(lay, dflags, wlook){ - if(flags & B_NO_BORDER_WINDOW_LOOK){ - LeftBorder = 0; - TopBorder = 0; - RightBorder = 0; - BottomBorder = 0; - }else{ - TopBorder = TOP; - LeftBorder = FRAME; - RightBorder = FRAME; - BottomBorder = FRAME; - } - Resize(lay->frame); -} - -/******************************************************* -* @description -*******************************************************/ -YMakDecorator::~YMakDecorator(void){ -} - -/******************************************************* -* @description -*******************************************************/ -click_type YMakDecorator::Clicked(BPoint pt, uint32 buttons){ -#ifdef DEBUG_DECOR -printf("YMakDecorator():Clicked(%f,%f)\n",pt.x,pt.y); -printf("ZoomRect:");ZoomRect.PrintToStream(); -#endif - - if(CloseRect.Contains(pt)){ - return CLICK_CLOSE; - } - if(ZoomRect.Contains(pt)){ - return CLICK_ZOOM; - } - //return CLICK_RESIZE_RB; - //return CLICK_NONE; - return CLICK_DRAG; -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::Resize(BRect rect){ - frame = rect; - - BRect But; - But.left = frame.left + 0; - But.right = frame.left + 12; - But.top = frame.top + 0; - But.bottom = frame.top + 12; - - CloseRect = But; - CloseRect.left += 4; - CloseRect.top += 4; - CloseRect.right += 4; - CloseRect.bottom += 4; - -} - -/******************************************************* -* @description -*******************************************************/ -BRect YMakDecorator::GetBorderSize(void){ - // I dont know what this does yet :P - return bsize; -} - -/******************************************************* -* @description -*******************************************************/ -BPoint YMakDecorator::GetMinimumSize(void){ - return minsize; -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::SetFlags(uint32 dflags){ - flags=dflags; -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::UpdateFont(void){ -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::UpdateTitle(const char *string){ -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::SetFocus(bool bfocused){ - focused=bfocused; -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::SetCloseButton(bool down){ - closestate=down; -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::SetZoomButton(bool down){ - zoomstate=down; -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::Draw(BRect update){ - BRect b = frame; - BRect cOBounds = frame; - - rgb_color cB = {0, 0, 0, 255}; - rgb_color cW = {251,251,251,255}; - rgb_color cG = {154,154,154,255}; - rgb_color cD = {113,113,113,255}; - rgb_color cL = {203,203,203,255}; - - // Debug yellow backgound to make sure we cover everthign :) - // Take this out in real ver for speed :P - rgb_color yellow = {255,255,0}; - driver->FillRect(frame,yellow); - - // Stroke outside border - driver->SetHighColor(cB.red,cB.green,cB.blue,cB.alpha); - driver->StrokeRect(b,NULL); - - // Stroke inside border - b = cOBounds; - b.top += TOP - 1; - b.bottom -= FRAME-1; - b.left += FRAME - 1; - b.right -= FRAME-1; - driver->StrokeRect(b,NULL); - - if(focused){ - // Stroke outer boder (raized) - b = cOBounds; - b.left += 1; - b.right -= 1; - b.top += 1; - b.bottom -= 1; - driver->SetHighColor(cW.red,cW.green,cW.blue,cW.alpha); - driver->MovePenTo(BPoint(b.left,b.top));driver->StrokeLine(BPoint(b.right,b.top),NULL); - - driver->MovePenTo(BPoint(b.left,b.bottom));driver->StrokeLine(BPoint(b.left,b.top),NULL); - driver->SetHighColor(cG.red,cG.green,cG.blue,cG.alpha); - driver->MovePenTo(BPoint(b.right,b.top));driver->StrokeLine(BPoint(b.right,b.bottom),NULL); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.left,b.bottom),NULL); - - // Stroke inter border (raized) - b = cOBounds; - b.top += TOP - 2; - b.bottom -= FRAME - 2; - b.left += FRAME - 2; - b.right -= FRAME - 2; - driver->SetHighColor(cG.red,cG.green,cG.blue,cG.alpha); - driver->MovePenTo(BPoint(b.left,b.top));driver->StrokeLine(BPoint(b.right,b.top),NULL); - driver->MovePenTo(BPoint(b.left,b.bottom));driver->StrokeLine(BPoint(b.left,b.top),NULL); - driver->SetHighColor(cW.red,cW.green,cW.blue,cW.alpha); - driver->MovePenTo(BPoint(b.right,b.top));driver->StrokeLine(BPoint(b.right,b.bottom),NULL); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.left,b.bottom),NULL); - - driver->SetHighColor(cL.red,cL.green,cL.blue,cL.alpha); - // Fill top - b = cOBounds; - b.bottom = b.top + TOP - 3; - b.top += 2; - b.left += 2; - b.right -= 2; - driver->FillRect(b,NULL); - // Fill left - b = cOBounds; - b.left += 2; - b.right = cOBounds.left + FRAME - 3; - b.top = cOBounds.top + TOP - 2; - b.bottom -= 2; - driver->FillRect(b,NULL); - // Fill right - b = cOBounds; - b.left = b.right - FRAME + 3; - b.right -= 2; - b.top = b.top + TOP - 2; - b.bottom -= 2; - driver->FillRect(b,NULL); - // fill bottom - b = cOBounds; - b.top = b.bottom - FRAME + 3; - b.bottom -= 2; - b.left += FRAME - 2; - b.right -= FRAME - 2; - driver->FillRect(b,NULL); - - // Stroke the lines .. stoke them oohh ya .. storkem .. - // - b = cOBounds; - b.left += 20; - b.right -= 20; - b.top += 4; - b.bottom += 10; - - //if((Flags & WND_NO_DEPTH_BUT) == 0){ - // b.right -= 20; - //} - - - driver->SetHighColor(cW.red,cW.green,cW.blue,cW.alpha); - driver->MovePenTo(BPoint(b.left,b.top+0));driver->StrokeLine(BPoint(b.right-1,b.top+0),NULL); - driver->MovePenTo(BPoint(b.left,b.top+2));driver->StrokeLine(BPoint(b.right-1,b.top+2),NULL); - driver->MovePenTo(BPoint(b.left,b.top+4));driver->StrokeLine(BPoint(b.right-1,b.top+4),NULL); - driver->MovePenTo(BPoint(b.left,b.top+6));driver->StrokeLine(BPoint(b.right-1,b.top+6),NULL); - driver->MovePenTo(BPoint(b.left,b.top+8));driver->StrokeLine(BPoint(b.right-1,b.top+8),NULL); - driver->MovePenTo(BPoint(b.left,b.top+10));driver->StrokeLine(BPoint(b.right-1,b.top+10),NULL); - -#ifdef DEBUG_DECOR -printf("About to draw high lines\n"); -printf("do done\n"); -#endif - driver->SetHighColor(cD.red,cD.green,cD.blue,cD.alpha); - driver->MovePenTo(BPoint(b.left+1,b.top+1));driver->StrokeLine(BPoint(b.right,b.top+1),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+3));driver->StrokeLine(BPoint(b.right,b.top+3),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+5));driver->StrokeLine(BPoint(b.right,b.top+5),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+7));driver->StrokeLine(BPoint(b.right,b.top+7),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+9));driver->StrokeLine(BPoint(b.right,b.top+9),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+11));driver->StrokeLine(BPoint(b.right,b.top+11),NULL); - - }else{ - driver->SetHighColor(cL.red,cL.green,cL.blue,cL.alpha); - // Fill top - b = cOBounds; - b.bottom = b.top + TOP - 2; - b.top += 1; - b.left += 1; - b.right -= 1; - driver->FillRect(b,NULL); - // Fill left side - b = cOBounds; - b.left += 1; - b.right = b.left + FRAME - 2; - b.top = b.top + TOP - 1; - b.bottom -= 1; - driver->FillRect(b,NULL); - // fill right - b = cOBounds; - b.left = b.right - FRAME + 2; - b.right -= 1; - b.top = b.top + TOP - 1; - b.bottom -= 1; - driver->FillRect(b,NULL); - // fill bottom - b = cOBounds; - b.top = b.bottom - FRAME + 2; - b.bottom -= 1; - b.left += FRAME - 1; - b.right -= FRAME - 1; - driver->FillRect(b,NULL); - } - - -/* if((flags & WND_NO_TITLE) == 0){ - // Stroke The title Text - driver->SetFgColor(cL.red,cL.green,cL.blue,cL.alpha); - b.left = 30; - b.right = 100; - //Font *font = new Font(DEFAULT_FONT_WINDOW); - //b.right = font->GetStringWidth(Title.c_str()); - - int32 len = strlen(Title.c_str()); - b.right = b.left + len * 7; - - - b.top = 2; - b.bottom = TOP - 3; - V->FillRect(b); - if(HasFocus){ - V->SetFgColor(0,0,0,255); - }else{ - V->SetFgColor(cD); - } - V->SetBgColor(cL); - V->MovePenTo(34,TOP-7); - V->DrawString(Title.c_str(), -1 ); - } -*/ - - - if(!(flags & B_NOT_CLOSABLE)){ - DrawClose(CloseRect); - } - if(!(flags & B_NOT_ZOOMABLE)){ - DrawZoom(ZoomRect); - } - - -/* if(!(flags & B_NOT_RESIZABLE)) -*/ -} - -void YMakDecorator::Draw(void) -{ - BRect b = frame; - BRect cOBounds = frame; - - rgb_color cB = {0, 0, 0, 255}; - rgb_color cW = {251,251,251,255}; - rgb_color cG = {154,154,154,255}; - rgb_color cD = {113,113,113,255}; - rgb_color cL = {203,203,203,255}; - - // Debug yellow backgound to make sure we cover everthign :) - // Take this out in real ver for speed :P - rgb_color yellow = {255,255,0}; - driver->FillRect(frame,yellow); - - // Stroke outside border - driver->SetHighColor(cB.red,cB.green,cB.blue,cB.alpha); - driver->StrokeRect(b,NULL); - - // Stroke inside border - b = cOBounds; - b.top += TOP - 1; - b.bottom -= FRAME-1; - b.left += FRAME - 1; - b.right -= FRAME-1; - driver->StrokeRect(b,NULL); - - if(focused){ - // Stroke outer boder (raized) - b = cOBounds; - b.left += 1; - b.right -= 1; - b.top += 1; - b.bottom -= 1; - driver->SetHighColor(cW.red,cW.green,cW.blue,cW.alpha); - driver->MovePenTo(BPoint(b.left,b.top));driver->StrokeLine(BPoint(b.right,b.top),NULL); - - driver->MovePenTo(BPoint(b.left,b.bottom));driver->StrokeLine(BPoint(b.left,b.top),NULL); - driver->SetHighColor(cG.red,cG.green,cG.blue,cG.alpha); - driver->MovePenTo(BPoint(b.right,b.top));driver->StrokeLine(BPoint(b.right,b.bottom),NULL); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.left,b.bottom),NULL); - - // Stroke inter border (raized) - b = cOBounds; - b.top += TOP - 2; - b.bottom -= FRAME - 2; - b.left += FRAME - 2; - b.right -= FRAME - 2; - driver->SetHighColor(cG.red,cG.green,cG.blue,cG.alpha); - driver->MovePenTo(BPoint(b.left,b.top));driver->StrokeLine(BPoint(b.right,b.top),NULL); - driver->MovePenTo(BPoint(b.left,b.bottom));driver->StrokeLine(BPoint(b.left,b.top),NULL); - driver->SetHighColor(cW.red,cW.green,cW.blue,cW.alpha); - driver->MovePenTo(BPoint(b.right,b.top));driver->StrokeLine(BPoint(b.right,b.bottom),NULL); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.left,b.bottom),NULL); - - driver->SetHighColor(cL.red,cL.green,cL.blue,cL.alpha); - // Fill top - b = cOBounds; - b.bottom = b.top + TOP - 3; - b.top += 2; - b.left += 2; - b.right -= 2; - driver->FillRect(b,NULL); - // Fill left - b = cOBounds; - b.left += 2; - b.right = cOBounds.left + FRAME - 3; - b.top = cOBounds.top + TOP - 2; - b.bottom -= 2; - driver->FillRect(b,NULL); - // Fill right - b = cOBounds; - b.left = b.right - FRAME + 3; - b.right -= 2; - b.top = b.top + TOP - 2; - b.bottom -= 2; - driver->FillRect(b,NULL); - // fill bottom - b = cOBounds; - b.top = b.bottom - FRAME + 3; - b.bottom -= 2; - b.left += FRAME - 2; - b.right -= FRAME - 2; - driver->FillRect(b,NULL); - - // Stroke the lines .. stoke them oohh ya .. storkem .. - // - b = cOBounds; - b.left += 20; - b.right -= 20; - b.top += 4; - b.bottom += 10; - - //if((Flags & WND_NO_DEPTH_BUT) == 0){ - // b.right -= 20; - //} - - - driver->SetHighColor(cW.red,cW.green,cW.blue,cW.alpha); - driver->MovePenTo(BPoint(b.left,b.top+0));driver->StrokeLine(BPoint(b.right-1,b.top+0),NULL); - driver->MovePenTo(BPoint(b.left,b.top+2));driver->StrokeLine(BPoint(b.right-1,b.top+2),NULL); - driver->MovePenTo(BPoint(b.left,b.top+4));driver->StrokeLine(BPoint(b.right-1,b.top+4),NULL); - driver->MovePenTo(BPoint(b.left,b.top+6));driver->StrokeLine(BPoint(b.right-1,b.top+6),NULL); - driver->MovePenTo(BPoint(b.left,b.top+8));driver->StrokeLine(BPoint(b.right-1,b.top+8),NULL); - driver->MovePenTo(BPoint(b.left,b.top+10));driver->StrokeLine(BPoint(b.right-1,b.top+10),NULL); - -#ifdef DEBUG_DECOR -printf("About to draw high lines\n"); -printf("do done\n"); -#endif - driver->SetHighColor(cD.red,cD.green,cD.blue,cD.alpha); - driver->MovePenTo(BPoint(b.left+1,b.top+1));driver->StrokeLine(BPoint(b.right,b.top+1),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+3));driver->StrokeLine(BPoint(b.right,b.top+3),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+5));driver->StrokeLine(BPoint(b.right,b.top+5),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+7));driver->StrokeLine(BPoint(b.right,b.top+7),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+9));driver->StrokeLine(BPoint(b.right,b.top+9),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+11));driver->StrokeLine(BPoint(b.right,b.top+11),NULL); - - }else{ - driver->SetHighColor(cL.red,cL.green,cL.blue,cL.alpha); - // Fill top - b = cOBounds; - b.bottom = b.top + TOP - 2; - b.top += 1; - b.left += 1; - b.right -= 1; - driver->FillRect(b,NULL); - // Fill left side - b = cOBounds; - b.left += 1; - b.right = b.left + FRAME - 2; - b.top = b.top + TOP - 1; - b.bottom -= 1; - driver->FillRect(b,NULL); - // fill right - b = cOBounds; - b.left = b.right - FRAME + 2; - b.right -= 1; - b.top = b.top + TOP - 1; - b.bottom -= 1; - driver->FillRect(b,NULL); - // fill bottom - b = cOBounds; - b.top = b.bottom - FRAME + 2; - b.bottom -= 1; - b.left += FRAME - 1; - b.right -= FRAME - 1; - driver->FillRect(b,NULL); - } - - -/* if((flags & WND_NO_TITLE) == 0){ - // Stroke The title Text - driver->SetFgColor(cL.red,cL.green,cL.blue,cL.alpha); - b.left = 30; - b.right = 100; - //Font *font = new Font(DEFAULT_FONT_WINDOW); - //b.right = font->GetStringWidth(Title.c_str()); - - int32 len = strlen(Title.c_str()); - b.right = b.left + len * 7; - - - b.top = 2; - b.bottom = TOP - 3; - V->FillRect(b); - if(HasFocus){ - V->SetFgColor(0,0,0,255); - }else{ - V->SetFgColor(cD); - } - V->SetBgColor(cL); - V->MovePenTo(34,TOP-7); - V->DrawString(Title.c_str(), -1 ); - } -*/ - - - if(!(flags & B_NOT_CLOSABLE)){ - DrawClose(CloseRect); - } - if(!(flags & B_NOT_ZOOMABLE)){ - DrawZoom(ZoomRect); - } - -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::DrawZoom(BRect r){ -// if(zoomstate) -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::DrawClose(BRect r){ - BRect b = CloseRect; - - // if((Flags & WND_NO_CLOSE_BUT)){ return; } -// if(!HasFocus){ return; } - - - b.left += 1; - b.right -= 1; - b.top += 1; - b.bottom -= 1; - driver->SetHighColor(32,32,32,255); - /*V->DrawLine(Point(b.left,b.top),Point(b.right,b.top)); - V->DrawLine(Point(b.right,b.top),Point(b.right,b.bottom)); - V->DrawLine(Point(b.left,b.bottom),Point(b.left,b.top)); - V->DrawLine(Point(b.right,b.bottom),Point(b.left,b.bottom));*/ - driver->StrokeRect(b,NULL); - - - b = CloseRect; - - // top left higlith - driver->SetHighColor(136,136,136,255); - driver->MovePenTo(BPoint(b.left,b.top));driver->StrokeLine(BPoint(b.right-1,b.top),NULL); - driver->MovePenTo(BPoint(b.left,b.top+1));driver->StrokeLine(BPoint(b.left,b.bottom-1),NULL); - - // right bottom shadow - driver->SetHighColor(251,251,251,255); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.left+1,b.bottom),NULL); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.right,b.top+1),NULL); - - if(closestate){ - b = CloseRect; - b.left += 2; - b.right -= 2; - b.top += 2; - b.bottom -= 2; - - // Button down - driver->SetHighColor(200,200,200,255); - driver->FillRect(b,NULL); - }else{ - b = CloseRect; - b.left += 2; - b.right -= 2; - b.top += 2; - b.bottom -= 2; - - // top left - driver->SetHighColor(240,240,240,255); - driver->MovePenTo(BPoint(b.left,b.top));driver->StrokeLine(BPoint(b.right,b.top),NULL); - driver->MovePenTo(BPoint(b.left,b.top));driver->StrokeLine(BPoint(b.left,b.bottom),NULL); - - // bottom right - driver->SetHighColor(136,136,136,255); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.left+1,b.bottom),NULL); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.right,b.top+1),NULL); - - // fill insdie (Hacked - Mack is a gradiant in the button :P!!) - driver->SetHighColor(203,203,203,255); - b.left += 1; - b.right -= 1; - b.top += 1; - b.bottom -= 1; - driver->FillRect(b,NULL); - } -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::SetLook(window_look wlook){ - look = wlook; -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::CalculateBorders(void){ - switch(look) - { - case B_NO_BORDER_WINDOW_LOOK: - { -// bsize.Set(0,0,0,0); - break; - } - case B_TITLED_WINDOW_LOOK: - case B_DOCUMENT_WINDOW_LOOK: - case B_BORDERED_WINDOW_LOOK: - { -// bsize.top=18; - break; - } - case B_MODAL_WINDOW_LOOK: - case B_FLOATING_WINDOW_LOOK: - { -// bsize.top=15; - break; - } - default: - { - break; - } - } -} - - - - diff --git a/src/servers/app/proto5/YMakDecorator.h b/src/servers/app/proto5/YMakDecorator.h deleted file mode 100644 index e52e95e5a7..0000000000 --- a/src/servers/app/proto5/YMakDecorator.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef _YNOP_MAK_DECORATOR_H_ -#define _YNOP_MAK_DECORATOR_H_ - -#include "Decorator.h" - -class YMakDecorator: public Decorator{ -public: - YMakDecorator(Layer *lay, uint32 dflags, window_look wlook); - ~YMakDecorator(void); - - click_type Clicked(BPoint pt, uint32 buttons); - void Resize(BRect rect); - BRect GetBorderSize(void); - BPoint GetMinimumSize(void); - void SetTitle(const char *newtitle); - void SetFlags(uint32 flags); - void SetLook(window_look wlook); - void UpdateFont(void); - void UpdateTitle(const char *string); - void SetFocus(bool focused); - void SetCloseButton(bool down); - void SetZoomButton(bool down); - void Draw(BRect update); - void Draw(void); - void DrawZoom(BRect r); - void DrawClose(BRect r); - void CalculateBorders(void); -private: - BRect frame; - - bool zoomstate; - bool closestate; - - BRect CloseRect; - BRect ZoomRect; - - int LeftBorder; - int TopBorder; - int RightBorder; - int BottomBorder; -/* - bool HasFocus; - bool CloseState; - bool ZoomState; - bool DepthState; -*/ -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/main.cpp b/src/servers/app/proto5/main.cpp deleted file mode 100644 index a237ea2468..0000000000 --- a/src/servers/app/proto5/main.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// main.cpp - - -const char app_sig[] = "application/x-vnd.myApp"; - -#include - -int main() -{ - if(is_computer_on()) - { - // TODO: start up the application! - } - - return 0; -} diff --git a/src/servers/app/proto5/obhey/obhey.c b/src/servers/app/proto5/obhey/obhey.c deleted file mode 100644 index 8e6bfbd617..0000000000 --- a/src/servers/app/proto5/obhey/obhey.c +++ /dev/null @@ -1,25 +0,0 @@ -#include -#include -#include -#include -/* - Sends a message to the OpenBeOS app_server's message port -*/ - -int main(int argc, char **argv) -{ - int32 msgcode; - - if(argc>2) - { - port_id serverport=atoi(argv[1]); - msgcode=atoi(argv[2]); - - write_port(serverport,msgcode,NULL,0); - printf("Sent %ld to port %ld\n",msgcode,serverport); - return 1; - } - - printf("obhey port \n"); - return 0; -} \ No newline at end of file diff --git a/src/servers/app/proto5/router/router.cpp b/src/servers/app/proto5/router/router.cpp deleted file mode 100644 index baf1a7df68..0000000000 --- a/src/servers/app/proto5/router/router.cpp +++ /dev/null @@ -1,134 +0,0 @@ -#include "router.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#include "PortLink.h" -#include "ServerProtocol.h" -//#define SERVER_PORT_NAME "OBappserver" -//#define SERVER_INPUT_PORT "OBinputport" - - -/******************************************************* -* -*******************************************************/ -BInputServerFilter* instantiate_input_filter(){ - return (new RouterInputFilter()); -} - -/******************************************************* -* -*******************************************************/ -RouterInputFilter::RouterInputFilter():BInputServerFilter(){ - port_id pid = find_port(SERVER_INPUT_PORT); - serverlink = new PortLink(pid); - -} - -/******************************************************* -* -*******************************************************/ -RouterInputFilter::~RouterInputFilter(){ -} - -/******************************************************* -* Everthing went just find .. right? -*******************************************************/ -status_t RouterInputFilter::InitCheck(){ - return B_OK; -} - - - -/******************************************************* -* -*******************************************************/ -filter_result RouterInputFilter::Filter(BMessage *message, BList *outList){ - if(serverlink == NULL){ - return B_DISPATCH_MESSAGE; - } - port_id pid = find_port(SERVER_INPUT_PORT); - if(pid < 0){ - return B_DISPATCH_MESSAGE; - } - serverlink->SetPort(pid); - - switch(message->what){ - case B_MOUSE_MOVED:{ - BPoint p; - uint32 buttons = 0; - // get piont and button from msg - if(message->FindPoint("where",&p) != B_OK){ - - } - int64 time=(int64)real_time_clock(); - - serverlink->SetOpCode(B_MOUSE_MOVED); - serverlink->Attach(&time,sizeof(int64)); - serverlink->Attach(&p.x,sizeof(float)); - serverlink->Attach(&p.y,sizeof(float)); - serverlink->Attach(&buttons,sizeof(int32)); - - // prevent server crashes from hanging the Input Server - serverlink->Flush(1000000); - }break; - case B_MOUSE_UP:{ - BPoint p; - - uint32 mod=modifiers(); - // Eventually, we will also be sending a uint32 buttons. - - int64 time=(int64)real_time_clock(); - - message->FindPoint("where",&p); - - serverlink->SetOpCode(B_MOUSE_UP); - serverlink->Attach(&time, sizeof(int64)); - serverlink->Attach(&p.x,sizeof(float)); - serverlink->Attach(&p.y,sizeof(float)); - serverlink->Attach(&mod, sizeof(uint32)); - - // prevent server crashes from hanging the Input Server - serverlink->Flush(1000000); - }break; - case B_MOUSE_DOWN:{ - BPoint p; - - uint32 buttons, - mod=modifiers(); - int32 clicks; - message->FindInt32("clicks",&clicks); - message->FindPoint("where",&p); - message->FindInt32("buttons",(int32*)&buttons); - - int64 time=(int64)real_time_clock(); - - serverlink->SetOpCode(B_MOUSE_DOWN); - serverlink->Attach(&time, sizeof(int64)); - serverlink->Attach(&p.x,sizeof(float)); - serverlink->Attach(&p.y,sizeof(float)); - serverlink->Attach(&mod, sizeof(uint32)); - serverlink->Attach(&buttons, sizeof(uint32)); - serverlink->Attach(&clicks, sizeof(uint32)); - - // prevent server crashes from hanging the Input Server - serverlink->Flush(1000000); - }break; - - // Should be some Mouse Down and Up code here .. - // Along with some Key Down and up codes .. - default: - break; - } - - //delete serverlink; - - // Let all msg flow normally to the - // Be app_server - return B_DISPATCH_MESSAGE; -} diff --git a/src/servers/app/proto5/router/router.h b/src/servers/app/proto5/router/router.h deleted file mode 100644 index 5cfa514e66..0000000000 --- a/src/servers/app/proto5/router/router.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _ROUTER_H -#define _ROUTER_H - -#include -#include -#include -#include - -class PortLink; - -// export this for the input_server -extern "C" _EXPORT BInputServerFilter* instantiate_input_filter(); - -class RouterInputFilter : public BInputServerFilter { - public: - RouterInputFilter(); - virtual ~RouterInputFilter(); - virtual status_t InitCheck(); - virtual filter_result Filter(BMessage *message, BList *outList); -private: - PortLink *serverlink; -}; -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/testobapp/BUGS b/src/servers/app/proto5/testobapp/BUGS deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/servers/app/proto5/testobapp/CHANGES b/src/servers/app/proto5/testobapp/CHANGES deleted file mode 100644 index 97ae3aae99..0000000000 --- a/src/servers/app/proto5/testobapp/CHANGES +++ /dev/null @@ -1,6 +0,0 @@ -OBApplication - Prototype 5 - -App properly falls through if construction failed -Added a server ping failsafe -Added REMOVEWINDOW code -Moved quit-all-windows code to Quit() to fix a crasher \ No newline at end of file diff --git a/src/servers/app/proto5/testobapp/DebugTools.cpp b/src/servers/app/proto5/testobapp/DebugTools.cpp deleted file mode 100644 index 0a0c6aed1d..0000000000 --- a/src/servers/app/proto5/testobapp/DebugTools.cpp +++ /dev/null @@ -1,219 +0,0 @@ -#include -#include -#include -#include "DebugTools.h" - -void PrintStatusToStream(status_t value) -{ - // Function which simply translates a returned status code into a string - // and dumps it to stdout - BString outstr; - switch(value) - { - case B_OK: - outstr="B_OK "; - break; - case B_NAME_NOT_FOUND: - outstr="B_NAME_NOT_FOUND "; - break; - case B_BAD_VALUE: - outstr="B_BAD_VALUE "; - break; - case B_ERROR: - outstr="B_ERROR "; - break; - case B_TIMED_OUT: - outstr="B_TIMED_OUT "; - break; - case B_NO_MORE_PORTS: - outstr="B_NO_MORE_PORTS "; - break; - case B_WOULD_BLOCK: - outstr="B_WOULD_BLOCK "; - break; - case B_BAD_PORT_ID: - outstr="B_BAD_PORT_ID "; - break; - case B_BAD_TEAM_ID: - outstr="B_BAD_TEAM_ID "; - break; - default: - outstr="undefined status value in debugtools::PrintStatusToStream() "; - break; - } - cout << "Status: " << outstr.String() << endl << flush; - -} - -void PrintColorSpaceToStream(color_space value) -{ - // Dump a color space to cout - BString outstr; - switch(value) - { - case B_RGB32: - outstr="B_RGB32 "; - break; - case B_RGBA32: - outstr="B_RGBA32 "; - break; - case B_RGB32_BIG: - outstr="B_RGB32_BIG "; - break; - case B_RGBA32_BIG: - outstr=" "; - break; - case B_UVL32: - outstr="B_UVL32 "; - break; - case B_UVLA32: - outstr="B_UVLA32 "; - break; - case B_LAB32: - outstr="B_LAB32 "; - break; - case B_LABA32: - outstr="B_LABA32 "; - break; - case B_HSI32: - outstr="B_HSI32 "; - break; - case B_HSIA32: - outstr="B_HSIA32 "; - break; - case B_HSV32: - outstr="B_HSV32 "; - break; - case B_HSVA32: - outstr="B_HSVA32 "; - break; - case B_HLS32: - outstr="B_HLS32 "; - break; - case B_HLSA32: - outstr="B_HLSA32 "; - break; - case B_CMY32: - outstr="B_CMY32"; - break; - case B_CMYA32: - outstr="B_CMYA32 "; - break; - case B_CMYK32: - outstr="B_CMYK32 "; - break; - case B_RGB24_BIG: - outstr="B_RGB24_BIG "; - break; - case B_RGB24: - outstr="B_RGB24 "; - break; - case B_LAB24: - outstr="B_LAB24 "; - break; - case B_UVL24: - outstr="B_UVL24 "; - break; - case B_HSI24: - outstr="B_HSI24 "; - break; - case B_HSV24: - outstr="B_HSV24 "; - break; - case B_HLS24: - outstr="B_HLS24 "; - break; - case B_CMY24: - outstr="B_CMY24 "; - break; - case B_GRAY1: - outstr="B_GRAY1 "; - break; - case B_CMAP8: - outstr="B_CMAP8 "; - break; - case B_GRAY8: - outstr="B_GRAY8 "; - break; - case B_YUV411: - outstr="B_YUV411 "; - break; - case B_YUV420: - outstr="B_YUV420 "; - break; - case B_YCbCr422: - outstr="B_YCbCr422 "; - break; - case B_YCbCr411: - outstr="B_YCbCr411 "; - break; - case B_YCbCr420: - outstr="B_YCbCr420 "; - break; - case B_YUV422: - outstr="B_YUV422 "; - break; - case B_YUV9: - outstr="B_YUV9 "; - break; - case B_YUV12: - outstr="B_YUV12 "; - break; - case B_RGB15: - outstr="B_RGB15 "; - break; - case B_RGBA15: - outstr="B_RGBA15 "; - break; - case B_RGB16: - outstr="B_RGB16 "; - break; - case B_RGB16_BIG: - outstr="B_RGB16_BIG "; - break; - case B_RGB15_BIG: - outstr="B_RGB15_BIG "; - break; - case B_RGBA15_BIG: - outstr="B_RGBA15_BIG "; - break; - case B_YCbCr444: - outstr="B_YCbCr444 "; - break; - case B_YUV444: - outstr="B_YUV444 "; - break; - case B_NO_COLOR_SPACE: - outstr="B_NO_COLOR_SPACE "; - break; - default: - outstr="Undefined color space "; - break; - } - cout << "Color Space: " << outstr.String() << flush; -} - -void TranslateMessageCodeToStream(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - - cout << "'" - << (char)((code & 0xFF000000) >> 24) - << (char)((code & 0x00FF0000) >> 16) - << (char)((code & 0x0000FF00) >> 8) - << (char)((code & 0x000000FF)) << "' "; -} - -void PrintMessageCode(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - - printf("Message code %c%c%c%c\n", - (char)((code & 0xFF000000) >> 24), - (char)((code & 0x00FF0000) >> 16), - (char)((code & 0x0000FF00) >> 8), - (char)((code & 0x000000FF)) ); -} - diff --git a/src/servers/app/proto5/testobapp/DebugTools.h b/src/servers/app/proto5/testobapp/DebugTools.h deleted file mode 100644 index 2f45b1ac6c..0000000000 --- a/src/servers/app/proto5/testobapp/DebugTools.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _DEBUGTOOLS_H_ -#define _DEBUGTOOLS_H_ - -#include -#include - -void PrintStatusToStream(status_t value); -void PrintColorSpaceToStream(color_space value); -void TranslateMessageCodeToStream(int32 code); -void PrintMessageCode(int32 code); - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/testobapp/OBApplication.cpp b/src/servers/app/proto5/testobapp/OBApplication.cpp deleted file mode 100644 index 2fcd3265c0..0000000000 --- a/src/servers/app/proto5/testobapp/OBApplication.cpp +++ /dev/null @@ -1,402 +0,0 @@ -/* - OBApplication.cpp: - Beginning framework for a *real* BApplication replacement for prototype #5 - -*/ - -#include -#include // for the pattern struct and screen mode defs -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ServerProtocol.h" -#include "PortLink.h" -#include "OBApplication.h" -#include "OBWindow.h" -#include "DebugTools.h" - -OBApplication *obe_app; - -#define DEBUG_OBAPP - -OBApplication::OBApplication(const char *sig) : BApplication(sig) -{ - if(sig) - signature=new BString(sig); - else - signature=new BString("application/x-vnd.obos-OBApplication"); - -#ifdef DEBUG_OBAPP -printf("OBApplication(%s)\n",signature->String()); -#endif - - // A BApplication is locked on start, but because this is not a "real" - // one, we do not actually lock it. - - initcheckval=B_OK; - - // Receives messages from server and others - messageport=create_port(50,"msgport"); - if(messageport==B_BAD_VALUE || messageport==B_NO_MORE_PORTS) - { - printf("OBApplication: Couldn't create message port\n"); - initcheckval=B_ERROR; - } - - // Find the port for the app_server - serverport=find_port("OBappserver"); - if(serverport==B_NAME_NOT_FOUND) - { - printf("OBApplication: Couldn't find server port\n"); - serverlink=NULL; - write_port(messageport,B_QUIT_REQUESTED,NULL,0); - initcheckval=B_ERROR; - } - else - { - serverlink=new PortLink(serverport); -#ifdef DEBUG_OBAPP -printf("OBApplication(%s): App Server Port %ld\n",signature->String(),serverport); -#endif - - // Notify server of app's existence - int32 replycode; - status_t replystat; - ssize_t replysize; - int8 *replybuffer; - - serverlink->SetOpCode(CREATE_APP); - serverlink->Attach(&messageport,sizeof(port_id)); -// serverlink.Attach(PID); - serverlink->Attach((char*)signature->String(),strlen(signature->String())); - - // Send and wait for ServerApp port. Necessary here (as opposed to start - // of message loop) in case any windows are created in application constructor - replybuffer=serverlink->FlushWithReply(&replycode,&replystat,&replysize); - serverport=*((port_id*)replybuffer); - serverlink->SetPort(serverport); - delete replybuffer; -#ifdef DEBUG_OBAPP -printf("OBApplication(%s): ServerApp Port %ld\n",signature->String(),serverport); -#endif - ReadyToRun(); - } - - obe_app=this; - windowlist=new BList(0); -} - -OBApplication::~OBApplication(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::~OBApplication()\n",signature->String()); -#endif - delete signature; - - if(serverlink) - delete serverlink; - -// OBWindow *win; -// for(int32 i=0; iCountItems(); i++) -// { -// win=(OBWindow*)windowlist->RemoveItem(i); -// if(win) -// win->Quit(); -// } - - delete windowlist; -} - -status_t OBApplication::InitCheck(void) const -{ - // Called to make sure everything in the constructor turned out ok. If it didn't, - // the application falls through and the process ends. - return initcheckval; -} - -void OBApplication::MainLoop(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::MainLoop()\n",signature->String()); -#endif - - int32 msgcode; - uint8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - // Modified this slightly so that OBApplications will eventually time out - // if the server crashes. Saves on a lot of Ctrl-Alt-Del's. :) CPU time is - // saved by setting the timeout to 3 seconds - more than enough time. - if(find_thread("OBAppServer")==B_NAME_NOT_FOUND) - { - printf("%s lost connection with server. Quitting.\n",signature->String()); - break; - } - - buffersize=port_buffer_size_etc(messageport,B_TIMEOUT,300000); - if(buffersize==B_TIMED_OUT) - continue; - - if(buffersize>0) - { - // buffers are flattened messages. Allocate necessary buffer and - // we'll cast it as a BMessage. - msgbuffer=new uint8[buffersize]; - bytesread=read_port(messageport,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(messageport,&msgcode,NULL,0); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case B_QUIT_REQUESTED: - { - // Attached data: - // None -// printf("%s: Quit requested\n",signature); - serverlink->SetOpCode(msgcode); - serverlink->Flush(); - break; - } -/* case SET_SERVER_PORT: - { - // This message is received when the server has created - // the ServerApp object to monitor our application. It is - // sending us the port to which we send future messages - - // Attached data: - // port_id - id of the port of the corresponding ServerApp - if(buffersize<1) - { - printf("%s: Set Server Port has no attached data\n",signature->String()); - break; - } -// printf("%s: Set Server Port to %ld\n",signature,*((port_id *)msgbuffer)); - serverport=*((port_id *)msgbuffer); - serverlink->SetPort(serverport); - ReadyToRun(); - break; - } -*/ - case ADDWINDOW: - { - // This message is received by a window's constructor so that it - // can be added to the window list - - // Attached Data: - // 1) OBWindow *window - - // I hope this is the right syntax... - windowlist->AddItem(msgbuffer); -#ifdef DEBUG_OBAPP -printf("%s: Add Window @ %p\n",signature->String(),msgbuffer); -#endif - break; - } - case REMOVEWINDOW: - { - // This message is received by a window's constructor so that it - // can be added to the window list - - // Attached Data: - // 1) OBWindow *window - - // I hope this is the right syntax... - windowlist->RemoveItem(msgbuffer); -#ifdef DEBUG_OBAPP -printf("%s: Remove Window @ %p\n",signature->String(),msgbuffer); -#endif - break; - } - case B_MOUSE_MOVED: - case B_MOUSE_DOWN: - case B_MOUSE_UP: - DispatchMessage(msgcode, (int8*)msgbuffer); - break; - - // Later on, this will default to passing the message to - // DispatchMessage(BMessage*, BHandler*) - default: - printf("OBApplication received unexpected code %ld - ",msgcode); - PrintMessageCode(msgcode); - break; - } - - if(msgcode==B_QUIT_REQUESTED) - { - printf("Quitting %s\n",signature->String()); - break; - } - } - - if(buffersize>0) - delete msgbuffer; - } -} - -void OBApplication::DispatchMessage(BMessage *msg, BHandler *handler) -{ -#ifdef DEBUG_OBAPP -printf("%s::DispatchMessage(BMessage*,BHandler*)\n",signature->String()); -#endif - BApplication::DispatchMessage(msg,handler); -} - -void OBApplication::DispatchMessage(int32 code, int8 *buffer) -{ - // This function will be necessary to handle server messages. - switch(code) - { - case B_MOUSE_DOWN: - case B_MOUSE_UP: - case B_MOUSE_MOVED: - break; - default: - printf("OBApplication %s received unknown code %ld\n",signature->String(),code); - break; - } -} - -void OBApplication::MessageReceived(BMessage *msg) -{ -#ifdef DEBUG_OBAPP -printf("%s::MessageReceived()\n",signature->String()); -#endif -} - -void OBApplication::ShowCursor(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::ShowCursor()\n",signature->String()); -#endif - serverlink->SetOpCode(SHOW_CURSOR); - serverlink->Flush(); -} - -void OBApplication::HideCursor(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::HideCursor()\n",signature->String()); -#endif - serverlink->SetOpCode(HIDE_CURSOR); - serverlink->Flush(); -} - -void OBApplication::ObscureCursor(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::ObscureCursor()\n",signature->String()); -#endif - serverlink->SetOpCode(OBSCURE_CURSOR); - serverlink->Flush(); -} - -bool OBApplication::IsCursorHidden(void) const -{ - return false; -} - -void OBApplication::SetCursor(const void *cursor) -{ -#ifdef DEBUG_OBAPP -printf("%s::SetCursor()\n",signature->String()); -#endif - // attach & send the 68-byte chunk - serverlink->SetOpCode(SET_CURSOR_DATA); - serverlink->Attach((void*)cursor, 68); - serverlink->Flush(); -} - -thread_id OBApplication::Run(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::Run()\n",signature->String()); -#endif - if(initcheckval==B_OK) - MainLoop(); - - return 0; -} - -status_t OBApplication::Archive(BMessage *data, bool deep = true) const -{ - return B_ERROR; -} - -void OBApplication::Quit(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::Quit()\n",signature->String()); -#endif - OBWindow *win; - while(windowlist->CountItems()>0) - { - win=(OBWindow*)windowlist->RemoveItem(0L); - if(win) - win->Quit(); - } - - BApplication::Quit(); -} - -bool OBApplication::QuitRequested(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::QuitRequested()\n",signature->String()); -#endif - return true; -} - -void OBApplication::Pulse(void) -{ -} - -void OBApplication::ArgvReceived(int32 argc, char **argv) -{ -} - -void OBApplication::AppActivated(bool active) -{ -} - -void OBApplication::RefsReceived(BMessage *a_message) -{ -} - -void OBApplication::AboutRequested(void) -{ -} - -BHandler *OBApplication::ResolveSpecifier(BMessage *msg,int32 index,BMessage *specifier, - int32 form,const char *property) -{ - return NULL; -} - -status_t OBApplication::GetSupportedSuites(BMessage *data) -{ - return B_ERROR; -} - -status_t OBApplication::Perform(perform_code d, void *arg) -{ - return B_ERROR; -} - -void OBApplication::ReadyToRun(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::ReadyToRun()\n",signature->String()); -#endif -} diff --git a/src/servers/app/proto5/testobapp/OBApplication.h b/src/servers/app/proto5/testobapp/OBApplication.h deleted file mode 100644 index 14478ddfba..0000000000 --- a/src/servers/app/proto5/testobapp/OBApplication.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef _OBOS_APPLICATION_H_ -#define _OBOS_APPLICATION_H_ - -#include -#include - -class PortLink; -class BList; -class OBWindow; - -class OBApplication : private BApplication -{ -public: - -OBApplication(const char *signature); -OBApplication(const char *signature, status_t *error); -virtual ~OBApplication(void); - -OBApplication(BMessage *data); -static BArchivable *Instantiate(BMessage *data); -virtual status_t Archive(BMessage *data, bool deep = true) const; - -status_t InitCheck() const; - -virtual thread_id Run(void); -virtual void Quit(void); -virtual bool QuitRequested(void); -virtual void Pulse(void); -virtual void ReadyToRun(void); -virtual void MessageReceived(BMessage *msg); -virtual void ArgvReceived(int32 argc, char **argv); -virtual void AppActivated(bool active); -virtual void RefsReceived(BMessage *a_message); -virtual void AboutRequested(void); - -virtual BHandler *ResolveSpecifier(BMessage *msg,int32 index, -BMessage *specifier,int32 form,const char *property); - -void ShowCursor(void); -void HideCursor(void); -void ObscureCursor(void); -bool IsCursorHidden(void) const; -void SetCursor(const void *cursor); -void SetCursor(const BCursor *cursor, bool sync=true); -int32 CountWindows(void) const; -BWindow *WindowAt(int32 index) const; -int32 CountLoopers(void) const; -BLooper *LooperAt(int32 index) const; -bool IsLaunching(void) const; -status_t GetAppInfo(app_info *info) const; -static BResources *AppResources(void); -virtual void DispatchMessage(BMessage *an_event,BHandler *handler); -void SetPulseRate(bigtime_t rate); -virtual status_t GetSupportedSuites(BMessage *data); -virtual status_t Perform(perform_code d, void *arg); - -protected: -friend OBWindow; - -void MainLoop(void); -void DispatchMessage(int32 code, int8 *buffer); - -port_id messageport, serverport; -BString *signature; -PortLink *serverlink; -BList *windowlist; -status_t initcheckval; -}; - -extern OBApplication *obe_app; -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/testobapp/OBTestApp.cpp b/src/servers/app/proto5/testobapp/OBTestApp.cpp deleted file mode 100644 index 5b9899f105..0000000000 --- a/src/servers/app/proto5/testobapp/OBTestApp.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "OBApplication.h" -#include "OBWindow.h" -#include "OBView.h" - -class OBTestApp : public OBApplication -{ -public: - OBTestApp(void); - ~OBTestApp(void); -}; - -OBWindow *win; - -OBTestApp::OBTestApp(void) : OBApplication("application/OBTestApp") -{ - win=new OBWindow(BRect(100,100,200,200), "OBWindow1",B_BORDERED_WINDOW_LOOK, - B_NORMAL_WINDOW_FEEL,0); - win->Show(); -} - -OBTestApp::~OBTestApp(void) -{ -} - -int main(void) -{ - OBTestApp *app=new OBTestApp(); - app->Run(); - delete app; -} diff --git a/src/servers/app/proto5/testobapp/OBView.cpp b/src/servers/app/proto5/testobapp/OBView.cpp deleted file mode 100644 index 1132f77db5..0000000000 --- a/src/servers/app/proto5/testobapp/OBView.cpp +++ /dev/null @@ -1,872 +0,0 @@ -#include -#include -#include "PortLink.h" -#include "ServerProtocol.h" -#include "OBView.h" -#include "OBWindow.h" - -//#define DEBUG_VIEW - -#ifndef SET_RGB_COLOR - #define SET_RGB_COLOR(a,b,c,d,e) a.red=b; a.green=c; a.blue=d; a.alpha=e; -#endif - -OBView::OBView(BRect frame,const char *name,uint32 resizeMask,uint32 flags) - : BHandler(name) -{ - viewflags=flags; - resizeflags=resizeMask; - origin_h=0.0; - origin_v=0.0; - - owner=NULL; - parent=NULL; - uppersibling=NULL; - lowersibling=NULL; - topchild=NULL; - bottomchild=NULL; - hidelevel=0; - - // This will be changed when added to a BWindow as the top view - topview=false; - - SET_RGB_COLOR(highcol,0,0,0,255); - SET_RGB_COLOR(lowcol,255,255,255,255); - SET_RGB_COLOR(viewcol,255,255,255,255); - - // We need to align to the nearest pixel, rounded down - // There's probably a better way to do this, but it'll work for now... - vframe.left=(int32)frame.left; - vframe.top=(int32)frame.top; - vframe.right=(int32)frame.right; - vframe.bottom=(int32)frame.bottom; -} - -OBView::~OBView() -{ - // Be Book says it's an error to delete while attached to a window. - // We'll just prevent that problem... - if(owner) - { - // No, this isn't an error to utilize parent and not owner. We - // aren't actually attached to the window class itself. We're - // attached to a view which is a member of the window. - parent->RemoveChild(this); - } - - - OBView *v; - for(v=topchild; v!=NULL; v=v->lowersibling) - delete v; -} - -void OBView::AttachedToWindow() -{ - // Hook function -} - -void OBView::AllAttached() -{ - // Hook function -} - -void OBView::DetachedFromWindow() -{ - // Hook function -} - -void OBView::AllDetached() -{ - // Hook function -} - -void OBView::MessageReceived(BMessage *msg) -{ - // Adds scripting support to the BHandler version. This is - // only a skeleton implementation, so it has been skipped - BHandler::MessageReceived(msg); -} - -void OBView::AddChild(OBView *child, OBView *before = NULL) -{ - if(!child) - return; - if(child->parent || child->owner) - { - printf("%s::AddChild(): child already has a parent\n",Name()); - return; - } - if(child->parent==this) - { - printf("%s::AddChild(): child already belongs to view\n",Name()); - return; - } - - // Adds a layer to the top of the layer's children -#ifdef DEBUG_VIEW - printf("%s::AddChild(%s)\n", Name(), child->Name()); -#endif - - child->parent=this; - child->owner=owner; - - // View specified. Add new child above the specified view - if(before) - { - if(before->parent==this) - { - child->lowersibling=before; - child->uppersibling=before->uppersibling; - before->uppersibling->lowersibling=child; - before->uppersibling=child; - - // If we're attached to a window, notify all child views of - // their attachment - if(owner) - { - CallAttached(child); - child->AllAttached(); - } - - } - else - { - printf("%s::AddChild(): Can't add %s before %s - different parents\n", - Name(), child->Name(), before->Name()); - } - return; - } - - // If we haven't specified, child is added to bottom of list - if(bottomchild!=NULL) - { - child->uppersibling=bottomchild; - bottomchild->lowersibling=child; - } - bottomchild=child; - -} - -bool OBView::RemoveChild(OBView *child) -{ - if(!child) - return false; - - if(child->parent!=this) - { - printf("%s::RemoveChild(): %s not child of this view\n",Name(),child->Name()); - return false; - } - - // Adds a layer to the top of the layer's children -#ifdef DEBUG_VIEW - printf("%s::RemoveChild(%s)\n", Name(), child->Name()); -#endif - - if(owner) - { - CallDetached(child); - - // We only need to tell the server to prune the layer tree - // at the child's level - PortLink *link=new PortLink(owner->outport); - link->SetOpCode(LAYER_DELETE); - link->Attach(child->id); - link->Flush(); - delete link; - } - - // Note that we do the pointer reassignments last because the other - // function calls made in RemoveChild() depend on these pointers - if(topchild==child) - topchild=child->lowersibling; - if(bottomchild==child) - bottomchild=child->lowersibling; - - if(child->uppersibling!=NULL) - child->uppersibling->lowersibling=child->lowersibling; - if(child->lowersibling!=NULL) - child->lowersibling->uppersibling=child->uppersibling; - - child->parent=NULL; - child->owner=NULL; - child->lowersibling=NULL; - child->uppersibling=NULL; - return true; -} - -bool OBView::RemoveSelf() -{ - return false; -} - -int32 OBView::CountChildren() const -{ - OBView *v=topchild; - int32 children=0; - - while(v!=NULL) - { - v=v->lowersibling; - children++; - } - - return children; -} - -OBView *OBView::ChildAt(int32 index) const -{ - // We're using a tree, so traverse the tree - OBView *v=topchild; - - for(int32 i=0;ilowersibling; - } - - return v; -} - -OBView *OBView::NextSibling() const -{ - return lowersibling; -} - -OBView *OBView::PreviousSibling() const -{ - return uppersibling; -} - -OBWindow *OBView::Window() const -{ - return owner; -} - -void OBView::Draw(BRect updateRect) -{ -} - -void OBView::MouseDown(BPoint where) -{ - // Hook function -} - -void OBView::MouseUp(BPoint where) -{ - // Hook function -} - -void OBView::MouseMoved(BPoint where,uint32 code,const BMessage *a_message) -{ - // Hook function -} - -void OBView::WindowActivated(bool state) -{ - // Hook function -} - -void OBView::KeyDown(const char *bytes, int32 numBytes) -{ - // Hook function -} - -void OBView::KeyUp(const char *bytes, int32 numBytes) -{ - // Hook function -} - -void OBView::Pulse() -{ - // Hook function -} - -void OBView::FrameMoved(BPoint new_position) -{ - // Hook function -} - -void OBView::FrameResized(float new_width, float new_height) -{ - // Hook function -} - -void OBView::TargetedByScrollView(BScrollView *scroll_view) -{ - // Hook function -} - -void OBView::BeginRectTracking(BRect startRect,uint32 style = B_TRACK_WHOLE_RECT) -{ - if(!owner) - { - printf("BeginRectTracking(): view must be attached to a window\n"); - return; - } - owner->serverlink->SetOpCode(BEGIN_RECT_TRACKING); - owner->serverlink->Attach(&startRect, sizeof(BRect)); - owner->serverlink->Attach(&style, sizeof(uint32)); - owner->serverlink->Flush(); -} - -void OBView::EndRectTracking(void) -{ - if(!owner) - { - printf("EndRectTracking(): view must be attached to a window\n"); - return; - } - owner->serverlink->SetOpCode(END_RECT_TRACKING); - owner->serverlink->Flush(); -} - -void OBView::GetMouse(BPoint *location, uint32 *buttons, - bool checkMessageQueue=true) -{ -} - -OBView *OBView::FindView(const char *name) -{ - OBView *v; - v=FindViewInChildren(name); - - return v; -} - -OBView *OBView::Parent() const -{ - return parent; -} - -BRect OBView::Bounds() const -{ - BRect rframe=vframe; - rframe.OffsetTo(0,0); - return rframe; -} - -BRect OBView::Frame() const -{ - return vframe; -} - -void OBView::ConvertToScreen(BPoint* pt) const -{ -} - -BPoint OBView::ConvertToScreen(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBView::ConvertFromScreen(BPoint* pt) const -{ -} - -BPoint OBView::ConvertFromScreen(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBView::ConvertToScreen(BRect *r) const -{ -} - -BRect OBView::ConvertToScreen(BRect r) const -{ - return BRect(0,0,0,0); -} - -void OBView::ConvertFromScreen(BRect *r) const -{ -} - -BRect OBView::ConvertFromScreen(BRect r) const -{ - return BRect(0,0,0,0); -} - -void OBView::ConvertToParent(BPoint *pt) const -{ -} - -BPoint OBView::ConvertToParent(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBView::ConvertFromParent(BPoint *pt) const -{ -} - -BPoint OBView::ConvertFromParent(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBView::ConvertToParent(BRect *r) const -{ -} - -BRect OBView::ConvertToParent(BRect r) const -{ - return BRect(0,0,0,0); -} - -void OBView::ConvertFromParent(BRect *r) const -{ -} - -BRect OBView::ConvertFromParent(BRect r) const -{ - return BRect(0,0,0,0); -} - -BPoint OBView::LeftTop() const -{ - return BPoint(-1,-1); -} - -void OBView::GetClippingRegion(BRegion *region) const -{ -} - -void OBView::ConstrainClippingRegion(BRegion *region) -{ -} - -void OBView::SetDrawingMode(drawing_mode mode) -{ -} - -drawing_mode OBView::DrawingMode() const -{ - return B_OP_COPY; -} - -void OBView::SetBlendingMode(source_alpha srcAlpha, alpha_function alphaFunc) -{ -} - -void OBView::GetBlendingMode(source_alpha *srcAlpha, alpha_function *alphaFunc) const -{ -} - -void OBView::SetPenSize(float size) -{ -} - -float OBView::PenSize() const -{ - return 0.0; -} - -void OBView::SetViewColor(rgb_color c) -{ - SET_RGB_COLOR(viewcol,c.red,c.green,c.blue,c.alpha); - owner->drawmsglink->Attach((int32)GFX_SET_VIEW_COLOR); - owner->drawmsglink->Attach((int8)c.red); - owner->drawmsglink->Attach((int8)c.green); - owner->drawmsglink->Attach((int8)c.blue); - owner->drawmsglink->Attach((int8)c.alpha); -} - -void OBView::SetViewColor(uchar r, uchar g, uchar b, uchar a=255) -{ - SET_RGB_COLOR(viewcol,r,g,b,a); - owner->drawmsglink->Attach((int32)GFX_SET_VIEW_COLOR); - owner->drawmsglink->Attach((int8)r); - owner->drawmsglink->Attach((int8)g); - owner->drawmsglink->Attach((int8)b); - owner->drawmsglink->Attach((int8)a); -} - -rgb_color OBView::ViewColor() const -{ - return viewcol; -} - -void OBView::SetHighColor(rgb_color c) -{ - SET_RGB_COLOR(highcol,c.red,c.green,c.blue,c.alpha); - owner->drawmsglink->Attach((int32)GFX_SET_HIGH_COLOR); - owner->drawmsglink->Attach((int8)c.red); - owner->drawmsglink->Attach((int8)c.green); - owner->drawmsglink->Attach((int8)c.blue); - owner->drawmsglink->Attach((int8)c.alpha); -} - -void OBView::SetHighColor(uchar r, uchar g, uchar b, uchar a=255) -{ - SET_RGB_COLOR(highcol,r,g,b,a); - owner->drawmsglink->Attach((int32)GFX_SET_HIGH_COLOR); - owner->drawmsglink->Attach((int8)r); - owner->drawmsglink->Attach((int8)g); - owner->drawmsglink->Attach((int8)b); - owner->drawmsglink->Attach((int8)a); -} - -rgb_color OBView::HighColor() const -{ - return highcol; -} - -void OBView::SetLowColor(rgb_color c) -{ - SET_RGB_COLOR(lowcol,c.red,c.green,c.blue,c.alpha); - owner->drawmsglink->Attach((int32)GFX_SET_LOW_COLOR); - owner->drawmsglink->Attach((int8)c.red); - owner->drawmsglink->Attach((int8)c.green); - owner->drawmsglink->Attach((int8)c.blue); - owner->drawmsglink->Attach((int8)c.alpha); -} - -void OBView::SetLowColor(uchar r, uchar g, uchar b, uchar a=255) -{ - SET_RGB_COLOR(lowcol,r,g,b,a); - owner->drawmsglink->Attach((int32)GFX_SET_LOW_COLOR); - owner->drawmsglink->Attach((int8)r); - owner->drawmsglink->Attach((int8)g); - owner->drawmsglink->Attach((int8)b); - owner->drawmsglink->Attach((int8)a); -} - -rgb_color OBView::LowColor() const -{ - return lowcol; -} - -void OBView::Invalidate(BRect invalRect) -{ - if(!owner) - { - printf("Invalidate(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach(invalRect); -} - -void OBView::Invalidate(const BRegion *invalRegion) -{ - // undocumented function -} - -void OBView::Invalidate() -{ - if(!owner) - { - printf("Invalidate(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach(Bounds()); -} - -void OBView::SetFlags(uint32 flags) -{ -} - -uint32 OBView::Flags() const -{ - return viewflags; -} - -void OBView::SetResizingMode(uint32 mode) -{ -} - -uint32 OBView::ResizingMode() const -{ - return resizeflags; -} - -void OBView::MoveBy(float dh, float dv) -{ -} - -void OBView::MoveTo(BPoint where) -{ -} - -void OBView::MoveTo(float x, float y) -{ -} - -void OBView::ResizeBy(float dh, float dv) -{ -} - -void OBView::ResizeTo(float width, float height) -{ -} - -void OBView::MakeFocus(bool focusState = true) -{ -} - -bool OBView::IsFocus() const -{ - return has_focus; -} - -void OBView::Show() -{ - hidelevel--; - - for(OBView *v=topchild; v!=NULL; v=v->lowersibling ) - v->Show(); -} - -void OBView::Hide() -{ - hidelevel++; - - for(OBView *v=topchild; v!=NULL; v=v->lowersibling ) - v->Show(); -} - -bool OBView::IsHidden() const -{ - return (hidelevel>0)?true:false; -} - -bool OBView::IsHidden(const OBView* looking_from) const -{ - // undocumented function - return false; -} - -void OBView::Flush() const -{ - // When attachment count inclusion is implemented, it needs to go - // in this function - - owner->drawmsglink->SetOpCode(GFX_FLUSH); - owner->drawmsglink->Flush(); -} - -void OBView::Sync() const -{ - // When attachment count inclusion is implemented, it needs to go - // in this function - - int32 code; - status_t status; - ssize_t buffersize; - - owner->drawmsglink->SetOpCode(GFX_SYNC); - - // Reply received: - - // Code: SYNC - // Attached data: none - // Buffersize: 0 - owner->drawmsglink->FlushWithReply(&code,&status,&buffersize); -} - -void OBView::StrokeRect(BRect r, pattern p=B_SOLID_HIGH) -{ - if(!owner) - { - printf("StrokeRect(): view must be attached to a window\n"); - return; - } - - owner->drawmsglink->Attach((int32)GFX_STROKE_RECT); - owner->drawmsglink->Attach(r); - owner->drawmsglink->Attach(&p, sizeof(pattern)); -} - -void OBView::FillRect(BRect r, pattern p=B_SOLID_HIGH) -{ - if(!owner) - { - printf("FillRect(): view must be attached to a window\n"); - return; - } - - owner->drawmsglink->Attach((int32)GFX_FILL_RECT); - owner->drawmsglink->Attach(r); - owner->drawmsglink->Attach(&p, sizeof(pattern)); -} - -void OBView::MovePenTo(BPoint pt) -{ - if(!owner) - { - printf("MovePenTo(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach((int32)GFX_MOVEPENTO); - owner->drawmsglink->Attach(pt); -} - -void OBView::MovePenTo(float x, float y) -{ - if(!owner) - { - printf("MovePenTo(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach((int32)GFX_MOVEPENTO); - owner->drawmsglink->Attach(BPoint(x,y)); -} - -void OBView::MovePenBy(float x, float y) -{ - if(!owner) - { - printf("MovePenBy(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach((int32)GFX_MOVEPENBY); - owner->drawmsglink->Attach(x); - owner->drawmsglink->Attach(y); -} - -BPoint OBView::PenLocation() const -{ - return BPoint(0,0); -} - -void OBView::StrokeLine(BPoint toPt,pattern p=B_SOLID_HIGH) -{ - if(!owner) - { - printf("StrokeLine(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach((int32)GFX_STROKE_LINE); - owner->drawmsglink->Attach(toPt); - owner->drawmsglink->Attach((pattern *)&p, sizeof(pattern)); -} - -void OBView::StrokeLine(BPoint pt0,BPoint pt1,pattern p=B_SOLID_HIGH) -{ - if(!owner) - { - printf("StrokeLine(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach((int32)GFX_MOVEPENTO); - owner->drawmsglink->Attach(pt0); - - owner->drawmsglink->Attach((int32)GFX_STROKE_LINE); - owner->drawmsglink->Attach(pt1); - owner->drawmsglink->Attach((pattern *)&p, sizeof(pattern)); -} - -// Protected members - -int32 OBView::GetServerToken(void) -{ - // Function which asks the app_server for an ID value - // NOTE that it requires an owner - - if(!owner) - { - printf("GetServerToken(): view must be attached to a window\n"); - return -1; - } - - int32 code; - status_t status; - ssize_t buffersize; - int32 *buffer; - - owner->serverlink->SetOpCode(VIEW_GET_TOKEN); - - // Reply received: - - // Code: GET_VIEW_TOKEN - // Attached data: - // 1) int32 view ID - buffer=(int32*)owner->drawmsglink->FlushWithReply(&code,&status,&buffersize); - id=*buffer; - - // necessary because each reply allocates memory from the heap for - // the returned buffer - delete buffer; - - return id; -} - -void OBView::CallAttached(OBView *view) -{ - // Recursively calls AttachedToWindow() for all children of the view - AddedToWindow(); - AttachedToWindow(); - - for(OBView *v=topchild; v!=NULL; v=v->lowersibling) - { - if(v->topchild) - CallAttached(v->topchild); - } -} - -void OBView::CallDetached(OBView *view) -{ - // Recursively calls DetachedFromWindow() for all children of the view - DetachedFromWindow(); - - for(OBView *v=topchild; v!=NULL; v=v->lowersibling) - { - if(v->topchild) - CallDetached(v->topchild); - } -} - -void OBView::AddedToWindow(void) -{ - // Hook function called during AddChild to take care of setup in server - // of adding a bunch of views at once, not just one - - // Theoretically, shouldn't be needed, but this is here in case I do - // something really stupid. ;) - if(!owner) - return; - - // If we're finally attached to a window, then the child needs to become - // known to the server - - // Create View message. Layers are app_server's view counterparts - - // Attach Data: - // 1) (int32) id of the parent view - // 2) (int32) id of the child view - // 3) (BRect) frame in parent's coordinates - // 4) (int32) resize flags - // 5) (int32) view flags - // 6) (uint16) view's hide level - id=GetServerToken(); - - PortLink *link=new PortLink(owner->outport); - link->SetOpCode(LAYER_CREATE); - link->Attach(parent->id); - link->Attach(id); - link->Attach(vframe); - link->Attach((int32)resizeflags); - link->Attach((int32)viewflags); - link->Attach(&hidelevel,sizeof(uint16)); - link->Flush(); - delete link; -} - -OBView *OBView::FindViewInChildren(const char *name) -{ - // Looks in all children of a view and returns the first view - // with a matching name. - - // Process: - // 1) Search this view's children starting with topchild - // 2) If not found, cycle through them again, this second time - // recursively searching each child. - // 3) If the view is found in the first child search, assign the ** - // and return the *. - // 4) If the view is found in the second child search, break out of the - // search loop by assigning and returning the * - // 5) If we complete the loop, it means that the view was not found. - // We should, thus, return NULL - return NULL; -} diff --git a/src/servers/app/proto5/testobapp/OBView.h b/src/servers/app/proto5/testobapp/OBView.h deleted file mode 100644 index 86a2448d8c..0000000000 --- a/src/servers/app/proto5/testobapp/OBView.h +++ /dev/null @@ -1,168 +0,0 @@ -#ifndef _OBVIEW_H_ -#define _OBVIEW_H_ - -#include -#include -#include -#include -#include -#include - -class BMessage; -class BString; -class BWindow; -class OBWindow; - -class OBView : public BHandler -{ -public: -OBView( BRect frame,const char *name,uint32 resizeMask,uint32 flags); -virtual ~OBView(); - -virtual void AttachedToWindow(); -virtual void AllAttached(); -virtual void DetachedFromWindow(); -virtual void AllDetached(); - -virtual void MessageReceived(BMessage *msg); - -void AddChild(OBView *child, OBView *before = NULL); -bool RemoveChild(OBView *child); -bool RemoveSelf(); -int32 CountChildren() const; -OBView *ChildAt(int32 index) const; -OBView *NextSibling() const; -OBView *PreviousSibling() const; - -OBWindow *Window() const; - -virtual void Draw(BRect updateRect); -virtual void MouseDown(BPoint where); -virtual void MouseUp(BPoint where); -virtual void MouseMoved( BPoint where,uint32 code,const BMessage *a_message); -virtual void WindowActivated(bool state); -virtual void KeyDown(const char *bytes, int32 numBytes); -virtual void KeyUp(const char *bytes, int32 numBytes); -virtual void Pulse(); -virtual void FrameMoved(BPoint new_position); -virtual void FrameResized(float new_width, float new_height); - -virtual void TargetedByScrollView(BScrollView *scroll_view); -void BeginRectTracking( BRect startRect,uint32 style = B_TRACK_WHOLE_RECT); -void EndRectTracking(); - -void GetMouse(BPoint *location,uint32 *buttons,bool checkMessageQueue=true); - -OBView *FindView(const char *name); -OBView *Parent() const; -BRect Bounds() const; -BRect Frame() const; -void ConvertToScreen(BPoint* pt) const; -BPoint ConvertToScreen(BPoint pt) const; -void ConvertFromScreen(BPoint* pt) const; -BPoint ConvertFromScreen(BPoint pt) const; -void ConvertToScreen(BRect *r) const; -BRect ConvertToScreen(BRect r) const; -void ConvertFromScreen(BRect *r) const; -BRect ConvertFromScreen(BRect r) const; -void ConvertToParent(BPoint *pt) const; -BPoint ConvertToParent(BPoint pt) const; -void ConvertFromParent(BPoint *pt) const; -BPoint ConvertFromParent(BPoint pt) const; -void ConvertToParent(BRect *r) const; -BRect ConvertToParent(BRect r) const; -void ConvertFromParent(BRect *r) const; -BRect ConvertFromParent(BRect r) const; -BPoint LeftTop() const; - -void GetClippingRegion(BRegion *region) const; -virtual void ConstrainClippingRegion(BRegion *region); - -virtual void SetDrawingMode(drawing_mode mode); -drawing_mode DrawingMode() const; - -void SetBlendingMode(source_alpha srcAlpha, alpha_function alphaFunc); -void GetBlendingMode(source_alpha *srcAlpha, alpha_function *alphaFunc) const; - -virtual void SetPenSize(float size); -float PenSize() const; - -virtual void SetViewColor(rgb_color c); -void SetViewColor(uchar r, uchar g, uchar b, uchar a = 255); -rgb_color ViewColor() const; - -virtual void SetHighColor(rgb_color a_color); -void SetHighColor(uchar r, uchar g, uchar b, uchar a = 255); -rgb_color HighColor() const; - -virtual void SetLowColor(rgb_color a_color); -void SetLowColor(uchar r, uchar g, uchar b, uchar a = 255); -rgb_color LowColor() const; - -void Invalidate(BRect invalRect); -void Invalidate(const BRegion *invalRegion); -void Invalidate(); - -virtual void SetFlags(uint32 flags); -uint32 Flags() const; -virtual void SetResizingMode(uint32 mode); -uint32 ResizingMode() const; -void MoveBy(float dh, float dv); -void MoveTo(BPoint where); -void MoveTo(float x, float y); -void ResizeBy(float dh, float dv); -void ResizeTo(float width, float height); -virtual void MakeFocus(bool focusState = true); -bool IsFocus() const; - -virtual void Show(); -virtual void Hide(); -bool IsHidden() const; -bool IsHidden(const OBView* looking_from) const; - -void Flush() const; -void Sync() const; - -void StrokeRect(BRect r, pattern p = B_SOLID_HIGH); -void FillRect(BRect r, pattern p = B_SOLID_HIGH); -void MovePenTo(BPoint pt); -void MovePenTo(float x, float y); -void MovePenBy(float x, float y); -BPoint PenLocation() const; -void StrokeLine( BPoint toPt,pattern p = B_SOLID_HIGH); -void StrokeLine( BPoint pt0,BPoint pt1,pattern p = B_SOLID_HIGH); - -protected: - friend OBWindow; - -int32 GetServerToken(void); -void CallAttached(OBView *view); -void CallDetached(OBView *view); -OBView *FindViewInChildren(const char *name); -void AddedToWindow(void); - -int32 id; -uint32 viewflags, resizeflags; -float origin_h; -float origin_v; -OBWindow* owner; - -OBView* parent; -OBView* uppersibling; -OBView* lowersibling; -OBView* topchild; -OBView* bottomchild; - -uint16 hidelevel; -bool topview; -bool has_focus; - -BRect vframe; -BRegion *clipregion; - -rgb_color highcol; -rgb_color lowcol; -rgb_color viewcol; -}; - -#endif diff --git a/src/servers/app/proto5/testobapp/OBWindow.cpp b/src/servers/app/proto5/testobapp/OBWindow.cpp deleted file mode 100644 index 6d88d8e362..0000000000 --- a/src/servers/app/proto5/testobapp/OBWindow.cpp +++ /dev/null @@ -1,443 +0,0 @@ -#include -#include -#include -#include "OBApplication.h" -#include "OBView.h" -#include "OBWindow.h" -#include "ServerProtocol.h" -#include "PortLink.h" - -#define DEBUG_OBWINDOW - -OBWindow::OBWindow(BRect frame,const char *title, window_type type, -uint32 flags,uint32 workspace = B_CURRENT_WORKSPACE) -{ -} - -OBWindow::OBWindow(BRect frame,const char *title, window_look look,window_feel feel, -uint32 flags,uint32 workspace = B_CURRENT_WORKSPACE) -{ -#ifdef DEBUG_OBWINDOW -printf("OBWindow(%s)\n",title); -#endif - Lock(); - - // Window starts hidden by default - hidelevel=1; - - wframe=frame; - wlook=look; - wfeel=feel; - wflags=flags; - wkspace=workspace; - - wtitle=new BString(title); - - // Receives messages from server and others - inport=create_port(50,"msgport"); - if(inport==B_BAD_VALUE || inport==B_NO_MORE_PORTS) - printf("OBWindow: Couldn't create message port\n"); - - // Notify app that we exist - OBWindow *win=this; - PortLink *link=new PortLink(obe_app->messageport); - link->SetOpCode(ADDWINDOW); - link->Attach(&win,sizeof(OBWindow*)); - link->Flush(); - delete link; - - // we set this flag because the window starts locked. When Show() is - // called it will unlock the looper and show the window - startlocked=true; - - // We create our serverlink utilizing our application's server port - // because the server's ServerApp will handle window creation - serverlink=new PortLink(obe_app->serverport); - - // make sure that the server port is valid. It will == B_NAME_NOT_FOUND if the - // OBApplication couldn't find the server - - if(obe_app->serverport!=B_NAME_NOT_FOUND) - { - // Notify server of window's existence - serverlink->SetOpCode(CREATE_WINDOW); - serverlink->Attach(wframe); - serverlink->Attach((int32)wflags); - serverlink->Attach(&inport,sizeof(port_id)); - serverlink->Attach((int32)wkspace); - serverlink->Attach((char*)wtitle->String(),wtitle->Length()); - - // Send and wait for ServerWindow port. Necessary here so we can respond to - // messages as soon as Show() is called. - - int32 replycode; - status_t replystat; - ssize_t replysize; - int8 *replybuffer; - - replybuffer=serverlink->FlushWithReply(&replycode,&replystat,&replysize); - outport=*((port_id*)replybuffer); - serverlink->SetPort(outport); - delete replybuffer; - -#ifdef DEBUG_OBWINDOW -printf("OBWindow(%s): ServerWindow Port %ld\n",wtitle->String(),outport); -#endif - - // Create and attach the top view - top_view=new OBView(wframe.OffsetToCopy(0,0),"top_view",B_FOLLOW_ALL, B_WILL_DRAW); - top_view->owner=this; - top_view->topview=true; - } - else - PostMessage(B_QUIT_REQUESTED); -} - -OBWindow::~OBWindow() -{ -#ifdef DEBUG_OBWINDOW -printf("~OBWindow(%s)\n",wtitle->String()); -#endif - // delete all children. How? OBView recursively deletes its children - delete top_view; - - delete wtitle; - delete serverlink; - delete drawmsglink; - -} - -void OBWindow::Quit() -{ -#ifdef DEBUG_OBWINDOW -printf("%s::Quit()\n",wtitle->String()); -#endif - // I hope this works. If it doesn't, we'll need to do a synchronous msg - OBWindow *win=this; - PortLink *link=new PortLink(obe_app->messageport); - link->SetOpCode(REMOVEWINDOW); - link->Attach(&win,sizeof(OBWindow *)); - link->Flush(); - delete link; - - // Server will need to be notified of window destruction - serverlink->SetOpCode(DELETE_WINDOW); - serverlink->Attach(&ID,sizeof(int32)); - serverlink->Flush(); - - // Quit our looper and delete our self :) - Quit(); -} - -void OBWindow::Close() -{ - Quit(); -} - -void OBWindow::AddChild(OBView *child, OBView *before = NULL) -{ -#ifdef DEBUG_OBWINDOW -printf("%s::AddChild()\n",wtitle->String()); -#endif - top_view->AddChild(child,before); -} - -bool OBWindow::RemoveChild(OBView *child) -{ -#ifdef DEBUG_OBWINDOW -printf("%s::RemoveChild()\n",wtitle->String()); -#endif - return top_view->RemoveChild(child); -} - -int32 OBWindow::CountChildren() const -{ - return top_view->CountChildren(); -} - -OBView *OBWindow::ChildAt(int32 index) const -{ - return top_view->ChildAt(index); -} - -void OBWindow::DispatchMessage(BMessage *message, BHandler *handler) -{ -} - -void OBWindow::MessageReceived(BMessage *message) -{ - // Not sure right now what needs to be handled. - switch(message->what) - { - default: - BLooper::MessageReceived(message); - } -} - -void OBWindow::FrameMoved(BPoint new_position) -{ -} - -void OBWindow::WorkspacesChanged(uint32 old_ws, uint32 new_ws) -{ -} - -void OBWindow::WorkspaceActivated(int32 ws, bool state) -{ -} - -void OBWindow::FrameResized(float new_width, float new_height) -{ -} - -void OBWindow::Minimize(bool minimize) -{ -} - -void OBWindow::Zoom(BPoint rec_position,float rec_width,float rec_height) -{ -} - -void OBWindow::Zoom() -{ -} - -void OBWindow::ScreenChanged(BRect screen_size, color_space depth) -{ -} - -bool OBWindow::NeedsUpdate() const -{ - return false; -} - -void OBWindow::UpdateIfNeeded() -{ -} - -OBView *OBWindow::FindView(const char *view_name) const -{ - return top_view->FindView(view_name); -} - -OBView *OBWindow::FindView(BPoint) const -{ - return NULL; -} - -OBView *OBWindow::CurrentFocus() const -{ - return focusedview; -} - -void OBWindow::Activate(bool=true) -{ -} - -void OBWindow::WindowActivated(bool state) -{ -} - -void OBWindow::ConvertToScreen(BPoint *pt) const -{ -} - -BPoint OBWindow::ConvertToScreen(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBWindow::ConvertFromScreen(BPoint *pt) const -{ -} - -BPoint OBWindow::ConvertFromScreen(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBWindow::ConvertToScreen(BRect *rect) const -{ -} - -BRect OBWindow::ConvertToScreen(BRect rect) const -{ - return BRect(0,0,0,0); -} - -void OBWindow::ConvertFromScreen(BRect *rect) const -{ -} - -BRect OBWindow::ConvertFromScreen(BRect rect) const -{ - return BRect(0,0,0,0); -} - -void OBWindow::MoveBy(float dx, float dy) -{ -} - -void OBWindow::MoveTo(BPoint) -{ -} - -void OBWindow::MoveTo(float x, float y) -{ -} - -void OBWindow::ResizeBy(float dx, float dy) -{ -} - -void OBWindow::ResizeTo(float width, float height) -{ -} - -void OBWindow::Show() -{ - if(startlocked) - { - startlocked=false; - Unlock(); - } - hidelevel--; - if(hidelevel==0) - { - serverlink->SetOpCode(SHOW_WINDOW); - serverlink->Flush(); - } -} - -void OBWindow::Hide() -{ - if(hidelevel==0) - { - serverlink->SetOpCode(HIDE_WINDOW); - serverlink->Flush(); - } - hidelevel++; -} - -bool OBWindow::IsHidden() const -{ - return false; -} - -bool OBWindow::IsMinimized() const -{ - return false; -} - -void OBWindow::Flush() const -{ - // When attachment count inclusion is implemented, it needs to go - // in this function - - drawmsglink->SetOpCode(GFX_FLUSH); - drawmsglink->Flush(); -} - -void OBWindow::Sync() const -{ - // When attachment count inclusion is implemented, it needs to go - // in this function - - int32 code; - status_t status; - ssize_t buffersize; - - drawmsglink->SetOpCode(GFX_SYNC); - - // Reply received: - - // Code: SYNC - // Attached data: none - // Buffersize: 0 - drawmsglink->FlushWithReply(&code,&status,&buffersize); -} - -status_t OBWindow::SendBehind(const OBWindow *window) -{ - return B_ERROR; -} - -void OBWindow::DisableUpdates() -{ -} - -void OBWindow::EnableUpdates() -{ -} - -void OBWindow::BeginViewTransaction() -{ -} - -void OBWindow::EndViewTransaction() -{ -} - -BRect OBWindow::Bounds() const -{ - return BRect(0,0,0,0); -} - -BRect OBWindow::Frame() const -{ - return BRect(0,0,0,0); -} - -const char *OBWindow::Title() const -{ - return NULL; -} - -void OBWindow::SetTitle(const char *title) -{ -} - -bool OBWindow::IsFront() const -{ - return false; -} - -bool OBWindow::IsActive() const -{ - return false; -} - -uint32 OBWindow::Workspaces() const -{ - return 0; -} - -void OBWindow::SetWorkspaces(uint32) -{ -} - -OBView *OBWindow::LastMouseMovedView() const -{ - return NULL; -} - -status_t OBWindow::AddToSubset(OBWindow *window) -{ - return B_ERROR; -} - -status_t OBWindow::RemoveFromSubset(OBWindow *window) -{ - return B_ERROR; -} - -bool OBWindow::QuitRequested() -{ - return false; -} - -thread_id OBWindow::Run() -{ - return 0; -} - diff --git a/src/servers/app/proto5/testobapp/OBWindow.h b/src/servers/app/proto5/testobapp/OBWindow.h deleted file mode 100644 index c3593cf874..0000000000 --- a/src/servers/app/proto5/testobapp/OBWindow.h +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef _OBWINDOW_H -#define _OBWINDOW_H - -#include -#include -#include -#include -#include -#include -#include -#include - -class BButton; -class BMenuBar; -class BMenuItem; -class BMessage; -class BMessageRunner; -class BMessenger; -class OBView; -class PortLink; - -struct message; -struct _cmd_key_; -struct _view_attr_; - -#define ADDWINDOW '_adw' -#define REMOVEWINDOW '_rmw' - -class OBWindow : public BLooper -{ -public: -OBWindow(BRect frame,const char *title, window_type type, -uint32 flags,uint32 workspace = B_CURRENT_WORKSPACE); - -OBWindow(BRect frame,const char *title, window_look look,window_feel feel, -uint32 flags,uint32 workspace = B_CURRENT_WORKSPACE); - -virtual ~OBWindow(); - -virtual void Quit(); -void Close(); - -void AddChild(OBView *child, OBView *before = NULL); -bool RemoveChild(OBView *child); -int32 CountChildren() const; -OBView *ChildAt(int32 index) const; - -virtual void DispatchMessage(BMessage *message, BHandler *handler); -virtual void MessageReceived(BMessage *message); -virtual void FrameMoved(BPoint new_position); -virtual void WorkspacesChanged(uint32 old_ws, uint32 new_ws); -virtual void WorkspaceActivated(int32 ws, bool state); -virtual void FrameResized(float new_width, float new_height); -virtual void Minimize(bool minimize); -virtual void Zoom( BPoint rec_position, - float rec_width, - float rec_height); -void Zoom(); -virtual void ScreenChanged(BRect screen_size, color_space depth); -bool NeedsUpdate() const; -void UpdateIfNeeded(); -OBView *FindView(const char *view_name) const; -OBView *FindView(BPoint) const; -OBView *CurrentFocus() const; -void Activate(bool = true); -virtual void WindowActivated(bool state); -void ConvertToScreen(BPoint *pt) const; -BPoint ConvertToScreen(BPoint pt) const; -void ConvertFromScreen(BPoint *pt) const; -BPoint ConvertFromScreen(BPoint pt) const; -void ConvertToScreen(BRect *rect) const; -BRect ConvertToScreen(BRect rect) const; -void ConvertFromScreen(BRect *rect) const; -BRect ConvertFromScreen(BRect rect) const; -void MoveBy(float dx, float dy); -void MoveTo(BPoint); -void MoveTo(float x, float y); -void ResizeBy(float dx, float dy); -void ResizeTo(float width, float height); -virtual void Show(); -virtual void Hide(); -bool IsHidden() const; -bool IsMinimized() const; - -void Flush() const; -void Sync() const; - -status_t SendBehind(const OBWindow *window); - -void DisableUpdates(); -void EnableUpdates(); - -void BeginViewTransaction(); -void EndViewTransaction(); - -BRect Bounds() const; -BRect Frame() const; -const char *Title() const; -void SetTitle(const char *title); -bool IsFront() const; -bool IsActive() const; -uint32 Workspaces() const; -void SetWorkspaces(uint32); -OBView *LastMouseMovedView() const; - - -status_t AddToSubset(OBWindow *window); -status_t RemoveFromSubset(OBWindow *window); - -virtual bool QuitRequested(); -virtual thread_id Run(); - -protected: -friend OBView; - -BString *wtitle; -int32 ID; -int32 topview_ID; -uint8 hidelevel; -uint32 wflags; - -PortLink *drawmsglink, *serverlink; -port_id inport; -port_id outport; - -OBView *top_view; -OBView *focusedview; -OBView *fLastMouseMovedView; -BRect wframe; - -window_look wlook; -window_feel wfeel; - -bool startlocked; -bool in_update; -bool is_active; -int32 wkspace; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/testobapp/PortLink.cpp b/src/servers/app/proto5/testobapp/PortLink.cpp deleted file mode 100644 index 8fba724569..0000000000 --- a/src/servers/app/proto5/testobapp/PortLink.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/* - PortLink.cpp: - A helper class for port-based messaging - ------------------------------------------------------------------------- -How it works: - The class utilizes a fixed-size array of PortLinkData object pointers. When -data is attached, a new PortLinkData object is allocated and a copy of the -passed data is created inside it. When the time comes for the message to be sent, -the data is pieced together into a flattened array and written to the port. ------------------------------------------------------------------------- -Data members: - -*attachments[] - fixed-size array of pointers used to hold the attached data -opcode - message value which is sent along with any data -target - port to which the message is sent when Flush() is called -replyport - port used with synchronous messaging - FlushWithReply() -bufferlength - total bytes taken up by attachments -num_attachments - internal variable which is used to track which "slot" - will be the next one to receive an attachment object -*/ - -#include "PortLink.h" -#include -#include -#include - -//#define PLDEBUG - -// Internal data storage class for holding attached data whilst it is waiting -// to be Flattened() and then Flushed(). There is no need for this to be called outside -// the PortLink class. -class PortLinkData -{ -public: - PortLinkData(void); - ~PortLinkData(void); - bool Set(void *data, size_t size); - char *buffer; - size_t buffersize; -}; - -PortLink::PortLink(port_id port) -{ - // For this class to be useful (and to prevent a lot of init problems) - // we require a port in the constructor - target=port; - - // We start out without any data attached to the port message - num_attachments=0; - opcode=0; - bufferlength=0; - replyport=create_port(30,"PortLink reply port"); -} - -PortLink::~PortLink(void) -{ - // If, for some odd reason, this is deleted with something attached, - // free the memory used by the attachments. We do not flush the queue - // because the port may no longer be valid in cases such as the app - // is in the process of quitting - MakeEmpty(); -} - -void PortLink::SetOpCode(int32 code) -{ - // Sets the message code. This does not change once the message is sent. - // Another call to SetOpCode() is required for such things. - opcode=code; -} - -void PortLink::SetPort(port_id port) -{ - // Sets the target port. While not necessary in most uses, this exists - // mostly to prevent flexibility problems - target=port; -} - -port_id PortLink::GetPort(void) -{ - // Simply returns the port at which the object is pointed. - return target; -} - -void PortLink::Flush(bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message off to the target, complete with attachments. NOTE: - // the recipient must delete all attachments, being the PortLink object assumes - // no responsiblity for the attachments once the message is sent. - int8 *msgbuffer; - int32 size; - - if(num_attachments>0) - { - FlattenData(&msgbuffer,&size); - - // Dump message to port, reset attachments, and clean up - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,msgbuffer,size,B_TIMEOUT, timeout); - else - write_port(target,opcode,msgbuffer,size); - MakeEmpty(); - } - else - { - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,NULL,0,B_TIMEOUT, timeout); - else - write_port(target,opcode,NULL,0); - } -} - -int8* PortLink::FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message to the target and then waits for a reply. The target will - // receive a message with the first item being the port_id to reply to. - // NOTE: like Flush(), any attached data must be deleted. - - // Effectively, an Attach() call inlined for changes - - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - { - *status=B_ERROR; - return NULL; - } - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&replyport,sizeof(port_id))) - { - bufferlength+=sizeof(port_id); - } - else - { - delete pld; - *status=B_ERROR; - return NULL; - } - - // Flatten() inlined to make some necessary changes - int8 *buffer=new int8[bufferlength]; - int8 *bufferindex=buffer; - size_t size=0; - - // attach our port_id first - memcpy(bufferindex, pld->buffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - - // attach everything else - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - } - - // Flush the thing....FOOSH! :P - write_port(target,opcode,buffer,size); - MakeEmpty(); - delete buffer; - - // Now we wait for the reply - if(timeout==B_INFINITE_TIMEOUT) - { - *buffersize=port_buffer_size(replyport); - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - else - { - *buffersize=port_buffer_size_etc(replyport,0,timeout); - if(*buffersize==B_TIMED_OUT) - { - *status=*buffersize; - return NULL; - } - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - - // We got this far, so we apparently have some data - *status=B_OK; - return buffer; -} - -void PortLink::Attach(void *data, size_t size) -{ - // This is the member called to attach data to a message. Attachments are - // treated to be in 'Append' mode, tacking on each attached piece of data - // to the end of the list. - - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - if(size==0) - return; - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -// These functions were added for a major convenience in passing common types -// Eventually, I'd like to templatize these, but for now, this'll do - -void PortLink::Attach(int32 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int32); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int16 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int16); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int8 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int8); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(float data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(float); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(bool data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(bool); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BRect data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BRect); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BPoint data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BPoint); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::FlattenData(int8 **buffer,int32 *size) -{ - // This function is where all the magic happens, but it is strictly internal. - // It iterates through each PortLinkData object and copies it to the main buffer - // which ends up, ultimately, being written to the PortLink's target port. - - // skip if there aree no attachments - if(bufferlength<1) - return; - - *buffer=new int8[bufferlength]; - int8 *bufferindex=*buffer; - PortLinkData *pld; - *size=0; - - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - *size+=pld->buffersize; - } -} - -void PortLink::MakeEmpty(void) -{ - // Nukes all the attachments currently held by the PortLink class - if(num_attachments!=0) - { - for(int i=0; i0) - free(buffer); -} - -bool PortLinkData::Set(void *data, size_t size) -{ - // Function copies the passed to the internal buffers for storage - if(size>0 && buffersize==0 && data!=NULL) - { - buffer=(char *)malloc(size); - if(buffer==NULL) - return false; - memcpy(buffer, data, size); - buffersize=size; - return true; - } - return false; -} diff --git a/src/servers/app/proto5/testobapp/PortLink.h b/src/servers/app/proto5/testobapp/PortLink.h deleted file mode 100644 index 9f5432daab..0000000000 --- a/src/servers/app/proto5/testobapp/PortLink.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _PORTLINK_H_ -#define _PORTLINK_H_ - -#include -#include -#include -#include - -#ifndef _PORTLINK_BUFFERSIZE -#define _PORTLINK_MAX_ATTACHMENTS 50 -#endif - -class PortLinkData; - -class PortLink -{ -public: - PortLink(port_id port); - ~PortLink(void); - void SetOpCode(int32 code); - void SetPort(port_id port); - port_id GetPort(void); - void Flush(bigtime_t timeout=B_INFINITE_TIMEOUT); - int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, - bigtime_t timeout=B_INFINITE_TIMEOUT); - void Attach(void *data, size_t size); - void Attach(int32 data); - void Attach(int16 data); - void Attach(int8 data); - void Attach(float data); - void Attach(bool data); - void Attach(BRect data); - void Attach(BPoint data); - void MakeEmpty(void); -protected: - void FlattenData(int8 **buffer,int32 *size); - port_id target, replyport; - int32 opcode, bufferlength; - int num_attachments; - PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS]; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/testobapp/ServerProtocol.h b/src/servers/app/proto5/testobapp/ServerProtocol.h deleted file mode 100644 index 1c8c3f3fdf..0000000000 --- a/src/servers/app/proto5/testobapp/ServerProtocol.h +++ /dev/null @@ -1,94 +0,0 @@ -#ifndef _APPSERVER_PROTOCOL_ -#define _APPSERVER_PROTOCOL_ - -#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' - -#define SERVER_PORT_NAME "OBappserver" -#define SERVER_INPUT_PORT "OBinputport" - -#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 GFX_COUNT_WORKSPACES 'gcws' -#define GFX_SET_WORKSPACE_COUNT 'ggwc' -#define GFX_CURRENT_WORKSPACE 'ggcw' -#define GFX_ACTIVATE_WORKSPACE 'gaws' -#define GFX_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' - -#define GFX_SET_HIGH_COLOR 'gshc' -#define GFX_SET_LOW_COLOR 'gslc' -#define GFX_SET_VIEW_COLOR 'gsvc' - -#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' - -#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' - -#define GFX_MOVEPENBY 'gmpb' -#define GFX_MOVEPENTO 'gmpt' -#define GFX_SETPENSIZE 'gsps' - -#define GFX_DRAW_STRING 'gdst' -#define GFX_SET_FONT 'gsft' -#define GFX_SET_FONT_SIZE 'gsfs' - -#define GFX_FLUSH 'gfsh' -#define GFX_SYNC 'gsyn' - -#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 BEGIN_RECT_TRACKING 'rtbg' -#define END_RECT_TRACKING 'rten' - -#define VIEW_GET_TOKEN 'vgtk' -#define VIEW_ADD 'vadd' -#define VIEW_REMOVE 'vrem' -#endif \ No newline at end of file diff --git a/src/servers/app/proto5/testobapp/TODO b/src/servers/app/proto5/testobapp/TODO deleted file mode 100644 index e7bb1f2efa..0000000000 --- a/src/servers/app/proto5/testobapp/TODO +++ /dev/null @@ -1,3 +0,0 @@ -Write server-side Add/Remove View code -Figure out a good screen update protocol -Flesh out OBWindow::MessageReceived() diff --git a/src/servers/app/proto6/AppServer.cpp b/src/servers/app/proto6/AppServer.cpp deleted file mode 100644 index 233bdef0d7..0000000000 --- a/src/servers/app/proto6/AppServer.cpp +++ /dev/null @@ -1,584 +0,0 @@ -/* - AppServer.cpp - File for the main app_server thread. This particular thread monitors for - application start and quit messages. It also starts the housekeeping threads - and initializes most of the server's globals. -*/ -#include -#include -#include "scheduler.h" -#include -#include -#include -#include -#include "AppServer.h" -#include "Layer.h" -#include "ServerApp.h" -#include "ServerWindow.h" -#include "Desktop.h" -#include "ServerProtocol.h" -#include "PortLink.h" -#include "DisplayDriver.h" -#include "DebugTools.h" -#include "BeDecorator.h" -#include "WinDecorator.h" -#include "YMakDecorator.h" - -//#define DEBUG_APPSERVER_THREAD - -// This bad boy holds only the top layer for each workspace -//BList *layerlist; - -// Used for mediating access to the layer lists -//BLocker *layerlock; - -// Used for access via instantiate_decorator -AppServer *app_server; - -AppServer::AppServer(void) : BApplication("application/x-vnd.obe-OBAppServer") -{ -#ifdef DEBUG_APPSERVER_THREAD - printf("AppServer()\n"); -#endif - - mouseport=create_port(30,SERVER_INPUT_PORT); - messageport=create_port(20,SERVER_PORT_NAME); -#ifdef DEBUG_APPSERVER_THREAD -printf("Server message port: %ld\n",messageport); -printf("Server input port: %ld\n",mouseport); -#endif - applist=new BList(0); - quitting_server=false; - exit_poller=false; - - // Set up the Desktop - init_desktop(3); - - // This is necessary to mediate access between the Poller and app_server threads - active_lock=new BLocker; - - // This locker is for app_server and Picasso to vy for control of the ServerApp list - applist_lock=new BLocker; - - // This locker is to mediate access to the make_decorator pointer - decor_lock=new BLocker; - - // Get the driver first - Poller thread utilizes the thing - driver=get_gfxdriver(); - - // Spawn our input-polling thread - 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); - if (picasso_id >= 0) - resume_thread(picasso_id); - - active_app=-1; - p_active_app=NULL; - - make_decorator=NULL; -// layerlock=new BLocker; -// layerlist=new BList(1); -} - -AppServer::~AppServer(void) -{ - shutdown_desktop(); - - ServerApp *tempapp; -// Layer *templayer; - int32 i; - applist_lock->Lock(); - for(i=0;iCountItems();i++) - { - tempapp=(ServerApp *)applist->ItemAt(i); - if(tempapp!=NULL) - delete tempapp; - } - delete applist; - applist_lock->Unlock(); - -/* layerlock->Lock(); - for(i=0;iCountItems();i++) - { - templayer=(Layer *)layerlist->ItemAt(i); - - if(templayer!=NULL) - { - templayer->PruneTree(); - delete templayer; - } - } - delete layerlist; - layerlock->Unlock(); - - delete layerlock; -*/ delete active_lock; - delete applist_lock; - - // If these threads are still running, kill them - after this, if exit_poller - // is deleted, who knows what will happen... These things will just return an - // error and fail if the threads have already exited. - kill_thread(poller_id); - kill_thread(picasso_id); - - delete decor_lock; - - make_decorator=NULL; -} - -thread_id AppServer::Run(void) -{ -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer::Run()\n"); -#endif - - MainLoop(); - return 0; -} - -void AppServer::MainLoop(void) -{ - // Main loop (duh). Monitors the message queue and dispatches as appropriate. - // Input messages are handled by the poller, however. - -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer::MainLoop()\n"); -#endif - - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(messageport); - if(buffersize>0) - msgbuffer=new int8[buffersize]; - bytesread=read_port(messageport,&msgcode,msgbuffer,buffersize); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case CREATE_APP: - case DELETE_APP: - case GET_SCREEN_MODE: - case B_QUIT_REQUESTED: - DispatchMessage(msgcode,msgbuffer); - break; - default: - { -#ifdef DEBUG_APPSERVER_THREAD -printf("Server received unexpected code %ld\n",msgcode); -#endif - break; - } - } - - } - - if(buffersize>0) - delete msgbuffer; - if(msgcode==DELETE_APP || msgcode==B_QUIT_REQUESTED) - { - 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); - -} - - -void AppServer::DispatchMessage(int32 code, int8 *buffer) -{ - int8 *index=buffer; - switch(code) - { - case CREATE_APP: - { - // Create the ServerApp to node monitor a new BApplication - -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer: Create App\n"); -#endif - - // Attached data: - // 1) port_id - port to reply to - // 2) port_id - receiver port of a regular app - // 3) char * - signature of the regular app - - // Find the necessary data - port_id reply_port=*((port_id*)index); index+=sizeof(port_id); - port_id app_port=*((port_id*)index); index+=sizeof(port_id); - - char *app_signature=(char *)index; - - // Create the ServerApp subthread for this app - applist_lock->Lock(); - ServerApp *newapp=new ServerApp(app_port,app_signature); - applist->AddItem(newapp); - applist_lock->Unlock(); - - active_lock->Lock(); - p_active_app=newapp; - active_app=applist->CountItems()-1; - - PortLink *replylink=new PortLink(reply_port); - replylink->SetOpCode(SET_SERVER_PORT); - replylink->Attach((int32)newapp->receiver); - replylink->Flush(); - - delete replylink; - - active_lock->Unlock(); - - newapp->Run(); - - break; - } - case DELETE_APP: - { - // Delete a ServerApp. Received only from the respective ServerApp when a - // BApplication asks it to quit. - -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer: Delete App\n"); -#endif - - // Attached Data: - // 1) thread_id - thread ID of the ServerApp to be deleted - - int32 i, appnum=applist->CountItems(); - ServerApp *srvapp; - thread_id srvapp_id=*((thread_id*)buffer); - - // Run through the list of apps and nuke the proper one - for(i=0;iItemAt(i); - - if(srvapp!=NULL && srvapp->monitor_thread==srvapp_id) - { - applist_lock->Lock(); - srvapp=(ServerApp *)applist->RemoveItem(i); - if(srvapp) - { - delete srvapp; - srvapp=NULL; - } - applist_lock->Unlock(); - active_lock->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; - active_lock->Unlock(); - break; // jump out of our for() loop - } - - } - break; - } - case 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 - // BScreens are done. - -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer: Get Screen Mode\n"); -#endif - // Attached Data: - // 1) port_id - port to reply to - - // Returned Data: - // 1) int32 width - // 2) int32 height - // 3) int depth - - PortLink *replylink=new PortLink(*((port_id*)index)); - replylink->SetOpCode(GET_SCREEN_MODE); - replylink->Attach(driver->GetWidth()); - replylink->Attach(driver->GetHeight()); - replylink->Attach((int16)driver->GetDepth()); - replylink->Flush(); - delete replylink; - break; - } - case B_QUIT_REQUESTED: - { -#ifdef DEBUG_APPSERVER_THREAD -printf("Shutdown sequence initiated.\n"); -#endif - - // Attached Data: - // none - - // 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. - PortLink *applink=new PortLink(0); - ServerApp *srvapp; - - applist_lock->Lock(); - int32 i,appnum=applist->CountItems(); - - applink->SetOpCode(QUIT_APP); - for(i=0;iItemAt(i); - if(srvapp!=NULL) - { - applink->SetPort(srvapp->receiver); - applink->Flush(); - } - } - applist_lock->Unlock(); - - delete applink; - // So when we delete the last ServerApp, we can exit the server - quitting_server=true; - exit_poller=true; - break; - } - default: - //printf("Unexpected message %ld (%lx) in AppServer::DispatchMessage()\n",code,code); - break; - } -} - -bool AppServer::LoadDecorator(BString path) -{ - // Loads a window decorator based on the supplied path and forces a decorator update. - // If it cannot load the specified decorator, it will retain the current one and - // return false. - - create_decorator *pcreatefunc=NULL; - get_decorator_version *pversionfunc=NULL; - status_t stat; - image_id addon; - - addon=load_add_on(path.String()); - - stat=get_image_symbol(addon, "get_decorator_version", B_SYMBOL_TYPE_TEXT, (void**)&pversionfunc); - if(stat!=B_OK) - { - printf("ERROR: Could not get version for Decorator %s\n", path.String()); - unload_add_on(addon); - return false; - } - - // As of now, we do nothing with decorator versions, but the possibility exists - // that the API will change even though I cannot forsee any reason to do so. If - // we *did* do anything with decorator versions, the assignment to a global would - // go here. - - stat=get_image_symbol(addon, "get_decorator_version", B_SYMBOL_TYPE_TEXT, (void**)&pversionfunc); - if(stat!=B_OK) - { - printf("ERROR: Could not get version for Decorator %s\n", path.String()); - unload_add_on(addon); - return false; - } - decor_lock->Lock(); - make_decorator=pcreatefunc; - decorator_id=addon; - decor_lock->Unlock(); - return true; -} - -void AppServer::LoadDefaultDecorator(void) -{ - // This function is called on server startup to provide a fallback decorator in - // case the decorator specified in the config file cannot be loaded. It just - // wouldn't do to have windows with no borders. ;) It also unloads any loaded - // decorator addons. We can specify that we want the default. It is no less - // functional - just internal. - -} - -Decorator *instantiate_decorator(Layer *lay, uint32 dflags, uint32 wlook) -{ - Decorator *decor=NULL; - - app_server->decor_lock->Lock(); - if(app_server->make_decorator!=NULL) - decor=app_server->make_decorator(lay, dflags, wlook); - else - { - decor=new BeDecorator(lay, dflags, wlook); -// decor=new WinDecorator(lay, dflags, wlook); -// decor=new YMakDecorator(lay, dflags, wlook); - } - - app_server->decor_lock->Unlock(); - return decor; -} - -void AppServer::Poller(void) -{ - // This thread handles nothing but input messages for mouse and keyboard - int32 msgcode; - int8 *msgbuffer=NULL,*index; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(mouseport); - if(buffersize>0) - msgbuffer=new int8[buffersize]; - bytesread=read_port(mouseport,&msgcode,msgbuffer,buffersize); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - // We don't need to do anything with these two, so just pass them - // onto the active application. Eventually, we will pass them onto - // the window which is currently under the cursor. - case B_MOUSE_DOWN: - case B_MOUSE_UP: - { -/* - active_lock->Lock(); - if(active_app>-1 && p_active_app!=NULL) - write_port(p_active_app->receiver, msgcode,msgbuffer,buffersize); - active_lock->Unlock(); -*/ - ServerWindow::HandleMouseEvent(msgcode,msgbuffer); - 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 - - index=msgbuffer; - - // Time sent is not necessary for cursor processing. - index += sizeof(int64); - - float tempx=0,tempy=0; - tempx=*((float*)index); - index+=sizeof(float); - tempy=*((float*)index); - index+=sizeof(float); - - driver->MoveCursorTo(tempx,tempy); - -/* active_lock->Lock(); - if(active_app>-1 && p_active_app!=NULL) - write_port(p_active_app->receiver, msgcode,msgbuffer,buffersize); - active_lock->Unlock(); -*/ - ServerWindow::HandleMouseEvent(msgcode,msgbuffer); - break; - } - default: - //printf("Server::Poller received unexpected code %ld\n",msgcode); - break; - } - - } - - if(buffersize>0) - delete msgbuffer; - - if(exit_poller) - break; - } -} - -int32 AppServer::PollerThread(void *data) -{ -#ifdef DEBUG_APPSERVER_THREAD -printf("Starting Poller thread...\n"); -#endif - AppServer *server=(AppServer *)data; - - // This won't return until it's told to - server->Poller(); - -#ifdef DEBUG_APPSERVER_THREAD -printf("Exiting Poller thread...\n"); -#endif - exit_thread(B_OK); - return B_OK; -} - -void AppServer::Picasso(void) -{ - int32 i; - ServerApp *app; - for(;;) - { - applist_lock->Lock(); - for(i=0;iCountItems(); i++) - { - app=(ServerApp*)applist->ItemAt(i); - ASSERT(app!=NULL); - app->PingTarget(); - } - applist_lock->Unlock(); - - // if poller thread has to exit, so do we - I just was too lazy - // to rename the variable name. ;) - if(exit_poller) - break; - - // we do this every other second so as not to suck *too* many CPU cycles - snooze(2000000); - } -} - -int32 AppServer::PicassoThread(void *data) -{ -#ifdef DEBUG_APPSERVER_THREAD -printf("Starting Picasso thread...\n"); -#endif - AppServer *server=(AppServer *)data; - - // This won't return until it's told to - server->Picasso(); - -#ifdef DEBUG_APPSERVER_THREAD -printf("Exiting Picasso thread...\n"); -#endif - exit_thread(B_OK); - return B_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(); - app_server->Run(); - delete app_server; - return 0; -} diff --git a/src/servers/app/proto6/AppServer.h b/src/servers/app/proto6/AppServer.h deleted file mode 100644 index 30fb9fcd9e..0000000000 --- a/src/servers/app/proto6/AppServer.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _OPENBEOS_APP_SERVER_H_ -#define _OPENBEOS_APP_SERVER_H_ - -#include -#include -#include -#include -//#include // for window_look -#include "Decorator.h" - -class Layer; -class BMessage; -class ServerApp; -class DisplayDriver; - -class AppServer : public BApplication -{ -public: - AppServer(void); - ~AppServer(void); - thread_id Run(void); - void MainLoop(void); - port_id messageport,mouseport; - void Poller(void); - void Picasso(void); - -private: - friend Decorator *instantiate_decorator(Layer *lay, uint32 dflags, uint32 wlook); - - void DispatchMessage(int32 code, int8 *buffer); - static int32 PollerThread(void *data); - static int32 PicassoThread(void *data); - bool LoadDecorator(BString path); - void LoadDefaultDecorator(void); - - image_id decorator_id; - create_decorator *make_decorator; // global function pointer - bool quitting_server; - BList *applist; - int32 active_app; - ServerApp *p_active_app; - thread_id poller_id, picasso_id; - - BLocker *active_lock, *applist_lock, *decor_lock; - bool exit_poller; - DisplayDriver *driver; -}; - -Decorator *instantiate_decorator(Layer *lay, uint32 dflags, uint32 wlook); -#endif diff --git a/src/servers/app/proto6/BeDecorator.cpp b/src/servers/app/proto6/BeDecorator.cpp deleted file mode 100644 index b5935bb81b..0000000000 --- a/src/servers/app/proto6/BeDecorator.cpp +++ /dev/null @@ -1,530 +0,0 @@ -#include "Layer.h" -#include "DisplayDriver.h" -#include -#include "BeDecorator.h" -#include "ColorUtils.h" - -//#define DEBUG_DECOR - -#ifdef DEBUG_DECOR -#include -#endif - -BeDecorator::BeDecorator(Layer *lay, uint32 dflags, uint32 wlook) - : Decorator(lay, dflags, wlook) -{ -#ifdef DEBUG_DECOR -printf("BeDecorator()\n"); -#endif - zoomstate=false; - closestate=false; - taboffset=0; - - // These hard-coded assignments will go bye-bye when the system colors - // API is implemented - - // commented these out because they are taken care of by the SetFocus() call - SetFocus(false); -// SetRGBColor(&tab_highcol,255,236,33); -// SetRGBColor(&tab_lowcol,234,181,0); - -// SetRGBColor(&button_highcol,255,255,0); -// SetRGBColor(&button_lowcol,255,203,0); - - SetRGBColor(&frame_highercol,216,216,216); - SetRGBColor(&frame_lowercol,110,110,110); - - SetRGBColor(&textcol,0,0,0); - - frame_highcol=MakeBlendColor(frame_lowercol,frame_highercol,0.75); - frame_midcol=MakeBlendColor(frame_lowercol,frame_highercol,0.5); - frame_lowcol=MakeBlendColor(frame_lowercol,frame_highercol,0.25); - - Resize(lay->frame); - - // We need to modify the visible rectangle because we have tabbed windows - if(lay->visible) - { - delete lay->visible; - lay->visible=GetFootprint(); - } - - // This flag is used to determine whether or not we're moving the tab - slidetab=false; -} - -BeDecorator::~BeDecorator(void) -{ -#ifdef DEBUG_DECOR -printf("~BeDecorator()\n"); -#endif -} - -click_type BeDecorator::Clicked(BPoint pt, uint32 buttons) -{ - // Clicked is a hit-testing function which is called by each - // decorator object's respective WindowBorder. When a click or - // mouse message is received, we must return to the WindowBorder - // what the click meant to us and the appropriate action for it - // to take. - - // the case order is important - we go from smallest to largest - // for efficiency's sake. - if(closerect.Contains(pt)) - { - -#ifdef DEBUG_DECOR -printf("BeDecorator():Clicked() - Close\n"); -#endif - - return CLICK_CLOSE; - } - - if(zoomrect.Contains(pt)) - { - -#ifdef DEBUG_DECOR -printf("BeDecorator():Clicked() - Zoom\n"); -#endif - - return CLICK_ZOOM; - } - - if(resizerect.Contains(pt) && dlook==WLOOK_DOCUMENT) - { - -#ifdef DEBUG_DECOR -printf("BeDecorator():Clicked() - Resize thumb\n"); -#endif - - return CLICK_RESIZE; - } - - // Clicking in the tab? - if(tabrect.Contains(pt)) - { - // Here's part of our window management stuff - if(buttons==B_PRIMARY_MOUSE_BUTTON && !focused) - return CLICK_MOVETOFRONT; - if(buttons==B_SECONDARY_MOUSE_BUTTON) - return CLICK_MOVETOBACK; - return CLICK_DRAG; - } - - // We got this far, so user is clicking on the border? - BRect brect(frame); - brect.top+=19; - BRect clientrect(brect.InsetByCopy(3,3)); - if(brect.Contains(pt) && !clientrect.Contains(pt)) - { -#ifdef DEBUG_DECOR -printf("BeDecorator():Clicked() - Drag\n"); -#endif - if(resizerect.Contains(pt)) - return CLICK_RESIZE; - - return CLICK_DRAG; - } - - // Guess user didn't click anything -#ifdef DEBUG_DECOR -printf("BeDecorator():Clicked()\n"); -#endif - return CLICK_NONE; -} - -void BeDecorator::Resize(BRect rect) -{ - // Here we determine the size of every rectangle that we use - // internally when we are given the size of the client rectangle. - - // Current version simply makes everything fit inside the rect - // instead of building around it. This will change. - -#ifdef DEBUG_DECOR -printf("BeDecorator()::Resize()"); rect.PrintToStream(); -#endif - frame=rect; - tabrect=frame; - resizerect=frame; - borderrect=frame; - closerect=frame; - - closerect.left+=(dlook==WLOOK_FLOATING)?2:4; - closerect.top+=(dlook==WLOOK_FLOATING)?6:4; - closerect.right=closerect.left+10; - closerect.bottom=closerect.top+10; - - borderrect.top+=19; - - resizerect.top=resizerect.bottom-18; - resizerect.left=resizerect.right-18; - - tabrect.bottom=tabrect.top+18; - if(layer->name) - { - float titlewidth=closerect.right - +driver->StringWidth(layer->name->String(), - layer->name->Length()) - +35; - tabrect.right=(titlewidthInclude(tabrect); - return reg; -} - -void BeDecorator::SetFlags(uint32 wflags) -{ - dflags=wflags; -} - -void BeDecorator::UpdateFont(void) -{ - // This will be updated once font capability is implemented -} - -void BeDecorator::UpdateTitle(const char *string) -{ - // Designed simply to redraw the title when it has changed on - // the client side. - if(string) - { - driver->SetDrawingMode(B_OP_OVER); - rgb_color tmpcol=driver->HighColor(); - driver->SetHighColor(textcol.red,textcol.green,textcol.blue); - driver->DrawString((char *)string,strlen(string), - BPoint(closerect.right+textoffset,closerect.bottom-1)); - driver->SetHighColor(tmpcol.red,tmpcol.green,tmpcol.blue); - driver->SetDrawingMode(B_OP_COPY); - } - -} - -void BeDecorator::SetFocus(bool bfocused) -{ - // SetFocus() performs necessary duties for color swapping and - // other things when a window is deactivated or activated. - - focused=bfocused; - - if(focused) - { - SetRGBColor(&tab_highcol,255,236,33); - SetRGBColor(&tab_lowcol,234,181,0); - - SetRGBColor(&button_highcol,255,255,0); - SetRGBColor(&button_lowcol,255,203,0); - } - else - { - SetRGBColor(&tab_highcol,235,235,235); - SetRGBColor(&tab_lowcol,160,160,160); - - SetRGBColor(&button_highcol,229,229,229); - SetRGBColor(&button_lowcol,153,153,153); - } - -} - -void BeDecorator::Draw(BRect update) -{ - // We need to draw a few things: the tab, the resize thumb, the borders, - // and the buttons - - if(tabrect.Intersects(update)) - DrawTab(); - - // Draw the top view's client area - just a hack :) - rgb_color blue={100,100,255,255}; - - if(borderrect.Intersects(update)) - driver->FillRect(borderrect,blue); - - DrawFrame(); -} - -void BeDecorator::Draw(void) -{ - // Easy way to draw everything - no worries about drawing only certain - // things - - DrawTab(); - - // Draw the top view's client area - just a hack :) - rgb_color blue={100,100,255,255}; - driver->FillRect(borderrect,blue); - - DrawFrame(); -} - -void BeDecorator::DrawZoom(BRect r) -{ - // If this has been implemented, then the decorator has a Zoom button - // which should be drawn based on the state of the member zoomstate - BRect zr=r; - zr.left+=zr.Width()/3; - zr.top+=zr.Height()/3; - - DrawBlendedRect(zr,zoomstate); - DrawBlendedRect(zr.OffsetToCopy(r.LeftTop()),zoomstate); -} - -void BeDecorator::DrawClose(BRect r) -{ - // Just like DrawZoom, but for a close button - DrawBlendedRect(r,closestate); -} - -void BeDecorator::DrawTab(void) -{ - // If a window has a tab, this will draw it and any buttons which are - // in it. - if(dlook==WLOOK_NO_BORDER) - return; - - rgb_color tmpcol; - float rstep,gstep,bstep; - - int steps=tabrect.IntegerHeight(); - rstep=float(tab_highcol.red-tab_lowcol.red)/steps; - gstep=float(tab_highcol.green-tab_lowcol.green)/steps; - bstep=float(tab_highcol.blue-tab_lowcol.blue)/steps; - - driver->StrokeRect(tabrect,frame_lowcol); - driver->BeginLineArray(steps+1); - for(float i=1;i<=steps; i++) - { - SetRGBColor(&tmpcol, uint8(tab_highcol.red-(i*rstep)), - uint8(tab_highcol.green-(i*gstep)), - uint8(tab_highcol.blue-(i*bstep))); - driver->AddLine(BPoint(tabrect.left+1,tabrect.top+i), - BPoint(tabrect.right-1,tabrect.top+i),tmpcol); - } - driver->EndLineArray(); - UpdateTitle(layer->name->String()); - - // Draw the buttons if we're supposed to - if(!(dflags & NOT_CLOSABLE)) - DrawClose(closerect); - if(!(dflags & NOT_ZOOMABLE)) - DrawZoom(zoomrect); -} - -void BeDecorator::DrawBlendedRect(BRect r, bool down) -{ - // This bad boy is used to draw a rectangle with a gradient. - // Note that it is not part of the Decorator API - it's specific - // to just the BeDecorator. Called by DrawZoom and DrawClose - - // Actually just draws a blended square - int32 w=r.IntegerWidth(), h=r.IntegerHeight(); - - rgb_color tmpcol,halfcol, startcol, endcol; - float rstep,gstep,bstep,i; - - int steps=(wStrokeLine(BPoint(r.left,r.top+i), - BPoint(r.left+i,r.top),tmpcol); - - SetRGBColor(&tmpcol, uint8(halfcol.red-(i*rstep)), - uint8(halfcol.green-(i*gstep)), - uint8(halfcol.blue-(i*bstep))); - driver->StrokeLine(BPoint(r.left+steps,r.top+i), - BPoint(r.left+i,r.top+steps),tmpcol); - - } - driver->StrokeRect(r,frame_lowcol); -} - -void BeDecorator::DrawFrame(void) -{ - // Duh, draws the window frame, I think. ;) - - if(dlook==WLOOK_NO_BORDER) - return; - - BRect r=borderrect; - - driver->BeginLineArray(12); - driver->AddLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top), - frame_midcol); - driver->AddLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom), - frame_lowcol); - driver->AddLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top), - frame_lowercol); - driver->AddLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom), - frame_lowercol); - - r.InsetBy(1,1); - driver->AddLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top), - frame_highercol); - driver->AddLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom), - frame_highercol); - driver->AddLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top), - frame_midcol); - driver->AddLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom), - frame_midcol); - - r.InsetBy(1,1); - driver->StrokeRect(r,frame_highcol); - - r.InsetBy(1,1); - driver->AddLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top), - frame_lowercol); - driver->AddLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom), - frame_lowercol); - driver->AddLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top), - frame_highercol); - driver->AddLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom), - frame_highercol); - driver->EndLineArray(); - - // Draw the resize thumb if we're supposed to - if(!(dflags & NOT_RESIZABLE)) - { - r=resizerect; - - int32 w=r.IntegerWidth(), h=r.IntegerHeight(); - - // This code is strictly for B_DOCUMENT_WINDOW looks - if(dlook==WLOOK_DOCUMENT) - { - rgb_color tmpcol,halfcol, startcol, endcol; - float rstep,gstep,bstep,i; - - int steps=(wStrokeLine(BPoint(r.left,r.top+i), - BPoint(r.left+i,r.top),tmpcol); - - SetRGBColor(&tmpcol, uint8(halfcol.red-(i*rstep)), - uint8(halfcol.green-(i*gstep)), - uint8(halfcol.blue-(i*bstep))); - driver->StrokeLine(BPoint(r.left+steps,r.top+i), - BPoint(r.left+i,r.top+steps),tmpcol); - } - driver->StrokeRect(r,frame_lowercol); - } - else - { - driver->StrokeLine(BPoint(r.right,r.top),BPoint(r.right-3,r.top), - frame_lowercol); - driver->StrokeLine(BPoint(r.left,r.bottom),BPoint(r.left,r.bottom-3), - frame_lowercol); - } - } -} - -void BeDecorator::SetLook(uint32 wlook) -{ - dlook=wlook; -} - -void BeDecorator::CalculateBorders(void) -{ - // Here we calculate the size of the border on each side - how much the - // decorator's visible area "sticks out" past the client rectangle. - switch(dlook) - { - case WLOOK_NO_BORDER: - { - bsize.Set(0,0,0,0); - break; - } - case WLOOK_TITLED: - case WLOOK_DOCUMENT: - case WLOOK_BORDERED: - { - bsize.top=18; - break; - } - case WLOOK_MODAL: - case WLOOK_FLOATING: - { - bsize.top=15; - break; - } - default: - { - break; - } - } -} diff --git a/src/servers/app/proto6/BeDecorator.h b/src/servers/app/proto6/BeDecorator.h deleted file mode 100644 index bb16d14bc5..0000000000 --- a/src/servers/app/proto6/BeDecorator.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef _BEOS_DECORATOR_H_ -#define _BEOS_DECORATOR_H_ - -#include "Decorator.h" - -class BeDecorator: public Decorator -{ -public: - BeDecorator(Layer *lay, uint32 dflags, uint32 wlook); - ~BeDecorator(void); - - click_type Clicked(BPoint pt, uint32 buttons); - void Resize(BRect rect); - void MoveBy(BPoint pt); - BPoint GetMinimumSize(void); - BRegion *GetFootprint(void); - void SetTitle(const char *newtitle); - void SetFlags(uint32 flags); - void SetLook(uint32 wlook); - void UpdateFont(void); - void UpdateTitle(const char *string); - void SetFocus(bool focused); - void Draw(void); - void Draw(BRect update); - void DrawZoom(BRect r); - void DrawClose(BRect r); - void DrawTab(void); - void DrawFrame(void); - void CalculateBorders(void); - - void DrawBlendedRect(BRect r, bool down); - uint32 taboffset; - - rgb_color tab_highcol, tab_lowcol; - rgb_color button_highcol, button_lowcol; - rgb_color frame_highcol, frame_midcol, frame_lowcol, frame_highercol, - frame_lowercol; - rgb_color textcol; - - bool slidetab; - BRect zoomrect,closerect,tabrect,frame, - resizerect,borderrect; - int textoffset; -}; - -#endif diff --git a/src/servers/app/proto6/ColorUtils.cc b/src/servers/app/proto6/ColorUtils.cc deleted file mode 100644 index 510476eca9..0000000000 --- a/src/servers/app/proto6/ColorUtils.cc +++ /dev/null @@ -1,101 +0,0 @@ -#include "ColorUtils.h" -#include -#include - -//#define DEBUG_COLOR_UTILS - -void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a=255) -{ - col->red=r; - col->green=g; - col->blue=b; - col->alpha=a; -} - -uint8 FindClosestColor(rgb_color *palette, rgb_color color) -{ - // We will be passed a 256-color palette and a 24-bit color - uint16 cindex=0,cdelta=765,delta=765; - rgb_color *c; - - for(uint16 i=0;i<256;i++) - { - c=&(palette[i]); - delta=abs(c->red-color.red)+abs(c->green-color.green)+ - abs(c->blue-color.blue); - - if(delta==0) - { - cindex=i; - break; - } - - if(delta1) - return newcol; - - delta=int16(col2.red)-int16(col.red); - mod=col.red + (position * delta); - newcol.red=uint8(mod); - if(mod>255 ) - newcol.red=255; - if(mod<0 ) - newcol.red=0; - - delta=int16(col2.green)-int16(col.green); - mod=col.green + (position * delta); - newcol.green=uint8(mod); - if(mod>255 ) - newcol.green=255; - if(mod<0 ) - newcol.green=0; - - delta=int16(col2.blue)-int16(col.blue); - mod=col.blue + (position * delta); - newcol.blue=uint8(mod); - if(mod>255 ) - newcol.blue=255; - if(mod<0 ) - newcol.blue=0; - - delta=int8(col2.alpha)-int8(col.alpha); - mod=col.alpha + (position * delta); - newcol.alpha=uint8(mod); - if(mod>255 ) - newcol.alpha=255; - if(mod<0 ) - newcol.alpha=0; -#ifdef DEBUG_COLOR_UTILS -printf("MakeBlendColor( {%u,%u,%u,%u}, {%u,%u,%u,%u}, %f) : {%u,%u,%u,%u}\n", - col.red,col.green,col.blue,col.alpha, - col2.red,col2.green,col2.blue,col2.alpha, - position, - newcol.red,newcol.green,newcol.blue,newcol.alpha); -#endif - return newcol; -} diff --git a/src/servers/app/proto6/ColorUtils.h b/src/servers/app/proto6/ColorUtils.h deleted file mode 100644 index 3eb674bc46..0000000000 --- a/src/servers/app/proto6/ColorUtils.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef COLORUTILS_H_ -#define COLORUTILS_H_ - -#include - -// Quick assignment for rgb_color structs -void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a=255); - -// Given a color palette, returns the index of the closest match to -// the color passed to it. Alpha values are not considered -uint8 FindClosestColor(rgb_color *palette, rgb_color color); -uint16 FindClosestColor16(rgb_color color); - -// Function which could be used to calculate gradient colors. Position is -// a floating point number such that 0.0 <= position <= 1.0. Any number outside -// this range will cause the function to fail and return the color (0,0,0,0) -// Alpha components are included in the calculations. 0 yields color #1 -// and 1 yields color #2. -rgb_color MakeBlendColor(rgb_color col, rgb_color col2, float position); -#endif diff --git a/src/servers/app/proto6/DebugTools.cpp b/src/servers/app/proto6/DebugTools.cpp deleted file mode 100644 index f626e927be..0000000000 --- a/src/servers/app/proto6/DebugTools.cpp +++ /dev/null @@ -1,222 +0,0 @@ -#include -#include -#include "DebugTools.h" - -void PrintStatusToStream(status_t value) -{ - // Function which simply translates a returned status code into a string - // and dumps it to stdout - cout << "Status: " << TranslateStatusToString(value).String() << endl << flush; -} - -BString TranslateStatusToString(status_t value) -{ - BString outstr; - switch(value) - { - case B_OK: - outstr="B_OK "; - break; - case B_NAME_NOT_FOUND: - outstr="B_NAME_NOT_FOUND "; - break; - case B_BAD_VALUE: - outstr="B_BAD_VALUE "; - break; - case B_ERROR: - outstr="B_ERROR "; - break; - case B_TIMED_OUT: - outstr="B_TIMED_OUT "; - break; - case B_NO_MORE_PORTS: - outstr="B_NO_MORE_PORTS "; - break; - case B_WOULD_BLOCK: - outstr="B_WOULD_BLOCK "; - break; - case B_BAD_PORT_ID: - outstr="B_BAD_PORT_ID "; - break; - case B_BAD_TEAM_ID: - outstr="B_BAD_TEAM_ID "; - break; - default: - outstr="undefined status value in debugtools::PrintStatusToStream() "; - break; - } - return BString(outstr); -} - -void PrintColorSpaceToStream(color_space value) -{ - // Dump a color space to cout - BString outstr; - switch(value) - { - case B_RGB32: - outstr="B_RGB32 "; - break; - case B_RGBA32: - outstr="B_RGBA32 "; - break; - case B_RGB32_BIG: - outstr="B_RGB32_BIG "; - break; - case B_RGBA32_BIG: - outstr=" "; - break; - case B_UVL32: - outstr="B_UVL32 "; - break; - case B_UVLA32: - outstr="B_UVLA32 "; - break; - case B_LAB32: - outstr="B_LAB32 "; - break; - case B_LABA32: - outstr="B_LABA32 "; - break; - case B_HSI32: - outstr="B_HSI32 "; - break; - case B_HSIA32: - outstr="B_HSIA32 "; - break; - case B_HSV32: - outstr="B_HSV32 "; - break; - case B_HSVA32: - outstr="B_HSVA32 "; - break; - case B_HLS32: - outstr="B_HLS32 "; - break; - case B_HLSA32: - outstr="B_HLSA32 "; - break; - case B_CMY32: - outstr="B_CMY32"; - break; - case B_CMYA32: - outstr="B_CMYA32 "; - break; - case B_CMYK32: - outstr="B_CMYK32 "; - break; - case B_RGB24_BIG: - outstr="B_RGB24_BIG "; - break; - case B_RGB24: - outstr="B_RGB24 "; - break; - case B_LAB24: - outstr="B_LAB24 "; - break; - case B_UVL24: - outstr="B_UVL24 "; - break; - case B_HSI24: - outstr="B_HSI24 "; - break; - case B_HSV24: - outstr="B_HSV24 "; - break; - case B_HLS24: - outstr="B_HLS24 "; - break; - case B_CMY24: - outstr="B_CMY24 "; - break; - case B_GRAY1: - outstr="B_GRAY1 "; - break; - case B_CMAP8: - outstr="B_CMAP8 "; - break; - case B_GRAY8: - outstr="B_GRAY8 "; - break; - case B_YUV411: - outstr="B_YUV411 "; - break; - case B_YUV420: - outstr="B_YUV420 "; - break; - case B_YCbCr422: - outstr="B_YCbCr422 "; - break; - case B_YCbCr411: - outstr="B_YCbCr411 "; - break; - case B_YCbCr420: - outstr="B_YCbCr420 "; - break; - case B_YUV422: - outstr="B_YUV422 "; - break; - case B_YUV9: - outstr="B_YUV9 "; - break; - case B_YUV12: - outstr="B_YUV12 "; - break; - case B_RGB15: - outstr="B_RGB15 "; - break; - case B_RGBA15: - outstr="B_RGBA15 "; - break; - case B_RGB16: - outstr="B_RGB16 "; - break; - case B_RGB16_BIG: - outstr="B_RGB16_BIG "; - break; - case B_RGB15_BIG: - outstr="B_RGB15_BIG "; - break; - case B_RGBA15_BIG: - outstr="B_RGBA15_BIG "; - break; - case B_YCbCr444: - outstr="B_YCbCr444 "; - break; - case B_YUV444: - outstr="B_YUV444 "; - break; - case B_NO_COLOR_SPACE: - outstr="B_NO_COLOR_SPACE "; - break; - default: - outstr="Undefined color space "; - break; - } - cout << "Color Space: " << outstr.String() << flush; -} - -void TranslateMessageCodeToStream(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - - cout << "'" - << (char)((code & 0xFF000000) >> 24) - << (char)((code & 0x00FF0000) >> 16) - << (char)((code & 0x0000FF00) >> 8) - << (char)((code & 0x000000FF)) << "' "; -} - -void PrintMessageCode(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - - printf("Message code %c%c%c%c\n", - (char)((code & 0xFF000000) >> 24), - (char)((code & 0x00FF0000) >> 16), - (char)((code & 0x0000FF00) >> 8), - (char)((code & 0x000000FF)) ); -} - diff --git a/src/servers/app/proto6/DebugTools.h b/src/servers/app/proto6/DebugTools.h deleted file mode 100644 index 7d4ed3db33..0000000000 --- a/src/servers/app/proto6/DebugTools.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _DEBUGTOOLS_H_ -#define _DEBUGTOOLS_H_ - -#include -#include -#include - -void PrintColorSpaceToStream(color_space value); -void TranslateMessageCodeToStream(int32 code); -void PrintMessageCode(int32 code); -BString TranslateStatusToString(status_t value); - -#endif diff --git a/src/servers/app/proto6/Decorator.cpp b/src/servers/app/proto6/Decorator.cpp deleted file mode 100644 index 3117887ecd..0000000000 --- a/src/servers/app/proto6/Decorator.cpp +++ /dev/null @@ -1,153 +0,0 @@ -#include "Decorator.h" - -Decorator::Decorator(Layer *lay, uint32 windowflags, uint32 wlook) -{ - layer=lay; - dflags=windowflags; - minsize.Set(0,0); - bsize.Set(1,1,1,1); - dlook=wlook; - focused=false; - driver=get_gfxdriver(); -} - -Decorator::~Decorator(void) -{ -} - -Layer* Decorator::GetLayer(void) -{ - return layer; -} - -click_type Decorator::Clicked(BPoint pt, uint32 buttons) -{ - return CLICK_NONE; -} - -void Decorator::Resize(BRect rect) -{ -} - -void Decorator::MoveBy(BPoint pt) -{ -} - -BRect Decorator::GetBorderSize(void) -{ - return bsize; -} - -BPoint Decorator::GetMinimumSize(void) -{ - return BPoint(0,0); -} - -BRegion * Decorator::GetFootprint(void) -{ - return NULL; -} - -void Decorator::SetFlags(uint32 flags) -{ - dflags=flags; -} - -uint32 Decorator::Flags(void) -{ - return dflags; -} - -void Decorator::SetLook(uint32 wlook) -{ - dlook=(uint32)wlook; -} - -uint32 Decorator::Look(void) -{ - return dlook; -} - -void Decorator::SetFeel(uint32 wfeel) -{ - dfeel=(uint32)wfeel; -} - -uint32 Decorator::Feel(void) -{ - return dfeel; -} - -void Decorator::UpdateTitle(const char *string) -{ -} - -void Decorator::UpdateFont(void) -{ -} - -void Decorator::SetFocus(bool focused) -{ -} - -void Decorator::SetCloseButton(bool down) -{ - closestate=down; -} - -void Decorator::SetZoomButton(bool down) -{ - zoomstate=down; -} - -void Decorator::SetMinimizeButton(bool down) -{ - minstate=down; -} - -bool Decorator::GetCloseButton(void) const -{ - return closestate; -} - -bool Decorator::GetZoomButton(void) const -{ - return zoomstate; -} - -bool Decorator::GetMinimizeButton(void) const -{ - return minstate; -} - -void Decorator::Draw(BRect update) -{ -} - -void Decorator::Draw(void) -{ -} - -void Decorator::DrawTab(void) -{ -} - -void Decorator::DrawFrame(void) -{ -} - -void Decorator::DrawZoom(BRect r) -{ -} - -void Decorator::DrawClose(BRect r) -{ -} - -void Decorator::DrawMinimize(BRect r) -{ -} - -void Decorator::CalculateBorders(void) -{ -} diff --git a/src/servers/app/proto6/Decorator.h b/src/servers/app/proto6/Decorator.h deleted file mode 100644 index 93e71b5928..0000000000 --- a/src/servers/app/proto6/Decorator.h +++ /dev/null @@ -1,107 +0,0 @@ -#ifndef _DECORATOR_H_ -#define _DECORATOR_H_ - -#include -#include -//#include -#include "Desktop.h" - -class Layer; -class DisplayDriver; - -typedef enum { CLICK_NONE=0, CLICK_ZOOM, CLICK_CLOSE, CLICK_MINIMIZE, - CLICK_TAB, CLICK_DRAG, CLICK_MOVETOBACK, CLICK_MOVETOFRONT, - - CLICK_RESIZE, CLICK_RESIZE_L, CLICK_RESIZE_T, - CLICK_RESIZE_R, CLICK_RESIZE_B, CLICK_RESIZE_LT, CLICK_RESIZE_RT, - CLICK_RESIZE_LB, CLICK_RESIZE_RB } click_type; - -// Definitions which are used in place of including Window.h -// window_look and window_feel are enumerated types, so we convert them -// to uint32's in order to ensure a constant size when sending via PortLink -// instead of depending on magic numbers in the header file. - -#define WLOOK_NO_BORDER 0 -#define WLOOK_BORDERED 1 -#define WLOOK_TITLED 2 -#define WLOOK_DOCUMENT 3 -#define WLOOK_MODAL 4 -#define WLOOK_FLOATING 5 - -#define WFEEL_NORMAL 0 -#define WFEEL_MODAL_SUBSET 1 -#define WFEEL_MODAL_APP 2 -#define WFEEL_MODAL_WINDOW 3 -#define WFEEL_FLOATING_SUBSET 4 -#define WFEEL_FLOATING_APP 5 -#define WFEEL_FLOATING_WINDOW 6 - -#define NOT_MOVABLE 0x00000001 -#define NOT_CLOSABLE 0x00000020 -#define NOT_ZOOMABLE 0x00000040 -#define NOT_MINIMIZABLE 0x00004000 -#define NOT_RESIZABLE 0x00000002 -#define NOT_H_RESIZABLE 0x00000004 -#define NOT_V_RESIZABLE 0x00000008 -#define AVOID_FRONT 0x00000080 -#define AVOID_FOCUS 0x00002000 -#define WILL_ACCEPT_FIRST_CLICK 0x00000010 -#define OUTLINE_RESIZE 0x00001000 -#define NO_WORKSPACE_ACTIVATION 0x00000100 -#define NOT_ANCHORED_ON_ACTIVATE 0x00020000 -#define ASYNCHRONOUS_CONTROLS 0x00080000 -#define QUIT_ON_WINDOW_CLOSE 0x00100000 - -class Decorator -{ -public: - Decorator(Layer *lay, uint32 windowflags, uint32 wlook); - virtual ~Decorator(void); - - Layer* GetLayer(void); - - virtual click_type Clicked(BPoint pt, uint32 buttons); - virtual void Resize(BRect rect); - virtual void MoveBy(BPoint pt); - virtual BRect GetBorderSize(void); - virtual BPoint GetMinimumSize(void); - virtual BRegion *GetFootprint(void); - virtual void SetFlags(uint32 flags); - virtual uint32 Flags(void); - virtual void SetLook(uint32 wlook); - virtual uint32 Look(void); - virtual void SetFeel(uint32 wfeel); - virtual uint32 Feel(void); - virtual void UpdateTitle(const char *string); - virtual void UpdateFont(void); - virtual void SetFocus(bool focused); - virtual void SetCloseButton(bool down); - virtual void SetZoomButton(bool down); - virtual void SetMinimizeButton(bool down); - bool GetCloseButton(void) const; - bool GetZoomButton(void) const; - bool GetMinimizeButton(void) const; - virtual void Draw(BRect update); - virtual void Draw(void); - virtual void DrawTab(void); - virtual void DrawFrame(void); - virtual void DrawZoom(BRect r); - virtual void DrawClose(BRect r); - virtual void DrawMinimize(BRect r); -protected: - virtual void CalculateBorders(void); - Layer *layer; - BPoint minsize; - uint32 dlook, dfeel, dflags; - BRect bsize; - bool focused; - bool zoomstate, closestate, minstate; - DisplayDriver *driver; -}; - -// C exports to hide the class-related stuff from the rest of the -// server. Written for each decorator, but don't amount to much. -typedef uint16 get_decorator_version(void); -typedef Decorator *create_decorator(Layer *lay, uint32 dflags, uint32 wlook); - -#endif diff --git a/src/servers/app/proto6/Desktop.cpp b/src/servers/app/proto6/Desktop.cpp deleted file mode 100644 index c1770042fd..0000000000 --- a/src/servers/app/proto6/Desktop.cpp +++ /dev/null @@ -1,413 +0,0 @@ -/* - Desktop.cpp: - Code necessary to handle the Desktop, defined as the collection of workspaces. -*/ - -//#define DEBUG_WORKSPACES - -#include -#include -#include -#include -#include -#include "ColorUtils.h" -#include "SystemPalette.h" -#include "ServerWindow.h" -#include "ServerCursor.h" -#include "Layer.h" -#include "DisplayDriver.h" -#include "ViewDriver.h" -#include "SecondDriver.h" -#include "ScreenDriver.h" -#include "Desktop.h" -#include "WindowBorder.h" - -class ServerWindow; -class ServerBitmap; -class Workspace; - -//--------------------GLOBALS------------------------- -uint32 workspace_count, active_workspace; -BList *desktop; -ServerCursor *startup_cursor; -Workspace *pactive_workspace; -DisplayDriver *gfxdriver; -int32 token_count=-1; -BLocker *workspacelock; -BLocker *layerlock; -UpdateNode *upnode; -//---------------------------------------------------- - - -//-------------------INTERNAL CLASS DEFS-------------- -class Workspace -{ -public: - Workspace(void); - Workspace(BPath imagepath); - ~Workspace(); - void SetBGColor(rgb_color col); - rgb_color BGColor(void); - thread_id tid; - - RootLayer *toplayer; - BList focuslist; - rgb_color bgcolor; - screen_info screendata, - olddata; -}; - -DisplayDriver *get_gfxdriver(void) -{ - return gfxdriver; -} - -Workspace::Workspace(void) -{ - workspace_count++; - - // default values - focuslist.MakeEmpty(); - bgcolor.red=51; - bgcolor.green=102; - bgcolor.blue=160; - screendata.mode=B_CMAP8; - screendata.spaces=B_8_BIT_640x480; - screendata.refresh_rate=60.0; - screendata.min_refresh_rate=60.0; - screendata.max_refresh_rate=60.0; - screendata.h_position=(uchar)50; - screendata.v_position=(uchar)50; - screendata.h_size=(uchar)50; - screendata.v_size=(uchar)50; - olddata=screendata; - - // We need one top layer for each workspace times the number of monitors - ick. - // Currently, we only have 1 monitor. *Whew* - char wspace_name[128]; - sprintf(wspace_name,"workspace %ld root",workspace_count); - toplayer=new RootLayer(BRect(0,0,639,439),wspace_name); -} - -Workspace::~Workspace(void) - { - workspace_count--; - toplayer->PruneTree(); -} - -void Workspace::SetBGColor(rgb_color col) -{ - bgcolor=col; - toplayer->SetColor(col); -#ifdef DEBUG_WORKSPACES -printf("Workspace::SetBGColor(%d,%d,%d,%d)\n",bgcolor.red,bgcolor.green, - bgcolor.blue,bgcolor.alpha); -#endif -} - -rgb_color Workspace::BGColor(void) -{ - return bgcolor; -} -//--------------------------------------------------- - - -//-----------------GLOBAL FUNCTION DEFS--------------- - -void init_desktop(int8 workspaces) -{ -#ifdef DEBUG_WORKSPACES -printf("init_desktop(%d)\n",workspaces); -#endif - workspace_count=workspaces; - if(workspace_count==0) - workspace_count++; - - // Instantiate and initialize display driver - gfxdriver=new ViewDriver(); -// gfxdriver=new SecondDriver(); -// gfxdriver=new ScreenDriver(); - gfxdriver->Initialize(); - - workspacelock=new BLocker(); - layerlock=new BLocker(); - -#ifdef DEBUG_WORKSPACES -printf("Driver %s\n", (gfxdriver->IsInitialized()==true)?"initialized":"NOT initialized"); -#endif - - desktop=new BList(0); - - // Create the workspaces we're supposed to have - for(int8 i=0; iAddItem(new Workspace()); - - // Load workspace preferences here - - // We're going to punch in some hardcoded settings for testing purposes. - // There are 3 workspaces hardcoded in for now, but we'll only use the - // second one. - Workspace *wksp=(Workspace*)desktop->ItemAt(1); - if(wksp!=NULL) // in case I forgot something - { - rgb_color bcol; - SetRGBColor(&bcol,0,200,236); - -// SetRGBColor(&(wksp->bgcolor),0,200,236); - wksp->SetBGColor(bcol); - screen_info *tempsd=&(wksp->screendata); - tempsd->mode=B_CMAP8; - tempsd->spaces=B_8_BIT_800x600; - tempsd->frame.Set(0,0,799,599); - } - else - printf("DW goofed on the workspace index :P\n"); - - // Activate workspace 0 - pactive_workspace=(Workspace *)desktop->ItemAt(0); - pactive_workspace->screendata.spaces=B_32_BIT_640x480; - gfxdriver->SetScreen(pactive_workspace->screendata.spaces); - - // Clear the screen - SetRGBColor(&(pactive_workspace->toplayer->bgcolor),80,85,152); - gfxdriver->Clear(pactive_workspace->toplayer->bgcolor); - startup_cursor=new ServerCursor(default_cursor); - gfxdriver->SetCursor(startup_cursor); - gfxdriver->ShowCursor(); - - pactive_workspace->toplayer->SetVisible(true); -#ifdef DEBUG_WORKSPACES -printf("Desktop initialized\n"); -#endif -} - -void shutdown_desktop(void) -{ - int32 i,count=desktop->CountItems(); - Workspace *w; - for(i=0;iItemAt(i); - if(w!=NULL) - delete w; - } - desktop->MakeEmpty(); - delete desktop; - gfxdriver->Shutdown(); - delete gfxdriver; - delete workspacelock; - delete layerlock; - delete startup_cursor; -} - - -int32 CountWorkspaces(void) -{ -#ifdef DEBUG_WORKSPACES -printf("CountWorkspaces() returned %ld\n",workspace_count); -#endif - return workspace_count; -} - -void SetWorkspaceCount(uint32 count) -{ - if(count<0) - { -#ifdef DEBUG_WORKSPACES -printf("SetWorkspaceCount(value<0) - DOH!\n"); -#endif - return; - } - if(count==workspace_count) - return; - - // Activate last workspace in new set if we're using one to be nuked - if(countItemAt(i)!=NULL) - { - delete (Workspace*)desktop->ItemAt(i); - desktop->RemoveItem(i); - } - } - } - else - { - // count > workspace_count here - - // Once we have default workspace preferences which can be set by the - // user, we'll end up having to initialize newly-added workspaces to that - // data. In the mean time, the defaults in the constructor will do. :) - for(uint32 i=count;iAddItem(new Workspace()); - } - } - - // don't forget to update our global! - workspace_count=desktop->CountItems(); - -#ifdef DEBUG_WORKSPACES -printf("SetWorkspaceCount(%ld)\n",workspace_count); -#endif - -} - -int32 CurrentWorkspace(void) -{ -#ifdef DEBUG_WORKSPACES -printf("CurrentWorkspace() returned %ld\n",active_workspace); -#endif - return active_workspace; -} - -void ActivateWorkspace(uint32 workspace) -{ - // In order to change workspaces, we'll need to make all the necessary - // changes to the screen to fit the new one, such as resolution, - // background color, color depth, refresh rate, etc. - - if(workspace>workspace_count || workspace<0) - return; - - Workspace *proposed=(Workspace *)desktop->ItemAt(workspace); - - if(proposed==NULL) - return; - - // Here's where we update all the screen stuff -// if(pactive_workspace->screendata.spaces != proposed->screendata.spaces) -// { - gfxdriver->SetScreen(proposed->screendata.spaces); - gfxdriver->Clear(proposed->bgcolor); - pactive_workspace->toplayer->SetVisible(false); - proposed->toplayer->SetVisible(true); -// } - // more if != then change code goes here. Currently, a lot of the code which - // uses this stuff is not implemented, so it's kind of moot. However, when we - // use the real graphics HW, it'll become important. - - // actually set our active workspace data to reflect the change in workspaces - pactive_workspace=proposed; - active_workspace=workspace; -#ifdef DEBUG_WORKSPACES -printf("ActivateWorkspace(%ld)\n",active_workspace); -#endif -} - -const color_map *SystemColors(void) -{ - return (const color_map *)&system_palette; -} - -status_t SetScreenSpace(uint32 index, uint32 res, bool stick = true) -{ -#ifdef DEBUG_WORKSPACES -printf("SetScreenSpace(%ld,%lu, %s)\n",index,res,(stick==true)?"true":"false"); -#endif - - if(index>workspace_count-1) - { - printf("SetScreenSpace was passed invalid workspace value %ld\n",index); - return B_ERROR; - } - if(res>0x800000) // the last "normal" screen mode defined in GraphicsDefs.h - { - printf("SetScreenSpace was passed invalid screen value %lu\n",res); - return B_ERROR; - } - - // When we actually use app_server preferences, we'll save the screen mode to - // the preferences so that we use this mode next boot. For now, we treat stick==false - if(stick==true) - { - // save the screen data here - } - if(index==active_workspace) - { - gfxdriver->SetScreen(res); - gfxdriver->Clear(pactive_workspace->bgcolor); - } - else - { - // just set the workspace's data here. right now, do nothing. - } - return B_OK; -} - -int32 GetViewToken(void) -{ - // Used to generate view and layer tokens - return ++token_count; -} - -void AddWindowToDesktop(ServerWindow *win,uint32 workspace) -{ - // Adds the top layer of each window to the root layer in the specified workspace. - // Note that in calling AddChild, a redraw is invoked - if(!win || workspace>workspace_count-1) - return; - - workspacelock->Lock(); - Workspace *w=(Workspace *)desktop->ItemAt(workspace); - if(w) - { - // a check for the B_CURRENT_WORKSPACE or B_ALL_WORKSPACES specifiers will - // go here later - - w->toplayer->AddChild(win->winborder); - } - workspacelock->Unlock(); -} - -void RemoveWindowFromDesktop(ServerWindow *win) -{ - // A little more time-consuming than AddWindow - if(!win) - return; - - workspacelock->Lock(); - - // a check for the B_CURRENT_WORKSPACE or B_ALL_WORKSPACES specifiers will - // go here later - - // If the window belongs on only 1 workspace, calling RemoveSelf is the most - // elegant solution. - win->winborder->RemoveSelf(); - workspacelock->Unlock(); -} - -Layer *GetRootLayer(void) -{ - layerlock->Lock(); - Layer *lay=(workspace_count>0)?pactive_workspace->toplayer:NULL; - layerlock->Unlock(); - - return lay; -} - -ServerWindow *GetActiveWindow(int32 workspace) -{ - Layer *root=GetRootLayer(); - if(!root) - return NULL; - Layer *lay=root->topchild, *nextlay; - while(lay!=NULL) - { - if(lay->serverwin && lay->serverwin->HasFocus()) - return lay->serverwin; - nextlay=lay->lowersibling; - lay=nextlay; - } - return NULL; -} - -// Another "just in case DW screws up again" section -#ifdef DEBUG_WORKSPACES -#undef DEBUG_WORKSPACES -#endif diff --git a/src/servers/app/proto6/Desktop.h b/src/servers/app/proto6/Desktop.h deleted file mode 100644 index a7787347c7..0000000000 --- a/src/servers/app/proto6/Desktop.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef _OBDESKTOP_H_ -#define _OBDESKTOP_H_ - - -#include -#include -#include - -class DisplayDriver; -class ServerWindow; -class Layer; - -void init_desktop(int8 workspaces); -void shutdown_desktop(void); -DisplayDriver *get_gfxdriver(void); - -// Workspace access functions -int32 CountWorkspaces(void); -void SetWorkspaceCount(uint32 count); - -int32 CurrentWorkspace(void); -void ActivateWorkspace(uint32 workspace); - -const color_map *SystemColors(void); -status_t SetScreenSpace(uint32 index, uint32 res, bool stick=true); - -void AddWindowToDesktop(ServerWindow *win,uint32 workspace); -void RemoveWindowFromDesktop(ServerWindow *win); -ServerWindow *GetActiveWindow(int32 workspace); -Layer *GetRootLayer(void); -int32 GetViewToken(void); - -typedef struct -{ - color_space mode; - BRect frame; - uint32 spaces; - float min_refresh_rate; - float max_refresh_rate; - float refresh_rate; - uchar h_position; - uchar v_position; - uchar h_size; - uchar v_size; -} screen_info; - -#endif diff --git a/src/servers/app/proto6/DisplayDriver.cpp b/src/servers/app/proto6/DisplayDriver.cpp deleted file mode 100644 index 54c8cd5fcd..0000000000 --- a/src/servers/app/proto6/DisplayDriver.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/* - DisplayDriver.cpp - Modular class to allow the server to not care what the ultimate output is - for graphics calls. -*/ -#include "DisplayDriver.h" -#include "ColorUtils.h" -#include "SystemPalette.h" -#include "ServerCursor.h" - -DisplayDriver::DisplayDriver(void) -{ - is_initialized=false; - cursor_visible=true; - show_on_move=false; - locker=new BLocker(); - - penpos.Set(0,0); - pensize=0.0; - - // initialize to BView defaults - highcol.red=0; - highcol.green=0; - highcol.blue=0; - highcol.alpha=0; - lowcol.red=255; - lowcol.green=255; - lowcol.blue=255; - lowcol.alpha=255; -} - -DisplayDriver::~DisplayDriver(void) -{ - delete locker; -} - -void DisplayDriver::Initialize(void) -{ // Loading loop to find proper driver or other setup for the driver -} - -bool DisplayDriver::IsInitialized(void) -{ // Let us know whether things worked out ok - return is_initialized; -} - -void DisplayDriver::Shutdown(void) -{ // For use by subclasses -} - -void DisplayDriver::SafeMode(void) -{ // Set video mode to 640x480x256 mode -} - -void DisplayDriver::Reset(void) -{ // Intended to reload and restart driver. Defaults to a safe mode -} - -void DisplayDriver::Clear(uint8 red,uint8 green,uint8 blue) -{ -} - -void DisplayDriver::Clear(rgb_color col) -{ -} - -void DisplayDriver::SetScreen(uint32 space) -{ // Set the screen to a particular mode -} - -int32 DisplayDriver::GetHeight(void) -{ // Gets the height of the current mode - return ginfo->height; -} - -int32 DisplayDriver::GetWidth(void) -{ // Gets the width of the current mode - return ginfo->width; -} - -int DisplayDriver::GetDepth(void) -{ // Gets the color depth of the current mode - return ginfo->bytes_per_row; -} - -void DisplayDriver::AddLine(BPoint pt1, BPoint pt2, rgb_color col) -{ -} - -void DisplayDriver::BeginLineArray(int32 count) -{ -} - -void DisplayDriver::Blit(BRect src, BRect dest) -{ // Screen-to-screen bitmap copying -} - -void DisplayDriver::DrawBitmap(ServerBitmap *bitmap, BRect source, BRect dest) -{ -} - -void DisplayDriver::DrawChar(char c, BPoint point) -{ -} - -void DisplayDriver::DrawLineArray(int32 count,BPoint *start, BPoint *end, rgb_color *color) -{ -} - -void DisplayDriver::DrawString(char *string, int length, BPoint point) -{ -} - -void DisplayDriver::EndLineArray(void) -{ -} - -void DisplayDriver::FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern) -{ -} - -void DisplayDriver::FillBezier(BPoint *points, uint8 *pattern) -{ -} - -void DisplayDriver::FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern) -{ -} - -void DisplayDriver::FillPolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void DisplayDriver::FillRect(BRect rect, uint8 *pattern) -{ -} - -void DisplayDriver::FillRect(BRect rect, rgb_color col) -{ -} - -void DisplayDriver::FillRegion(BRegion *region) -{ -} - -void DisplayDriver::FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ -} - -void DisplayDriver::FillShape(BShape *shape) -{ -} - -void DisplayDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ -} - -void DisplayDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col) -{ -} - -drawing_mode DisplayDriver::GetDrawingMode(void) -{ - return B_OP_COPY; -} - -void DisplayDriver::HideCursor(void) -{ -} - -rgb_color DisplayDriver::HighColor(void) -{ - locker->Lock(); - rgb_color col=highcol; - locker->Unlock(); - return col; -} - -bool DisplayDriver::IsCursorHidden(void) -{ - return false; -} - -rgb_color DisplayDriver::LowColor(void) -{ - locker->Lock(); - rgb_color col=lowcol; - locker->Unlock(); - return col; -} - -void DisplayDriver::ObscureCursor(void) -{ // Hides cursor until mouse is moved -} - -void DisplayDriver::MoveCursorTo(float x, float y) -{ -} - -void DisplayDriver::MovePenTo(BPoint pt) -{ // Moves the graphics pen to this position - penpos=pt; -} - -BPoint DisplayDriver::PenPosition(void) -{ - return penpos; -} - -float DisplayDriver::PenSize(void) -{ - return pensize; -} - -void DisplayDriver::SetCursor(ServerCursor *cursor) -{ -} - -void DisplayDriver::SetDrawingMode(drawing_mode mode) -{ -} - -void DisplayDriver::SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - SetRGBColor(&highcol,r,g,b,a); - high16=FindClosestColor16(highcol); - high8=FindClosestColor(system_palette,highcol); -} - -void DisplayDriver::SetHighColor(rgb_color col) -{ - highcol=col; - high16=FindClosestColor16(highcol); - high8=FindClosestColor(system_palette,highcol); -} - -void DisplayDriver::SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - SetRGBColor(&lowcol,r,g,b,a); - low16=FindClosestColor16(lowcol); - low8=FindClosestColor(system_palette,lowcol); -} - -void DisplayDriver::SetLowColor(rgb_color col) -{ - lowcol=col; - low16=FindClosestColor16(lowcol); - low8=FindClosestColor(system_palette,lowcol); -} - -void DisplayDriver::SetPenSize(float size) -{ - pensize=(size>0)?size:1; -} - -void DisplayDriver::SetPixel(int x, int y, uint8 *pattern) -{ // Internal function utilized by other functions to draw to the buffer - // Will eventually be an inline function -} - -void DisplayDriver::ShowCursor(void) -{ -} - -float DisplayDriver::StringWidth(const char *string, int32 length) -{ - return -1.0; -} - -void DisplayDriver::StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeBezier(BPoint *points, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern) -{ -} - -void DisplayDriver::StrokeLine(BPoint point, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeLine(BPoint pt1, BPoint pt2, rgb_color col) -{ -} - -void DisplayDriver::StrokePolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void DisplayDriver::StrokeRect(BRect rect, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeRect(BRect rect, rgb_color col) -{ -} - -void DisplayDriver::StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeShape(BShape *shape) -{ -} - -void DisplayDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col) -{ -} - -void DisplayDriver::Line32(BPoint pt, BPoint pt2, uint8 *pattern) -{ -} - -void DisplayDriver::Line16(BPoint pt, BPoint pt2, uint8 *pattern) -{ -} - -void DisplayDriver::Line8(BPoint pt, BPoint pt2, uint8 *pattern) -{ -} diff --git a/src/servers/app/proto6/DisplayDriver.h b/src/servers/app/proto6/DisplayDriver.h deleted file mode 100644 index f453a25bb8..0000000000 --- a/src/servers/app/proto6/DisplayDriver.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef _GFX_DRIVER_H_ -#define _GFX_DRIVER_H_ - -#include -#include -#include -#include "Desktop.h" - -class ServerBitmap; -class ServerCursor; - -#ifndef ROUND - #define ROUND(a) ( (a-long(a))>=.5)?(long(a)+1):(long(a)) -#endif - -typedef struct -{ - uchar *xormask, *andmask; - int32 width, height; - int32 hotx, hoty; - -} cursor_data; - -#ifndef HOOK_DEFINE_CURSOR - -#define HOOK_DEFINE_CURSOR 0 -#define HOOK_MOVE_CURSOR 1 -#define HOOK_SHOW_CURSOR 2 -#define HOOK_DRAW_LINE_8BIT 3 -#define HOOK_DRAW_LINE_16BIT 12 -#define HOOK_DRAW_LINE_32BIT 4 -#define HOOK_DRAW_RECT_8BIT 5 -#define HOOK_DRAW_RECT_16BIT 13 -#define HOOK_DRAW_RECT_32BIT 6 -#define HOOK_BLIT 7 -#define HOOK_DRAW_ARRAY_8BIT 8 -#define HOOK_DRAW_ARRAY_16BIT 14 // Not implemented in current R5 drivers -#define HOOK_DRAW_ARRAY_32BIT 9 -#define HOOK_SYNC 10 -#define HOOK_INVERT_RECT 11 - -#endif - -class ServerCursor; - -#define DRAW_COPY 0 -#define DRAW_OVER 1 -#define DRAW_ERASE 2 -#define DRAW_INVERT 3 -#define DRAW_ADD 4 -#define DRAW_SUBTRACT 5 -#define DRAW_BLEND 6 -#define DRAW_MIN 7 -#define DRAW_MAX 8 -#define DRAW_SELECT 9 -#define DRAW_ALPHA 10 - - -class DisplayDriver -{ -public: - DisplayDriver(void); - virtual ~DisplayDriver(void); - - virtual void Initialize(void); // Sets the driver - virtual bool IsInitialized(void); - virtual void Shutdown(void); // You never know when you'll need this - - virtual void SafeMode(void); // Easy-access functions for common tasks - virtual void Reset(void); - virtual void Clear(uint8 red,uint8 green,uint8 blue); - virtual void Clear(rgb_color col); - - // Settings functions - virtual void SetScreen(uint32 space); - virtual int32 GetHeight(void); - virtual int32 GetWidth(void); - virtual int GetDepth(void); - - // Drawing functions - virtual void AddLine(BPoint pt1, BPoint pt2, rgb_color col); - virtual void BeginLineArray(int32 count); - virtual void Blit(BRect src, BRect dest); - virtual void DrawBitmap(ServerBitmap *bitmap, BRect source, BRect dest); - virtual void DrawChar(char c, BPoint point); - virtual void DrawLineArray(int32 count,BPoint *start, BPoint *end, rgb_color *color); - virtual void DrawString(char *string, int length, BPoint point); - virtual void EndLineArray(void); - - virtual void FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void FillBezier(BPoint *points, uint8 *pattern); - virtual void FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void FillPolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void FillRect(BRect rect, uint8 *pattern); - virtual void FillRect(BRect rect, rgb_color col); - virtual void FillRegion(BRegion *region); - virtual void FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void FillShape(BShape *shape); - virtual void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - virtual void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col); - -// virtual void GetBlendingMode(source_alpha *srcmode, alpha_function *funcmode); - virtual drawing_mode GetDrawingMode(void); - virtual void HideCursor(void); - rgb_color HighColor(void); - virtual bool IsCursorHidden(void); - rgb_color LowColor(void); - virtual void MoveCursorTo(float x, float y); - virtual void MovePenTo(BPoint pt); - virtual void ObscureCursor(void); - virtual BPoint PenPosition(void); - virtual float PenSize(void); -// virtual void SetBlendingMode(source_alpha srcmode, alpha_function funcmode); - virtual void SetCursor(ServerCursor *cursor); - virtual void SetDrawingMode(drawing_mode mode); - virtual void ShowCursor(void); - virtual void SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetHighColor(rgb_color col); - virtual void SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetLowColor(rgb_color col); - virtual void SetPenSize(float size); - virtual void SetPixel(int x, int y, uint8 *pattern); - - virtual float StringWidth(const char *string, int32 length); - virtual void StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void StrokeBezier(BPoint *points, uint8 *pattern); - virtual void StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void StrokeLine(BPoint point, uint8 *pattern); - virtual void StrokeLine(BPoint pt1, BPoint pt2, rgb_color col); - virtual void StrokePolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void StrokeRect(BRect rect,uint8 *pattern); - virtual void StrokeRect(BRect rect, rgb_color col); - virtual void StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void StrokeShape(BShape *shape); - virtual void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - virtual void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col); - - graphics_card_hook ghooks[48]; - graphics_card_info *ginfo; - -protected: - virtual void Line32(BPoint pt, BPoint pt2, uint8 *pattern); - virtual void Line16(BPoint pt, BPoint pt2, uint8 *pattern); - virtual void Line8(BPoint pt, BPoint pt2, uint8 *pattern); - - bool is_initialized, cursor_visible, show_on_move; - ServerCursor *current_cursor; - BLocker *locker; - rgb_color highcol, lowcol; - uint16 high16, low16; - uint8 high8, low8; - BPoint penpos; - float pensize; -}; - -#endif diff --git a/src/servers/app/proto6/Globals.h b/src/servers/app/proto6/Globals.h deleted file mode 100644 index 9998489220..0000000000 --- a/src/servers/app/proto6/Globals.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _SERVER_GLOBALS_H_ -#define _SERVER_GLOBALS_H_ - -#include -BList *gBitmaplist, *gLayerlist; - -#endif diff --git a/src/servers/app/proto6/Jamfile b/src/servers/app/proto6/Jamfile deleted file mode 100644 index 8f3ea00a74..0000000000 --- a/src/servers/app/proto6/Jamfile +++ /dev/null @@ -1,35 +0,0 @@ -SubDir OBOS_TOP src servers app proto6 ; - -Server OBAppServer : - # Misc. Sources - BeDecorator.cpp - ColorUtils.cc - DebugTools.cpp - Decorator.cpp - PortLink.cpp - YMakDecorator.cpp - - # Operating Classes - AppServer.cpp - Desktop.cpp - Layer.cpp - ServerApp.cpp - ServerBitmap.cpp - ServerCursor.cpp - ServerWindow.cpp - SystemPalette.cpp - WindowBorder.cpp - - # Display Modules - DisplayDriver.cpp - ScreenDriver.cpp - SecondDriver.cpp - ViewDriver.cpp -; -LinkSharedOSLibs OBAppServer : be root game translation stdc++.r4 ; - - -SubInclude OBOS_TOP src servers app proto6 driverharness ; -SubInclude OBOS_TOP src servers app proto6 router ; -SubInclude OBOS_TOP src servers app proto6 testobapp ; - diff --git a/src/servers/app/proto6/Layer.cpp b/src/servers/app/proto6/Layer.cpp deleted file mode 100644 index cdb556aefb..0000000000 --- a/src/servers/app/proto6/Layer.cpp +++ /dev/null @@ -1,885 +0,0 @@ -/* - Layer.cpp - Class used for rendering to the frame buffer. One layer per view on screen and - also for window decorators -*/ -#include "Layer.h" -#include "ServerWindow.h" -#include "Desktop.h" -#include "PortLink.h" -#include "DisplayDriver.h" -#include -#include -#include -#include -#include - -//#define DEBUG_LAYERS - -Layer::Layer(BRect rect, const char *layername, ServerWindow *srvwin, - int32 viewflags, int32 token) -{ - if(rect.IsValid()) - // frame is in parent layer's coordinates - frame=rect; - else - { -#ifdef DEBUG_LAYERS -printf("Invalid BRect: "); rect.PrintToStream(); -#endif - frame.Set(0,0,1,1); - } - - name=new BString(layername); - - // Layer does not start out as a part of the tree - parent=NULL; - uppersibling=NULL; - lowersibling=NULL; - topchild=NULL; - bottomchild=NULL; - - visible=new BRegion(Bounds()); - full=new BRegion(Bounds()); - invalid=NULL; - - serverwin=srvwin; - - view_token=token; - - flags=viewflags; - - hidecount=0; - is_dirty=false; - is_updating=false; - - // Because this is not part of the tree, level is negative (thus, irrelevant) - level=0; -#ifdef DEBUG_LAYERS - PrintToStream(); -#endif -} - -Layer::Layer(BRect rect, const char *layername) -{ - // This constructor is used for the top layer in each workspace - if(rect.IsValid()) - frame=rect; - else - frame.Set(0,0,1,1); - - name=new BString(layername); - - // Layer is the root for the workspace - parent=NULL; - uppersibling=NULL; - lowersibling=NULL; - topchild=NULL; - bottomchild=NULL; - - visible=new BRegion(Bounds()); - full=new BRegion(Bounds()); - invalid=NULL; - - serverwin=NULL; - flags=0; - hidecount=0; - is_dirty=false; - - level=0; - - view_token=-1; -#ifdef DEBUG_LAYERS - PrintToStream(); -#endif -} - -Layer::~Layer(void) -{ -#ifdef DEBUG_LAYERS -printf("Layer Destructor for %s\n",name->String()); -#endif - if(visible) - { - delete visible; - visible=NULL; - } - if(full) - { - delete full; - full=NULL; - } - if(invalid) - { - delete invalid; - invalid=NULL; - } - if(name) - { - delete name; - name=NULL; - } -} - -// Tested for adding children with 1 and 2 child cases, but not more -void Layer::AddChild(Layer *layer) -{ - // Adds a layer to the top of the layer's children -#ifdef DEBUG_LAYERS -printf("AddChild %s\n",layer->name->String()); -printf("Before AddChild: \n"); -PrintNode(); -if(parent) - parent->PrintNode(); -if(uppersibling) - uppersibling->PrintNode(); -if(lowersibling) - lowersibling->PrintNode(); -if(topchild) - topchild->PrintNode(); -if(bottomchild) - bottomchild->PrintNode(); -#endif - - - if(layer->parent!=NULL) - { - printf("ERROR: AddChild(): View already has a parent\n"); - return; - } - layer->parent=this; - if(layer->visible && layer->hidecount==0 && visible) - { - // Technically, we could safely take the address of ConvertToParent(BRegion) - // but we don't just to avoid a compiler nag - - BRegion *reg=new BRegion(layer->ConvertToParent(layer->visible)); - visible->Exclude(reg); - delete reg; - } - - if(topchild!=NULL) - { - layer->lowersibling=topchild; - topchild->uppersibling=layer; - if(layer->frame.Intersects(layer->lowersibling->frame)) - { - if(layer->lowersibling->visible && layer->lowersibling->hidecount==0) - { - BRegion *reg=new BRegion(ConvertToParent(layer->visible)); - BRegion *reg2=new BRegion(layer->lowersibling->ConvertFromParent(reg)); - delete reg; - layer->lowersibling->visible->Exclude(reg2); - delete reg2; - } - } - } - else - bottomchild=layer; - topchild=layer; - layer->level=level+1; - -#ifdef DEBUG_LAYERS -printf("After AddChild: \n"); -PrintNode(); -if(parent) - parent->PrintNode(); -if(uppersibling) - uppersibling->PrintNode(); -if(lowersibling) - lowersibling->PrintNode(); -if(topchild) - topchild->PrintNode(); -if(bottomchild) - bottomchild->PrintNode(); -#endif -} - -// Tested for cases with 1 and 2 children, but no more than that -void Layer::RemoveChild(Layer *layer) -{ - // Remove a layer from the tree -#ifdef DEBUG_LAYERS -printf("RemoveChild %s\n",layer->name->String()); -printf("Before RemoveChild: \n"); -PrintNode(); -if(parent) - parent->PrintNode(); -if(uppersibling) - uppersibling->PrintNode(); -if(lowersibling) - lowersibling->PrintNode(); -if(topchild) - topchild->PrintNode(); -if(bottomchild) - bottomchild->PrintNode(); -#endif - - if(layer->parent==NULL) - { - printf("ERROR: RemoveChild(): View doesn't have a parent\n"); - return; - } - if(layer->parent!=this) - { - printf("ERROR: RemoveChild(): View is not a child of this layer\n"); - return; - } - - if(hidecount==0 && layer->visible && layer->parent->visible) - { - BRegion *reg=new BRegion(ConvertToParent(visible)); - layer->parent->visible->Include(reg); - delete reg; - } - - // Take care of parent - layer->parent=NULL; - if(topchild==layer) - topchild=layer->lowersibling; - if(bottomchild==layer) - bottomchild=layer->uppersibling; - - // Take care of siblings - if(layer->uppersibling!=NULL) - layer->uppersibling->lowersibling=layer->lowersibling; - if(layer->lowersibling!=NULL) - layer->lowersibling->uppersibling=layer->uppersibling; - layer->SetLevel(0); - layer->uppersibling=NULL; - layer->lowersibling=NULL; - -#ifdef DEBUG_LAYERS -printf("After RemoveChild: \n"); -PrintNode(); -if(parent) - parent->PrintNode(); -if(uppersibling) - uppersibling->PrintNode(); -if(lowersibling) - lowersibling->PrintNode(); -if(topchild) - topchild->PrintNode(); -if(bottomchild) - bottomchild->PrintNode(); -#endif -} - -void Layer::RemoveSelf(void) -{ - // A Layer removes itself from the tree (duh) -#ifdef DEBUG_LAYERS - cout << "RemoveSelf " << name->String() << endl; -#endif - if(parent==NULL) - { - cout << "ERROR: RemoveSelf(): View doesn't have a parent\n" << flush; - return; - } - parent->RemoveChild(this); -} - -Layer *Layer::GetChildAt(BPoint pt, bool recursive=false) -{ - // 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 *child; - if(recursive) - { - for(child=bottomchild; child!=NULL; child=child->uppersibling) - { - if(child->bottomchild!=NULL) - child->GetChildAt(pt,true); - - if(child->hidecount>0) - continue; - - if(child->frame.Contains(pt)) - return child; - } - } - else - { - for(child=bottomchild; child!=NULL; child=child->uppersibling) - { - if(child->hidecount>0) - continue; -// if(child->visible && child->visible->Contains(ConvertFromTop(pt))) -// printf("child hit by mouse. News at 11\n"); - if(child->frame.Contains(pt)) - return child; - } - } - return NULL; -} - -BRect Layer::Bounds(void) -{ - return frame.OffsetToCopy(0,0); -} - -BRect Layer::Frame(void) -{ - return frame; -} - -void Layer::SetLevel(int32 value) -{ - // Sets hierarchy level of layer and all children -#ifdef DEBUG_LAYERS - printf("SetLevel %ld\n",value); -#endif - level=value; - - Layer *lay; - - lay=topchild; - - while(lay!=NULL) - { - if(lay->topchild!=NULL) - lay->topchild->SetLevel(value+1); - lay=lay->lowersibling; - } -} - -void Layer::PruneTree(void) -{ - // recursively deletes all children (and grandchildren, etc) of the passed layer - // This is mostly used for server shutdown or deleting a workspace -#ifdef DEBUG_LAYERS - printf("PruneTree() at level %ld\n", level); -#endif - Layer *lay,*nextlay; - - lay=topchild; - topchild=NULL; - - while(lay!=NULL) - { - if(lay->topchild!=NULL) - { -// lay->topchild->PruneTree(); - lay->PruneTree(); - } - nextlay=lay->lowersibling; - lay->lowersibling=NULL; - delete lay; - lay=nextlay; - } - // Man, this thing is short. Elegant, ain't it? :P -} - -Layer *Layer::FindLayer(int32 token) -{ - // recursive search for a layer based on its view token - Layer *lay, *trylay; - - // Search child layers first - for(lay=topchild; lay!=NULL; lay=lay->lowersibling) - { - if(lay->view_token==token) - return lay; - } - - // Hmmm... not in this layer's children. Try lower descendants - for(lay=topchild; lay!=NULL; lay=lay->lowersibling) - { - trylay=lay->FindLayer(token); - if(trylay) - return trylay; - } - - // Well, we got this far in the function, so apparently there is no match to be found - return NULL; -} - -// Tested -void Layer::Invalidate(BRegion region) -{ - int32 i; - BRect r; - - // See if the region intersects with our current area - if(region.Intersects(Bounds()) && hidecount==0) - { - BRegion clippedreg(region); - clippedreg.IntersectWith(visible); - if(clippedreg.CountRects()>0) - { - is_dirty=true; - if(invalid) - invalid->Include(&clippedreg); - else - invalid=new BRegion(clippedreg); - } - } - - BRegion *reg; - for(Layer *lay=topchild;lay!=NULL; lay=lay->lowersibling) - { - if(lay->hidecount==0) - { - reg=new BRegion(lay->ConvertFromParent(®ion)); - - for(i=0;iCountRects();i++) - { - r=reg->RectAt(i); - if(frame.Intersects(r)) - lay->Invalidate(r); - } - - delete reg; - } - } -} - -// Tested -void Layer::Invalidate(BRect rect) -{ - // Make our own section dirty and pass it on to any children, if necessary.... - // YES, WE ARE SHARING DIRT! Mudpies anyone? :D - - if(Frame().Intersects(rect)) - { - - // Clip the rectangle to the visible region of the layer - if(visible->Intersects(rect)) - { - BRegion reg(rect); - reg.IntersectWith(visible); - if(reg.CountRects()>0) - { - is_dirty=true; - if(invalid) - invalid->Include(®); - else - invalid=new BRegion(reg); - } - } - } - for(Layer *lay=topchild;lay!=NULL; lay=lay->lowersibling) - lay->Invalidate(lay->ConvertFromParent(rect)); -} - -void Layer::RequestDraw(void) -{ - if(visible==NULL || hidecount>0) - return; - - if(serverwin) - { - if(invalid==NULL) - invalid=new BRegion(*visible); - serverwin->RequestDraw(invalid->Frame()); - delete invalid; - invalid=NULL; - } - - is_dirty=false; - for(Layer *lay=topchild; lay!=NULL; lay=lay->lowersibling) - { - if(lay->IsDirty()) - lay->RequestDraw(); - } - -} - -bool Layer::IsDirty(void) const -{ -// return is_dirty; - return (!invalid)?true:false; -} - -void Layer::ShowLayer(void) -{ - if(hidecount==0) - return; - - hidecount--; - if(hidecount==0) - { - BRegion *reg=new BRegion(ConvertToParent(visible)); - parent->visible->Exclude(reg); - delete reg; - is_dirty=true; - } - - Layer *child; - for(child=topchild; child!=NULL; child=child->lowersibling) - child->ShowLayer(); -} - -void Layer::HideLayer(void) -{ - if(hidecount==0) - { - BRegion *reg=new BRegion(ConvertToParent(visible)); - parent->visible->Include(reg); - delete reg; - parent->is_dirty=true; - is_dirty=true; - } - hidecount++; - - Layer *child; - for(child=topchild; child!=NULL; child=child->lowersibling) - child->HideLayer(); -} - -// Tested -uint32 Layer::CountChildren(void) -{ - uint32 i=0; - Layer *lay=topchild; - while(lay!=NULL) - { - lay=lay->lowersibling; - i++; - } - return i; -} - -void Layer::MoveBy(float x, float y) -{ - BRect oldframe(frame); - frame.OffsetBy(x,y); - - if(parent) - { - if(parent->invalid==NULL) - parent->invalid=new BRegion(oldframe); - else - parent->invalid->Include(oldframe); - } - -// for(Layer *lay=topchild; lay!=NULL; lay=lay->lowersibling) -// lay->MoveBy(x,y); - Invalidate(Frame()); -} - -void Layer::ResizeBy(float x, float y) -{ - BRect oldframe=frame; - frame.right+=x; - frame.bottom+=y; - - if(parent) - parent->RebuildRegions(); - else - RebuildRegions(); - -// for(Layer *lay=topchild; lay!=NULL; lay=lay->lowersibling) -// lay->ResizeBy(x,y); - if(x<0 || y<0) - parent->Invalidate(oldframe); - Invalidate(Bounds()); -} - -void Layer::RebuildRegions(bool include_children=true) -{ - if(full) - full->Include(Bounds()); - else - full=new BRegion(Bounds()); - - if(visible) - visible->Include(Bounds()); - else - visible=new BRegion(Bounds()); - - // Remove child footprints from visible region here - - if(include_children) - { - for(Layer *lay=topchild; lay!=NULL; lay=lay->lowersibling) - { - if(lay->topchild) - lay->RebuildRegions(true); - } - } -} - -void Layer::PrintToStream(void) -{ - printf("-----------\nLayer %s\n",name->String()); - if(parent) - printf("Parent: %s (%p)\n",parent->name->String(), parent); - else - printf("Parent: NULL\n"); - if(uppersibling) - printf("Upper sibling: %s (%p)\n",uppersibling->name->String(), uppersibling); - else - printf("Upper sibling: NULL\n"); - if(lowersibling) - printf("Lower sibling: %s (%p)\n",lowersibling->name->String(), lowersibling); - else - printf("Lower sibling: NULL\n"); - if(topchild) - printf("Top child: %s (%p)\n",topchild->name->String(), topchild); - else - printf("Top child: NULL\n"); - if(bottomchild) - printf("Bottom child: %s (%p)\n",bottomchild->name->String(), bottomchild); - else - printf("Bottom child: NULL\n"); - printf("Frame: "); frame.PrintToStream(); - printf("Token: %ld\nLevel: %ld\n",view_token, level); - printf("Hide count: %u\n",hidecount); - if(invalid) - { - printf("Invalid Areas: "); invalid->PrintToStream(); - } - else - printf("Invalid Areas: NULL\n"); - if(visible) - { - printf("Visible Areas: "); visible->PrintToStream(); - } - else - printf("Visible Areas: NULL\n"); - printf("Is updating = %s\n",(is_updating)?"yes":"no"); -} - -void Layer::PrintNode(void) -{ - printf("-----------\nLayer %s\n",name->String()); - if(parent) - printf("Parent: %s (%p)\n",parent->name->String(), parent); - else - printf("Parent: NULL\n"); - if(uppersibling) - printf("Upper sibling: %s (%p)\n",uppersibling->name->String(), uppersibling); - else - printf("Upper sibling: NULL\n"); - if(lowersibling) - printf("Lower sibling: %s (%p)\n",lowersibling->name->String(), lowersibling); - else - printf("Lower sibling: NULL\n"); - if(topchild) - printf("Top child: %s (%p)\n",topchild->name->String(), topchild); - else - printf("Top child: NULL\n"); - if(bottomchild) - printf("Bottom child: %s (%p)\n",bottomchild->name->String(), bottomchild); - else - printf("Bottom child: NULL\n"); -} - -// Tested -BRect Layer::ConvertToParent(BRect rect) -{ - return (rect.OffsetByCopy(frame.LeftTop())); -} - -// Tested -BPoint Layer::ConvertToParent(BPoint point) -{ - float x=point.x + frame.left, - y=point.y+frame.top; - return (BPoint(x,y)); -} - -// Tested -BRegion Layer::ConvertToParent(BRegion *reg) -{ - BRegion newreg; - for(int32 i=0; iCountRects();i++) - newreg.Include(ConvertToParent(reg->RectAt(i))); - return BRegion(newreg); -} - -// Tested -BRect Layer::ConvertFromParent(BRect rect) -{ - return (rect.OffsetByCopy(frame.left*-1,frame.top*-1)); -} - -// Tested -BPoint Layer::ConvertFromParent(BPoint point) -{ - return ( point-frame.LeftTop()); -} - -// Tested -BRegion Layer::ConvertFromParent(BRegion *reg) -{ - BRegion newreg; - for(int32 i=0; iCountRects();i++) - newreg.Include(ConvertFromParent(reg->RectAt(i))); - return BRegion(newreg); -} - -// Tested -BRegion Layer::ConvertToTop(BRegion *reg) -{ - BRegion newreg; - for(int32 i=0; iCountRects();i++) - newreg.Include(ConvertToTop(reg->RectAt(i))); - return BRegion(newreg); -} - -// Tested -BRect Layer::ConvertToTop(BRect rect) -{ - if (parent!=NULL) - return(parent->ConvertToTop(rect.OffsetByCopy(frame.LeftTop())) ); - else - return(rect); -} - -// Tested -BPoint Layer::ConvertToTop(BPoint point) -{ - if (parent!=NULL) - return(parent->ConvertToTop(point + frame.LeftTop()) ); - else - return(point); -} - -// Tested -BRegion Layer::ConvertFromTop(BRegion *reg) -{ - BRegion newreg; - for(int32 i=0; iCountRects();i++) - newreg.Include(ConvertFromTop(reg->RectAt(i))); - return BRegion(newreg); -} - -// Tested -BRect Layer::ConvertFromTop(BRect rect) -{ - if (parent!=NULL) - return(parent->ConvertFromTop(rect.OffsetByCopy(frame.LeftTop().x*-1, - frame.LeftTop().y*-1)) ); - else - return(rect); -} - -// Tested -BPoint Layer::ConvertFromTop(BPoint point) -{ - if (parent!=NULL) - return(parent->ConvertFromTop(point - frame.LeftTop()) ); - else - return(point); -} - -RootLayer::RootLayer(BRect rect, const char *layername, ServerWindow *srvwin, - int32 viewflags, int32 token) - : Layer(rect,layername,srvwin,viewflags,token) -{ - updater_id=-1; -} - -RootLayer::RootLayer(BRect rect, const char *layername) - : Layer(rect,layername) -{ - updater_id=-1; - driver=get_gfxdriver(); -} - -RootLayer::~RootLayer(void) -{ -} - -void RootLayer::SetVisible(bool fVisible) -{ - if(is_visible!=fVisible) - { - is_visible=fVisible; -/* if(visible) - { - updater_id=spawn_thread(UpdaterThread,name->String(),B_NORMAL_PRIORITY,this); - if(updater_id!=B_NO_MORE_THREADS && updater_id!=B_NO_MEMORY) - resume_thread(updater_id); - } -*/ - } -} - -bool RootLayer::IsVisible(void) const -{ - return is_visible; -} - -int32 RootLayer::UpdaterThread(void *data) -{ - // Updater thread which checks to see if its layer needs updating. If so, then - // call the recursive function RequestDraw. - - RootLayer *root=(RootLayer*)data; - - while(1) - { - if(!root->is_visible) - { - return 0; - exit_thread(1); - } - - if(root->IsDirty()) - { - layerlock->Lock(); - root->RequestDraw(); - layerlock->Unlock(); - } - } -} - -void RootLayer::RequestDraw(void) -{ - if(!invalid) - return; - - ASSERT(driver!=NULL); - -#ifdef DEBUG_LAYERS -printf("Root::RequestDraw: invalid rects: %ld\n",invalid->CountRects()); -#endif - - // Redraw the base - for(int32 i=0; invalid->CountRects();i++) - { - if(invalid->RectAt(i).IsValid()) - { -#ifdef DEBUG_LAYERS -printf("Root::RequestDraw:FillRect, color %u,%u,%u,%u\n",bgcolor.red,bgcolor.green, - bgcolor.blue,bgcolor.alpha); -#endif - driver->FillRect(invalid->RectAt(i),bgcolor); - } - else - break; - } - - delete invalid; - invalid=NULL; - is_dirty=false; - - // force redraw of all dirty windows - for(Layer *lay=topchild; lay!=NULL; lay=lay->lowersibling) - { - if(lay->IsDirty()) - lay->RequestDraw(); - } - -} - -void RootLayer::SetColor(rgb_color col) -{ - bgcolor=col; -#ifdef DEBUG_LAYERS -printf("Root::SetColor(%u,%u,%u,%u)\n",bgcolor.red,bgcolor.green, - bgcolor.blue,bgcolor.alpha); -#endif -} - -rgb_color RootLayer::GetColor(void) const -{ - return bgcolor; -} diff --git a/src/servers/app/proto6/Layer.h b/src/servers/app/proto6/Layer.h deleted file mode 100644 index 2313de00ba..0000000000 --- a/src/servers/app/proto6/Layer.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef _LAYER_H_ -#define _LAYER_H_ - -#include -#include -#include -#include -#include -#include - -class ServerWindow; -class UpdateNode; -class DisplayDriver; - -class Layer -{ -public: - Layer(BRect rect, const char *layername, ServerWindow *srvwin, - int32 viewflags, int32 token); - Layer(BRect rect, const char *layername); - virtual ~Layer(void); - - void ShowLayer(void); - void HideLayer(void); - Layer *FindLayer(int32 token); - void MoveLayer(BPoint delta, bool include_children=true); - void AddChild(Layer *child); - void RemoveChild(Layer *child); - void RemoveSelf(void); - uint32 CountChildren(void); - Layer *GetChildAt(BPoint pt, bool recursive=false); - BRect Bounds(void); - BRect Frame(void); - - void MoveBy(float x, float y); - void ResizeBy(float x, float y); - - void RebuildRegions(bool include_children=true); - bool IsDirty(void) const; - void PrintToStream(void); - void PrintNode(void); - void PruneTree(void); - void SetLevel(int32 value); - void Invalidate(BRect rect); - void Invalidate(BRegion region); - virtual void RequestDraw(void); - - BRect ConvertToParent(BRect rect); - BPoint ConvertToParent(BPoint point); - BRegion ConvertToParent(BRegion *reg); - BRect ConvertFromParent(BRect rect); - BPoint ConvertFromParent(BPoint point); - BRegion ConvertFromParent(BRegion *reg); - BRegion ConvertToTop(BRegion *reg); - BRect ConvertToTop(BRect rect); - BPoint ConvertToTop(BPoint point); - BRegion ConvertFromTop(BRegion *reg); - BRect ConvertFromTop(BRect rect); - BPoint ConvertFromTop(BPoint point); - - BRect frame; - - Layer *parent, - *uppersibling, - *lowersibling, - *topchild, - *bottomchild; - - BRegion *visible, - *invalid, - *full; - - ServerWindow *serverwin; - - BString *name; - int32 view_token; // identifier for the corresponding view - int32 level; // how far layer is from root - int32 flags; // view flags - uint8 hidecount; - bool is_dirty; // true if we need to redraw - bool is_updating; - bool is_visible; -}; - -class RootLayer : public Layer -{ -public: - RootLayer(BRect rect, const char *layername, ServerWindow *srvwin, - int32 viewflags, int32 token); - RootLayer(BRect rect, const char *layername); - ~RootLayer(void); - virtual void RequestDraw(void); - void SetVisible(bool is_visible); - bool IsVisible(void) const; - - void SetColor(rgb_color col); - rgb_color GetColor(void) const; - - static int32 UpdaterThread(void *data); - rgb_color bgcolor; -private: - thread_id updater_id; - bool visible; - DisplayDriver *driver; -}; - -extern BLocker *layerlock; -extern BList *layerlist; -extern Layer *rootlayer; -#endif diff --git a/src/servers/app/proto6/PortLink.cpp b/src/servers/app/proto6/PortLink.cpp deleted file mode 100644 index 8fba724569..0000000000 --- a/src/servers/app/proto6/PortLink.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/* - PortLink.cpp: - A helper class for port-based messaging - ------------------------------------------------------------------------- -How it works: - The class utilizes a fixed-size array of PortLinkData object pointers. When -data is attached, a new PortLinkData object is allocated and a copy of the -passed data is created inside it. When the time comes for the message to be sent, -the data is pieced together into a flattened array and written to the port. ------------------------------------------------------------------------- -Data members: - -*attachments[] - fixed-size array of pointers used to hold the attached data -opcode - message value which is sent along with any data -target - port to which the message is sent when Flush() is called -replyport - port used with synchronous messaging - FlushWithReply() -bufferlength - total bytes taken up by attachments -num_attachments - internal variable which is used to track which "slot" - will be the next one to receive an attachment object -*/ - -#include "PortLink.h" -#include -#include -#include - -//#define PLDEBUG - -// Internal data storage class for holding attached data whilst it is waiting -// to be Flattened() and then Flushed(). There is no need for this to be called outside -// the PortLink class. -class PortLinkData -{ -public: - PortLinkData(void); - ~PortLinkData(void); - bool Set(void *data, size_t size); - char *buffer; - size_t buffersize; -}; - -PortLink::PortLink(port_id port) -{ - // For this class to be useful (and to prevent a lot of init problems) - // we require a port in the constructor - target=port; - - // We start out without any data attached to the port message - num_attachments=0; - opcode=0; - bufferlength=0; - replyport=create_port(30,"PortLink reply port"); -} - -PortLink::~PortLink(void) -{ - // If, for some odd reason, this is deleted with something attached, - // free the memory used by the attachments. We do not flush the queue - // because the port may no longer be valid in cases such as the app - // is in the process of quitting - MakeEmpty(); -} - -void PortLink::SetOpCode(int32 code) -{ - // Sets the message code. This does not change once the message is sent. - // Another call to SetOpCode() is required for such things. - opcode=code; -} - -void PortLink::SetPort(port_id port) -{ - // Sets the target port. While not necessary in most uses, this exists - // mostly to prevent flexibility problems - target=port; -} - -port_id PortLink::GetPort(void) -{ - // Simply returns the port at which the object is pointed. - return target; -} - -void PortLink::Flush(bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message off to the target, complete with attachments. NOTE: - // the recipient must delete all attachments, being the PortLink object assumes - // no responsiblity for the attachments once the message is sent. - int8 *msgbuffer; - int32 size; - - if(num_attachments>0) - { - FlattenData(&msgbuffer,&size); - - // Dump message to port, reset attachments, and clean up - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,msgbuffer,size,B_TIMEOUT, timeout); - else - write_port(target,opcode,msgbuffer,size); - MakeEmpty(); - } - else - { - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,NULL,0,B_TIMEOUT, timeout); - else - write_port(target,opcode,NULL,0); - } -} - -int8* PortLink::FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message to the target and then waits for a reply. The target will - // receive a message with the first item being the port_id to reply to. - // NOTE: like Flush(), any attached data must be deleted. - - // Effectively, an Attach() call inlined for changes - - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - { - *status=B_ERROR; - return NULL; - } - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&replyport,sizeof(port_id))) - { - bufferlength+=sizeof(port_id); - } - else - { - delete pld; - *status=B_ERROR; - return NULL; - } - - // Flatten() inlined to make some necessary changes - int8 *buffer=new int8[bufferlength]; - int8 *bufferindex=buffer; - size_t size=0; - - // attach our port_id first - memcpy(bufferindex, pld->buffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - - // attach everything else - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - } - - // Flush the thing....FOOSH! :P - write_port(target,opcode,buffer,size); - MakeEmpty(); - delete buffer; - - // Now we wait for the reply - if(timeout==B_INFINITE_TIMEOUT) - { - *buffersize=port_buffer_size(replyport); - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - else - { - *buffersize=port_buffer_size_etc(replyport,0,timeout); - if(*buffersize==B_TIMED_OUT) - { - *status=*buffersize; - return NULL; - } - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - - // We got this far, so we apparently have some data - *status=B_OK; - return buffer; -} - -void PortLink::Attach(void *data, size_t size) -{ - // This is the member called to attach data to a message. Attachments are - // treated to be in 'Append' mode, tacking on each attached piece of data - // to the end of the list. - - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - if(size==0) - return; - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -// These functions were added for a major convenience in passing common types -// Eventually, I'd like to templatize these, but for now, this'll do - -void PortLink::Attach(int32 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int32); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int16 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int16); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int8 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int8); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(float data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(float); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(bool data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(bool); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BRect data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BRect); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BPoint data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BPoint); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::FlattenData(int8 **buffer,int32 *size) -{ - // This function is where all the magic happens, but it is strictly internal. - // It iterates through each PortLinkData object and copies it to the main buffer - // which ends up, ultimately, being written to the PortLink's target port. - - // skip if there aree no attachments - if(bufferlength<1) - return; - - *buffer=new int8[bufferlength]; - int8 *bufferindex=*buffer; - PortLinkData *pld; - *size=0; - - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - *size+=pld->buffersize; - } -} - -void PortLink::MakeEmpty(void) -{ - // Nukes all the attachments currently held by the PortLink class - if(num_attachments!=0) - { - for(int i=0; i0) - free(buffer); -} - -bool PortLinkData::Set(void *data, size_t size) -{ - // Function copies the passed to the internal buffers for storage - if(size>0 && buffersize==0 && data!=NULL) - { - buffer=(char *)malloc(size); - if(buffer==NULL) - return false; - memcpy(buffer, data, size); - buffersize=size; - return true; - } - return false; -} diff --git a/src/servers/app/proto6/PortLink.h b/src/servers/app/proto6/PortLink.h deleted file mode 100644 index 429f342024..0000000000 --- a/src/servers/app/proto6/PortLink.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _PORTLINK_H_ -#define _PORTLINK_H_ - -#include -#include -#include -#include - -#ifndef _PORTLINK_BUFFERSIZE -#define _PORTLINK_MAX_ATTACHMENTS 50 -#endif - -class PortLinkData; - -class PortLink -{ -public: - PortLink(port_id port); - ~PortLink(void); - void SetOpCode(int32 code); - void SetPort(port_id port); - port_id GetPort(void); - void Flush(bigtime_t timeout=B_INFINITE_TIMEOUT); - int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, - bigtime_t timeout=B_INFINITE_TIMEOUT); - void Attach(void *data, size_t size); - void Attach(int32 data); - void Attach(int16 data); - void Attach(int8 data); - void Attach(float data); - void Attach(bool data); - void Attach(BRect data); - void Attach(BPoint data); - void MakeEmpty(void); -protected: - void FlattenData(int8 **buffer,int32 *size); - port_id target, replyport; - int32 opcode, bufferlength; - int num_attachments; - PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS]; -}; - -#endif diff --git a/src/servers/app/proto6/ScreenDriver.cpp b/src/servers/app/proto6/ScreenDriver.cpp deleted file mode 100644 index 1928324e9a..0000000000 --- a/src/servers/app/proto6/ScreenDriver.cpp +++ /dev/null @@ -1,915 +0,0 @@ -/* - ScreenDriver.cpp - Replacement class for the ViewDriver which utilizes a BWindowScreen for ease - of testing without requiring a second video card for SecondDriver and also - without the limitations (mostly speed) of ViewDriver. - - Note that unlike ViewDriver, this graphics module does NOT emulate - the Input Server. The Router input server filter is required for use. - - The concept is pretty close to the retooled ViewDriver, where each module - call locks a couple BLockers and draws to the buffer. - - Components: - ScreenDriver: actual driver module - FrameBuffer: BWindowScreen derivative which provides the module access - to the video card - Internal functions for doing graphics on the buffer - - Done: - Basic module init and shutdown - Clear() - 8-bit and 32-bit - SetPixel32 - StrokeLine(pt,pt,rgb_color) - StrokeRect - both forms - FillRect - both forms, but not using fastest methods - ToDo: - 16-Bit mode functions - StrokeLine(pt,pattern) needs to utilize patterns - FillRect(rect,pattern) needs to utilize patterns - Implement a lot of functions -*/ -#include "ScreenDriver.h" -#include "ServerCursor.h" -#include "ServerProtocol.h" -#include "ServerBitmap.h" -#include "SystemPalette.h" -#include "ColorUtils.h" -#include "PortLink.h" -#include "DebugTools.h" -#include -#include -#include -#include - -#define DEBUG_DRIVER - -// Define this if you want to use the spacebar to launch the server prototype's -// test application -#define LAUNCH_TESTAPP - -#ifdef LAUNCH_TESTAPP -#include -#include -#endif - -// functions internal to the driver -void Clear_32Bit(void *buffer, int width, int height, rgb_color col); -void Clear_16Bit(void *buffer, int width, int height, uint16 col); -void Clear_8Bit(void *buffer, int width, int height, uint8 col); - -void HLine_32Bit(graphics_card_info i, uint16 x, uint16 y, uint16 length, rgb_color col); -void HLine_16Bit(graphics_card_info i, uint16 x, uint16 y, uint16 length, uint16 col); -void HLine_16Bit(graphics_card_info i, uint16 x, uint16 y, uint16 length, uint8 col); - -FrameBuffer::FrameBuffer(const char *title, uint32 space, status_t *st,bool debug) - : BWindowScreen(title,space,st,debug) -{ - is_connected=false; -} - -FrameBuffer::~FrameBuffer(void) -{ -} - -void FrameBuffer::ScreenConnected(bool connected) -{ - is_connected=connected; - if(connected) - { - // Cache the state just in case - graphics_card_info *info=CardInfo(); - gcinfo=*info; - } -} - -void FrameBuffer::MessageReceived(BMessage *msg) -{ - switch(msg->what) - { - case B_KEY_DOWN: - { - int32 key; - msg->FindInt32("key",&key); - if(key==0x47) // Enter key - { - port_id serverport=find_port(SERVER_PORT_NAME); - write_port(serverport,B_QUIT_REQUESTED,NULL,0); - break; - } - #ifdef LAUNCH_TESTAPP - if(key==0x5e) - { - printf("Launching test app\n"); - status_t value; - BEntry entry("/boot/home/Desktop/openbeos/proto6/OBApplication/OBApplication"); - entry_ref ref; - entry.GetRef(&ref); - value=be_roster->Launch(&ref); - - BString str=TranslateStatusToString(value); - printf("Launch return code: %s",str.String()); - printf("\n"); - } - #endif - } - default: - BWindowScreen::MessageReceived(msg); - } -} - -bool FrameBuffer::QuitRequested(void) -{ - port_id serverport=find_port(SERVER_PORT_NAME); - - if(serverport!=B_NAME_NOT_FOUND) - write_port(serverport,B_QUIT_REQUESTED,NULL,0); - - return true; -} - -ScreenDriver::ScreenDriver(void) -{ - status_t st; - fbuffer=new FrameBuffer("OBAppServer",B_8_BIT_640x480,&st,true); - - drawmode=DRAW_COPY; - // Create our cursor here - cursor=new ServerBitmap(BRect(0,0,16,16),B_CMAP8); -} - -ScreenDriver::~ScreenDriver(void) -{ - delete cursor; -} - -void ScreenDriver::Initialize(void) -{ - fbuffer->Show(); - - // draw on the module's default cursor here to make it look preety - - // wait 1 sec for the window to show... - snooze(500000); -} - -void ScreenDriver::Shutdown(void) -{ - fbuffer->Lock(); - fbuffer->Quit(); -} - -void ScreenDriver::Clear(uint8 red,uint8 green,uint8 blue) -{ - locker->Lock(); - rgb_color c; - SetRGBColor(&c,red,green,blue); - Clear(c); - locker->Unlock(); -} - -void ScreenDriver::Clear(rgb_color col) -{ - locker->Lock(); -#ifdef DEBUG_DRIVER -printf("ScreenDriver::Clear(%u,%u,%u)\n",col.red,col.green,col.blue); -#endif - if(fbuffer->IsConnected()) - { - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 32: - case 24: - { -printf("Clear: 32/24-bit\n"); - Clear_32Bit(fbuffer->gcinfo.frame_buffer, - fbuffer->gcinfo.width,fbuffer->gcinfo.height,col); - break; - } - case 16: - case 15: - { -printf("Clear: 16/15-bit unimplemented\n"); - // Look up color here -// uint16 c; -// Clear_16Bit(gcinfo.frame_buffer,gcinfo.width,gcinfo.height,c); - break; - } - case 8: - { -printf("Clear: 8-bit\n"); - // Look up color here - uint8 c=FindClosestColor(fbuffer->ColorList(),col); - - Clear_8Bit(fbuffer->gcinfo.frame_buffer, - fbuffer->gcinfo.width,fbuffer->gcinfo.height, c); - break; - } - default: - { -#ifdef DEBUG_DRIVER -printf("Clear: unknown bit depth %u\n",fbuffer->gcinfo.bits_per_pixel); -#endif - break; - } - } - } - else - { -#ifdef DEBUG_DRIVER -printf("Clear: driver is disconnected\n"); -#endif - } - locker->Unlock(); -} - -void ScreenDriver::DrawBitmap(ServerBitmap *bitmap, BRect source, BRect dest) -{ - locker->Lock(); -#ifdef DEBUG_DRIVER -printf("ScreenDriver::DrawBitmap(*, (%f,%f,%f,%f),(%f,%f,%f,%f) )\n", - source.left,source.top,source.right,source.bottom, - dest.left,dest.top,dest.right,dest.bottom); -#endif - if(fbuffer->IsConnected()) - { - // Scale bitmap here if source!=dest - - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 32: - case 24: - { - printf("DrawBitmap: 32/24-bit unimplemented\n"); - break; - } - case 16: - case 15: - { - printf("DrawBitmap: 16/15-bit unimplemented\n"); - break; - } - case 8: - { - printf("DrawBitmap: 8-bit unimplemented\n"); - break; - } - default: - { -#ifdef DEBUG_DRIVER -printf("Clear: unknown bit depth %u\n",fbuffer->gcinfo.bits_per_pixel); -#endif - break; - } - } - } - - locker->Unlock(); -} - -void ScreenDriver::FillRect(BRect rect, uint8 *pattern) -{ - locker->Lock(); - - FillRect(rect,highcol); - - locker->Unlock(); -} - -void ScreenDriver::FillRect(BRect rect, rgb_color col) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::FillRect( (%f,%f,%f,%f), {%u,%u,%u,%u}\n",rect.left,rect.top, - rect.right,rect.bottom,col.red,col.green,col.blue,col.alpha); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - // int32 width=rect.IntegerWidth(); - for(int32 i=(int32)rect.top;i<=rect.bottom;i++) - // HLine(fbuffer->gcinfo,(int32)rect.left,i,width,col); - StrokeLine(BPoint(rect.left,i),BPoint(rect.right,i),col); - } - locker->Unlock(); -} - -void ScreenDriver::FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::FillRoundRect( (%f,%f,%f,%f), %llx) ---->Unimplemented<----\n",rect.left,rect.top, - rect.right,rect.bottom,*((uint64*)pattern)); -#endif - FillRect(rect,pattern); -} - -void ScreenDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::FillTriangle(%llx): --->Currently Unimplemented<---\n",*((uint64*)pattern)); -printf("\tFirst: (%f,%f)\n\tSecond: (%f,%f)\n\tThird: (%f,%f)\n",first.x,first.y, - second.x,second.y,third.x,third.y); -rect.PrintToStream(); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - BPoint oldpos=penpos; - MovePenTo(first); StrokeLine(second,pattern); - MovePenTo(second); StrokeLine(third,pattern); - MovePenTo(third); StrokeLine(first,pattern); - penpos=oldpos; - } - locker->Unlock(); -} - -void ScreenDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::FillTriangle({%u,%u,%u,%u}): --->Currently Unimplemented<---\n", - col.red,col.green,col.blue,col.alpha); -printf("\tFirst: (%f,%f)\n\tSecond: (%f,%f)\n\tThird: (%f,%f)\n",first.x,first.y, - second.x,second.y,third.x,third.y); -rect.PrintToStream(); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - StrokeLine(first,second,col); - StrokeLine(first,third,col); - StrokeLine(third,second,col); - } - locker->Unlock(); -} - -void ScreenDriver::SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - rgb_color col={r,g,b,a}; - SetHighColor(col); -} - -void ScreenDriver::SetHighColor(rgb_color col) -{ - highcol=col; - - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 16: - case 15: - high16=FindClosestColor16(highcol); - break; - case 8: - high8=FindClosestColor(system_palette,highcol); - break; - default: - break; - } -} - -void ScreenDriver::SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - rgb_color col={r,g,b,a}; - SetLowColor(col); -} - -void ScreenDriver::SetLowColor(rgb_color col) -{ - lowcol=col; - - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 16: - case 15: - low16=FindClosestColor16(highcol); - break; - case 8: - low8=FindClosestColor(system_palette,highcol); - break; - default: - break; - } -} - -void ScreenDriver::SetPixel(int x, int y, uint8 *pattern) -{ - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 32: - case 24: - SetPixel32(x,y,highcol); - break; - case 16: - case 15: - SetPixel16(x,y,FindClosestColor16(highcol)); - break; - default: - printf("SetPixel8 Unimplemented\n"); -// SetPixel8(x,y,FindClosestColor(highcol)); - break; - } - -} - -void ScreenDriver::SetPixel32(int x, int y, rgb_color col) -{ - // Code courtesy of YNOP's SecondDriver - union - { - uint8 bytes[4]; - uint32 word; - }c1; - - c1.bytes[0]=col.blue; - c1.bytes[1]=col.green; - c1.bytes[2]=col.red; - c1.bytes[3]=col.alpha; - - uint32 *bits=(uint32*)fbuffer->gcinfo.frame_buffer; - *(bits + x + (y*fbuffer->gcinfo.width))=c1.word; -} - -void ScreenDriver::SetPixel16(int x, int y, uint16 col) -{ -#ifdef DEBUG_DRIVER -printf("SetPixel16 unimplemented\n"); -#endif -} - -void ScreenDriver::SetPixel8(int x, int y, uint8 col) -{ - // When the DisplayDriver API changes, we'll use the uint8 highcolor. Until then, - // we'll use *pattern - uint8 *bits=(uint8*)fbuffer->gcinfo.frame_buffer; - *(bits + x + (y*fbuffer->gcinfo.bytes_per_row))=col; -} - -void ScreenDriver::SetScreen(uint32 space) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::SetScreen(%lu}\n",space); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - fbuffer->SetSpace(space); - - // We have changed the frame buffer info, so update the cached info - graphics_card_info *info=fbuffer->CardInfo(); - fbuffer->gcinfo=*info; - } - locker->Unlock(); -} - -void ScreenDriver::StrokeLine(BPoint point, uint8 *pattern) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeLine( (%f,%f), %llx}\n",point.x,point.y,*((uint64*)pattern)); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - // Courtesy YNOP's SecondDriver with minor changes by DW - int oct=0; - int xoff=(int32)penpos.x; - int yoff=(int32)penpos.y; - int32 x2=(int32)point.x-xoff; - int32 y2=(int32)point.y-yoff; - int32 x1=0; - int32 y1=0; - if(y2<0){ y2=-y2; oct+=4; }//bit2=1 - if(x2<0){ x2=-x2; oct+=2;}//bit1=1 - if(x2Unlock(); -} - -void ScreenDriver::StrokeLine(BPoint start, BPoint end, rgb_color col) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeLine( (%f,%f),(%f,%f), {%u,%u,%u,%u}\n",start.x,start.y, - end.x,end.y,col.red,col.green,col.blue,col.alpha); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - // Courtesy YNOP's SecondDriver with minor changes by DW - rgb_color savecol=highcol; - SetHighColor(col.red,col.green,col.blue); - - int oct=0; - int xoff=(int32)start.x; - int yoff=(int32)start.y; - int32 x2=(int32)end.x-xoff; - int32 y2=(int32)end.y-yoff; - int32 x1=0; - int32 y1=0; - if(y2<0){ y2=-y2; oct+=4; }//bit2=1 - if(x2<0){ x2=-x2; oct+=2;}//bit1=1 - if(x2Unlock(); -} - -void ScreenDriver::StrokePolygon(int *x, int *y, int numpoints, bool is_closed) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokePolygon( is_closed=%s)\n",(is_closed==true)?"true":"false"); -for(int debug=0;debugLock(); - if(fbuffer->IsConnected()) - { - for(int32 i=0; i<(numpoints-1); i++) - StrokeLine(BPoint(x[i],y[i]),BPoint(x[i+1],y[i+1]),highcol); - - if(is_closed) - StrokeLine(BPoint(x[numpoints-1],y[numpoints-1]),BPoint(x[0],y[0]),highcol); - } - locker->Unlock(); -} - -void ScreenDriver::StrokeRect(BRect rect,uint8 *pattern) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeRect( (%f,%f,%f,%f), %llx)\n",rect.left,rect.top, - rect.right,rect.bottom,*((uint64*)pattern)); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - BPoint oldpos=penpos; - - MovePenTo(rect.LeftTop()); StrokeLine(BPoint(rect.right,rect.top),pattern); - MovePenTo(BPoint(rect.right,rect.top)); StrokeLine(BPoint(rect.right,rect.bottom),pattern); - MovePenTo(BPoint(rect.right,rect.bottom)); StrokeLine(BPoint(rect.left,rect.bottom),pattern); - MovePenTo(BPoint(rect.left,rect.bottom)); StrokeLine(BPoint(rect.left,rect.top),pattern); - -// Line32(rect.LeftTop(),BPoint(rect.right,rect.top),pattern); -// Line32(BPoint(rect.right,rect.top),BPoint(rect.right,rect.bottom),pattern); -// Line32(BPoint(rect.right,rect.bottom),BPoint(rect.left,rect.bottom),pattern); -// Line32(BPoint(rect.left,rect.bottom),BPoint(rect.left,rect.top),pattern); - - penpos=oldpos; - } - locker->Unlock(); -} - -void ScreenDriver::StrokeRect(BRect rect,rgb_color col) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeRect( (%f,%f,%f,%f), {%u,%u,%u,%u}\n",rect.left,rect.top, - rect.right,rect.bottom,col.red,col.green,col.blue,col.alpha); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - StrokeLine(BPoint(rect.left,rect.top),BPoint(rect.right,rect.top),col); - StrokeLine(BPoint(rect.right,rect.top),BPoint(rect.right,rect.bottom),col); - StrokeLine(BPoint(rect.right,rect.bottom),BPoint(rect.left,rect.bottom),col); - StrokeLine(BPoint(rect.left,rect.bottom),BPoint(rect.left,rect.top),col); - } - locker->Unlock(); -} - -void ScreenDriver::StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeRoundRect( (%f,%f,%f,%f), %llx) ---->Unimplemented<----\n",rect.left,rect.top, - rect.right,rect.bottom,*((uint64*)pattern)); -#endif - StrokeRect(rect,pattern); -} - -void ScreenDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeTriangle(%llx):\n",*((uint64*)pattern)); -printf("\tFirst: (%f,%f)\n\tSecond: (%f,%f)\n\tThird: (%f,%f)\n",first.x,first.y, - second.x,second.y,third.x,third.y); -rect.PrintToStream(); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - BPoint oldpos=penpos; - MovePenTo(first); StrokeLine(second,pattern); - MovePenTo(second); StrokeLine(third,pattern); - MovePenTo(third); StrokeLine(first,pattern); - penpos=oldpos; - } - locker->Unlock(); -} - -void ScreenDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeTriangle({%u,%u,%u,%u}):\n", - col.red,col.green,col.blue,col.alpha); -printf("\tFirst: (%f,%f)\n\tSecond: (%f,%f)\n\tThird: (%f,%f)\n",first.x,first.y, - second.x,second.y,third.x,third.y); -rect.PrintToStream(); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - StrokeLine(first,second,col); - StrokeLine(first,third,col); - StrokeLine(third,second,col); - } - locker->Unlock(); -} - -void ScreenDriver::Line32(BPoint pt, BPoint pt2, uint8 *pattern) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::Line32( (%f,%f),(%f,%f), 0x%llx\n",pt.x,pt.y, - pt2.x,pt2.y,*((int64*)pattern)); -#endif - // Courtesy YNOP's SecondDriver with minor changes by DW - int oct=0; - int xoff=(int32)pt.x; - int yoff=(int32)pt.y; - int32 x2=(int32)pt2.x-xoff; - int32 y2=(int32)pt2.y-yoff; - int32 x1=0; - int32 y1=0; - if(y2<0){ y2=-y2; oct+=4; }//bit2=1 - if(x2<0){ x2=-x2; oct+=2;}//bit1=1 - if(x232) - patindex=0; - } -} - -void ScreenDriver::SetPixelPattern(int x, int y, uint8 *pattern, uint8 patternindex) -{ - // This function is designed to add pattern support to this thing. Should be - // inlined later to add speed lost in the multiple function calls. -#ifdef DEBUG_DRIVER -printf("ScreenDriver::SetPixelPattern(%u,%u,%llx,%u)\n",x,y,*((int64*)pattern),patternindex); -#endif - if(patternindex>32) - return; - - if(fbuffer->IsConnected()) - { - uint64 *p64=(uint64*)pattern; - - // check for transparency in mask. If transparent, we can quit here - - bool transparent_bit= - ( *p64 & ~((uint64)2 << (32-patternindex)))?true:false; -printf("SetPixelPattern: pattern=0x%llx\n",*p64); -printf("SetPixelPattern: bit=0x%llx\n",((uint64)2 << (32-patternindex))); -printf("SetPixelPattern: bit mask=0x%llx\n",~((uint64)2 << (32-patternindex))); -printf("SetPixelPattern: bit value=%s\n",transparent_bit?"true":"false"); - - bool highcolor_bit= - ( *p64 & ~((uint64)2 << (64-patternindex)))?true:false; - - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 32: - case 24: - { - - break; - } - case 16: - case 15: - { - break; - } - case 8: - { - break; - } - default: - { -#ifdef DEBUG_DRIVER -printf("SetPixelPattern: unknown bit depth %u\n",fbuffer->gcinfo.bits_per_pixel); -#endif - break; - } - } - } - else - { -#ifdef DEBUG_DRIVER -printf("SetPixelPattern: driver is disconnected\n"); -#endif - } -} - -void Clear_32Bit(void *buffer, int width, int height, rgb_color col) -{ -#ifdef DEBUG_DRIVER -printf("Clear_32Bit(*,%d,%d,(r=%u,g=%u,b=%u,a=%u)\n",width,height,col.red,col.green, - col.blue,col.alpha); -#endif - - uint32 c=0,*pcolor=(uint32*)buffer; - - // apparently width=bytes per row - uint32 bpr=width; - - // ARGB order - c|=col.alpha * 0x01000000; - c|=col.red * 0x010000; - c|=col.green * 0x0100; - c|=col.blue; - -#ifdef DEBUG_DRIVER -printf("Clear color value: 0x%lx\n",c); -#endif - for(int32 j=0;jbpr)?length-((x+length)-bpr):length; - - pcolor=(uint32*)i.frame_buffer; - pcolor+=(y*bpr)+(x*4); - for(int32 i=0;ibpr)?length-((x+length)-bpr):length; - - memset(pcolor,col,bytes); -} diff --git a/src/servers/app/proto6/ScreenDriver.h b/src/servers/app/proto6/ScreenDriver.h deleted file mode 100644 index 0f35717241..0000000000 --- a/src/servers/app/proto6/ScreenDriver.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef _SCREENDRIVER_H_ -#define _SCREENDRIVER_H_ - -#include -#include -#include -#include -#include -#include -#include -#include // for clipping_rect definition -#include -#include "DisplayDriver.h" - -class VDWindow; -class ServerCursor; -class ServerBitmap; - - -class FrameBuffer : public BWindowScreen -{ -public: - FrameBuffer(const char *title, uint32 space, status_t *st,bool debug); - ~FrameBuffer(void); - void ScreenConnected(bool connected); - void MessageReceived(BMessage *msg); - bool IsConnected(void) const { return is_connected; } - bool QuitRequested(void); - - graphics_card_info gcinfo; -protected: - bool is_connected; -}; - -class ScreenDriver : public DisplayDriver -{ -public: - ScreenDriver(void); - ~ScreenDriver(void); - - void Initialize(void); - void Shutdown(void); - - void Clear(uint8 red,uint8 green,uint8 blue); - void Clear(rgb_color col); - - // Settings functions - void SetScreen(uint32 space); -/* int32 GetHeight(void); - int32 GetWidth(void); - int GetDepth(void); - - // Drawing functions - void Blit(BRect src, BRect dest); -*/ void DrawBitmap(ServerBitmap *bitmap, BRect source, BRect dest); -/* void DrawChar(char c, BPoint point); - void DrawString(char *string, int length, BPoint point); - - void FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - void FillBezier(BPoint *points, uint8 *pattern); - void FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - void FillPolygon(int *x, int *y, int numpoints, bool is_closed); -*/ void FillRect(BRect rect, uint8 *pattern); - void FillRect(BRect rect, rgb_color col); -// void FillRegion(BRegion *region); - void FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); -// void FillShape(BShape *shape); - - void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col); -/* - void HideCursor(void); - bool IsCursorHidden(void); - void MoveCursorTo(float x, float y); - void ObscureCursor(void); - float PenSize(void); - void SetCursor(ServerCursor *cursor); -*/ - void SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - void SetHighColor(rgb_color col); - void SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - void SetLowColor(rgb_color col); - - void SetPixel(int x, int y, uint8 *pattern); - - void SetPixel32(int x, int y, rgb_color col); - void SetPixel16(int x, int y, uint16 col); - void SetPixel8(int x, int y, uint8 col); - void SetPixelPattern(int x, int y, uint8 *pattern, uint8 patternindex); - -// void ShowCursor(void); - -// void StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); -// void StrokeBezier(BPoint *points, uint8 *pattern); -// void StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - void StrokeLine(BPoint point, uint8 *pattern); - void StrokeLine(BPoint pt1, BPoint pt2, rgb_color col); - void StrokePolygon(int *x, int *y, int numpoints, bool is_closed); - void StrokeRect(BRect rect,uint8 *pattern); - void StrokeRect(BRect rect,rgb_color col); - void StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); -// void StrokeShape(BShape *shape); - void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col); - -protected: - void Line32(BPoint pt, BPoint pt2, uint8 *pattern); - FrameBuffer *fbuffer; - int hide_cursor; - ServerBitmap *cursor; - int32 drawmode; -}; - -#endif diff --git a/src/servers/app/proto6/SecondDriver.cpp b/src/servers/app/proto6/SecondDriver.cpp deleted file mode 100644 index ca99a3b9e5..0000000000 --- a/src/servers/app/proto6/SecondDriver.cpp +++ /dev/null @@ -1,836 +0,0 @@ -/******************************************************* -* SecondDriver -* -* Second driver is a Drvier abstraction layer for the -* OBOS app_server. It provides access to the Graphic -* HW via the low level api calls. This provides a -* way to run the app_server on real HW. -* This driver also makes it easy for you to run the -* OBOS app_server in parallel with the Be app_server -* when two or more video cards are installed in your -* computer. -* -* @author YNOP (ynop@beunited.org) -* @version beta1 (p5) -* -* History: -* - Added Ellipse (Stroke & Fill) -* Ran though test app to make sure worked -* Fixed HorizLine to used fill_span instead of fill_rect :P -* Updated the Cursor code to work again. -* Made new cursor (Be-hand like) -* - Added StrokeBezir -* Added HorizLine for speed -* - Added HW acceleration methods -* - Brez Line added -* - Created by YNOP -* -* Todo: -* Clean up src and add more comments :P -* Redo StrokeLine to use PenSize -* Redo StrokeLine to use pattern -* Mouse Cursor seems to be broken in proto5 ? -* Add in a way to read app_server_settings file so we can get the real settings -* Make display mode settings more flexable -* Look into FreeType for DrawString :P fun fun fun -* -* Todo methods: -* Blit() DrawBitmap() DrawString() FillArc() FillBezier() FillPolygon() -* FillRegion() FillRoundRect() FillShape() FillTriangle() -* StrokeArc() StrokeRoundRect() StrokeShpae() -* -*******************************************************/ -#include -#include - -#include - -#include "PortLink.h" -#include "ServerProtocol.h" -#include "ServerBitmap.h" -#include "ServerCursor.h" -#include "DebugTools.h" -#include "SecondDriver.h" -#include "SecondDriverHelper.h" - -/******************************************************* -* @description -*******************************************************/ -SecondDriver::SecondDriver(void):DisplayDriver(){ - SetupBezier(); - hide_cursor = false; - fd = -1; - image = -1; - - gah = NULL; - bits = NULL; - bpr = -1; - - scs = NULL; - mc = NULL; - sc = NULL; - - et = NULL; - re = NULL; - - s2sb = NULL; - fr = NULL; - ir = NULL; - s2stb = NULL; - fs = NULL; - -} - -/******************************************************* -* @description -*******************************************************/ -SecondDriver::~SecondDriver(void){ - if(is_initialized){ - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::Initialize(void){ - et = NULL; - bits = NULL; - - // Find a driver - fd = get_device(); - if(fd < 0){ - printf("No Device settings found.\n"); - fd = find_device(); - }else{ - printf("Device read from settings file\n"); - } - if(fd < 0){ - printf("No device find, trying fallback stub\n"); - fd = fallback_device(); - } - if(fd < 0){ - printf("Didn't find device :(\n"); - is_initialized = false; - } - /* load the accelerant */ - image = load_accelerant(fd, &gah); - if (image >= 0){ - // Set up the display to a valid resolution - if(get_and_set_mode(gah,&dm) == B_OK){ - // Here we are all good - if(dm.space == B_CMAP8){ - set_palette(gah); - } - get_frame_buffer(gah, &fbc); - bits = (uint32*)fbc.frame_buffer/*_dma*/; - bpr = fbc.bytes_per_row/4; // sould be by depth - - if(dm.flags & B_HARDWARE_CURSOR){ - // Lets check out tha hardwar cursoer stuff :P - printf("Mode supports Hardware cursors\n"); - scs = (set_cursor_shape)gah(B_SET_CURSOR_SHAPE,NULL); - mc = (move_cursor)gah(B_MOVE_CURSOR,NULL); - sc = (show_cursor)gah(B_SHOW_CURSOR,NULL); - } - - // Ok. now lets see if we can add some spiffy - // 2D acceleration to this :) - accelerant_engine_count aec = (accelerant_engine_count)gah(B_ACCELERANT_ENGINE_COUNT,NULL); - uint32 count = aec(); - if(count > 0){ - acquire_engine ae = (acquire_engine)gah(B_ACQUIRE_ENGINE,NULL); - re = (release_engine)gah(B_RELEASE_ENGINE,NULL); - if(ae(B_2D_ACCELERATION,1000,&st,&et) == B_OK){ - // Now lets see if we have some functions - printf("You should be verry happy. You have 2D hardware Acceleration\n"); - s2sb = (screen_to_screen_blit)gah(B_SCREEN_TO_SCREEN_BLIT,NULL); - fr = (fill_rectangle)gah(B_FILL_RECTANGLE,NULL); - ir = (invert_rectangle)gah(B_INVERT_RECTANGLE,NULL); - s2stb = (screen_to_screen_transparent_blit)gah(B_SCREEN_TO_SCREEN_TRANSPARENT_BLIT,NULL); - fs = (fill_span)gah(B_FILL_SPAN,NULL); - } - } - is_initialized = true; - }else{ - // failed to set mode - is_initialized = false; - } - }else{ - // image failed to load - is_initialized = false; - } - - if(is_initialized){ - printf("\n\tSecond Driver by YNOP (ynop@beunited.org)\n"); - printf("\tSecond Driver is copyrigth YNOP 2002\n"); - printf("\tHave fun, its all set up :)\n\n"); - } - - SetCursor((ServerCursor*)NULL); - ShowCursor(); - int32 h = GetHeight(); - int32 w = GetWidth(); - MoveCursorTo(w/2,h/2); - -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::Shutdown(void){ - printf("\tShuting down SecondDriver\n"); - if(et){ - if(re(et,&st) != B_OK){ - printf("Failed to release engine\n"); - } - } - - uninit_accelerant ua = (uninit_accelerant)gah(B_UNINIT_ACCELERANT,NULL); - if(ua){ ua();} - - unload_add_on(image); - - // clsoe the file now... - close(fd); - - - is_initialized=false; -} - -/******************************************************* -* @description -*******************************************************/ -bool SecondDriver::IsInitialized(void){ - return is_initialized; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SafeMode(void){ -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::Reset(void){ -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetScreen(uint32 space){ - // Clear(51,102,152); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::Clear(uint8 red, uint8 green, uint8 blue){ - rgb_color r; - r.red = red; - r.blue = blue; - r.green = green; - Clear(r); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::Clear(rgb_color col){ - highcol = col; - FillRect(BRect(0,0,GetHeight()-1,GetWidth()-1),NULL); -} - -/******************************************************* -* @description -*******************************************************/ -int32 SecondDriver::GetHeight(void){ - // Gets the height of the current mode - return dm.virtual_height; -} - -/******************************************************* -* @description -*******************************************************/ -int32 SecondDriver::GetWidth(void){ - // Gets the width of the current mode - return dm.virtual_width; -} - -/******************************************************* -* @description -*******************************************************/ -int SecondDriver::GetDepth(void){ - // Gets the color depth of the current mode - return 0; -} - -/******************************************************* -* @description -*******************************************************/ -#ifdef PROTO_4 - void SecondDriver::Blit(BPoint loc, ServerBitmap *src, ServerBitmap *dest) -#else - void SecondDriver::Blit(BRect src, BRect dest) -#endif -{ - printf("Calling Blit (not wirten yet)\n"); - if(s2sb){ - printf("Accelerated Blit\n"); - }else{ - - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::DrawBitmap(ServerBitmap *bitmap, BRect source, BRect dest){ - printf("Calling DrawBitmap (not writen yet)\n"); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::DrawChar(char c, BPoint point){ - char string[2]; - string[0]=c; - string[1]='\0'; - DrawString(string,2,point); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::DrawString(char *string, int length, BPoint point){ - printf("DrawString is not writen yet\n"); - - // i would say that libtruetype would do some good herer -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern){ - printf("FillArc is not writen yet\n"); - StrokeArc(centerx,centery,xradius,yradius,angle,span,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillBezier(BPoint *points, uint8 *pattern){ - printf("FillBezier is not writen yet\n"); - StrokeBezier(points,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern){ - MidpointEllipse(centerx,centery,x_radius,y_radius,true,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillPolygon(int *x, int *y, int numpoints, bool is_closed){ - printf("FillPolygon is not writen yet\n"); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillRect(BRect rect, uint8 *pattern){ - if(fr){ - // usieng accelertated 2d file - union{ - uint8 bytes[4]; - uint32 word; - }c1; - - //printf("Accelerated Fill\n"); - fill_rect_params frp; - frp.left =(uint16) rect.left; - frp.top =(uint16) rect.top; - frp.right =(uint16) rect.right; - frp.bottom =(uint16) rect.bottom; - c1.bytes[0] = highcol.blue; - c1.bytes[1] = highcol.green; - c1.bytes[2] = highcol.red; - fr(et,c1.word,&frp,1); - }else{ - for(int32 i = 0;i < rect.Height()-1;i++){ - MovePenTo(BPoint(rect.left,rect.top+i)); - StrokeLine(BPoint(rect.right,rect.top+i),pattern); - //HorizLine(rect.left,rect.right,rect.top+i); // uses accel :P - } - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillRect(BRect rect, rgb_color col){ - rgb_color tmpc = highcol; - highcol = col; - FillRect(rect, NULL); - highcol = tmpc; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillRegion(BRegion *region){ - printf("RillRegion is not writen yet\n"); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern){ - printf("FillRoundRect is not writen yet\n"); - StrokeRoundRect(rect,xradius,yradius,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillShape(BShape *shape){ - printf("FillShape is not writen yet\n"); - StrokeShape(shape); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern){ - printf("FillTriangle is not writen yet\n"); - StrokeTriangle(first,second,third,rect,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color color){ - printf("FillTriangle is not writen yet\n"); - StrokeTriangle(first,second,third,rect,color); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::HideCursor(void){ - if(sc){ - sc(false); - cursor_visible = false; - }else{ - printf("Shoftware Hide Cursor\n"); - } -} - -/******************************************************* -* @description -*******************************************************/ -bool SecondDriver::IsCursorHidden(void){ - return cursor_visible; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::ObscureCursor(void){ - // Hides cursor until mouse is moved - HideCursor(); - show_on_move = true; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::MoveCursorTo(float x, float y){ - if(show_on_move){ - ShowCursor(); - } - if(mc){ - mc((short unsigned int)x,(short unsigned int)y); - }else{ - printf("Software move Cursor\n"); - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::MovePenTo(BPoint pt){ - penpos = pt; -} - -/******************************************************* -* @description -*******************************************************/ -BPoint SecondDriver::PenPosition(void){ - return penpos; -} - -/******************************************************* -* @description -*******************************************************/ -float SecondDriver::PenSize(void){ - return pensize; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetCursor(int32 value){ - printf("Setcursoer value?\n"); - // Uh what is this all about? -} - - - - -//0 - 1 = black -//0 - 0 = what -//1 - 0 = trans -//1 - 1 = invert - -// Pointy cursor -/*uint8 andMask[] = { - 63,255,15,255,131,255,128,127,192,31,192,31,224,63,224,63, - 224,31,240,15,243,7,255,131,255,193,255,224,255,240,255,248 -}; -uint8 xorMask[] = { - 192,0,176,0,76,0,67,128,32,96,32,32,16,64,16,64, - 16,32,11,16,12,136,0,68,0,34,0,17,0,9,0,7 -};*/ -// BeOS like cursor -uint8 andMask[] = { - 255,255,255,255,199,255,195,255,195,255,224,31,224,3,240,1, - 240,0,192,0,128,0,128,0,192,0,240,0,252,1,254,7 -}; -uint8 xorMask[] = { - 0,0,0,0,56,0,36,0,36,0,19,224,18,92,9,42, - 8,1,60,0,76,0,66,0,48,0,12,0,2,0,1,0 -}; - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetCursor(ServerCursor *cursor){ - printf("Setting cursor\n"); - current_cursor = cursor; -// uint8 *andMask; - // uint8 *xorMask; - if(scs){ -// scs(cursor->width,cursor->height,(short unsigned int)cursor->hotspot.x,(short unsigned int)cursor->hotspot.y,andMask,xorMask); - scs(16,16,3,3,andMask,xorMask); - }else{ - printf("Setting software cursor\n"); - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetPenSize(float size){ - pensize = size; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetPixel(int x, int y, uint8 *pattern){ - union{ - uint8 bytes[4]; - uint32 word; - }c1; - - c1.bytes[0] = highcol.blue; - c1.bytes[1] = highcol.green; - c1.bytes[2] = highcol.red; - c1.bytes[3] = highcol.alpha; - - *(bits + x + y*bpr) = c1.word; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::ShowCursor(void){ - printf("\tShow Cursor\n"); - show_on_move = false; - cursor_visible = true; - if(sc){ - sc(true); - }else{ - printf("Software show cursor\n"); - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern){ - printf("StrokeArch is not writen yet\n"); -} - - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::StrokeBezier(BPoint *pts, uint8 *pattern){ - BPoint segment[SEGMENTS + 1]; - computeSegments(pts[0], pts[1],pts[2],pts[3], segment); - - MovePenTo(segment[0]); - - for(int32 s = 1 ; s <= SEGMENTS ; ++s ){ - if(segment[s].x != segment[s - 1].x || segment[s].y != segment[s - 1].y ) { - StrokeLine(segment[s],pattern); - } - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern){ - MidpointEllipse(centerx,centery,x_radius,y_radius,false,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::StrokeLine(BPoint point, uint8 *pattern){ - if(penpos.y == point.y){ - HorizLine(penpos.x,point.x,point.y,pattern); - return; - } - - int oct = 0; - int xoff = (int32)penpos.x; - int yoff = (int32)penpos.y; - int32 x2 = (int32)point.x-xoff; - int32 y2 = (int32)point.y-yoff; - int32 x1 = 0; - int32 y1 = 0; -// if(y2==0){ if (x1>x2){int t=x1;x1=x2;x2=t;}HorizLine(x1+xoff,x2+xoff,y1+yoff); return;} - if(y2<0){ y2 = -y2; oct+=4; }//bit2=1 - if(x2<0){ x2 = -x2; oct+=2;}//bit1=1 - if(x2 x2){ int32 t=x1;x1=x2;x2=t; } - if(fr){ - union{ - uint8 bytes[4]; - uint32 word; - }c1; - - //printf("Accelerated HorizLine\n"); - uint16 list[3]; - list[0] = y; - list[1] = x1; - list[2] = x2; - c1.bytes[0] = highcol.blue; - c1.bytes[1] = highcol.green; - c1.bytes[2] = highcol.red; - fs(et,c1.word,list,1); - }else{ - //software hline - printf("\t!!HorizLine without HWaccel is a waist\n"); - for(int32 i = x1; i <= x2;i++){ - SetPixel(i,y,pattern); - } - } - -} - -//void EllipsePoints(float cx,float cy,int32 x, int32 y){ -// view->StrokeLine(BPoint(x+cent.x,y+cent.y),BPoint(x+cent.x,y+cent.y)); -// view->StrokeLine(BPoint(-x+cent.x,y+cent.y),BPoint(-x+cent.x,y+cent.y)); -// view->StrokeLine(BPoint(x+cent.x,-y+cent.y),BPoint(x+cent.x,-y+cent.y)); -// view->StrokeLine(BPoint(-x+cent.x,-y+cent.y),BPoint(-x+cent.x,-y+cent.y)); -#define EllipsePoints(cx,cy,x,y,pattern){ \ - SetPixel( x+cx, y+cx,pattern); \ - SetPixel(-x+cx, y+cx,pattern); \ - SetPixel( x+cx,-y+cx,pattern); \ - SetPixel(-x+cx,-y+cx,pattern); \ -} - - -//void EllipsePointsFill(BPoint cent,int32 x, int32 y,pattern){ -// view->StrokeLine(BPoint(-x+cent.x,y+cent.y),BPoint(x+cent.x,y+cent.y)); -// view->StrokeLine(BPoint(-x+cent.x,-y+cent.y),BPoint(x+cent.x,-y+cent.y)); - - #define EllipsePointsFill(cx,cy,x,y,pattern){ \ - HorizLine(-x+cx,x+cx, y+cy, pattern); \ - HorizLine(-x+cx,x+cx, -y+cy, pattern); \ -} - - -/******************************************************* -* -*******************************************************/ -void SecondDriver::MidpointEllipse(float centx,float centy,int32 xrad, int32 yrad,bool fill,uint8 *pattern){ - if(xrad < 0){ xrad = -xrad; } - if(yrad < 0){ yrad = -yrad; } - double d2; - int32 x = 0; - int32 y = yrad; - - int32 xradSqr = xrad*xrad; - int32 yradSqr = yrad*yrad; - - double dl = yradSqr - (xradSqr*yrad) + (0.25 *xradSqr); - - if(fill){ EllipsePointsFill(centx,centy,x,y,pattern); }else{ EllipsePoints(centx,centy,x,y,pattern); } - - // Test gradient if still in region 1 - while((xradSqr*(y-.5)) > (yradSqr*(x+1))){ - if(dl < 0){ // Select E - dl += yradSqr*(2*x + 3); - }else{ // Select SE - dl += yradSqr*(2*x + 3) + xradSqr*(-2*y + 2); - y--; - } - x++; - if(fill){ EllipsePointsFill(centx,centy,x,y,pattern); }else{ EllipsePoints(centx,centy,x,y,pattern); } - } - - d2 = (yradSqr*(x + .5)*(x + .5)) + (xradSqr*(y-1)*(y-1)) - xradSqr*yradSqr; - while(y > 0){ - if(d2 < 0){ // Select SE - d2 += yradSqr*(2*x + 2) + xradSqr*(-2*y + 3); - x++; - }else{ // Select E - d2 += xradSqr*(-2*y + 3); - } - y--; - if(fill){ EllipsePointsFill(centx,centy,x,y,pattern); }else{ EllipsePoints(centx,centy,x,y,pattern); } - } -} - - - -#ifdef DEBUG_DRIVER_MODULE -#undef DEBUG_DRIVER_MODULE -#endif diff --git a/src/servers/app/proto6/SecondDriver.h b/src/servers/app/proto6/SecondDriver.h deleted file mode 100644 index 68fd6fd3f9..0000000000 --- a/src/servers/app/proto6/SecondDriver.h +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef _SECDRIVER_H_ -#define _SECDRIVER_H_ - -#include -#include -#include -#include -#include // for pattern struct -#include -#include -#include "DisplayDriver.h" - -#include -#include -#include - -class BBitmap; -class PortLink; -class VDWindow; -class ServerCursor; - - -class SecondDriver:public DisplayDriver{ -public: - SecondDriver(void); - virtual ~SecondDriver(void); - - virtual void Initialize(void); // Sets the driver - virtual bool IsInitialized(void); - virtual void Shutdown(void); // You never know when you'll need this - - virtual void SafeMode(void); // Easy-access functions for common tasks - virtual void Reset(void); - virtual void Clear(uint8 red,uint8 green,uint8 blue); - virtual void Clear(rgb_color col); - - // Settings functions - virtual void SetScreen(uint32 space); - virtual int32 GetHeight(void); - virtual int32 GetWidth(void); - virtual int GetDepth(void); - - // Drawing functions - #ifdef PROTO_4 - virtual void Blit(BPoint loc, ServerBitmap *src, ServerBitmap *dest); - #else - virtual void Blit(BRect src, BRect dest); - #endif - virtual void DrawBitmap(ServerBitmap *bitmap, BRect source, BRect dest); - virtual void DrawChar(char c, BPoint point); - virtual void DrawString(char *string, int length, BPoint point); - - virtual void FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void FillBezier(BPoint *points, uint8 *pattern); - virtual void FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void FillPolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void FillRect(BRect rect, uint8 *pattern); - virtual void FillRect(BRect rect, rgb_color col); - virtual void FillRegion(BRegion *region); - virtual void FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void FillShape(BShape *shape); - virtual void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - virtual void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color color); - - virtual void HideCursor(void); - virtual bool IsCursorHidden(void); - virtual void MoveCursorTo(float x, float y); - virtual void MovePenTo(BPoint pt); - virtual void ObscureCursor(void); - virtual BPoint PenPosition(void); - virtual float PenSize(void); - virtual void SetCursor(int32 value); - virtual void SetCursor(ServerCursor *cursor); - virtual void SetPenSize(float size); - virtual void SetPixel(int x, int y, uint8 *pattern); - virtual void ShowCursor(void); - - virtual void StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void StrokeBezier(BPoint *points, uint8 *pattern); - virtual void StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void StrokeLine(BPoint point, uint8 *pattern); - virtual void StrokeLine(BPoint pt1, BPoint pt2, rgb_color col); - virtual void StrokePolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void StrokeRect(BRect rect,uint8 *pattern); - virtual void StrokeRect(BRect rect,rgb_color col); - virtual void StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void StrokeShape(BShape *shape); - virtual void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - virtual void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color color); -private: - void HorizLine(int32 x1,int32 x2,int32 y, uint8 *pattern); - void MidpointEllipse(float centerx, float centery,int32 xrad, int32 yrad,bool fill,uint8 *pattern); -protected: - int hide_cursor; - - int fd; - image_id image; - GetAccelerantHook gah; - display_mode dm; - - frame_buffer_config fbc; - - uint32 *bits; - int32 bpr; - - set_cursor_shape scs; - move_cursor mc; - show_cursor sc; - - sync_token st; - engine_token *et; - release_engine re; - - screen_to_screen_blit s2sb; - fill_rectangle fr; - invert_rectangle ir; - screen_to_screen_transparent_blit s2stb; - fill_span fs; - - -}; - -#endif diff --git a/src/servers/app/proto6/SecondDriverHelper.h b/src/servers/app/proto6/SecondDriverHelper.h deleted file mode 100644 index ff3ee288d7..0000000000 --- a/src/servers/app/proto6/SecondDriverHelper.h +++ /dev/null @@ -1,435 +0,0 @@ -/******************************************************* -* SecondDriver -* -* Helper methods for SecondDriver. This is where we -* put all the code that inits the real HW and -* seaches for the acceleration methods an all that -* other stuff. -* -* @author YNOP (ynop@beunited.org) -*******************************************************/ -#ifndef _SECDRIVER_HELPER_H_ -#define _SECDRIVER_HELPER_H_ - -//#include -#include -#include - -#include -#include -#include // has ioctl ?:P -//#include -#include - -#define DEV_GRAPHICS "/dev/graphics/" -#define ACCELERANTS_DIR "/accelerants/" -#define DEV_STUB "stub" - -/******************************************************* -* @description Loads the driver from settings ... -*******************************************************/ -int get_device(){ -// 102b_0519_001300 102b_051a_001400 stub - return open(DEV_GRAPHICS"102b_051a_001400", B_READ_WRITE); -// return -1; -} - -/******************************************************* -* @description Loads the stub driver - never fun -*******************************************************/ -int fallback_device(){ - return open(DEV_GRAPHICS DEV_STUB, B_READ_WRITE); -} - -/******************************************************* -* @description Find the first device that it can open -* in the /dev/graphics dir and returns it. -*******************************************************/ -int find_device(){ - DIR *d; - struct dirent *e; - char name_buf[1024]; - int fd = -1; - //bool foundfirst = false; // hacky way of finding second video card in your box - - printf("Probeing %s for device...\n",DEV_GRAPHICS); - - /* open directory apath */ - d = opendir(DEV_GRAPHICS); - if(!d){ return B_ERROR; } - while((e = readdir(d)) != NULL){ - if (!strcmp(e->d_name, ".") || !strcmp(e->d_name, "..") || !strcmp(e->d_name, "stub")){ - continue; - } - strcpy(name_buf, DEV_GRAPHICS); -// strcat(name_buf, "/"); - strcat(name_buf, e->d_name); - fd = open(name_buf, B_READ_WRITE); - ///printf("Opening device %s\n",name_buf); - if(fd >= 0){ - //printf("Open wend ok\n"); - /*if(!foundfirst){ - foundfirst = true; - printf("\tbut we are not going to use it as app_server is\n"); - }else{ - // found it :) - */ printf("\tOpened device %s\n",name_buf); - closedir(d); - return fd; - //} - }else{ - //foundfirst = true; // this is a proper find as the app_server should let us open the dev - printf("\tCouldn't open device %s\n",name_buf); - } - } - closedir(d); - return B_ERROR; -} - -/******************************************************* -* @description Finds and loads the Accelerant for -* this device -*******************************************************/ -image_id load_accelerant(int fd, GetAccelerantHook *hook) { - status_t result; - image_id image = -1; - char - signature[1024], - path[PATH_MAX]; - struct stat st; - const static directory_which vols[] = { - B_USER_ADDONS_DIRECTORY, - B_COMMON_ADDONS_DIRECTORY, - B_BEOS_ADDONS_DIRECTORY - }; - - /* get signature from driver */ - result = ioctl(fd, B_GET_ACCELERANT_SIGNATURE, &signature, sizeof(signature)); - if (result != B_OK){ - printf("Failed to get accelerant signature from drived!\n"); - return result; - } - - printf("Searching for Accelerant named \"%s\"\n",signature); - - // note failure by default - for(int32 i=0; i < (int32)(sizeof (vols) / sizeof (vols[0])); i++) { - //printf("attempting to get path for %ld (%d)\n", i, vols[i]); - if(find_directory(vols[i], -1, false, path, PATH_MAX) != B_OK) { - printf("warning: find directory failed (continueing)\n"); - continue; - } - - strcat (path, ACCELERANTS_DIR); - strcat (path, signature); - printf("\tTrying %s\n",path); - - // don't try to load non-existant files - if (stat(path, &st) != 0) continue; - - // try and load it up.. - image = load_add_on(path); - if (image >= 0) { - printf("\tAccelerant loaded - trying to init\n"); - // get entrypoint from accelerant - result = get_image_symbol(image, B_ACCELERANT_ENTRY_POINT, -#if defined(__INTEL__) - B_SYMBOL_TYPE_ANY, -#else - B_SYMBOL_TYPE_TEXT, -#endif - (void **)hook); - if (result == B_OK) { - init_accelerant ia; - ia = (init_accelerant)(*hook)(B_INIT_ACCELERANT, NULL); - if(ia && ((result = ia(fd)) == B_OK)) { - // we have a winner! - //printf("Accelerant %s \n", path); - printf("\tAccelerant Init() was B_OK\n"); - break; - } else { - printf("\tAccelerant Init() failed: %ld\n", result); - } - } else { - printf("\tCouldn't find the entry point :-(\n"); - } - // unload the accelerant, as we must be able to init! - unload_add_on(image); - } - if (image < 0) printf("\tLoad Image failure. ID: %.8lx (%s)\n", image, strerror(image)); - // mark failure to load image - image = -1; - } - - //printf("Add-on image id: %ld\n", image); - return image; -} - -/******************************************************* -* @description -*******************************************************/ -static const char *spaceToString(uint32 cs) { - const char *s; - switch (cs) { -#define s2s(a) case a: s = #a ; break - s2s(B_RGB32); - s2s(B_RGBA32); - s2s(B_RGB32_BIG); - s2s(B_RGBA32_BIG); - s2s(B_RGB16); - s2s(B_RGB16_BIG); - s2s(B_RGB15); - s2s(B_RGBA15); - s2s(B_RGB15_BIG); - s2s(B_RGBA15_BIG); - s2s(B_CMAP8); - s2s(B_GRAY8); - s2s(B_GRAY1); - s2s(B_YCbCr422); - s2s(B_YCbCr420); - s2s(B_YUV422); - s2s(B_YUV411); - s2s(B_YUV9); - s2s(B_YUV12); - default: - s = "unknown"; break; -#undef s2s - } - return s; -} - -/******************************************************* -* @description -*******************************************************/ -void dump_mode(display_mode *dm) { - display_timing *t = &(dm->timing); - printf(" pixel_clock: %ldKHz\n", t->pixel_clock); - printf(" H: %4d %4d %4d %4d\n", t->h_display, t->h_sync_start, t->h_sync_end, t->h_total); - printf(" V: %4d %4d %4d %4d\n", t->v_display, t->v_sync_start, t->v_sync_end, t->v_total); - printf(" timing flags:"); - if (t->flags & B_BLANK_PEDESTAL) printf(" B_BLANK_PEDESTAL"); - if (t->flags & B_TIMING_INTERLACED) printf(" B_TIMING_INTERLACED"); - if (t->flags & B_POSITIVE_HSYNC) printf(" B_POSITIVE_HSYNC"); - if (t->flags & B_POSITIVE_VSYNC) printf(" B_POSITIVE_VSYNC"); - if (t->flags & B_SYNC_ON_GREEN) printf(" B_SYNC_ON_GREEN"); - if (!t->flags) printf(" (none)\n"); - else printf("\n"); - printf(" refresh rate: %4.2f\n", ((double)t->pixel_clock * 1000) / ((double)t->h_total * (double)t->v_total)); - printf(" color space: %s\n", spaceToString(dm->space)); - printf(" virtual size: %dx%d\n", dm->virtual_width, dm->virtual_height); - printf("dispaly start: %d,%d\n", dm->h_display_start, dm->v_display_start); - - printf(" mode flags:"); - if (dm->flags & B_SCROLL) printf(" B_SCROLL"); - if (dm->flags & B_8_BIT_DAC) printf(" B_8_BIT_DAC"); - if (dm->flags & B_HARDWARE_CURSOR) printf(" B_HARDWARE_CURSOR"); - if (dm->flags & B_PARALLEL_ACCESS) printf(" B_PARALLEL_ACCESS"); -// if (dm->flags & B_SUPPORTS_OVERLAYS) printf(" B_SUPPORTS_OVERLAYS"); - if (!dm->flags) printf(" (none)\n"); - else printf("\n"); -} - -/******************************************************* -* @description -*******************************************************/ -void simple_dump_mode(display_mode *dm){ - //printf("H: %4d\n", t->h_display); - //printf("V: %4d\n", t->v_display); - display_timing *t = &(dm->timing); - printf("Virtual size: %d x %d\n", dm->virtual_width, dm->virtual_height); - printf("Color space: %s\n", spaceToString(dm->space)); - printf("Refresh rate: %4.2f\n", ((double)t->pixel_clock * 1000) / ((double)t->h_total * (double)t->v_total)); -} - -/******************************************************* -* @description -*******************************************************/ -void mode_from_settings(display_mode *dm){ - // display_timing *t = &(dm->timing); - dm->space = B_RGB32; - dm->virtual_width = 800; - dm->virtual_height = 600; - dm->h_display_start = 0; - dm->v_display_start = 0; -} - -/******************************************************* -* @description -*******************************************************/ -status_t get_and_set_mode(GetAccelerantHook gah, display_mode *dm) { - printf("Setting up display mode\n"); - accelerant_mode_count gmc; - uint32 mode_count; - get_mode_list gml; - display_mode *mode_list, target, high, low; - propose_display_mode pdm; - status_t result = B_ERROR; - set_display_mode sdm; - - /* find the propose mode hook */ - pdm = (propose_display_mode)gah(B_PROPOSE_DISPLAY_MODE, NULL); - if (!pdm) { - printf("No B_PROPOSE_DISPLAY_MODE\n"); - goto exit0; - } - /* and the set mode hook */ - sdm = (set_display_mode)gah(B_SET_DISPLAY_MODE, NULL); - if (!sdm) { - printf("No B_SET_DISPLAY_MODE\n"); - goto exit0; - } - - /* how many modes does the driver support */ - gmc = (accelerant_mode_count)gah(B_ACCELERANT_MODE_COUNT, NULL); - if (!gmc) { - printf("No B_ACCELERANT_MODE_COUNT\n"); - goto exit0; - } - mode_count = gmc(); - printf("\tDriver supports %lu differnat video modes\n", mode_count); - if (mode_count == 0) goto exit0; - - /* get a list of graphics modes from the driver */ - gml = (get_mode_list)gah(B_GET_MODE_LIST, NULL); - if (!gml) { - printf("No B_GET_MODE_LIST\n"); - goto exit0; - } - mode_list = (display_mode *)calloc(sizeof(display_mode), mode_count); - if (!mode_list) { - printf("Couldn't calloc() for mode list\n"); - goto exit0; - } - if (gml(mode_list) != B_OK) { - printf("mode list retrieval failed\n"); - goto free_mode_list; - } - - /* take the first mode in the list */ - //printf("\tPropose Display Mode\n------------------------\n"); - //simple_dump_mode(&mode_list[69]); - //mode_from_settings(&mode_list[69]); - target = mode_list[69]; - high = mode_list[69]; - low = mode_list[69]; - /* make as tall a virtual height as possible */ - //target.virtual_height = high.virtual_height = 0xffff; - // virtual hight should only be used if a res larger than - // the screen can handle - /* propose the display mode */ - if (pdm(&target, &low, &high) == B_ERROR) { - printf("propose_display_mode failed\n"); - goto free_mode_list; - } - printf("------Target display mode------\n"); - simple_dump_mode(&target); - printf("-------------------------------\n"); - /* we got a display mode, now set it */ - if (sdm(&target) == B_ERROR) { - printf("set display mode failed\n"); - goto free_mode_list; - } - /* note the mode and success */ - *dm = target; - result = B_OK; - -free_mode_list: - free(mode_list); -exit0: - return result; -} - - -/******************************************************* -* @description -*******************************************************/ -void get_frame_buffer(GetAccelerantHook gah, frame_buffer_config *fbc) { - get_frame_buffer_config gfbc; - gfbc = (get_frame_buffer_config)gah(B_GET_FRAME_BUFFER_CONFIG, NULL); - gfbc(fbc); -} - -/******************************************************* -* @description -*******************************************************/ -sem_id get_sem(GetAccelerantHook gah) { - accelerant_retrace_semaphore ars; - ars = (accelerant_retrace_semaphore)gah(B_ACCELERANT_RETRACE_SEMAPHORE, NULL); - return ars(); -} - -/******************************************************* -* @description -*******************************************************/ -void set_palette(GetAccelerantHook gah) { - set_indexed_colors sic; - sic = (set_indexed_colors)gah(B_SET_INDEXED_COLORS, NULL); - if (sic) { - /* booring grey ramp for now */ - uint8 map[3 * 256]; - uint8 *p = map; - int i; - for (i = 0; i < 256; i++) { - *p++ = i; - *p++ = i; - *p++ = i; - } - sic(256, 0, map, 0); - } -} - -// This is a ll the stuff needed to stroke a Bezier Curve.. -// Note that we should probably wait and alloc this data latter -// on when we stroke our first Curve. That way if no curve ever -// gets render (unlikely i know) then this space would be saved. -#define SEGMENTS 32 -#define Fixed float -static Fixed weight1[SEGMENTS + 1]; -static Fixed weight2[SEGMENTS + 1]; -#define w1(s) weight1[s] -#define w2(s) weight2[s] -#define w3(s) weight2[SEGMENTS - s] -#define w4(s) weight1[SEGMENTS - s] -#define FixMul(a,b) (a)*(b) -#define FixRound(a) ((a-int32(a))>=.5)?(int32(a)+1):(int32(a)) -#define FixRatio(a,b) ((a)/float(b)) - -/******************************************************* -* @description Creats the two Bernstien Pollynomials -* We only need to creat two becase the 1 & 4 are -* mirrors and the 2 & 3 are mirros. -*******************************************************/ -void SetupBezier(){ - Fixed t, zero, one; - int s; - zero = FixRatio(0, 1); - one = FixRatio(1, 1); - - weight1[0] = one; - weight2[0] = zero; - for(s = 1 ;s < SEGMENTS ;++s){ - t = FixRatio(s, SEGMENTS); - weight1[s] = FixMul(one - t, FixMul(one - t, one - t)); - weight2[s] = 3 * FixMul(t, FixMul(t - one, t - one)); - } - weight1[SEGMENTS] = zero; - weight2[SEGMENTS] = zero; -} - -/******************************************************* -* @description Useing the weights of the 4 bernstein -* pollynomials calc the segment endpoints. This is -* the real worker method -*******************************************************/ -static void computeSegments(BPoint p1,BPoint p2, BPoint p3, BPoint p4, BPoint *segment){ - int s; - segment[0] = p1; - for(s = 1;s < SEGMENTS;++s){ - segment[s].y = FixRound(w1(s) * p1.y + w2(s) * p2.y + w3(s) * p3.y + w4(s) * p4.y); - segment[s].x = FixRound(w1(s) * p1.x + w2(s) * p2.x + w3(s) * p3.x + w4(s) * p4.x); - } - segment[SEGMENTS] = p4; -} - -#endif - diff --git a/src/servers/app/proto6/ServerApp.cpp b/src/servers/app/proto6/ServerApp.cpp deleted file mode 100644 index 65516aae3c..0000000000 --- a/src/servers/app/proto6/ServerApp.cpp +++ /dev/null @@ -1,831 +0,0 @@ -/* - ServerApp.cpp - Class which works with a BApplication. Handles all messages coming - from and going to its application. -*/ -//#define DEBUG_SERVERAPP_MSGS -//#define DEBUG_SERVERAPP_CURSORS -//#define DEBUG_SERVERAPP_MISC - -#include -#include -#include -#include -#include "Desktop.h" -#include "DisplayDriver.h" -//#include "Layer.h" -#include "ServerApp.h" -#include "ServerWindow.h" -#include "ServerBitmap.h" -#include "ServerProtocol.h" -#include "ServerCursor.h" -#include "PortLink.h" -#include -#include -#include -#include "DebugTools.h" - - -ServerApp::ServerApp(port_id msgport, char *signature) -{ - // need to copy the signature because the message buffer - // owns the copy which we are passed as a parameter. - app_sig=(signature)?signature:"Application"; - - // sender is the monitored app's event port - sender=msgport; - applink=new PortLink(sender); - - port_info pinfo; - get_port_info(sender,&pinfo); - target_id=pinfo.team; - - // receiver is the port to which the app sends messages for the server - receiver=create_port(30,app_sig.String()); - -#ifdef DEBUG_SERVERAPP_MISC -printf("ServerApp port for app %s is at %ld\n",app_sig.String(),receiver); -#endif - - if(receiver==B_NO_MORE_PORTS) - { - // uh-oh. We have a serious problem. Tell the app to quit - applink->SetOpCode(B_QUIT_REQUESTED); - applink->Flush(); - } - - // No longer necessary. This message is sent from the app_server thread - // now because of changes in the application structure from previous - // prototypes. -/* else - { - // Everything checks out, so tell the application - // where to send future messages - applink->SetOpCode(SET_SERVER_PORT); - applink->Attach(&receiver,sizeof(port_id)); - applink->Flush(); - } -*/ - applink->SetPort(sender); - winlist=new BList(0); - bmplist=new BList(0); - driver=get_gfxdriver(); - isactive=false; - cursor=new ServerCursor(); - - // This exists for testing the graphics access module and will disappear - // when layers are implemented - high.red=255; - high.green=255; - high.blue=255; - high.alpha=255; - low.red=0; - low.green=0; - low.blue=0; - low.alpha=255; -} - -ServerApp::~ServerApp(void) -{ -#ifdef DEBUG_SERVERAPP_MISC -printf("%s: ~ServerApp\n",app_sig.String()); -#endif - int32 i; - ServerWindow *tempwin; - for(i=0;iCountItems();i++) - { - tempwin=(ServerWindow*)winlist->ItemAt(i); - if(tempwin) - delete tempwin; - } - winlist->MakeEmpty(); - delete winlist; - - ServerBitmap *tempbmp; - for(i=0;iCountItems();i++) - { - tempbmp=(ServerBitmap*)bmplist->ItemAt(i); - if(tempbmp) - delete tempbmp; - } - bmplist->MakeEmpty(); - delete bmplist; - - delete applink; - applink=NULL; - delete cursor; - - // Kill the monitor thread if it exists - thread_info info; - if(get_thread_info(monitor_thread,&info)==B_OK) - kill_thread(monitor_thread); -} - -bool ServerApp::Run(void) -{ -#ifdef DEBUG_SERVERAPP_MISC -printf("%s: Run()\n",app_sig.String()); -#endif - // Unlike a BApplication, a ServerApp is *supposed* to return immediately - // when its Run function is called. - monitor_thread=spawn_thread(MonitorApp,app_sig.String(),B_NORMAL_PRIORITY,this); - if(monitor_thread==B_NO_MORE_THREADS || monitor_thread==B_NO_MEMORY) - return false; - resume_thread(monitor_thread); - return true; -} - -bool ServerApp::PingTarget(void) -{ - // This function is called by the app_server thread to ensure that - // the target app still exists. We do this not by sending a message - // but by calling get_port_info. We don't want to send ping messages - // just because the app might simply be hung. If this is the case, it - // should be up to the user to kill it. If the app has been killed, its - // ports will be invalid. Thus, if get_port_info returns an error, we - // tell the app_server to delete the respective ServerApp. - - team_info tinfo; - if(get_team_info(target_id,&tinfo)==B_BAD_TEAM_ID) - { - port_id serverport=find_port(SERVER_PORT_NAME); - if(serverport==B_NAME_NOT_FOUND) - { - printf("PANIC: ServerApp %s could not find the app_server port in PingTarget()!\n",app_sig.String()); - return false; - } - applink->SetPort(serverport); - applink->SetOpCode(DELETE_APP); - applink->Attach(&monitor_thread,sizeof(thread_id)); - applink->Flush(); -#ifdef DEBUG_SERVERAPP_MISC -printf("%s: target application is dead. ServerApp is quitting\n",app_sig.String()); -#endif - return false; - } - return true; -} - -int32 ServerApp::MonitorApp(void *data) -{ - ServerApp *app=(ServerApp *)data; - app->Loop(); - exit_thread(0); - return 0; -} - -void ServerApp::Loop(void) -{ -#ifdef DEBUG_SERVERAPP_MISC -printf("%s: Loop()\n",app_sig.String()); -#endif - // Message-dispatching loop for the ServerApp - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(receiver); - - if(buffersize>0) - { - // buffers are PortLink messages. Allocate necessary buffer and - // we'll cast it as a BMessage. - msgbuffer=new int8[buffersize]; - bytesread=read_port(receiver,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(receiver,&msgcode,NULL,0); - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { -// -------------- Messages received from the Application ------------------ - case B_QUIT_REQUESTED: - { - // 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) - { - printf("PANIC: ServerApp %s could not find the app_server port!\n",app_sig.String()); - break; - } - applink->SetPort(serverport); - applink->SetOpCode(DELETE_APP); - applink->Attach(&monitor_thread,sizeof(thread_id)); - applink->Flush(); - break; - } - -// -------------- 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. Eventually, this will be replaced by a - // BMessage - write_port(sender, msgcode, msgbuffer, buffersize); - break; - } - case QUIT_APP: - { - // This message is received from the app_server thread - // because the server was asked to quit. Thus, we - // ask all apps to quit. This is NOT the same as system - // shutdown and will happen only in testing - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp asking %s to quit\n",app_sig.String()); -#endif - applink->SetOpCode(B_QUIT_REQUESTED); - applink->Flush(); - break; - } - default: - { - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp received unrecognized code: "); -PrintMessageCode(msgcode); -#endif - - DispatchMessage(msgcode, msgbuffer); - break; - } - } - - } - - if(buffersize>0) - delete msgbuffer; - - if(msgcode==B_QUIT_REQUESTED) - break; - } -} - -void ServerApp::DispatchMessage(int32 code, int8 *buffer) -{ -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp "); -PrintMessageCode(code); -#endif - -int8 *index=buffer; - switch(code) - { - case CREATE_WINDOW: - { - // Create the ServerWindow to node monitor a new OBWindow - - // Attached data: - // 1) port_id reply port - // 2) BRect window frame - // 3) uint32 window flags - // 4) port_id window's message port - // 5) uint32 workspace index - // 6) const char * title - - // Find the necessary data - port_id reply_port=*((port_id*)index); index+=sizeof(port_id); - BRect rect=*((BRect*)index); index+=sizeof(BRect); - - uint32 winlook=*((uint32*)index); index+=sizeof(uint32); - uint32 winfeel=*((uint32*)index); index+=sizeof(uint32); - uint32 winflags=*((uint32*)index); index+=sizeof(uint32); - - port_id win_port=*((port_id*)index); index+=sizeof(port_id); - uint32 workspace=*((uint32*)index); index+=sizeof(uint32); - - // Create the ServerWindow object for this window - ServerWindow *newwin=new ServerWindow(rect,(const char *)index, - winlook, winfeel, winflags,this,win_port,workspace); - winlist->AddItem(newwin); - - // 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->Attach((int32)newwin->receiver); - replylink->Flush(); - - delete replylink; - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: Create Window()\n"); -printf("Frame: "); rect.PrintToStream(); -printf("Title: %s\n",(const char*)index); -printf("SenderPort: %ld\n",win_port); -printf("Look: 0x%lx\n",winlook); -printf("Feel: 0x%lx\n",winfeel); -printf("Flags: 0x%lx\n",winflags); -printf("Workspace: 0x%lx\n",workspace); -#endif - - break; - - } - case DELETE_WINDOW: - { - // Received from a ServerWindow when its window quits - - // Attached data: - // 1) thread_id ServerWindow ID - thread_id winid; - ServerWindow *w; - for(int32 i=0;iCountItems();i++) - { - w=(ServerWindow*)winlist->ItemAt(i); - if(w->thread==winid) - { - winlist->RemoveItem(w); - delete w; - break; - } - } -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: Delete Window()\n"); -printf("Thread ID: %ld",winid); -#endif - break; - } - case GFX_SET_SCREEN_MODE: - { - // Attached data - // 1) int32 workspace # - // 2) uint32 screen mode - // 3) bool make default - int32 workspace=*((int32*)index); index+=sizeof(int32); - uint32 mode=*((uint32*)index); index+=sizeof(uint32); - - SetScreenSpace(workspace,mode,*((bool*)index)); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: SetScreenMode(%ld,%lu,%s)\n",workspace, - mode,(*((bool*)index)==true)?"true":"false"); -#endif - break; - } - case GFX_ACTIVATE_WORKSPACE: - { - // Attached data - // 1) int32 workspace index - ActivateWorkspace(*((int32*)index)); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: ActivateWorkspace(%ld)\n",*((int32*)index)); -#endif - break; - } - case SHOW_CURSOR: - { - driver->ShowCursor(); - break; - } - case HIDE_CURSOR: - { - driver->HideCursor(); - break; - } - case OBSCURE_CURSOR: - { - driver->ObscureCursor(); - break; - } - case SET_CURSOR_DATA: - { - // Attached data: 68 bytes of cursor data - - // Get the data, update the app's cursor, and update the - // app's cursor if active. - int8 cdata[68]; - memcpy(cdata, buffer, 68); - cursor->SetCursor(cdata); - driver->SetCursor(cursor); -#ifdef DEBUG_SERVERAPP_CURSOR -printf("ServerApp: SetCursor(%d,%d,%d,%d)\n",r,g,b,a); -#endif - break; - } - case SET_CURSOR_BCURSOR: - // Not yet implemented - break; - - case SET_CURSOR_BBITMAP: - // Not yet implemented - break; - - // Graphics messages - case GFX_SET_HIGH_COLOR: - { - // Attached data: - // 1) uint8 red - // 2) uint8 green - // 3) uint8 blue - // 4) uint8 alpha - - uint8 r,g,b,a; - r=*((uint8*)index); index+=sizeof(uint8); - g=*((uint8*)index); index+=sizeof(uint8); - b=*((uint8*)index); index+=sizeof(uint8); - a=*((uint8*)index); - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: SetHighColor(%d,%d,%d,%d)\n",r,g,b,a); -#endif - driver->SetHighColor(r,g,b,a); - break; - } - case GFX_SET_LOW_COLOR: - { - // Attached data: - // 1) uint8 red - // 2) uint8 green - // 3) uint8 blue - // 4) uint8 alpha - - uint8 r,g,b,a; - r=*((uint8*)index); index+=sizeof(uint8); - g=*((uint8*)index); index+=sizeof(uint8); - b=*((uint8*)index); index+=sizeof(uint8); - a=*((uint8*)index); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: SetHighColor(%d,%d,%d,%d)\n",r,g,b,a); -#endif - driver->SetLowColor(r,g,b,a); - break; - } - case GFX_MOVEPENBY: - { - // Attached data: - // 1) BPoint pt - - // Default functionality is MoveTo, so get the current position - // from the driver and compensate - BPoint *ptindex,passed_pt; - - ptindex=(BPoint*)index; - passed_pt=driver->PenPosition(); - passed_pt+=*ptindex; -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp MovePenBy: (%f,%f)\n",ptindex->x,ptindex->y); -printf("Pen moved to (%f,%f)\n",passed_pt.x,passed_pt.y); -#endif - driver->MovePenTo(passed_pt); - break; - } - case GFX_MOVEPENTO: - { - // Attached data: - // 1) BPoint pt - BPoint *pt; - pt=(BPoint*)index; -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp MovePenTo: (%f,%f)\n",pt->x,pt->y); -#endif - driver->MovePenTo(*pt); - break; - } - case GFX_SETPENSIZE: - { - // Attached data: - // 1) float pen size -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp SetPenSize(%f)\n",*((float*)index)); -#endif - driver->SetPenSize(*((float*)index)); - break; - } - case GFX_DRAW_STRING: - { - // Attached data: - // 1) uint16 string length - // 2) char * string - // 3) BPoint point - - uint16 length=*((uint16*)index); index+=sizeof(uint16); -// char *string=new char[length]; -// strcpy(string, (const char *)index); index+=length; - BString string=(char *)index; index+=length; - BPoint point=*((BPoint*)index); - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp DrawString(%s, %d, BPoint(%f,%f))\n",string.String(),length,point.x,point.y); -#endif - driver->DrawString((char*)string.String(), length, point); -// delete string; - break; - } - case GFX_SET_FONT_SIZE: - break; - case GFX_STROKE_ARC: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) float starting angle - // 6) float span (arc length in degrees) - // 7) uint8[8] pattern - float cx,cy,rx,ry,angle,span; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); - angle=*((float*)index); index+=sizeof(float); - span=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeArc: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("Angle, Span: %f,%f\n",angle, span); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeArc(cx,cy,rx,ry,angle,span,(uint8*)index); - break; - } - case GFX_STROKE_BEZIER: - { - // Attached data: - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BPoint #4 - // 5) uint8[8] pattern - -#ifdef DEBUG_SERVERAPP_MSGS -BPoint *pt=(BPoint*)index; -printf("ServerApp StrokeBezier:\n"); -printf("Point 1: "); pt[0].PrintToStream(); -printf("Point 2: "); pt[1].PrintToStream(); -printf("Point 3: "); pt[2].PrintToStream(); -printf("Point 4: "); pt[3].PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeBezier((BPoint*)index,(uint8*)(index+(sizeof(BPoint)*4))); - break; - } - case GFX_STROKE_ELLIPSE: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) uint8[8] pattern - float cx,cy,rx,ry; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeEllipse: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeEllipse(cx,cy,rx,ry,(uint8*)index); - break; - } - case GFX_STROKE_LINE: - { - // Attached data: - // 1) BPoint endpoint - // 2) uint8[8] pattern - BPoint *pt; - pt=(BPoint*)index; index+=sizeof(BPoint); - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeLineTo: (%f,%f)\n",pt->x,pt->y); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeLine(*pt,(uint8*)index); - break; - } - case GFX_STROKE_POLYGON: - break; - case GFX_STROKE_RECT: - { - // Attached data: - // 1) BRect rect - // 2) uint8[8] pattern - BRect rect; - rect=*((BRect*)index); index+=sizeof(BRect); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeRect: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeRect(rect, (uint8*)index); - break; - } - case GFX_STROKE_ROUNDRECT: - { - // Attached data: - // 1) BRect rect - // 2) float x_radius - // 3) float y_radius - // 4) uint8[8] pattern - BRect rect; - float x,y; - - rect=*((BRect*)index); index+=sizeof(BRect); - x=*((float*)index); index+=sizeof(float); - y=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeRoundRect: "); rect.PrintToStream(); -printf("Radii: %f,%f\n",x,y); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeRoundRect(rect, x,y,(uint8*)index); - break; - } - case GFX_STROKE_SHAPE: - break; - case GFX_STROKE_TRIANGLE: - { - // Attached data - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BRect invalid rect - // 5) uint8[8] pattern - BPoint pt1,pt2,pt3; - BRect rect; - pt1=*((BPoint*)index); index+=sizeof(BPoint); - pt2=*((BPoint*)index); index+=sizeof(BPoint); - pt3=*((BPoint*)index); index+=sizeof(BPoint); - rect=*((BRect*)index); index+=sizeof(BRect); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeTriangle: "); -printf("Point 1: "); pt1.PrintToStream(); -printf("Point 2: "); pt2.PrintToStream(); -printf("Point 3: "); pt3.PrintToStream(); -printf("Rectangle: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeTriangle(pt1,pt2,pt3,rect,(uint8*)index); - break; - } - case GFX_FILL_ARC: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) float starting angle - // 6) float span (arc length in degrees) - // 7) uint8[8] pattern - float cx,cy,rx,ry,angle,span; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); - angle=*((float*)index); index+=sizeof(float); - span=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillArc: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("Angle, Span: %f,%f\n",angle, span); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillArc(cx,cy,rx,ry,angle,span,(uint8*)index); - break; - } - case GFX_FILL_BEZIER: - { - // Attached data: - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BPoint #4 - // 5) uint8[8] pattern - -#ifdef DEBUG_SERVERAPP_MSGS -BPoint *pt=(BPoint*)index; -printf("ServerApp FillBezier:\n"); -printf("Point 1: "); pt[0].PrintToStream(); -printf("Point 2: "); pt[1].PrintToStream(); -printf("Point 3: "); pt[2].PrintToStream(); -printf("Point 4: "); pt[3].PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillBezier((BPoint*)index,(uint8*)(index+(sizeof(BPoint)*4))); - break; - } - case GFX_FILL_ELLIPSE: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) uint8[8] pattern - float cx,cy,rx,ry; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillEllipse: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillEllipse(cx,cy,rx,ry,(uint8*)index); - break; - } - case GFX_FILL_POLYGON: - break; - case GFX_FILL_RECT: - { - // Attached data: - // 1) BRect rect - // 2) uint8[8] pattern - BRect rect; - rect=*((BRect*)index); index+=sizeof(BRect); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillRect: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillRect(rect, (uint8*)index); - break; - } - case GFX_FILL_REGION: - break; - case GFX_FILL_ROUNDRECT: - { - // Attached data: - // 1) BRect rect - // 2) float x_radius - // 3) float y_radius - // 4) uint8[8] pattern - BRect rect; - float x,y; - - rect=*((BRect*)index); index+=sizeof(BRect); - x=*((float*)index); index+=sizeof(float); - y=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillRoundRect: "); rect.PrintToStream(); -printf("Radii: %f,%f\n",x,y); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillRoundRect(rect, x,y,(uint8*)index); - break; - } - case GFX_FILL_SHAPE: - break; - case GFX_FILL_TRIANGLE: - { - // Attached data - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BRect invalid rect - // 5) uint8[8] pattern - BPoint pt1,pt2,pt3; - BRect rect; - pt1=*((BPoint*)index); index+=sizeof(BPoint); - pt2=*((BPoint*)index); index+=sizeof(BPoint); - pt3=*((BPoint*)index); index+=sizeof(BPoint); - rect=*((BRect*)index); index+=sizeof(BRect); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillTriangle: "); -printf("Point 1: "); pt1.PrintToStream(); -printf("Point 2: "); pt2.PrintToStream(); -printf("Point 3: "); pt3.PrintToStream(); -printf("Rectangle: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillTriangle(pt1,pt2,pt3,rect,(uint8*)index); - break; - } - default: - { -#ifdef DEBUG_SERVERAPP_MSGS -cout << "DispatchMessage::Unrecognized code: "; -TranslateMessageCodeToStream(code); -cout << endl << flush; -#endif - break; - } - } -} - -// Prevent any preprocessor problems in case I screw something up -#ifdef DEBUG_SERVERAPP_MSGS -#undef DEBUG_SERVERAPP_MSGS -#endif - -#ifdef DEBUG_SERVERAPP_CURSORS -#undef DEBUG_SERVERAPP_CURSORS -#endif diff --git a/src/servers/app/proto6/ServerApp.h b/src/servers/app/proto6/ServerApp.h deleted file mode 100644 index 16a01f8bf1..0000000000 --- a/src/servers/app/proto6/ServerApp.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef _SRVAPP_H_ -#define _SRVAPP_H_ - -#include -#include -class BMessage; -class PortLink; -class BList; -class ServerCursor; -class DisplayDriver; - -class ServerApp -{ -public: - ServerApp(port_id msgport, char *signature); - ~ServerApp(void); - - bool Run(void); - static int32 MonitorApp(void *data); - void Loop(void); - bool IsActive(void) const { return isactive; } - void Activate(bool value) { isactive=value; } - bool PingTarget(void); - -// char *app_sig; - port_id sender,receiver; - BString app_sig; - thread_id monitor_thread; - PortLink *applink; - BList *winlist, *bmplist; - ServerCursor *cursor; - DisplayDriver *driver; - rgb_color high, low; // just for testing until layers are implemented - -protected: - void DispatchMessage(int32 code, int8 *buffer); - - bool isactive; - team_id target_id; -}; - -#endif diff --git a/src/servers/app/proto6/ServerBitmap.cpp b/src/servers/app/proto6/ServerBitmap.cpp deleted file mode 100644 index ee01f297f3..0000000000 --- a/src/servers/app/proto6/ServerBitmap.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* - ServerBitmap.cpp - Bitmap class which is intended to provide an easy way to package all the - data associated with a picture. It's very low-level, so there's still - plenty to do when coding with 'em. Also, they can be used to access draw on the - frame buffer in a relatively easy way, although it is currently unclear - whether this functionality will even be necessary. -*/ - -// These three includes for ServerBitmap(const char *path_to_image_file) only -#include -#include -#include - -#include -#include "ServerBitmap.h" -#include "Desktop.h" - -ServerBitmap::ServerBitmap(BRect rect,color_space space,int32 BytesPerLine=0) -{ - width=rect.IntegerWidth()+1; - height=rect.IntegerHeight()+1; - cspace=space; - is_vram=false; - is_area=false; - areaid=B_ERROR; - - HandleSpace(space, BytesPerLine); - buffer=new uint8[bytesperline*height]; - driver=get_gfxdriver(); -} - -ServerBitmap::ServerBitmap(int32 w,int32 h,color_space space,int32 BytesPerLine=0) -{ - width=w; - height=h; - cspace=space; - is_vram=false; - is_area=false; - areaid=B_ERROR; - - HandleSpace(space, BytesPerLine); - buffer=new uint8[bytesperline*height]; - driver=get_gfxdriver(); -} - -ServerBitmap::ServerBitmap(int32 w,int32 h,color_space space, area_id areaID, int32 BytesPerLine=0) -{ - // This version is used for holding BBitmaps as one of the undocumented BBitmap - // constructors allows - it creates an area on the server's side. - width=w; - height=h; - cspace=space; - is_vram=false; - is_area=true; - - HandleSpace(space, BytesPerLine); - area_info ainfo; - areaid=areaID; - get_area_info(areaid, &ainfo); - buffer=(uint8*)ainfo.address; - driver=get_gfxdriver(); -} - -ServerBitmap::ServerBitmap(void) -{ - // This version is obviously intended for use as an easy-access class for the - // frame buffer. AtheOS does it and it's small, so why not? Worst case, this - // can disappear if not necessary. - is_vram=true; - is_area=false; - areaid=B_ERROR; - UpdateSettings(); -} - -// This particular version is not intended for use except for testing purposes. -// It loads a BBitmap and copies it to the ServerBitmap. Probably will disappear -// when the *real* server is written -ServerBitmap::ServerBitmap(const char *path) -{ - BBitmap *bmp=BTranslationUtils::GetBitmap(path); - assert(bmp!=NULL); - - if(bmp==NULL) - { - width=0; - height=0; - cspace=B_NO_COLOR_SPACE; - bytesperline=0; - } - else - { - width=bmp->Bounds().IntegerWidth(); - height=bmp->Bounds().IntegerHeight(); - cspace=bmp->ColorSpace(); - bytesperline=bmp->BytesPerRow(); - buffer=new uint8[bmp->BitsLength()]; - memcpy(buffer,(void *)bmp->Bits(),bmp->BitsLength()); - } -} - -ServerBitmap::~ServerBitmap(void) -{ - if(!is_vram) - delete buffer; -} - -void ServerBitmap::UpdateSettings(void) -{ - // This is only used when the object is pointing to the frame buffer - driver=get_gfxdriver(); - bpp=driver->GetDepth(); - width=driver->GetWidth(); - height=driver->GetHeight(); -} - -void ServerBitmap::SetBuffer(void *buffer) -{ - buffer=(uint8 *)buffer; -} - -uint8 *ServerBitmap::Buffer(void) -{ - return buffer; -} - -uint32 ServerBitmap::BitsLength(void) -{ - return (uint32)(bytesperline*height); -} - -void ServerBitmap::HandleSpace(color_space space, int32 BytesPerLine) -{ - // Function written to handle color space setup which is required - // by the two "normal" constructors - - // Big convoluted mess just to handle every color space and dword align - // the buffer - switch(space) - { - // Buffer is dword-aligned, so nothing need be done - // aside from allocate the memory - case B_RGB32: - case B_RGBA32: - case B_RGB32_BIG: - case B_RGBA32_BIG: - case B_UVL32: - case B_UVLA32: - case B_LAB32: - case B_LABA32: - case B_HSI32: - case B_HSIA32: - case B_HSV32: - case B_HSVA32: - case B_HLS32: - case B_HLSA32: - case B_CMY32: - case B_CMYA32: - case B_CMYK32: - - // 24-bit = 32-bit with extra 8 bits ignored - case B_RGB24_BIG: - case B_RGB24: - case B_LAB24: - case B_UVL24: - case B_HSI24: - case B_HSV24: - case B_HLS24: - case B_CMY24: - { - if(BytesPerLine<(width*4)) - bytesperline=width*4; - else - bytesperline=BytesPerLine; - bpp=32; - break; - } - // Calculate size and dword-align - - // 1-bit - case B_GRAY1: - { - int32 numbytes=width>>3; - if((width % 8) != 0) - numbytes++; - if(BytesPerLine -#include -#include -#include "DisplayDriver.h" - -class ServerBitmap -{ -public: - ServerBitmap(BRect rect,color_space space,int32 BytesPerLine=0); - ServerBitmap(int32 w,int32 h,color_space space,int32 BytesPerLine=0); - ServerBitmap(int32 w,int32 h,color_space space, area_id areaID, int32 BytesPerLine=0); - ServerBitmap(void); - ServerBitmap(const char *path); - ~ServerBitmap(void); - void UpdateSettings(void); - void SetBuffer(void *buffer); - uint8 *Buffer(void); - void SetArea(area_id ID); - area_id Area(void); - uint32 BitsLength(void); - BRect Bounds() { return BRect(0,0,width-1,height-1); }; - int32 BytesPerRow(void) { return bytesperline; }; - - int32 width,height; - int32 bytesperline; - color_space cspace; - int bpp; - -protected: - void HandleSpace(color_space space, int32 BytesPerLine); - DisplayDriver *driver; - bool is_vram,is_area; - area_id areaid; - uint8 *buffer; -}; - -#endif diff --git a/src/servers/app/proto6/ServerCursor.cpp b/src/servers/app/proto6/ServerCursor.cpp deleted file mode 100644 index bb11e51760..0000000000 --- a/src/servers/app/proto6/ServerCursor.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - ServerCursor.cpp - This is the server-side class used to handle cursors. Note that it - will handle the R5 cursor API, but it will also handle taking a bitmap. - - ServerCursors are 32-bit. Eventually, we will be mapping colors to fit - when the set is called. - - This is new code, and there may be changes to the API before it settles - in. -*/ - -#include "ServerCursor.h" -#include "ServerBitmap.h" -#include -#include - -int8 default_cursor[]={ - 16,1,0,0, - - // data - 0xff, 0x80, 0x80, 0x80, 0x81, 0x00, 0x80, 0x80, 0x80, 0x40, 0x80, 0x80, 0x81, 0x00, 0xa2, 0x00, - 0xd4, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - - // mask - 0xff, 0x80, 0xff, 0x80, 0xff, 0x00, 0xff, 0x80, 0xff, 0xc0, 0xff, 0x80, 0xff, 0x00, 0xfe, 0x00, - 0xdc, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -long pow2(int power) -{ - if(power==0) - return 1; - return long(2 << (power-1)); -} - -ServerCursor::ServerCursor(void) -{ - // For when an application is started. This will probably disappear once I - // get the stuff for default cursors established - is_initialized=false; - position.Set(0,0); -} - -ServerCursor::ServerCursor(ServerBitmap *bmp, ServerBitmap *cmask=NULL) -{ - // The OpenBeOS R1 API uses Bitmaps to create cursors - more flexibility that way. - is_initialized=false; - position.Set(0,0); - SetCursor(bmp); -} - -ServerCursor::ServerCursor(int8 *data) -{ - // For handling the idiot R5 API data format - is_initialized=false; - position.Set(0,0); - SetCursor(data); -} - -ServerCursor::~ServerCursor(void) -{ - if(is_initialized) - delete bitmap; -} - -void ServerCursor::SetCursor(int8 *data) -{ - // 68-byte array used in R5 for holding cursors. - // This API has serious problems and should be deprecated(but supported) - // in a future release, perhaps right after the first one - - if(is_initialized) - { - delete bitmap; - } - cspace=B_RGBA32; - - bitmap=new ServerBitmap(16,16,B_RGBA32); - width=16; - height=16; - bounds.Set(0,0,15,15); - - // Now that we have all the setup, we're going to map (for now) the cursor - // to RGBA32. Eventually, there will be support for 16 and 8-bit depths - uint32 black=0xFF000000, - white=0xFFFFFFFF, - *bmppos; - uint16 *cursorpos, *maskpos,cursorflip, maskflip, - cursorval, maskval; - uint8 i,j; - - cursorpos=(uint16*)(data+4); - maskpos=(uint16*)(data+36); - - // for each row in the cursor data - for(j=0;j<16;j++) - { - bmppos=(uint32*)(bitmap->Buffer()+ (j*bitmap->bytesperline) ); - - // On intel, our bytes end up swapped, so we must swap them back - cursorflip=(cursorpos[j] & 0xFF) << 8; - cursorflip |= (cursorpos[j] & 0xFF00) >> 8; - maskflip=(maskpos[j] & 0xFF) << 8; - maskflip |= (maskpos[j] & 0xFF00) >> 8; - - // for each column in each row of cursor data - for(i=0;i<16;i++) - { - // Get the values and dump them to the bitmap - cursorval=cursorflip & pow2(15-i); - maskval=maskflip & pow2(15-i); - bmppos[i]=((cursorval!=0)?black:white) & ((maskval>0)?0xFFFFFFFF:0x00FFFFFF); - } - } -} - -// Currently unimplemented -void ServerCursor::SetCursor(ServerBitmap *bmp, ServerBitmap *cmask=NULL) -{ -/* if(is_initialized) - delete bitmap; - cspace=bmp->cspace; - - bitmap=new ServerBitmap(bmp->width,bmp->height,cspace); - - width=bmp->width; - height=bmp->height; - bounds.Set(0,0,bmp->width-1,bmp->height-1); -*/ -} - -void ServerCursor::MoveTo(int32 x, int32 y) -{ - position.Set(x,y); -} diff --git a/src/servers/app/proto6/ServerCursor.h b/src/servers/app/proto6/ServerCursor.h deleted file mode 100644 index b49352c2eb..0000000000 --- a/src/servers/app/proto6/ServerCursor.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _SERVER_SPRITE_H -#define _SERVER_SPRITE_H - -#include -#include - -class ServerBitmap; - -class ServerCursor -{ -public: - ServerCursor(ServerBitmap *bmp,ServerBitmap *cmask=NULL); - ServerCursor(int8 *data); - ServerCursor(void); - ~ServerCursor(void); - void MoveTo(int32 x, int32 y); - void SetCursor(int8 *data); - void SetCursor(ServerBitmap *bmp, ServerBitmap *cmask=NULL); - - ServerBitmap *bitmap; - - color_space cspace; - BRect bounds; - int width,height; - BPoint position,hotspot; - bool is_initialized; -}; - -extern int8 default_cursor[]; - -#endif diff --git a/src/servers/app/proto6/ServerProtocol.h b/src/servers/app/proto6/ServerProtocol.h deleted file mode 100644 index bf7c2f0a8a..0000000000 --- a/src/servers/app/proto6/ServerProtocol.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef _APPSERVER_PROTOCOL_ -#define _APPSERVER_PROTOCOL_ - -#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' - -#define SERVER_PORT_NAME "OBappserver" -#define SERVER_INPUT_PORT "OBinputport" - - -// This will be modified. Currently a kludge for the input server until -// BScreens are implemented by the IK Taeam -#define GET_SCREEN_MODE 'gsmd' - -#define SET_UI_COLORS 'suic' -#define GET_UI_COLOR 'guic' -#define SET_DECORATOR 'sdec' -#define GET_DECORATOR 'gdec' - -#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 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' - -#define GFX_SET_HIGH_COLOR 'gshc' -#define GFX_SET_LOW_COLOR 'gslc' -#define GFX_SET_VIEW_COLOR 'gsvc' - -#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' - -#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' - -#define GFX_MOVEPENBY 'gmpb' -#define GFX_MOVEPENTO 'gmpt' -#define GFX_SETPENSIZE 'gsps' - -#define GFX_DRAW_STRING 'gdst' -#define GFX_SET_FONT 'gsft' -#define GFX_SET_FONT_SIZE 'gsfs' - -#define GFX_FLUSH 'gfsh' -#define GFX_SYNC 'gsyn' - -#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 BEGIN_RECT_TRACKING 'rtbg' -#define END_RECT_TRACKING 'rten' - -#define VIEW_GET_TOKEN 'vgtk' -#define VIEW_ADD 'vadd' -#define VIEW_REMOVE 'vrem' -#endif diff --git a/src/servers/app/proto6/ServerWindow.cpp b/src/servers/app/proto6/ServerWindow.cpp deleted file mode 100644 index bd88d427da..0000000000 --- a/src/servers/app/proto6/ServerWindow.cpp +++ /dev/null @@ -1,507 +0,0 @@ -/* - ServerWindow.cpp - Class which works with a BWindow. Handles all messages coming from and - going to its window plus all drawing calls. -*/ -#include -#include -#include -#include -#include -#include // for B_XXXXX_MOUSE_BUTTON defines -#include "AppServer.h" -#include "Layer.h" -#include "PortLink.h" -#include "ServerWindow.h" -#include "ServerApp.h" -#include "ServerProtocol.h" -#include "WindowBorder.h" -#include "DebugTools.h" - -//#define DEBUG_SERVERWIN - -// Used for providing identifiers for views -int32 view_counter=0; - -// Used in window focus management -ServerWindow *active_serverwindow=NULL; - -ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook, - uint32 wfeel, uint32 wflags, ServerApp *winapp, port_id winport, uint32 index) -{ - title=new BString; - if(string) - title->SetTo(string); - else - title->SetTo("Window"); -#ifdef DEBUG_SERVERWIN -printf("ServerWindow() %s\n",title->String()); -#endif - - // This must happen before the WindowBorder object - it needs this object's frame - // to be valid - frame=rect; - - // set these early also - the decorator will also need them - winflags=wflags; - winlook=wlook; - winfeel=wfeel; - - - winborder=new WindowBorder(this, title->String()); - - // hard code this for now - window look also needs to be attached and sent to - // server by BWindow constructor - decorator=instantiate_decorator(winborder, winflags, wlook); -#ifdef DEBUG_SERVERWIN -if(decorator==NULL) - printf("ServerWindow() %s: NULL decorator returned\n",title->String()); -#endif - winborder->SetDecorator(decorator); -#ifdef DEBUG_SERVERWIN -printf("ServerWindow() %s: decorator set\n",title->String()); -#endif - - // sender is the monitored app's event port - sender=winport; - winlink=new PortLink(sender); - - if(winapp!=NULL) - applink=new PortLink(winapp->receiver); - else - applink=NULL; -#ifdef DEBUG_SERVERWIN -printf("ServerWindow() %s: PortLink established\n",title->String()); -#endif - - // 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 thread - thread=spawn_thread(MonitorWin,title->String(),B_NORMAL_PRIORITY,this); - if(thread!=B_NO_MORE_THREADS && thread!=B_NO_MEMORY) - resume_thread(thread); -#ifdef DEBUG_SERVERWIN -printf("ServerWindow() %s: MonitorThread spawned\n",title->String()); -#endif - - workspace=index; - - AddWindowToDesktop(this,index); -#ifdef DEBUG_SERVERWIN -printf("ServerWindow() %s: Added to Desktop\n",title->String()); -#endif -} - -ServerWindow::~ServerWindow(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::~ServerWindow()\n",title->String()); -#endif - RemoveWindowFromDesktop(this); - if(applink) - { - delete applink; - applink=NULL; - - delete title; - delete winlink; - delete decorator; - delete winborder; - } - kill_thread(thread); -} - -void ServerWindow::RequestDraw(BRect rect) -{ - winlink->SetOpCode(LAYER_DRAW); - winlink->Attach(&rect,sizeof(BRect)); - winlink->Flush(); -} - -void ServerWindow::ReplaceDecorator(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::ReplaceDecorator()\n",title->String()); -#endif -} - -void ServerWindow::Quit(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::Quit()\n",title->String()); -#endif -} - -const char *ServerWindow::GetTitle(void) -{ - return title->String(); -} - -ServerApp *ServerWindow::GetApp(void) -{ - return app; -} - -void ServerWindow::Show(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::Show()\n",title->String()); -#endif - if(winborder) - { - winborder->ShowLayer(); - ActivateWindow(this); -// winborder->Draw(frame); - } -} - -void ServerWindow::Hide(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::Hide()\n",title->String()); -#endif - if(winborder) - winborder->HideLayer(); -} - -bool ServerWindow::IsHidden(void) -{ - return (hidecount==0)?true:false; -} - -void ServerWindow::SetFocus(bool value) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::SetFocus(%s)\n",title->String(),(value==true)?"true":"false"); -#endif - if(active!=value) - { - active=value; - decorator->SetFocus(value); - decorator->Draw(); - } -} - -bool ServerWindow::HasFocus(void) -{ - return active; -} - -void ServerWindow::WorkspaceActivated(int32 NewWorkspace, const BPoint Resolution, color_space CSpace) -{ -} - -void ServerWindow::WindowActivated(bool Active) -{ -} - -void ServerWindow::ScreenModeChanged(const BPoint Resolustion, color_space CSpace) -{ -} - -void ServerWindow::SetFrame(const BRect &rect) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::SetFrame()",title->String()); rect.PrintToStream(); -#endif - frame=rect; -} - -BRect ServerWindow::Frame(void) -{ - return frame; -} - -status_t ServerWindow::Lock(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::Lock()\n",title->String()); -#endif - return locker.Lock(); -} - -void ServerWindow::Unlock(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::Unlock()\n",title->String()); -#endif - locker.Unlock(); -} - -bool ServerWindow::IsLocked(void) -{ - return locker.IsLocked(); -} - -void ServerWindow::Loop(void) -{ - // Message-dispatching loop for the ServerWindow - -#ifdef DEBUG_SERVERWIN -printf("%s::Loop()\n",title->String()); -#endif - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(receiver); - - if(buffersize>0) - { - msgbuffer=new int8[buffersize]; - bytesread=read_port(receiver,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(receiver,&msgcode,NULL,0); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case 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) (int32) id of the child view - // 3) (BRect) frame in parent's coordinates - // 4) (int32) resize flags - // 5) (int32) view flags - // 6) (uint16) view's hide level - - 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)thread); - applink->Flush(); - break; - } - case VIEW_GET_TOKEN: - { - // Request to get a view identifier - this is synchronous, so reply - // immediately - - // Attached data: - // 1) port_id reply port - port_id reply_port=*((port_id*)msgbuffer); - PortLink *link=new PortLink(reply_port); - link->Attach(view_counter++); - link->Flush(); - break; - } - default: - DispatchMessage(msgcode,msgbuffer); - break; - } - - } - - if(buffersize>0) - delete msgbuffer; - - 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; -} - -void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer) -{ - ServerWindow *mousewin=NULL; - int8 *index=buffer; - - // Find the window which will receive our mouse event. - Layer *root=GetRootLayer(); - WindowBorder *winborder; - ASSERT(root!=NULL); - - // Dispatch the mouse event to the proper window - switch(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 - -// int64 time=*((int64*)index); - index+=sizeof(int64); - float x=*((float*)index); - index+=sizeof(float); - float y=*((float*)index); - index+=sizeof(float); -// int32 modifiers=*((int32*)index); - index+=sizeof(uint32); - uint32 buttons=*((uint32*)index); - index+=sizeof(uint32); -// int32 clicks=*((int32*)index); - BPoint pt(x,y); - - // If we have clicked on a window, - winborder=(WindowBorder*)root->GetChildAt(pt); - if(winborder) - { - mousewin=winborder->Window(); - ASSERT(mousewin!=NULL); - winborder->MouseDown(pt,buttons); - -#ifdef DEBUG_SERVERWIN -printf("ServerWindow() %s: MouseDown(%.1f,%.1f)\n",mousewin->title->String(),x,y); -#endif - } - 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 - -// int64 time=*((int64*)index); - index+=sizeof(int64); - float x=*((float*)index); - index+=sizeof(float); - float y=*((float*)index); - index+=sizeof(float); -// int32 modifiers=*((int32*)index); - BPoint pt(x,y); - - is_moving_window=false; - winborder=(WindowBorder*)root->GetChildAt(pt); - if(winborder) - { - mousewin=winborder->Window(); - ASSERT(mousewin!=NULL); - - // Eventually, we will build in MouseUp messages with buttons specified - // For now, we just "assume" no mouse specification with a 0. - winborder->MouseUp(pt,0); - - // Do cool mouse stuff here - -#ifdef DEBUG_SERVERWIN -printf("ServerWindow() %s: MouseUp(%.1f,%.1f)\n",mousewin->title->String(),x,y); -#endif - } - 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 -// int64 time=*((int64*)index); - index+=sizeof(int64); - float x=*((float*)index); - index+=sizeof(float); - float y=*((float*)index); - index+=sizeof(float); - uint32 buttons=*((uint32*)index); - BPoint pt(x,y); - - if(!is_moving_window) - { - winborder=(WindowBorder*)root->GetChildAt(pt); - if(winborder) - { - mousewin=winborder->Window(); - ASSERT(mousewin!=NULL); - - winborder->MouseMoved(pt,buttons); - } - } - else - { - mousewin=active_serverwindow; - ASSERT(mousewin!=NULL); - - mousewin->winborder->MouseMoved(pt,buttons); - } - break; - } - default: - { -#ifdef DEBUG_SERVERWIN -printf("HandleMouseEvent() received an unrecognized mouse event"); -PrintMessageCode(code); -#endif - break; - } - } -} - -void ActivateWindow(ServerWindow *win) -{ - if(active_serverwindow==win) - return; - if(active_serverwindow) - active_serverwindow->SetFocus(false); - active_serverwindow=win; - if(win) - win->SetFocus(true); -} diff --git a/src/servers/app/proto6/ServerWindow.h b/src/servers/app/proto6/ServerWindow.h deleted file mode 100644 index 9266979aea..0000000000 --- a/src/servers/app/proto6/ServerWindow.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef _SERVERWIN_H_ -#define _SERVERWIN_H_ - -#include -#include -#include -#include -#include -#include - -class BString; -class BMessenger; -class BPoint; -class ServerApp; -class Decorator; -class PortLink; -class WindowBorder; - -class ServerWindow -{ -public: - ServerWindow(BRect rect, const char *string, uint32 wlook, uint32 wfeel, - uint32 wflags, ServerApp *winapp, port_id winport, uint32 index); - ~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 SetFocus(bool value); - bool HasFocus(void); - void RequestDraw(BRect rect); - - void WorkspaceActivated(int32 NewDesktop, const BPoint Resolution, color_space CSpace); - void WindowActivated(bool Active); - void ScreenModeChanged(const BPoint Resolution, color_space CSpace); - - void SetFrame(const BRect &rect); - BRect Frame(void); - - status_t Lock(void); - void Unlock(void); - bool IsLocked(void); - - void DispatchMessage(int32 code, int8 *msgbuffer); - static int32 MonitorWin(void *data); - static void HandleMouseEvent(int32 code, int8 *buffer); - void Loop(void); - - BString *title; - int32 winlook, winfeel, winflags; - int32 workspace; - bool active; - - ServerApp *app; - - Decorator *decorator; - WindowBorder *winborder; - bigtime_t lasthit; // Time of last mouse click - - thread_id thread; - port_id receiver; // Messages from window - port_id sender; // Messages to window - PortLink *winlink,*applink; - BLocker locker; - BRect frame; - uint8 hidecount; -}; - -void ActivateWindow(ServerWindow *win); - - -#endif diff --git a/src/servers/app/proto6/SystemPalette.cpp b/src/servers/app/proto6/SystemPalette.cpp deleted file mode 100644 index dc3fdcd40f..0000000000 --- a/src/servers/app/proto6/SystemPalette.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/* - SystemPalette.cpp - One global function to generate the palette which is the default BeOS - System palette and the variable to go with it -*/ - -#include "SystemPalette.h" - -rgb_color system_palette[256]; - -void GenerateSystemPalette(rgb_color *palette) -{ - int i,j,index=0; - int indexvals1[]={ 255,229,204,179,154,129,105,80,55,30 }, - indexvals2[]={ 255,203,152,102,51,0 }; - rgb_color *currentcol; - - // Grays 0,0,0 -> 248,248,248 by 8's - for(i=0; i<=248; i+=8,index++) - { - currentcol=&(palette[index]); - currentcol->red=i; - currentcol->green=i; - currentcol->blue=i; - currentcol->alpha=255; - } - - // Blues, following indexvals1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=0; - currentcol->blue=indexvals1[i]; - currentcol->alpha=255; - } - - // Reds, following indexvals1 - 1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals1[i] - 1; - currentcol->green=0; - currentcol->blue=0; - currentcol->alpha=255; - } - - // Greens, following indexvals1 - 1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=indexvals1[i] - 1; - currentcol->blue=0; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=152; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=255; - currentcol->blue=255; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=0;i<4;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=152; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=0; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=255; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=203; - index++; - - // Mostly array runs from here on out - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=203; - currentcol->green=203; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=152; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=102; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=51; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=152; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=102; - index++; - - // knocks out 4 assignment loops at once :) - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=152; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - currentcol+=sizeof(rgb_color); - currentcol->red=230; - currentcol->green=134; - currentcol->blue=0; - index++; - - for(i=1;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=0; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=102; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=175; - currentcol->blue=19; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=255; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=203; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=3;i>=0;i--,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - for(i=2;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - for(i=0;i<5;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=203; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=227; - currentcol->blue=70; - index++; - - for(j=2;j<6;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=0; - index++; - - for(i=5;i<=0;i--,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - -} diff --git a/src/servers/app/proto6/SystemPalette.h b/src/servers/app/proto6/SystemPalette.h deleted file mode 100644 index 18f1d4542e..0000000000 --- a/src/servers/app/proto6/SystemPalette.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _SYSTEM_PALETTE_H_ -#define _SYSTEM_PALETTE_H_ - -#include - -void GenerateSystemPalette(rgb_color *palette); -extern rgb_color system_palette[]; - -#endif diff --git a/src/servers/app/proto6/ViewDriver.cpp b/src/servers/app/proto6/ViewDriver.cpp deleted file mode 100644 index 3f8f090d52..0000000000 --- a/src/servers/app/proto6/ViewDriver.cpp +++ /dev/null @@ -1,1084 +0,0 @@ -/* - ViewDriver: - First, slowest, and easiest driver class in the app_server which is designed - to utilize the BeOS graphics functions to cut out a lot of junk in getting the - drawing infrastructure in this server. - - The concept is to have VDView::Draw() draw a bitmap, which is a "frame buffer" - of sorts, utilize a second view to write to it. This cuts out - the most problems with having a crapload of code to get just right without - having to write a bunch of unit tests - - Components: 3 classes, VDView, VDWindow, and ViewDriver - - ViewDriver - a wrapper class which mostly posts messages to the VDWindow - VDWindow - does most of the work. - VDView - doesn't do all that much except display the rendered bitmap -*/ - -#define DEBUG_DRIVER_MODULE -//#define DEBUG_SERVER_EMU - -//#define DISABLE_SERVER_EMU - -#include -#include -#include -#include -#include -#include -#include -#include "PortLink.h" -#include "ServerProtocol.h" -#include "ServerBitmap.h" -#include "ViewDriver.h" -#include "ServerCursor.h" -#include "DebugTools.h" - -enum -{ -VDWIN_CLEAR=100, - -VDWIN_SHOWCURSOR, -VDWIN_HIDECURSOR, -VDWIN_OBSCURECURSOR, -VDWIN_MOVECURSOR, -VDWIN_SETCURSOR, -}; - -ViewDriver *viewdriver_global; - -VDView::VDView(BRect bounds) - : BView(bounds,"viewdriver_view",B_FOLLOW_ALL, B_WILL_DRAW) -{ - viewbmp=new BBitmap(bounds,B_RGB32,true); - - // This link for sending mouse messages to the OBAppServer. - // This is only to take the place of the Input Server. I suppose I could write - // an addon filter to be more like the Input Server, but then I wouldn't be working - // on this thing! :P - serverlink=new PortLink(find_port(SERVER_INPUT_PORT)); - -#ifdef DEBUG_DRIVER_MODULE - printf("VDView: app_server input port: %ld\n",serverlink->GetPort()); -#endif - - // Create a cursor which isn't just a box - cursor=new BBitmap(BRect(0,0,20,20),B_RGBA32,true); - BView *v=new BView(cursor->Bounds(),"v", B_FOLLOW_NONE, B_WILL_DRAW); - hide_cursor=0; - - cursor->Lock(); - cursor->AddChild(v); - - v->SetHighColor(255,255,255,0); - v->FillRect(cursor->Bounds()); - v->SetHighColor(255,0,0,255); - v->FillTriangle(cursor->Bounds().LeftTop(),cursor->Bounds().RightTop(),cursor->Bounds().LeftBottom()); - - cursor->RemoveChild(v); - cursor->Unlock(); - - cursorframe=cursor->Bounds(); - oldcursorframe=cursor->Bounds(); -} - -VDView::~VDView(void) -{ - delete serverlink; - delete viewbmp; - delete cursor; -} - -void VDView::AttachedToWindow(void) -{ -} - -void VDView::Draw(BRect rect) -{ - if(viewbmp) - { - DrawBitmapAsync(viewbmp,oldcursorframe,oldcursorframe); - DrawBitmapAsync(viewbmp,rect,rect); - - if(hide_cursor==0 && obscure_cursor==false) - { - SetDrawingMode(B_OP_ALPHA); - DrawBitmapAsync(cursor,cursor->Bounds(),cursorframe); - SetDrawingMode(B_OP_COPY); - } - Sync(); - } -} - -// These functions emulate the Input Server by sending the *exact* same kind of messages -// to the server's port. Being we're using a regular window, it would make little sense -// to do anything else. - -void VDView::MouseDown(BPoint pt) -{ -#ifdef DEBUG_SERVER_EMU -printf("ViewDriver::MouseDown\t"); -#endif - // 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 -#ifndef DISABLE_SERVER_EMU - BPoint p; - - uint32 buttons, - mod=modifiers(), - clicks=1; // can't get the # of clicks without a *lot* of extra work :( - - int64 time=(int64)real_time_clock(); - - GetMouse(&p,&buttons); - - serverlink->SetOpCode(B_MOUSE_DOWN); - serverlink->Attach(&time, sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - serverlink->Attach(&mod, sizeof(uint32)); - serverlink->Attach(&buttons, sizeof(uint32)); - serverlink->Attach(&clicks, sizeof(uint32)); - serverlink->Flush(); -#endif -} - -void VDView::MouseMoved(BPoint pt, uint32 transit, const BMessage *msg) -{ - // Attach 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 -#ifndef DISABLE_SERVER_EMU - BPoint p; - uint32 buttons; - int64 time=(int64)real_time_clock(); - - serverlink->SetOpCode(B_MOUSE_MOVED); - serverlink->Attach(&time,sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - GetMouse(&p,&buttons); - serverlink->Attach(&buttons,sizeof(int32)); - serverlink->Flush(); -#endif -} - -void VDView::MouseUp(BPoint pt) -{ -#ifdef DEBUG_SERVER_EMU -printf("ViewDriver::MouseUp\t"); -#endif - // 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 -#ifndef DISABLE_SERVER_EMU - BPoint p; - - uint32 buttons, - mod=modifiers(); - - int64 time=(int64)real_time_clock(); - - GetMouse(&p,&buttons); - - serverlink->SetOpCode(B_MOUSE_UP); - serverlink->Attach(&time, sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - serverlink->Attach(&mod, sizeof(uint32)); - serverlink->Flush(); -#endif -} - -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- - -VDWindow::VDWindow(void) - : BWindow(BRect(100,60,740,540),"OBOS App Server, P6",B_TITLED_WINDOW, - B_NOT_ZOOMABLE | B_NOT_RESIZABLE) -{ - view=new VDView(Bounds()); - AddChild(view); -} - -VDWindow::~VDWindow(void) -{ -} - -void VDWindow::MessageReceived(BMessage *msg) -{ - switch(msg->what) - { - case VDWIN_SHOWCURSOR: - { - if(view->hide_cursor>0) - { - view->hide_cursor--; -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: ShowCursor() - still hidden\n"); -#endif - } - if(view->hide_cursor==0) - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: ShowCursor() - cursor shown\n"); -#endif - view->Invalidate(view->cursorframe); - } - break; - } - case VDWIN_HIDECURSOR: - { - view->hide_cursor++; -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: HideCursor()\n"); -#endif - if(view->hide_cursor==1) - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: HideCursor() - cursor was hidden\n"); -#endif - view->Invalidate(view->cursorframe); - } - break; - } - case VDWIN_OBSCURECURSOR: - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: ObscureCursor()\n"); -#endif - view->obscure_cursor=true; - view->Invalidate(view->cursorframe); - break; - } - case VDWIN_MOVECURSOR: - { - float x,y; - msg->FindFloat("x",&x); - msg->FindFloat("y",&y); - - // this was changed because an extra message was - // sent even though the mouse was never moved - if(view->cursorframe.left!=x || view->cursorframe.top!=y) - { - if(view->obscure_cursor) - view->obscure_cursor=false; - - view->oldcursorframe=view->cursorframe; - view->cursorframe.OffsetTo(x,y); - } - - if(view->hide_cursor==0) - view->Invalidate(view->oldcursorframe); - break; - } - case VDWIN_SETCURSOR: - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: SetCursor()\n"); -#endif - ServerCursor *cdata; - msg->FindPointer("SCursor",(void**)&cdata); - - if(cdata!=NULL) - { - BBitmap *bmp=new BBitmap(BRect(0,0,cdata->width-1,cdata->height-1), - cdata->cspace); - - // Copy the server bitmap in the cursor to a BBitmap - uint8 *sbmppos=(uint8*)cdata->bitmap->Buffer(), - *bbmppos=(uint8*)bmp->Bits(); - - int32 bytes=cdata->bitmap->bytesperline, - bbytes=bmp->BytesPerRow(); - - for(int i=0;iheight;i++) - memcpy(bbmppos+(i*bbytes), sbmppos+(i*bytes), bytes); - - // Replace the bitmap - delete view->cursor; - view->cursor=bmp; - view->Invalidate(view->cursorframe); - break; - } - break; - } - default: - BWindow::MessageReceived(msg); - break; - } -} - -bool VDWindow::QuitRequested(void) -{ - port_id serverport=find_port(SERVER_PORT_NAME); - - if(serverport!=B_NAME_NOT_FOUND) - write_port(serverport,B_QUIT_REQUESTED,NULL,0); - - return true; -} - -void VDWindow::WindowActivated(bool active) -{ - // This is just to hide the regular system cursor so we can see our own - if(active) - be_app->HideCursor(); - else - be_app->ShowCursor(); -} - -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- - -ViewDriver::ViewDriver(void) -{ - viewdriver_global=this; - screenwin=new VDWindow(); - framebuffer=screenwin->view->viewbmp; - serverlink=screenwin->view->serverlink; - hide_cursor=0; -} - -ViewDriver::~ViewDriver(void) -{ - if(is_initialized) - { - screenwin->Lock(); - screenwin->Quit(); - } -} - -void ViewDriver::Initialize(void) -{ - drawview=new BView(framebuffer->Bounds(),"drawview",B_FOLLOW_ALL, B_WILL_DRAW); - framebuffer->AddChild(drawview); - - hide_cursor=0; - obscure_cursor=false; - - SetPenSize(1.0); - MovePenTo(BPoint(0,0)); - is_initialized=true; - - // We can afford to call the above functions without locking - // because the window is locked until Show() is first called - screenwin->Show(); -} - -void ViewDriver::Shutdown(void) -{ - locker->Lock(); - is_initialized=false; - locker->Unlock(); -} - -bool ViewDriver::IsInitialized(void) -{ - return is_initialized; -} - -void ViewDriver::SafeMode(void) -{ - SetScreen(B_8_BIT_640x480); -} - -void ViewDriver::Reset(void) -{ - SafeMode(); - Clear(255,255,255); -} - -void ViewDriver::SetScreen(uint32 space) -{ - screenwin->Lock(); - int16 w=640,h=480; - color_space s; - - switch(space) - { - case B_32_BIT_800x600: - case B_16_BIT_800x600: - case B_8_BIT_800x600: - { - w=800; h=600; - break; - } - case B_32_BIT_1024x768: - case B_16_BIT_1024x768: - case B_8_BIT_1024x768: - { - w=1024; h=768; - break; - } - default: - break; - } - screenwin->ResizeTo(w-1,h-1); - - switch(space) - { - case B_32_BIT_640x480: - case B_32_BIT_800x600: - case B_32_BIT_1024x768: - s=B_RGBA32; - break; - case B_16_BIT_640x480: - case B_16_BIT_800x600: - case B_16_BIT_1024x768: - s=B_RGBA15; - break; - case B_8_BIT_640x480: - case B_8_BIT_800x600: - case B_8_BIT_1024x768: - s=B_CMAP8; - break; - default: - break; - } - - - delete framebuffer; - - screenwin->view->viewbmp=new BBitmap(BRect(0,0,w-1,h-1),s,true); - framebuffer=screenwin->view->viewbmp; - drawview=new BView(framebuffer->Bounds(),"drawview",B_FOLLOW_ALL, B_WILL_DRAW); - framebuffer->AddChild(drawview); - - screenwin->Unlock(); -} - -void ViewDriver::Clear(uint8 red, uint8 green, uint8 blue) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(red,green,blue); - drawview->FillRect(drawview->Bounds()); - drawview->Sync(); - screenwin->view->Invalidate(); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::Clear(rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(col); - drawview->FillRect(drawview->Bounds()); - drawview->Sync(); - screenwin->view->Invalidate(); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -int32 ViewDriver::GetHeight(void) -{ - screenwin->Lock(); - int32 h=bufferheight; - screenwin->Unlock(); - - return h; -} - -int32 ViewDriver::GetWidth(void) -{ - screenwin->Lock(); - int32 w=bufferwidth; - screenwin->Unlock(); - - return w; -} - -int ViewDriver::GetDepth(void) -{ - screenwin->Lock(); - int d=bufferdepth; - screenwin->Unlock(); - - return d; -} - -void ViewDriver::AddLine(BPoint pt1, BPoint pt2, rgb_color col) -{ - drawview->AddLine(pt1,pt2,col); - laregion.Include(BRect(pt1,pt2)); -} - -void ViewDriver::BeginLineArray(int32 count) -{ - // NOTE: the unlocking is done in EndLineArray()! - screenwin->Lock(); - framebuffer->Lock(); - laregion.MakeEmpty(); - drawview->BeginLineArray(count); -} - -void ViewDriver::Blit(BRect src, BRect dest) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->CopyBits(src,dest); - drawview->Sync(); - screenwin->view->Invalidate(dest); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::DrawBitmap(ServerBitmap *bitmap) -{ -} - -void ViewDriver::DrawLineArray(int32 count,BPoint *start, BPoint *end, rgb_color *color) -{ - screenwin->Lock(); - framebuffer->Lock(); - - BRegion invalid; - drawview->BeginLineArray(count+1); - for(int32 i=0;iAddLine(start[i],end[i],color[i]); - invalid.Include(BRect(start[i],end[i])); - } - drawview->EndLineArray(); - drawview->Sync(); - screenwin->view->Invalidate(invalid.Frame()); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::DrawChar(char c, BPoint point) -{ - char string[2]; - string[0]=c; - string[1]='\0'; - DrawString(string,2,point); -} - -void ViewDriver::DrawString(char *string, int length, BPoint point) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->DrawString(string,length,point); - font_height fheight; - drawview->GetFontHeight(&fheight); - BRect invalid(point,BPoint(point.x+drawview->StringWidth(string,length), - fheight.ascent+5)); - drawview->Sync(); - screenwin->view->Invalidate(invalid); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::EndLineArray(void) -{ - // NOTE: the locking is done in BeginLineArray()! - drawview->EndLineArray(); - drawview->Sync(); - screenwin->view->Invalidate(laregion.Frame()); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->FillArc(BPoint(centerx,centery),xradius,yradius,angle,span,*((pattern*)pat)); - else - drawview->FillArc(BPoint(centerx,centery),xradius,yradius,angle,span); - drawview->Sync(); - screenwin->view->Invalidate(BRect(centerx-xradius,centery-yradius, - centerx+xradius,centery+yradius)); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillBezier(BPoint *points, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->FillBezier(points,*((pattern*)pat)); - else - drawview->FillBezier(points); - drawview->Sync(); - - // Invalidate the whole view until I get around to adding in the invalid rect calc code - screenwin->view->Invalidate(); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->FillEllipse(BPoint(centerx,centery),x_radius,y_radius,*((pattern*)pat)); - else - drawview->FillEllipse(BPoint(centerx,centery),x_radius,y_radius); - drawview->Sync(); - screenwin->view->Invalidate(BRect(centerx-x_radius,centery-y_radius, - centerx+x_radius,centery+y_radius)); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillPolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void ViewDriver::FillRect(BRect rect, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->FillRect(rect,*((pattern*)pat)); - else - drawview->FillRect(rect); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillRect(BRect rect, rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(col); - drawview->FillRect(rect); - drawview->SetHighColor(highcolor); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillRegion(BRegion *region) -{ -} - -void ViewDriver::FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->FillRoundRect(rect,xradius,yradius,*((pattern*)pat)); - else - drawview->FillRoundRect(rect,xradius,yradius); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillShape(BShape *shape) -{ -} - -void ViewDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->FillTriangle(first,second,third,rect,*((pattern*)pat)); - else - drawview->FillTriangle(first,second,third,rect); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(col); - drawview->FillTriangle(first,second,third,rect); - drawview->SetHighColor(highcolor); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::HideCursor(void) -{ - screenwin->Lock(); - locker->Lock(); - - hide_cursor++; - screenwin->PostMessage(VDWIN_HIDECURSOR); - - locker->Unlock(); - screenwin->Unlock(); - -} - -bool ViewDriver::IsCursorHidden(void) -{ - screenwin->Lock(); - bool value=(hide_cursor>0)?true:false; - screenwin->Unlock(); - return value; -} - -void ViewDriver::ObscureCursor(void) -{ - screenwin->Lock(); - screenwin->PostMessage(VDWIN_OBSCURECURSOR); - screenwin->Unlock(); -} - -void ViewDriver::MoveCursorTo(float x, float y) -{ - screenwin->Lock(); - BMessage *msg=new BMessage(VDWIN_MOVECURSOR); - msg->AddFloat("x",x); - msg->AddFloat("y",y); - screenwin->PostMessage(msg); - screenwin->Unlock(); -} - -void ViewDriver::MovePenTo(BPoint pt) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->MovePenTo(pt); - penpos=pt; - framebuffer->Unlock(); - screenwin->Unlock(); -} - -BPoint ViewDriver::PenPosition(void) -{ - return penpos; -} - -float ViewDriver::PenSize(void) -{ - return pensize; -} - -void ViewDriver::SetCursor(ServerCursor *cursor) -{ - if(cursor!=NULL) - { - screenwin->Lock(); - BBitmap *bmp=new BBitmap(BRect(0,0,cursor->width-1,cursor->height-1), - cursor->cspace); - - // Copy the server bitmap in the cursor to a BBitmap - uint8 *sbmppos=(uint8*)cursor->bitmap->Buffer(), - *bbmppos=(uint8*)bmp->Bits(); - - int32 bytes=cursor->bitmap->bytesperline, - bbytes=bmp->BytesPerRow(); - - for(int i=0;iheight;i++) - memcpy(bbmppos+(i*bbytes), sbmppos+(i*bytes), bytes); - - // Replace the bitmap - delete screenwin->view->cursor; - screenwin->view->cursor=bmp; - screenwin->view->Invalidate(screenwin->view->cursorframe); - screenwin->Unlock(); - } -} - -void ViewDriver::SetPenSize(float size) -{ - screenwin->Lock(); - framebuffer->Lock(); - pensize=size; - drawview->SetPenSize(size); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(r,g,b,a); - highcolor.red=r; - highcolor.green=g; - highcolor.blue=b; - highcolor.alpha=a; - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::SetHighColor(rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(col); - highcolor=col; - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetLowColor(r,g,b,a); - lowcolor.red=r; - lowcolor.green=g; - lowcolor.blue=b; - lowcolor.alpha=a; - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::SetLowColor(rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetLowColor(col); - lowcolor=col; - framebuffer->Unlock(); - screenwin->Unlock(); -} - -drawing_mode ViewDriver::GetDrawingMode(void) -{ - drawing_mode dm; - - screenwin->Lock(); - framebuffer->Lock(); - dm=drawview->DrawingMode(); - framebuffer->Unlock(); - screenwin->Unlock(); - return dm; -} - -void ViewDriver::SetDrawingMode(drawing_mode dmode) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetDrawingMode(dmode); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::SetPixel(int x, int y, uint8 *pattern) -{ -} - -void ViewDriver::ShowCursor(void) -{ - screenwin->Lock(); - if(hide_cursor>0) - { - hide_cursor--; - screenwin->PostMessage(VDWIN_SHOWCURSOR); - } - screenwin->Unlock(); -} - -float ViewDriver::StringWidth(const char *string, int32 length) -{ - return drawview->StringWidth(string,length); -} - -void ViewDriver::StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->StrokeArc(BPoint(centerx,centery),xradius,yradius,angle,span,*((pattern*)pat)); - else - drawview->StrokeArc(BPoint(centerx,centery),xradius,yradius,angle,span); - drawview->Sync(); - screenwin->view->Invalidate(BRect(centerx-xradius,centery-yradius, - centerx+xradius,centery+yradius)); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeBezier(BPoint *points, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->StrokeBezier(points,*((pattern*)pat)); - else - drawview->StrokeBezier(points); - drawview->Sync(); - - // Invalidate the whole view until I get around to adding in the invalid rect calc code - screenwin->view->Invalidate(); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->StrokeEllipse(BPoint(centerx,centery),x_radius,y_radius,*((pattern*)pat)); - else - drawview->StrokeEllipse(BPoint(centerx,centery),x_radius,y_radius); - drawview->Sync(); - screenwin->view->Invalidate(BRect(centerx-x_radius,centery-y_radius, - centerx+x_radius,centery+y_radius)); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeLine(BPoint point, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->StrokeLine(point,*((pattern*)pat)); - else - drawview->StrokeLine(point); - drawview->Sync(); - screenwin->view->Invalidate(BRect(penpos,point)); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeLine(BPoint pt1, BPoint pt2, rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(col); - drawview->StrokeLine(pt1,pt2); - drawview->SetHighColor(highcolor); - drawview->Sync(); - screenwin->view->Invalidate(BRect(pt1,pt2)); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokePolygon(int *x, int *y, int numpoints, bool is_closed) -{ - screenwin->Lock(); - framebuffer->Lock(); - - BRegion invalid; - - drawview->BeginLineArray(numpoints+2); - BPoint start,end; - for(int i=1;iAddLine(start,end,highcolor); - invalid.Include(BRect(start,end)); - } - - if(is_closed) - { - start.Set(x[numpoints-1],y[numpoints-1]); - end.Set(x[0],y[0]); - drawview->AddLine(start,end,highcolor); - invalid.Include(BRect(start,end)); - } - drawview->EndLineArray(); - - drawview->Sync(); - screenwin->view->Invalidate(invalid.Frame()); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeRect(BRect rect, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->StrokeRect(rect,*((pattern*)pat)); - else - drawview->StrokeRect(rect); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeRect(BRect rect, rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(col); - drawview->StrokeRect(rect); - drawview->SetHighColor(highcolor); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->StrokeRoundRect(rect,xradius,yradius,*((pattern*)pat)); - else - drawview->StrokeRoundRect(rect,xradius,yradius); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeShape(BShape *shape) -{ -} - -void ViewDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->StrokeTriangle(first,second,third,rect,*((pattern*)pat)); - else - drawview->StrokeTriangle(first,second,third,rect); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(col); - drawview->StrokeTriangle(first,second,third,rect); - drawview->SetHighColor(highcolor); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} diff --git a/src/servers/app/proto6/ViewDriver.h b/src/servers/app/proto6/ViewDriver.h deleted file mode 100644 index 81ef3a79d3..0000000000 --- a/src/servers/app/proto6/ViewDriver.h +++ /dev/null @@ -1,140 +0,0 @@ -#ifndef _VIEWDRIVER_H_ -#define _VIEWDRIVER_H_ - -#include -#include -#include -#include -#include // for pattern struct -#include -#include -#include "DisplayDriver.h" - -class BBitmap; -class PortLink; -class VDWindow; -class ServerCursor; - -class VDView : public BView -{ -public: - VDView(BRect bounds); - ~VDView(void); - void AttachedToWindow(void); - void Draw(BRect rect); - void MouseDown(BPoint pt); - void MouseMoved(BPoint pt, uint32 transit, const BMessage *msg); - void MouseUp(BPoint pt); - - BBitmap *viewbmp; - PortLink *serverlink; - - int hide_cursor; - BBitmap *cursor; - - BRect cursorframe, oldcursorframe; - bool obscure_cursor; -}; - -class VDWindow : public BWindow -{ -public: - VDWindow(void); - ~VDWindow(void); - void MessageReceived(BMessage *msg); - bool QuitRequested(void); - void WindowActivated(bool active); - - VDView *view; -}; - -class ViewDriver : public DisplayDriver -{ -public: - ViewDriver(void); - ~ViewDriver(void); - - void Initialize(void); // Sets the driver - bool IsInitialized(void); - void Shutdown(void); // You never know when you'll need this - - void SafeMode(void); // Easy-access functions for common tasks - void Reset(void); - void Clear(uint8 red,uint8 green,uint8 blue); - void Clear(rgb_color col); - - // Settings functions - void SetScreen(uint32 space); - int32 GetHeight(void); - int32 GetWidth(void); - int GetDepth(void); - - // Drawing functions - void AddLine(BPoint pt1, BPoint pt2, rgb_color col); - void BeginLineArray(int32 count); - void Blit(BRect src, BRect dest); - void DrawBitmap(ServerBitmap *bitmap); - void DrawLineArray(int32 count,BPoint *start, BPoint *end, rgb_color *color); - void DrawChar(char c, BPoint point); - void DrawString(char *string, int length, BPoint point); - void EndLineArray(void); - - void FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - void FillBezier(BPoint *points, uint8 *pattern); - void FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - void FillPolygon(int *x, int *y, int numpoints, bool is_closed); - void FillRect(BRect rect, uint8 *pattern); - void FillRect(BRect rect, rgb_color col); - void FillRegion(BRegion *region); - void FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - void FillShape(BShape *shape); - void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col); - - void HideCursor(void); - bool IsCursorHidden(void); - void MoveCursorTo(float x, float y); - void MovePenTo(BPoint pt); - void ObscureCursor(void); - BPoint PenPosition(void); - float PenSize(void); - void SetCursor(ServerCursor *cursor); - drawing_mode GetDrawingMode(void); - void SetDrawingMode(drawing_mode mode); - void SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - void SetHighColor(rgb_color col); - void SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - void SetLowColor(rgb_color col); - void SetPenSize(float size); - void SetPixel(int x, int y, uint8 *pattern); - void ShowCursor(void); - - float StringWidth(const char *string, int32 length); - void StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - void StrokeBezier(BPoint *points, uint8 *pattern); - void StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - void StrokeLine(BPoint point, uint8 *pattern); - void StrokeLine(BPoint pt1, BPoint pt2, rgb_color col); - void StrokePolygon(int *x, int *y, int numpoints, bool is_closed); - void StrokeRect(BRect rect,uint8 *pattern); - void StrokeRect(BRect rect,rgb_color col); - void StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - void StrokeShape(BShape *shape); - void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col); - VDWindow *screenwin; -protected: - int hide_cursor; - bool obscure_cursor; - BBitmap *framebuffer; - BView *drawview; - - PortLink *serverlink; - // Region used to track of invalid areas for the Begin/EndLineArray functions - BRegion laregion; - rgb_color highcolor,lowcolor; - int32 bufferheight, bufferwidth; - int bufferdepth; -}; - -#endif diff --git a/src/servers/app/proto6/WinDecorator.cpp b/src/servers/app/proto6/WinDecorator.cpp deleted file mode 100644 index c2a2f8632e..0000000000 --- a/src/servers/app/proto6/WinDecorator.cpp +++ /dev/null @@ -1,441 +0,0 @@ -#include "Layer.h" -#include "DisplayDriver.h" -#include -#include "WinDecorator.h" -#include "ColorUtils.h" - -//#define DEBUG_DECOR - -#ifdef DEBUG_DECOR -#include -#endif - -WinDecorator::WinDecorator(Layer *lay, uint32 dflags, uint32 wlook) - : Decorator(lay, dflags, wlook) -{ -#ifdef DEBUG_DECOR -printf("WinDecorator()\n"); -#endif - zoomstate=false; - closestate=false; - minstate=false; - taboffset=0; - - // These hard-coded assignments will go bye-bye when the system colors - // API is implemented - - SetRGBColor(&tab_highcol,100,100,255); - SetRGBColor(&tab_lowcol,40,0,255); - - SetRGBColor(&button_highercol,255,255,255); - SetRGBColor(&button_lowercol,0,0,0); - - button_highcol=MakeBlendColor(button_lowercol,button_highercol,0.85); - button_midcol=MakeBlendColor(button_lowercol,button_highercol,0.75); - button_lowcol=MakeBlendColor(button_lowercol,button_highercol,0.5); - - SetRGBColor(&frame_highercol,216,216,216); - SetRGBColor(&frame_lowercol,110,110,110); - - SetRGBColor(&textcol,0,0,0); - - frame_highcol=MakeBlendColor(frame_lowercol,frame_highercol,0.75); - frame_midcol=MakeBlendColor(frame_lowercol,frame_highercol,0.5); - frame_lowcol=MakeBlendColor(frame_lowercol,frame_highercol,0.25); - - Resize(lay->frame); - - textoffset=5; -} - -WinDecorator::~WinDecorator(void) -{ -#ifdef DEBUG_DECOR -printf("~WinDecorator()\n"); -#endif -} - -click_type WinDecorator::Clicked(BPoint pt, uint32 buttons) -{ - // Clicked is a hit-testing function which is called by each - // decorator object's respective WindowBorder. When a click or - // mouse message is received, we must return to the WindowBorder - // what the click meant to us and the appropriate action for it - // to take. - - // the case order is important - we go from smallest to largest - // for efficiency's sake. - if(closerect.Contains(pt)) - { - -#ifdef DEBUG_DECOR -printf("WinDecorator():Clicked() - Close\n"); -#endif - - return CLICK_CLOSE; - } - - if(zoomrect.Contains(pt)) - { - -#ifdef DEBUG_DECOR -printf("WinDecorator():Clicked() - Zoom\n"); -#endif - - return CLICK_ZOOM; - } - - if(minrect.Contains(pt)) - { - -#ifdef DEBUG_DECOR -printf("WinDecorator():Clicked() - Minimize\n"); -#endif - - return CLICK_MINIMIZE; - } - - // Clicking in the tab? - if(tabrect.Contains(pt)) - { - // Here's part of our window management stuff - if(buttons==B_PRIMARY_MOUSE_BUTTON && !focused) - return CLICK_MOVETOFRONT; - if(buttons==B_SECONDARY_MOUSE_BUTTON) - return CLICK_MOVETOBACK; - return CLICK_DRAG; - } - - // We got this far, so user is clicking on the border? - BRect brect(frame); - brect.top+=19; - BRect clientrect(brect.InsetByCopy(3,3)); - if(brect.Contains(pt) && !clientrect.Contains(pt)) - { -#ifdef DEBUG_DECOR -printf("WinDecorator():Clicked() - Resize\n"); -#endif - if(brect.Contains(pt)) - return CLICK_RESIZE; - } - - // Guess user didn't click anything -#ifdef DEBUG_DECOR -printf("WinDecorator():Clicked()\n"); -#endif - return CLICK_NONE; -} - -void WinDecorator::Resize(BRect rect) -{ - // Here we determine the size of every rectangle that we use - // internally when we are given the size of the client rectangle. - - // Current version simply makes everything fit inside the rect - // instead of building around it. This will change. - -#ifdef DEBUG_DECOR -printf("WinDecorator()::Resize()"); rect.PrintToStream(); -#endif - frame=rect; - tabrect=frame; - borderrect=frame; - - borderrect.top+=19; - - tabrect.bottom=tabrect.top+18; - - zoomrect=tabrect; - zoomrect.top+=4; - zoomrect.right-=4; - zoomrect.bottom-=4; - zoomrect.left=zoomrect.right-10; - zoomrect.bottom=zoomrect.top+10; - - closerect=zoomrect; - zoomrect.OffsetBy(0-zoomrect.Width()-4,0); - - minrect=zoomrect; - minrect.OffsetBy(0-zoomrect.Width()-2,0); - -} - -void WinDecorator::MoveBy(BPoint pt) -{ - // Move all internal rectangles the appropriate amount - frame.OffsetBy(pt); - closerect.OffsetBy(pt); - tabrect.OffsetBy(pt); - borderrect.OffsetBy(pt); - zoomrect.OffsetBy(pt); - minrect.OffsetBy(pt); -} - -BPoint WinDecorator::GetMinimumSize(void) -{ - // This is currently unused, but minsize is the minimum size the - // window may take. - return minsize; -} - -void WinDecorator::SetFlags(uint32 wflags) -{ - dflags=wflags; -} - -void WinDecorator::UpdateFont(void) -{ - // This will be updated once font capability is implemented -} - -void WinDecorator::UpdateTitle(const char *string) -{ - // Designed simply to redraw the title when it has changed on - // the client side. - if(string) - { - driver->SetDrawingMode(B_OP_OVER); - rgb_color tmpcol=driver->HighColor(); - driver->SetHighColor(textcol.red,textcol.green,textcol.blue); - driver->DrawString((char *)string,strlen(string), - BPoint(frame.left+textoffset,closerect.bottom-1)); - driver->SetHighColor(tmpcol.red,tmpcol.green,tmpcol.blue); - driver->SetDrawingMode(B_OP_COPY); - } - -} - -void WinDecorator::SetFocus(bool bfocused) -{ - // SetFocus() performs necessary duties for color swapping and - // other things when a window is deactivated or activated. - - focused=bfocused; - - if(focused) - { - SetRGBColor(&tab_highcol,100,100,255); - SetRGBColor(&tab_lowcol,40,0,255); - } - else - { - SetRGBColor(&tab_highcol,220,220,220); - SetRGBColor(&tab_lowcol,128,128,128); - } -} - -void WinDecorator::Draw(BRect update) -{ - // We need to draw a few things: the tab, the resize thumb, the borders, - // and the buttons - - if(tabrect.Intersects(update)) - DrawTab(); - - // Draw the top view's client area - just a hack :) - rgb_color blue={100,100,255,255}; - - if(borderrect.Intersects(update)) - driver->FillRect(borderrect,blue); - - DrawFrame(); -} - -void WinDecorator::Draw(void) -{ - // Easy way to draw everything - no worries about drawing only certain - // things - - DrawTab(); - - // Draw the top view's client area - just a hack :) - rgb_color blue={100,100,255,255}; - driver->FillRect(borderrect,blue); - - DrawFrame(); -} - -void WinDecorator::DrawZoom(BRect r) -{ - // If this has been implemented, then the decorator has a Zoom button - // which should be drawn based on the state of the member zoomstate - DrawBlendedRect(r,zoomstate); - - // Draw the Zoom box - driver->StrokeRect(r.InsetByCopy(2,2),textcol); -} - -void WinDecorator::DrawClose(BRect r) -{ - // Just like DrawZoom, but for a close button - DrawBlendedRect(r,closestate); - - // Draw the X - driver->StrokeLine(BPoint(closerect.left+2,closerect.top+2),BPoint(closerect.right-2, - closerect.bottom-2),textcol); - driver->StrokeLine(BPoint(closerect.right-2,closerect.top+2),BPoint(closerect.left+2, - closerect.bottom-2),textcol); -} - -void WinDecorator::DrawMinimize(BRect r) -{ - // Just like DrawZoom, but for a Minimize button - DrawBlendedRect(r,minstate); - - driver->StrokeLine(BPoint(minrect.left+2,minrect.bottom-2),BPoint(minrect.right-2, - minrect.bottom-2),textcol); -} - -void WinDecorator::DrawTab(void) -{ - // If a window has a tab, this will draw it and any buttons which are - // in it. - if(dlook==WLOOK_NO_BORDER) - return; - - rgb_color tmpcol; - float rstep,gstep,bstep; - - int steps=tabrect.IntegerWidth(); - rstep=float(tab_highcol.red-tab_lowcol.red)/steps; - gstep=float(tab_highcol.green-tab_lowcol.green)/steps; - bstep=float(tab_highcol.blue-tab_lowcol.blue)/steps; - - driver->StrokeRect(tabrect,frame_lowcol); - - driver->BeginLineArray(steps); - for(float i=1;iAddLine(BPoint(tabrect.left+i,tabrect.top+1), - BPoint(tabrect.left+i,tabrect.bottom-1),tmpcol); - } - driver->EndLineArray(); - UpdateTitle(layer->name->String()); - - // Draw the buttons if we're supposed to - if(!(dflags & NOT_CLOSABLE)) - DrawClose(closerect); - if(!(dflags & NOT_ZOOMABLE)) - DrawZoom(zoomrect); - if(!(dflags & NOT_MINIMIZABLE)) - DrawMinimize(minrect); -} - -void WinDecorator::DrawBlendedRect(BRect r, bool down) -{ - // This bad boy is used to draw a rectangle with a gradient. - // Note that it is not part of the Decorator API - it's specific - // to just the WinDecorator. Called by DrawZoom and DrawClose - BRect zr=r; - rgb_color startcol,endcol; - rgb_color start2col,end2col; - - if(down) - { - startcol=button_lowercol; - start2col=button_lowcol; - endcol=button_highercol; - end2col=button_highcol; - } - else - { - startcol=button_highercol; - start2col=button_highcol; - end2col=button_lowcol; - endcol=button_lowercol; - } - driver->BeginLineArray(8); - driver->AddLine(BPoint(zr.left,zr.top),BPoint(zr.right-1,zr.top),startcol); - driver->AddLine(BPoint(zr.left,zr.top),BPoint(zr.left,zr.bottom-1),startcol); - driver->AddLine(BPoint(zr.right,zr.top),BPoint(zr.right,zr.bottom),endcol); - driver->AddLine(BPoint(zr.left,zr.bottom),BPoint(zr.right,zr.bottom),endcol); - - zr.InsetBy(1,1); - driver->AddLine(BPoint(zr.left,zr.top),BPoint(zr.right-1,zr.top),start2col); - driver->AddLine(BPoint(zr.left,zr.top),BPoint(zr.left,zr.bottom-1),start2col); - driver->AddLine(BPoint(zr.right,zr.top),BPoint(zr.right,zr.bottom),end2col); - driver->AddLine(BPoint(zr.left,zr.bottom),BPoint(zr.right,zr.bottom),end2col); - driver->EndLineArray(); - zr.InsetBy(1,1); - driver->FillRect(zr,button_midcol); -} - -void WinDecorator::DrawFrame(void) -{ - // Duh, draws the window frame, I think. ;) - - if(dlook==WLOOK_NO_BORDER) - return; - - BRect r=borderrect; - - driver->BeginLineArray(12); - driver->AddLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top), - frame_midcol); - driver->AddLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom), - frame_lowcol); - driver->AddLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top), - frame_lowercol); - driver->AddLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom), - frame_lowercol); - - r.InsetBy(1,1); - driver->AddLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top), - frame_highercol); - driver->AddLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom), - frame_highercol); - driver->AddLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top), - frame_midcol); - driver->AddLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom), - frame_midcol); - - r.InsetBy(1,1); - driver->StrokeRect(r,frame_highcol); - - r.InsetBy(1,1); - driver->AddLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top), - frame_lowercol); - driver->AddLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom), - frame_lowercol); - driver->AddLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top), - frame_highercol); - driver->AddLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom), - frame_highercol); - driver->EndLineArray(); -} - -void WinDecorator::SetLook(uint32 wlook) -{ - dlook=wlook; -} - -void WinDecorator::CalculateBorders(void) -{ - // Here we calculate the size of the border on each side - how much the - // decorator's visible area "sticks out" past the client rectangle. - switch(dlook) - { - case WLOOK_NO_BORDER: - { - bsize.Set(0,0,0,0); - break; - } - case WLOOK_TITLED: - case WLOOK_DOCUMENT: - case WLOOK_BORDERED: - case WLOOK_MODAL: - case WLOOK_FLOATING: - { - bsize.top=18; - break; - } - default: - { - break; - } - } -} diff --git a/src/servers/app/proto6/WinDecorator.h b/src/servers/app/proto6/WinDecorator.h deleted file mode 100644 index 9c623bcc70..0000000000 --- a/src/servers/app/proto6/WinDecorator.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _WIN_DECORATOR_H_ -#define _WIN_DECORATOR_H_ - -#include "Decorator.h" - -class WinDecorator: public Decorator -{ -public: - WinDecorator(Layer *lay, uint32 dflags, uint32 wlook); - ~WinDecorator(void); - - click_type Clicked(BPoint pt, uint32 buttons); - void Resize(BRect rect); - void MoveBy(BPoint pt); - BPoint GetMinimumSize(void); - void SetTitle(const char *newtitle); - void SetFlags(uint32 flags); - void SetLook(uint32 wlook); - void UpdateFont(void); - void UpdateTitle(const char *string); - void SetFocus(bool focused); - void Draw(void); - void Draw(BRect update); - void DrawZoom(BRect r); - void DrawClose(BRect r); - void DrawMinimize(BRect r); - void DrawTab(void); - void DrawFrame(void); - void CalculateBorders(void); - - void DrawBlendedRect(BRect r, bool down); - uint32 taboffset; - - rgb_color tab_highcol, tab_lowcol; - rgb_color button_highercol, button_lowercol; - rgb_color button_highcol, button_midcol, button_lowcol; - rgb_color frame_highcol, frame_midcol, frame_lowcol, frame_highercol, - frame_lowercol; - rgb_color textcol; - - BRect zoomrect,closerect,minrect,tabrect,frame,borderrect; - int textoffset; -}; - -#endif diff --git a/src/servers/app/proto6/WindowBorder.cpp b/src/servers/app/proto6/WindowBorder.cpp deleted file mode 100644 index 7499656837..0000000000 --- a/src/servers/app/proto6/WindowBorder.cpp +++ /dev/null @@ -1,370 +0,0 @@ -#include -#include -#include -#include -#include "View.h" // for mouse button defines -#include "ServerWindow.h" -#include "WindowBorder.h" -#include "Decorator.h" -#include "Desktop.h" - -#define DEBUG_WINBORDER - -#ifdef DEBUG_WINBORDER -#include -#endif - -bool is_moving_window=false; -bool is_resizing_window=false; -extern ServerWindow *active_serverwindow; - -WindowBorder::WindowBorder(ServerWindow *win, const char *bordertitle) - : Layer((win==NULL)?BRect(0,0,1,1):win->frame, - (win==NULL)?NULL:win->title->String()) -{ -#ifdef DEBUG_WINBORDER -printf("WindowBorder()\n"); -#endif - mbuttons=0; - swin=win; - mousepos.Set(0,0); - update=false; - - title=new BString(bordertitle); - hresizewin=false; - vresizewin=false; - -} - -WindowBorder::~WindowBorder(void) -{ -#ifdef DEBUG_WINBORDER -printf("~WindowBorder()\n"); -#endif - delete title; -} - -void WindowBorder::MouseDown(BPoint pt, uint32 buttons) -{ - mbuttons=buttons; - click_type click=decor->Clicked(pt, mbuttons); - mousepos=pt; - - switch(click) - { - case CLICK_MOVETOBACK: - { - MoveToBack(); - break; - } - case CLICK_MOVETOFRONT: - { - MoveToFront(); - break; - } - case CLICK_CLOSE: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): SetCloseButton\n"); -#endif - decor->SetCloseButton(true); - decor->Draw(); - break; - } - case CLICK_ZOOM: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): SetZoomButton\n"); -#endif - decor->SetZoomButton(true); - decor->Draw(); - break; - } - case CLICK_MINIMIZE: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): SetMinimizeButton\n"); -#endif - decor->SetMinimizeButton(true); - decor->Draw(); - break; - } - case CLICK_DRAG: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): Click Tab\n"); -#endif - if(buttons==B_PRIMARY_MOUSE_BUTTON) - { - is_moving_window=true; - } - if(buttons==B_SECONDARY_MOUSE_BUTTON) - MoveToBack(); - break; - } - case CLICK_RESIZE: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): Click Resize\n"); -#endif - if(buttons==B_PRIMARY_MOUSE_BUTTON) - { - is_resizing_window=true; - } - break; - } - case CLICK_NONE: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): Click None\n"); -#endif - break; - } - default: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder()::MouseDown: Undefined click type\n"); -#endif - break; - } - } - if(click!=CLICK_NONE) - ActivateWindow(swin); -} - -void WindowBorder::MouseMoved(BPoint pt, uint32 buttons) -{ - click_type click=decor->Clicked(pt, mbuttons); - if(click!=CLICK_CLOSE && decor->GetCloseButton()) - { - decor->SetCloseButton(false); - decor->Draw(); - } - - if(click!=CLICK_ZOOM && decor->GetZoomButton()) - { - decor->SetZoomButton(false); - decor->Draw(); - } - - if(click!=CLICK_MINIMIZE && decor->GetMinimizeButton()) - { - decor->SetMinimizeButton(false); - decor->Draw(); - } - - if(is_moving_window==true) - { - float dx=pt.x-mousepos.x, - dy=pt.y-mousepos.y; - if(dx!=0 || dy!=0) - { - BRect oldmoveframe=swin->frame; - clientframe.OffsetBy(pt); - - swin->Lock(); - swin->frame.OffsetBy(dx,dy); - swin->Unlock(); - - layerlock->Lock(); -// InvalidateLowerSiblings(oldmoveframe); - parent->Invalidate(oldmoveframe); - MoveBy(dx,dy); - parent->RequestDraw(); - decor->MoveBy(BPoint(dx, dy)); - decor->Draw(); - layerlock->Unlock(); - } - } - if(is_resizing_window==true) - { - float dx=pt.x-mousepos.x, - dy=pt.y-mousepos.y; - if(dx!=0 || dy!=0) - { - clientframe.right+=dx; - clientframe.bottom+=dy; - - swin->Lock(); - swin->frame.right+=dx; - swin->frame.bottom+=dy; - swin->Unlock(); - - layerlock->Lock(); - ResizeBy(dx,dy); - parent->RequestDraw(); - layerlock->Unlock(); - decor->Resize(swin->frame); - decor->Draw(); - } - } - mousepos=pt; -} - -void WindowBorder::MouseUp(BPoint pt, uint32 buttons) -{ -// mbuttons&= ~buttons; - mbuttons=buttons; - is_moving_window=false; - is_resizing_window=false; - - click_type click=decor->Clicked(pt, mbuttons); - - switch(click) - { - case CLICK_CLOSE: - { - decor->SetCloseButton(false); - decor->Draw(); - - // call close window stuff here - - break; - } - case CLICK_ZOOM: - { - decor->SetZoomButton(false); - decor->Draw(); - - // call zoom stuff here - - break; - } - case CLICK_MINIMIZE: - { - decor->SetMinimizeButton(false); - decor->Draw(); - - // call minimize stuff here - - } - default: - { - break; - } - } -} - -void WindowBorder::Draw(BRect update_rect) -{ -#ifdef DEBUG_WINBORDER -printf("WindowBorder()::Draw():"); update_rect.PrintToStream(); -#endif - - if(update && visible!=NULL) - is_updating=true; - - decor->Draw(update_rect); - - if(update && visible!=NULL) - is_updating=false; -} - -void WindowBorder::SetDecorator(Decorator *newdecor) -{ - // AtheOS kills the decorator here. However, the decor - // under OBOS doesn't belong to the border - it belongs to the - // ServerWindow, so the ServerWindow will handle all (de)allocation - // tasks. We just need to update the pointer. -#ifdef DEBUG_WINBORDER -printf("WindowBorder::SetDecorator(%p)\n",newdecor); -#endif - if(newdecor) - { - decor=newdecor; -// if(visible) -// delete visible; -// visible=decor->GetFootprint(); - } -} - -ServerWindow *WindowBorder::Window(void) const -{ - return swin; -} -void WindowBorder::RequestDraw(void) -{ - if(invalid) - { -// for(int32 i=0; iCountRects();i++) -// decor->Draw(ConvertToTop(invalid->RectAt(i))); - decor->Draw(); - delete invalid; - invalid=NULL; - is_dirty=false; - } - -} - -void WindowBorder::InvalidateLowerSiblings(BRect r) -{ - // this is used to update the other windows when a window border - // is moved or resized. - Layer *lay; - BRect toprect=ConvertToTop(r); - - for(lay=uppersibling;lay!=NULL;lay=lay->uppersibling) - { - lay->Invalidate(toprect); - lay->RequestDraw(); - } -} - -void WindowBorder::MoveToBack(void) -{ -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): MoveToBack\n"); -#endif - Layer *temp=NULL; - if(uppersibling) - temp=uppersibling; - - // Move the window to the back (the top of the tree) - Layer *top=GetRootLayer(); - ASSERT(top!=NULL); - layerlock->Lock(); - top->RemoveChild(this); - top->AddChild(this); - level=1; - swin->SetFocus(false); - decor->SetFocus(false); - decor->Draw(); - - if(temp) - ActivateWindow(uppersibling->serverwin); - layerlock->Unlock(); -} - -void WindowBorder::MoveToFront(void) -{ -#ifdef DEBUG_WINBORDER -printf("MoveToFront: \n"); -#endif - // Move the window to the front by making it the bottom - // child of the root layer - Layer *top=GetRootLayer(); - layerlock->Lock(); - - top->RemoveChild(this); - - // Make this the bottom child of the parent layer. Can't use - // AddChild(), so we'll manipulate the pointers directly. Remember, - // we need to change pointers for 4 layers - the parent, the - // uppersibling (if any), the lowersibling, and the layer in question - - // temporary placeholder while we exchange the data - Layer *templayer; - - // tweak parent - templayer=top->bottomchild; - top->bottomchild=this; - - // Tweak this layer - parent=top; - uppersibling=templayer; - uppersibling->lowersibling=this; - lowersibling=NULL; - - layerlock->Unlock(); - is_moving_window=true; -} diff --git a/src/servers/app/proto6/WindowBorder.h b/src/servers/app/proto6/WindowBorder.h deleted file mode 100644 index ba2295399d..0000000000 --- a/src/servers/app/proto6/WindowBorder.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _WINBORDER_H_ -#define _WINBORDER_H_ - -#include -#include -#include "Layer.h" - -class ServerWindow; -class Decorator; - -class WindowBorder : public Layer -{ -public: - WindowBorder(ServerWindow *win, const char *bordertitle); - ~WindowBorder(void); - void MouseDown(BPoint pt, uint32 buttons); - void MouseMoved(BPoint pt, uint32 buttons); - void MouseUp(BPoint pt, uint32 buttons); - void Draw(BRect update); - void SystemColorsUpdated(void); - void SetDecorator(Decorator *newdecor); - ServerWindow *Window(void) const; - void RequestDraw(void); - void InvalidateLowerSiblings(BRect r); - void MoveToBack(void); - void MoveToFront(void); - - ServerWindow *swin; - BString *title; - Decorator *decor; - int32 flags; - BRect frame, clientframe; - uint32 mbuttons; - BPoint mousepos; - bool update; - bool hresizewin,vresizewin; -}; - -extern bool is_moving_window, is_resizing_window; -#endif diff --git a/src/servers/app/proto6/YMakDecorator.cpp b/src/servers/app/proto6/YMakDecorator.cpp deleted file mode 100644 index 2f5187e659..0000000000 --- a/src/servers/app/proto6/YMakDecorator.cpp +++ /dev/null @@ -1,660 +0,0 @@ -/******************************************************* -* YMakDecorator -* -* Writen by YNOP. -* used BeOS Magnify and decor to try to figure out -* how it looks. -* Originaly writen on AtheOS as MakDadddy Decor. -* Hacked around several times, and then ported -* (by me again) to OBOS app_server Decorator API -* -* TODO -* Fix title issuse (We need a Font width to center by) -* Fix any issuse that came about via porting -* These may have to do with the fact that the origin is -* differnat for the two API's and also with the fact -* that we can test anything yet :P -* Border size should change with Font Height -* -* @author YNOP (ynop@beunited.org) -* @version 1 (p5) -*******************************************************/ - - -#include "Layer.h" -#include "DisplayDriver.h" -#include "YMakDecorator.h" - -//#define DEBUG_DECOR - -#ifdef DEBUG_DECOR -#include -#endif - -// Hardcoded sized .. TOP should be Font based... -#define TOP 22 -#define FRAME 6 - -/******************************************************* -* @description -*******************************************************/ -YMakDecorator::YMakDecorator(Layer *lay, uint32 flags, uint32 wlook) - :Decorator(lay, flags, wlook) -{ - if(dflags & WLOOK_NO_BORDER){ - LeftBorder = 0; - TopBorder = 0; - RightBorder = 0; - BottomBorder = 0; - }else{ - TopBorder = TOP; - LeftBorder = FRAME; - RightBorder = FRAME; - BottomBorder = FRAME; - } - Resize(lay->frame); -} - -/******************************************************* -* @description -*******************************************************/ -YMakDecorator::~YMakDecorator(void){ -} - -/******************************************************* -* @description -*******************************************************/ -click_type YMakDecorator::Clicked(BPoint pt, uint32 buttons){ -#ifdef DEBUG_DECOR -printf("YMakDecorator():Clicked(%f,%f)\n",pt.x,pt.y); -printf("ZoomRect:");ZoomRect.PrintToStream(); -#endif - - if(CloseRect.Contains(pt)){ - return CLICK_CLOSE; - } - if(ZoomRect.Contains(pt)){ - return CLICK_ZOOM; - } - - //return CLICK_RESIZE_RB; - //return CLICK_NONE; - return CLICK_DRAG; -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::Resize(BRect rect){ - frame = rect; - - BRect But; - But.left = frame.left + 0; - But.right = frame.left + 12; - But.top = frame.top + 0; - But.bottom = frame.top + 12; - - CloseRect = But; - CloseRect.left += 4; - CloseRect.top += 4; - CloseRect.right += 4; - CloseRect.bottom += 4; - -} - -/******************************************************* -* @description -*******************************************************/ -BPoint YMakDecorator::GetMinimumSize(void){ - return minsize; -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::SetFlags(uint32 flags){ - dflags=flags; -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::UpdateFont(void){ -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::UpdateTitle(const char *string){ -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::SetFocus(bool bfocused){ - focused=bfocused; -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::Draw(BRect update){ - BRect b = frame; - BRect cOBounds = frame; - - rgb_color cB = {0, 0, 0, 255}; - rgb_color cW = {251,251,251,255}; - rgb_color cG = {154,154,154,255}; - rgb_color cD = {113,113,113,255}; - rgb_color cL = {203,203,203,255}; - - // Debug yellow backgound to make sure we cover everthign :) - // Take this out in real ver for speed :P - rgb_color yellow = {255,255,0}; - driver->FillRect(frame,yellow); - - // Stroke outside border - driver->SetHighColor(cB.red,cB.green,cB.blue,cB.alpha); - driver->StrokeRect(b,NULL); - - // Stroke inside border - b = cOBounds; - b.top += TOP - 1; - b.bottom -= FRAME-1; - b.left += FRAME - 1; - b.right -= FRAME-1; - driver->StrokeRect(b,NULL); - - if(focused){ - // Stroke outer boder (raized) - b = cOBounds; - b.left += 1; - b.right -= 1; - b.top += 1; - b.bottom -= 1; - driver->SetHighColor(cW.red,cW.green,cW.blue,cW.alpha); - driver->MovePenTo(BPoint(b.left,b.top));driver->StrokeLine(BPoint(b.right,b.top),NULL); - - driver->MovePenTo(BPoint(b.left,b.bottom));driver->StrokeLine(BPoint(b.left,b.top),NULL); - driver->SetHighColor(cG.red,cG.green,cG.blue,cG.alpha); - driver->MovePenTo(BPoint(b.right,b.top));driver->StrokeLine(BPoint(b.right,b.bottom),NULL); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.left,b.bottom),NULL); - - // Stroke inter border (raized) - b = cOBounds; - b.top += TOP - 2; - b.bottom -= FRAME - 2; - b.left += FRAME - 2; - b.right -= FRAME - 2; - driver->SetHighColor(cG.red,cG.green,cG.blue,cG.alpha); - driver->MovePenTo(BPoint(b.left,b.top));driver->StrokeLine(BPoint(b.right,b.top),NULL); - driver->MovePenTo(BPoint(b.left,b.bottom));driver->StrokeLine(BPoint(b.left,b.top),NULL); - driver->SetHighColor(cW.red,cW.green,cW.blue,cW.alpha); - driver->MovePenTo(BPoint(b.right,b.top));driver->StrokeLine(BPoint(b.right,b.bottom),NULL); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.left,b.bottom),NULL); - - driver->SetHighColor(cL.red,cL.green,cL.blue,cL.alpha); - // Fill top - b = cOBounds; - b.bottom = b.top + TOP - 3; - b.top += 2; - b.left += 2; - b.right -= 2; - driver->FillRect(b,NULL); - // Fill left - b = cOBounds; - b.left += 2; - b.right = cOBounds.left + FRAME - 3; - b.top = cOBounds.top + TOP - 2; - b.bottom -= 2; - driver->FillRect(b,NULL); - // Fill right - b = cOBounds; - b.left = b.right - FRAME + 3; - b.right -= 2; - b.top = b.top + TOP - 2; - b.bottom -= 2; - driver->FillRect(b,NULL); - // fill bottom - b = cOBounds; - b.top = b.bottom - FRAME + 3; - b.bottom -= 2; - b.left += FRAME - 2; - b.right -= FRAME - 2; - driver->FillRect(b,NULL); - - // Stroke the lines .. stoke them oohh ya .. storkem .. - // - b = cOBounds; - b.left += 20; - b.right -= 20; - b.top += 4; - b.bottom += 10; - - //if((Flags & WND_NO_DEPTH_BUT) == 0){ - // b.right -= 20; - //} - -/* - driver->SetHighColor(cW.red,cW.green,cW.blue,cW.alpha); - driver->MovePenTo(BPoint(b.left,b.top+0));driver->StrokeLine(BPoint(b.right-1,b.top+0),NULL); - driver->MovePenTo(BPoint(b.left,b.top+2));driver->StrokeLine(BPoint(b.right-1,b.top+2),NULL); - driver->MovePenTo(BPoint(b.left,b.top+4));driver->StrokeLine(BPoint(b.right-1,b.top+4),NULL); - driver->MovePenTo(BPoint(b.left,b.top+6));driver->StrokeLine(BPoint(b.right-1,b.top+6),NULL); - driver->MovePenTo(BPoint(b.left,b.top+8));driver->StrokeLine(BPoint(b.right-1,b.top+8),NULL); - driver->MovePenTo(BPoint(b.left,b.top+10));driver->StrokeLine(BPoint(b.right-1,b.top+10),NULL); -*/ - // tightened the loop to reflect the changes in the DisplayDriver API - for(int j=0;j<12;j+=2) - driver->StrokeLine(BPoint(b.left,b.top+j),BPoint(b.right-1,b.top+j),cW); - -#ifdef DEBUG_DECOR -printf("About to draw high lines\n"); -printf("do done\n"); -#endif -/* - driver->SetHighColor(cD.red,cD.green,cD.blue,cD.alpha); - driver->MovePenTo(BPoint(b.left+1,b.top+1));driver->StrokeLine(BPoint(b.right,b.top+1),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+3));driver->StrokeLine(BPoint(b.right,b.top+3),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+5));driver->StrokeLine(BPoint(b.right,b.top+5),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+7));driver->StrokeLine(BPoint(b.right,b.top+7),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+9));driver->StrokeLine(BPoint(b.right,b.top+9),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+11));driver->StrokeLine(BPoint(b.right,b.top+11),NULL); -*/ - // tightened the loop to reflect the changes in the DisplayDriver API - for(int j=1;j<13;j+=2) - driver->StrokeLine(BPoint(b.left+1,b.top+j),BPoint(b.right,b.top+j),cD); - - }else{ - driver->SetHighColor(cL.red,cL.green,cL.blue,cL.alpha); - // Fill top - b = cOBounds; - b.bottom = b.top + TOP - 2; - b.top += 1; - b.left += 1; - b.right -= 1; - driver->FillRect(b,NULL); - // Fill left side - b = cOBounds; - b.left += 1; - b.right = b.left + FRAME - 2; - b.top = b.top + TOP - 1; - b.bottom -= 1; - driver->FillRect(b,NULL); - // fill right - b = cOBounds; - b.left = b.right - FRAME + 2; - b.right -= 1; - b.top = b.top + TOP - 1; - b.bottom -= 1; - driver->FillRect(b,NULL); - // fill bottom - b = cOBounds; - b.top = b.bottom - FRAME + 2; - b.bottom -= 1; - b.left += FRAME - 1; - b.right -= FRAME - 1; - driver->FillRect(b,NULL); - } - - -/* if((dflags & WND_NO_TITLE) == 0){ - // Stroke The title Text - driver->SetFgColor(cL.red,cL.green,cL.blue,cL.alpha); - b.left = 30; - b.right = 100; - //Font *font = new Font(DEFAULT_FONT_WINDOW); - //b.right = font->GetStringWidth(Title.c_str()); - - int32 len = strlen(Title.c_str()); - b.right = b.left + len * 7; - - - b.top = 2; - b.bottom = TOP - 3; - V->FillRect(b); - if(HasFocus){ - V->SetFgColor(0,0,0,255); - }else{ - V->SetFgColor(cD); - } - V->SetBgColor(cL); - V->MovePenTo(34,TOP-7); - V->DrawString(Title.c_str(), -1 ); - } -*/ - - - if(!(dflags & NOT_CLOSABLE)){ - DrawClose(CloseRect); - } - if(!(dflags & NOT_ZOOMABLE)){ - DrawZoom(ZoomRect); - } - - -/* if(!(dflags & NOT_RESIZABLE)) -*/ -} - -void YMakDecorator::Draw(void) -{ - BRect b = frame; - BRect cOBounds = frame; - - rgb_color cB = {0, 0, 0, 255}; - rgb_color cW = {251,251,251,255}; - rgb_color cG = {154,154,154,255}; - rgb_color cD = {113,113,113,255}; - rgb_color cL = {203,203,203,255}; - - // Debug yellow backgound to make sure we cover everthign :) - // Take this out in real ver for speed :P - rgb_color yellow = {255,255,0}; - driver->FillRect(frame,yellow); - - // Stroke outside border - driver->SetHighColor(cB.red,cB.green,cB.blue,cB.alpha); - driver->StrokeRect(b,NULL); - - // Stroke inside border - b = cOBounds; - b.top += TOP - 1; - b.bottom -= FRAME-1; - b.left += FRAME - 1; - b.right -= FRAME-1; - driver->StrokeRect(b,NULL); - - if(focused){ - // Stroke outer boder (raized) - b = cOBounds; - b.left += 1; - b.right -= 1; - b.top += 1; - b.bottom -= 1; - driver->SetHighColor(cW.red,cW.green,cW.blue,cW.alpha); - driver->MovePenTo(BPoint(b.left,b.top));driver->StrokeLine(BPoint(b.right,b.top),NULL); - - driver->MovePenTo(BPoint(b.left,b.bottom));driver->StrokeLine(BPoint(b.left,b.top),NULL); - driver->SetHighColor(cG.red,cG.green,cG.blue,cG.alpha); - driver->MovePenTo(BPoint(b.right,b.top));driver->StrokeLine(BPoint(b.right,b.bottom),NULL); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.left,b.bottom),NULL); - - // Stroke inter border (raized) - b = cOBounds; - b.top += TOP - 2; - b.bottom -= FRAME - 2; - b.left += FRAME - 2; - b.right -= FRAME - 2; - driver->SetHighColor(cG.red,cG.green,cG.blue,cG.alpha); - driver->MovePenTo(BPoint(b.left,b.top));driver->StrokeLine(BPoint(b.right,b.top),NULL); - driver->MovePenTo(BPoint(b.left,b.bottom));driver->StrokeLine(BPoint(b.left,b.top),NULL); - driver->SetHighColor(cW.red,cW.green,cW.blue,cW.alpha); - driver->MovePenTo(BPoint(b.right,b.top));driver->StrokeLine(BPoint(b.right,b.bottom),NULL); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.left,b.bottom),NULL); - - driver->SetHighColor(cL.red,cL.green,cL.blue,cL.alpha); - // Fill top - b = cOBounds; - b.bottom = b.top + TOP - 3; - b.top += 2; - b.left += 2; - b.right -= 2; - driver->FillRect(b,NULL); - // Fill left - b = cOBounds; - b.left += 2; - b.right = cOBounds.left + FRAME - 3; - b.top = cOBounds.top + TOP - 2; - b.bottom -= 2; - driver->FillRect(b,NULL); - // Fill right - b = cOBounds; - b.left = b.right - FRAME + 3; - b.right -= 2; - b.top = b.top + TOP - 2; - b.bottom -= 2; - driver->FillRect(b,NULL); - // fill bottom - b = cOBounds; - b.top = b.bottom - FRAME + 3; - b.bottom -= 2; - b.left += FRAME - 2; - b.right -= FRAME - 2; - driver->FillRect(b,NULL); - - // Stroke the lines .. stoke them oohh ya .. storkem .. - // - b = cOBounds; - b.left += 20; - b.right -= 20; - b.top += 4; - b.bottom += 10; - - //if((Flags & WND_NO_DEPTH_BUT) == 0){ - // b.right -= 20; - //} - -/* - driver->SetHighColor(cW.red,cW.green,cW.blue,cW.alpha); - - driver->MovePenTo(BPoint(b.left,b.top+0));driver->StrokeLine(BPoint(b.right-1,b.top+0),NULL); - driver->MovePenTo(BPoint(b.left,b.top+2));driver->StrokeLine(BPoint(b.right-1,b.top+2),NULL); - driver->MovePenTo(BPoint(b.left,b.top+4));driver->StrokeLine(BPoint(b.right-1,b.top+4),NULL); - driver->MovePenTo(BPoint(b.left,b.top+6));driver->StrokeLine(BPoint(b.right-1,b.top+6),NULL); - driver->MovePenTo(BPoint(b.left,b.top+8));driver->StrokeLine(BPoint(b.right-1,b.top+8),NULL); - driver->MovePenTo(BPoint(b.left,b.top+10));driver->StrokeLine(BPoint(b.right-1,b.top+10),NULL); -*/ - // tightened the loop to reflect the changes in the DisplayDriver API - for(int j=0;j<12;j+=2) - driver->StrokeLine(BPoint(b.left,b.top+j),BPoint(b.right-1,b.top+j),cW); - -#ifdef DEBUG_DECOR -printf("About to draw high lines\n"); -printf("do done\n"); -#endif -/* - driver->SetHighColor(cD.red,cD.green,cD.blue,cD.alpha); - - driver->MovePenTo(BPoint(b.left+1,b.top+1));driver->StrokeLine(BPoint(b.right,b.top+1),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+3));driver->StrokeLine(BPoint(b.right,b.top+3),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+5));driver->StrokeLine(BPoint(b.right,b.top+5),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+7));driver->StrokeLine(BPoint(b.right,b.top+7),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+9));driver->StrokeLine(BPoint(b.right,b.top+9),NULL); - driver->MovePenTo(BPoint(b.left+1,b.top+11));driver->StrokeLine(BPoint(b.right,b.top+11),NULL); -*/ - // tightened the loop to reflect the changes in the DisplayDriver API - for(int j=1;j<13;j+=2) - driver->StrokeLine(BPoint(b.left+1,b.top+j),BPoint(b.right,b.top+j),cD); - - }else{ - driver->SetHighColor(cL.red,cL.green,cL.blue,cL.alpha); - // Fill top - b = cOBounds; - b.bottom = b.top + TOP - 2; - b.top += 1; - b.left += 1; - b.right -= 1; - driver->FillRect(b,NULL); - // Fill left side - b = cOBounds; - b.left += 1; - b.right = b.left + FRAME - 2; - b.top = b.top + TOP - 1; - b.bottom -= 1; - driver->FillRect(b,NULL); - // fill right - b = cOBounds; - b.left = b.right - FRAME + 2; - b.right -= 1; - b.top = b.top + TOP - 1; - b.bottom -= 1; - driver->FillRect(b,NULL); - // fill bottom - b = cOBounds; - b.top = b.bottom - FRAME + 2; - b.bottom -= 1; - b.left += FRAME - 1; - b.right -= FRAME - 1; - driver->FillRect(b,NULL); - } - - -/* if((dflags & WND_NO_TITLE) == 0){ - // Stroke The title Text - driver->SetFgColor(cL.red,cL.green,cL.blue,cL.alpha); - b.left = 30; - b.right = 100; - //Font *font = new Font(DEFAULT_FONT_WINDOW); - //b.right = font->GetStringWidth(Title.c_str()); - - int32 len = strlen(Title.c_str()); - b.right = b.left + len * 7; - - - b.top = 2; - b.bottom = TOP - 3; - V->FillRect(b); - if(HasFocus){ - V->SetFgColor(0,0,0,255); - }else{ - V->SetFgColor(cD); - } - V->SetBgColor(cL); - V->MovePenTo(34,TOP-7); - V->DrawString(Title.c_str(), -1 ); - } -*/ - - - if(!(dflags & NOT_CLOSABLE)){ - DrawClose(CloseRect); - } - if(!(dflags & NOT_ZOOMABLE)){ - DrawZoom(ZoomRect); - } - -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::DrawZoom(BRect r){ -// if(zoomstate) -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::DrawClose(BRect r){ - BRect b = CloseRect; - - // if((dflags & WND_NO_CLOSE_BUT)){ return; } -// if(!HasFocus){ return; } - - - b.left += 1; - b.right -= 1; - b.top += 1; - b.bottom -= 1; - driver->SetHighColor(32,32,32,255); - /*V->DrawLine(Point(b.left,b.top),Point(b.right,b.top)); - V->DrawLine(Point(b.right,b.top),Point(b.right,b.bottom)); - V->DrawLine(Point(b.left,b.bottom),Point(b.left,b.top)); - V->DrawLine(Point(b.right,b.bottom),Point(b.left,b.bottom));*/ - driver->StrokeRect(b,NULL); - - - b = CloseRect; - - // top left higlith - driver->SetHighColor(136,136,136,255); - driver->MovePenTo(BPoint(b.left,b.top));driver->StrokeLine(BPoint(b.right-1,b.top),NULL); - driver->MovePenTo(BPoint(b.left,b.top+1));driver->StrokeLine(BPoint(b.left,b.bottom-1),NULL); - - // right bottom shadow - driver->SetHighColor(251,251,251,255); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.left+1,b.bottom),NULL); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.right,b.top+1),NULL); - - if(closestate){ - b = CloseRect; - b.left += 2; - b.right -= 2; - b.top += 2; - b.bottom -= 2; - - // Button down - driver->SetHighColor(200,200,200,255); - driver->FillRect(b,NULL); - }else{ - b = CloseRect; - b.left += 2; - b.right -= 2; - b.top += 2; - b.bottom -= 2; - - // top left - driver->SetHighColor(240,240,240,255); - driver->MovePenTo(BPoint(b.left,b.top));driver->StrokeLine(BPoint(b.right,b.top),NULL); - driver->MovePenTo(BPoint(b.left,b.top));driver->StrokeLine(BPoint(b.left,b.bottom),NULL); - - // bottom right - driver->SetHighColor(136,136,136,255); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.left+1,b.bottom),NULL); - driver->MovePenTo(BPoint(b.right,b.bottom));driver->StrokeLine(BPoint(b.right,b.top+1),NULL); - - // fill insdie (Hacked - Mack is a gradiant in the button :P!!) - driver->SetHighColor(203,203,203,255); - b.left += 1; - b.right -= 1; - b.top += 1; - b.bottom -= 1; - driver->FillRect(b,NULL); - } -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::SetLook(uint32 wlook){ - dlook = wlook; -} - -/******************************************************* -* @description -*******************************************************/ -void YMakDecorator::CalculateBorders(void){ - switch(dlook) - { - case WLOOK_NO_BORDER: - { -// bsize.Set(0,0,0,0); - break; - } - case WLOOK_TITLED: - case WLOOK_DOCUMENT: - case WLOOK_BORDERED: - { -// bsize.top=18; - break; - } - case WLOOK_MODAL: - case WLOOK_FLOATING: - { -// bsize.top=15; - break; - } - default: - { - break; - } - } -} - -void YMakDecorator::MoveBy(BPoint pt) -{ - frame.OffsetBy(pt); - CloseRect.OffsetBy(pt); - ZoomRect.OffsetBy(pt); -} diff --git a/src/servers/app/proto6/YMakDecorator.h b/src/servers/app/proto6/YMakDecorator.h deleted file mode 100644 index f7a3afe397..0000000000 --- a/src/servers/app/proto6/YMakDecorator.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef _YNOP_MAK_DECORATOR_H_ -#define _YNOP_MAK_DECORATOR_H_ - -#include "Decorator.h" - -class YMakDecorator: public Decorator{ -public: - YMakDecorator(Layer *lay, uint32 dflags, uint32 wlook); - ~YMakDecorator(void); - - click_type Clicked(BPoint pt, uint32 buttons); - void Resize(BRect rect); - BPoint GetMinimumSize(void); - void SetTitle(const char *newtitle); - void SetFlags(uint32 flags); - void SetLook(uint32 wlook); - void UpdateFont(void); - void UpdateTitle(const char *string); - void SetFocus(bool focused); - void Draw(BRect update); - void Draw(void); - void DrawZoom(BRect r); - void DrawClose(BRect r); - void CalculateBorders(void); - void MoveBy(BPoint pt); -private: - BRect frame; - - bool zoomstate; - bool closestate; - - BRect CloseRect; - BRect ZoomRect; - - int LeftBorder; - int TopBorder; - int RightBorder; - int BottomBorder; -/* - bool HasFocus; - bool CloseState; - bool ZoomState; - bool DepthState; -*/ -}; - -#endif diff --git a/src/servers/app/proto6/driverharness/AppServer.cpp b/src/servers/app/proto6/driverharness/AppServer.cpp deleted file mode 100644 index 9ee4e49423..0000000000 --- a/src/servers/app/proto6/driverharness/AppServer.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/* - AppServer.cpp - File for the main app_server thread. This particular thread monitors for - application start and quit messages. It also starts the housekeeping threads - and initializes most of the server's globals. -*/ -#include -#include -#include "scheduler.h" -#include -#include -#include -#include -#include -#include "AppServer.h" -#include "Desktop.h" -#include "ServerProtocol.h" -#include "ServerCursor.h" -#include "PortLink.h" -#include "DisplayDriver.h" -#include "DebugTools.h" -#include "ViewDriver.h" -#include "DirectDriver.h" -#include "ScreenDriver.h" - -//#define DEBUG_APPSERVER_THREAD - -AppServer::AppServer(void) : BApplication("application/x-vnd.obe-OBAppServer") -{ -#ifdef DEBUG_APPSERVER_THREAD - printf("AppServer()\n"); -#endif - - mouseport=create_port(30,SERVER_INPUT_PORT); - messageport=create_port(20,SERVER_PORT_NAME); -#ifdef DEBUG_APPSERVER_THREAD -printf("Server message port: %ld\n",messageport); -printf("Server input port: %ld\n",mouseport); -#endif - applist=new BList(0); - quitting_server=false; - exit_poller=false; - -// driver=new ViewDriver; -// driver=new DirectDriver; - driver=new ScreenDriver; - driver->Initialize(); - - // Spawn our input-polling thread - poller_id = spawn_thread(PollerThread, "Poller", B_NORMAL_PRIORITY, this); - if (poller_id >= 0) - resume_thread(poller_id); -} - -AppServer::~AppServer(void) -{ - // If these threads are still running, kill them - after this, if exit_poller - // is deleted, who knows what will happen... These things will just return an - // error and fail if the threads have already exited. - kill_thread(poller_id); - - driver->Shutdown(); - delete driver; - -} - -void AppServer::RunTests(void) -{ - driver->SetScreen(B_32_BIT_800x600); - driver->Clear(80,85,152); - -// TestScreenStates(); - TestArcs(); - TestBeziers(); - TestEllipses(); - TestLines(); - TestPolygon(); - TestRects(); - TestRegions(); - TestShape(); - TestTriangle(); - - TestCursors(); - TestFonts(); - -} - -thread_id AppServer::Run(void) -{ -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer::Run()\n"); -#endif - RunTests(); - MainLoop(); - return 0; -} - -void AppServer::MainLoop(void) -{ - // Main loop (duh). Monitors the message queue and dispatches as appropriate. - // Input messages are handled by the poller, however. - -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer::MainLoop()\n"); -#endif - - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(messageport); - if(buffersize>0) - msgbuffer=new int8[buffersize]; - bytesread=read_port(messageport,&msgcode,msgbuffer,buffersize); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case CREATE_APP: - case DELETE_APP: - case B_QUIT_REQUESTED: - DispatchMessage(msgcode,msgbuffer); - break; - default: - { -#ifdef DEBUG_APPSERVER_THREAD -printf("Server received unexpected code %ld\n",msgcode); -#endif - break; - } - } - - } - - if(buffersize>0) - delete msgbuffer; - if(msgcode==DELETE_APP || msgcode==B_QUIT_REQUESTED) - { - 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); - -} - - -void AppServer::DispatchMessage(int32 code, int8 *buffer) -{ - switch(code) - { - case B_QUIT_REQUESTED: - { - quitting_server=true; - exit_poller=true; - break; - } - default: - break; - } -} - -void AppServer::Poller(void) -{ - // This thread handles nothing but input messages for mouse and keyboard - int32 msgcode; - int8 *msgbuffer=NULL,*index; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(mouseport); - if(buffersize>0) - msgbuffer=new int8[buffersize]; - bytesread=read_port(mouseport,&msgcode,msgbuffer,buffersize); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - // 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 - - index=msgbuffer; - - // Time sent is not necessary for cursor processing. - index += sizeof(int64); - - float tempx=0,tempy=0; - tempx=*((float*)index); - index+=sizeof(float); - tempy=*((float*)index); - index+=sizeof(float); - - driver->MoveCursorTo(tempx,tempy); - - break; - } - default: - //printf("Server::Poller received unexpected code %ld\n",msgcode); - break; - } - - } - - if(buffersize>0) - delete msgbuffer; - - if(exit_poller) - break; - } -} - -int32 AppServer::PollerThread(void *data) -{ -#ifdef DEBUG_APPSERVER_THREAD -printf("Starting Poller thread...\n"); -#endif - AppServer *server=(AppServer *)data; - - // This won't return until it's told to - server->Poller(); - -#ifdef DEBUG_APPSERVER_THREAD -printf("Exiting Poller thread...\n"); -#endif - exit_thread(B_OK); - return B_OK; -} - -void AppServer::TestScreenStates(void) -{ - driver->SetScreen(B_8_BIT_640x480); - snooze(3000000); - driver->SetScreen(B_8_BIT_800x600); -} - -void AppServer::TestArcs(void) -{ - driver->SetHighColor(0,0,255); - driver->FillArc(275,95,70,45,40,210,(uint8 *)&B_SOLID_HIGH); - - for(int i=0; i<45; i+=5) - { - driver->SetHighColor(128+(i*2),128+(i*2),128+(i*2)); - driver->StrokeArc(280+i,100+i,75+i,50+i,45+i,215+i,(uint8 *)&B_SOLID_HIGH); - } -} - -void AppServer::TestBeziers(void) -{ - BPoint pts[4]; - - pts[0].Set(500,300), - pts[1].Set(350,450), - pts[2].Set(350,300), - pts[3].Set(500,450); - - driver->SetHighColor(0,255,0); - driver->StrokeBezier(pts, (uint8 *)&B_SOLID_HIGH); - - // Fill Bezier - pts[0].Set(250,250), - pts[1].Set(300,300), - pts[2].Set(300,250), - pts[3].Set(300,250); - - driver->SetHighColor(255,0,0); - driver->FillBezier(pts, (uint8 *)&B_SOLID_HIGH); - -} - -void AppServer::TestEllipses(void) -{ - driver->SetHighColor(0,0,0); - driver->FillEllipse(200,200, 10, 5,(uint8*)&B_SOLID_HIGH); - - for(int i=5; i<255; i+=10) - { - driver->SetHighColor(i,i,i); - driver->StrokeEllipse(200,200, 10+i, 5+i,(uint8*)&B_SOLID_HIGH); - } - -} - -void AppServer::TestFonts(void) -{ - // Draw String - BString string("OpenBeOS: The Future is Drawing Near..."); - uint16 length=string.Length(); - - driver->SetHighColor(0,0,0); - driver->DrawString((char*)string.String(),length,BPoint(10,200)); -} - -void AppServer::TestLines(void) -{ - int32 i; - rgb_color col; - col.red=255; - col.green=0; - col.blue=0; - - driver->MovePenTo(BPoint(10,150)); - driver->SetHighColor(255,0,0); - - for(i=0;i<100;i++) - { - col.green=100+i; - col.blue=100+i; - driver->StrokeLine(BPoint(10,10),BPoint(10+i,100),col); - } - - for(i=0;i<100;i++) - driver->StrokeLine(BPoint(10+i,200),(uint8*)&B_SOLID_HIGH); - -// BPoint start[100],end[100]; -// rgb_color colarray[100]; - -/* for(i=0;i<100;i++) - { - start[i].Set(10,10); - end[i].Set(110,10+i); - colarray[i].red=100+i; - colarray[i].green=100+i; - colarray[i].blue=255; - } - driver->DrawLineArray(100,start,end,colarray); -*/ - driver->BeginLineArray(100); - for(i=0;i<100;i++) - { - col.red=100+i; - col.green=100+i; - col.blue=255; - driver->AddLine(BPoint(10,10),BPoint(110,10+i),col); - } - driver->EndLineArray(); -} - -void AppServer::TestPolygon(void) -{ - int x[]={10,20,30,40,50,40,30,20,10}; - int y[]={20,10,20,30,40,50,40,30,25}; - driver->StrokePolygon(x,y,9,false); -} - -void AppServer::TestRects(void) -{ - BRect rect(10,270,75,335); - - rgb_color col; - col.red=255; - col.green=255; - col.blue=0; - - driver->SetHighColor(255,0,0); - driver->StrokeRect(rect,(uint8*)&B_SOLID_HIGH); - - rect.InsetBy(1,1); - driver->SetHighColor(0,0,0); - driver->FillRect(rect,(uint8*)&B_SOLID_HIGH); - - rect.InsetBy(1,1); - driver->StrokeRect(rect,col); - - rect.InsetBy(1,1); - col.red=0; - driver->FillRect(rect,col); - - rect.OffsetBy(100,10); - driver->SetHighColor(0,255,0); - driver->StrokeRoundRect(rect,10,30,(uint8*)&B_SOLID_HIGH); - - rect.OffsetBy(100,10); - driver->SetHighColor(0,255,255); - driver->FillRoundRect(rect,10,30,(uint8*)&B_SOLID_HIGH); -} - -void AppServer::TestRegions(void) -{ -} - -void AppServer::TestShape(void) -{ -} - -void AppServer::TestTriangle(void) -{ - BRect invalid; - BPoint pt[3]; - pt[0].Set(600,100); - pt[1].Set(500,200); - pt[2].Set(550,450); - - invalid.Set( MIN( MIN(pt[0].x,pt[1].x), pt[2].x), - MIN( MIN(pt[0].y,pt[1].y), pt[2].y), - MAX( MAX(pt[0].x,pt[1].x), pt[2].x), - MAX( MAX(pt[0].y,pt[1].y), pt[2].y) ); - - driver->SetHighColor(228,228,50); - driver->FillTriangle(pt[0],pt[1],pt[2],invalid,(uint8*)&B_SOLID_HIGH); - - - pt[0].Set(50,50); - pt[1].Set(200,475); - pt[2].Set(400,400); - invalid.Set( MIN( MIN(pt[0].x,pt[1].x), pt[2].x), - MIN( MIN(pt[0].y,pt[1].y), pt[2].y), - MAX( MAX(pt[0].x,pt[1].x), pt[2].x), - MAX( MAX(pt[0].y,pt[1].y), pt[2].y) ); - // Stroke Triangle - driver->SetHighColor(0,128,128); - driver->StrokeTriangle(pt[0],pt[1],pt[2],invalid,(uint8*)&B_SOLID_HIGH); -} - -void AppServer::TestCursors(void) -{ - int8 cross[] = { 16,1,5,5, - 14,0,4,0,4,0,4,0,128,32,241,224,128,32,4,0, - 4,0,4,0,14,0,0,0,0,0,0,0,0,0,0,0, - 14,0,4,0,4,0,4,0,128,32,245,224,128,32,4,0, - 4,0,4,0,14,0,0,0,0,0,0,0,0,0,0,0 }; - - ServerCursor *crosscursor=new ServerCursor(cross); - driver->SetCursor(crosscursor); - - driver->HideCursor(); - driver->ShowCursor(); - driver->ObscureCursor(); - - delete crosscursor; -} - -int main( int argc, char** argv ) -{ - // There can be only one.... - if(find_port(SERVER_PORT_NAME)!=B_NAME_NOT_FOUND) - return -1; - - AppServer *app_server = new AppServer(); - app_server->Run(); - delete app_server; - return 0; -} diff --git a/src/servers/app/proto6/driverharness/AppServer.h b/src/servers/app/proto6/driverharness/AppServer.h deleted file mode 100644 index ea9f32bf5d..0000000000 --- a/src/servers/app/proto6/driverharness/AppServer.h +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef _OPENBEOS_APP_SERVER_H_ -#define _OPENBEOS_APP_SERVER_H_ - -#include -#include -#include -#include -#include // for window_look - -class BMessage; -class DisplayDriver; - -class AppServer : public BApplication -{ -public: - AppServer(void); - ~AppServer(void); - thread_id Run(void); - void MainLoop(void); - port_id messageport,mouseport; - void Poller(void); - - void TestScreenStates(void); - void TestArcs(void); - void TestBeziers(void); - void TestEllipses(void); - void TestFonts(void); - void TestLines(void); - void TestPolygon(void); - void TestRects(void); - void TestRegions(void); - void TestShape(void); - void TestTriangle(void); - void TestCursors(void); - -private: - void RunTests(void); - void DispatchMessage(int32 code, int8 *buffer); - static int32 PollerThread(void *data); - bool quitting_server; - BList *applist; - int32 active_app; - thread_id poller_id; - - BLocker *active_lock, *applist_lock, *decor_lock; - bool exit_poller; - DisplayDriver *driver; -}; - -#endif diff --git a/src/servers/app/proto6/driverharness/ColorUtils.cc b/src/servers/app/proto6/driverharness/ColorUtils.cc deleted file mode 100644 index a3b8591508..0000000000 --- a/src/servers/app/proto6/driverharness/ColorUtils.cc +++ /dev/null @@ -1,46 +0,0 @@ -#include "ColorUtils.h" -#include "SystemPalette.h" -#include -#include - -void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a=255) -{ - col->red=r; - col->green=g; - col->blue=b; - col->alpha=a; -} - -uint8 FindClosestColor(rgb_color *palette, rgb_color color) -{ - // We will be passed a 256-color palette and a 24-bit color - uint16 cindex=0,cdelta=765,delta=765; - rgb_color *c; - - for(uint16 i=0;i<256;i++) - { - c=&(palette[i]); - delta=abs(c->red-color.red)+abs(c->green-color.green)+ - abs(c->blue-color.blue); - - if(delta==0) - { - cindex=i; - break; - } - - if(delta - -// Quick assignment for rgb_color structs -void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a=255); - -// Given a color palette, returns the index of the closest match to -// the color passed to it. Alpha values are not considered -uint8 FindClosestColor(rgb_color *palette, rgb_color color); -uint16 FindClosestColor16(rgb_color color); -#endif diff --git a/src/servers/app/proto6/driverharness/DHApp.cpp b/src/servers/app/proto6/driverharness/DHApp.cpp deleted file mode 100644 index cd10ee976e..0000000000 --- a/src/servers/app/proto6/driverharness/DHApp.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "DHApp.h" -#include "DisplayDriver.h" -#include "ViewDriver.h" - -DHApp::DHApp(void) : BApplication("application/x-vnd.obos-DDriverHarness") -{ - driver=new ViewDriver; - driver->Initialize(); -} - -DHApp::~DHApp(void) -{ - driver->Shutdown(); - delete driver; -} - -int main(void) -{ - DHApp *app=new DHApp; - app->Run(); - delete app; - return 0; -} diff --git a/src/servers/app/proto6/driverharness/DHApp.h b/src/servers/app/proto6/driverharness/DHApp.h deleted file mode 100644 index e80fce0142..0000000000 --- a/src/servers/app/proto6/driverharness/DHApp.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef _DHAPP_H_ -#define _DHAPP_H_ - -#include - -class DisplayDriver; - -class DHApp : public BApplication -{ -public: - DHApp(void); - ~DHApp(void); - DisplayDriver *driver; -}; - -#endif diff --git a/src/servers/app/proto6/driverharness/DHServerBitmap.cpp b/src/servers/app/proto6/driverharness/DHServerBitmap.cpp deleted file mode 100644 index 2622bd6a41..0000000000 --- a/src/servers/app/proto6/driverharness/DHServerBitmap.cpp +++ /dev/null @@ -1,269 +0,0 @@ -/* - ServerBitmap.cpp - Bitmap class which is intended to provide an easy way to package all the - data associated with a picture. It's very low-level, so there's still - plenty to do when coding with 'em. Also, they can be used to access draw on the - frame buffer in a relatively easy way, although it is currently unclear - whether this functionality will even be necessary. -*/ - -// These three includes for ServerBitmap(const char *path_to_image_file) only -#include -#include -#include - -#include -#include "ServerBitmap.h" -#include "Desktop.h" - -//#define DEBUG_BITMAP - -#ifdef DEBUG_BITMAP -#include -#endif - -ServerBitmap::ServerBitmap(BRect rect,color_space space,int32 BytesPerLine=0) -{ - width=rect.IntegerWidth()+1; - height=rect.IntegerHeight()+1; - cspace=space; - is_vram=false; - is_area=false; - areaid=B_ERROR; - - HandleSpace(space, BytesPerLine); - buffer=new uint8[bytesperline*height]; -// driver=get_gfxdriver(); -} - -ServerBitmap::ServerBitmap(int32 w,int32 h,color_space space,int32 BytesPerLine=0) -{ - width=w; - height=h; - cspace=space; - is_vram=false; - is_area=false; - areaid=B_ERROR; - - HandleSpace(space, BytesPerLine); - buffer=new uint8[bytesperline*height]; -// driver=get_gfxdriver(); -} - -ServerBitmap::ServerBitmap(int32 w,int32 h,color_space space, area_id areaID, int32 BytesPerLine=0) -{ - // This version is used for holding BBitmaps as one of the undocumented BBitmap - // constructors allows - it creates an area on the server's side. - width=w; - height=h; - cspace=space; - is_vram=false; - is_area=true; - - HandleSpace(space, BytesPerLine); - area_info ainfo; - areaid=areaID; - get_area_info(areaid, &ainfo); - buffer=(uint8*)ainfo.address; -// driver=get_gfxdriver(); -} - -ServerBitmap::ServerBitmap(void) -{ - // This version is obviously intended for use as an easy-access class for the - // frame buffer. AtheOS does it and it's small, so why not? Worst case, this - // can disappear if not necessary. - is_vram=true; - is_area=false; - areaid=B_ERROR; - UpdateSettings(); -} - -// This particular version is not intended for use except for testing purposes. -// It loads a BBitmap and copies it to the ServerBitmap. Probably will disappear -// when the *real* server is written -ServerBitmap::ServerBitmap(const char *path) -{ - BBitmap *bmp=BTranslationUtils::GetBitmap(path); - assert(bmp!=NULL); - - if(bmp==NULL) - { - width=0; - height=0; - cspace=B_NO_COLOR_SPACE; - bytesperline=0; - } - else - { - width=bmp->Bounds().IntegerWidth(); - height=bmp->Bounds().IntegerHeight(); - cspace=bmp->ColorSpace(); - bytesperline=bmp->BytesPerRow(); - buffer=new uint8[bmp->BitsLength()]; - memcpy(buffer,(void *)bmp->Bits(),bmp->BitsLength()); - } -} - -ServerBitmap::~ServerBitmap(void) -{ - if(!is_vram) - delete buffer; -} - -void ServerBitmap::UpdateSettings(void) -{ - // This is only used when the object is pointing to the frame buffer -// driver=get_gfxdriver(); - bpp=driver->GetDepth(); - width=driver->GetWidth(); - height=driver->GetHeight(); -} - -void ServerBitmap::SetBuffer(void *buffer) -{ - buffer=(uint8 *)buffer; -} - -uint8 *ServerBitmap::Buffer(void) -{ - return buffer; -} - -uint32 ServerBitmap::BitsLength(void) -{ - return (uint32)(bytesperline*height); -} - -void ServerBitmap::HandleSpace(color_space space, int32 BytesPerLine) -{ - // Function written to handle color space setup which is required - // by the two "normal" constructors - - // Big convoluted mess just to handle every color space and dword align - // the buffer - switch(space) - { - // Buffer is dword-aligned, so nothing need be done - // aside from allocate the memory - case B_RGB32: - case B_RGBA32: - case B_RGB32_BIG: - case B_RGBA32_BIG: - case B_UVL32: - case B_UVLA32: - case B_LAB32: - case B_LABA32: - case B_HSI32: - case B_HSIA32: - case B_HSV32: - case B_HSVA32: - case B_HLS32: - case B_HLSA32: - case B_CMY32: - case B_CMYA32: - case B_CMYK32: - - // 24-bit = 32-bit with extra 8 bits ignored - case B_RGB24_BIG: - case B_RGB24: - case B_LAB24: - case B_UVL24: - case B_HSI24: - case B_HSV24: - case B_HLS24: - case B_CMY24: - { - if(BytesPerLine<(width*4)) - bytesperline=width*4; - else - bytesperline=BytesPerLine; - bpp=32; - break; - } - // Calculate size and dword-align - - // 1-bit - case B_GRAY1: - { - int32 numbytes=width>>3; - if((width % 8) != 0) - numbytes++; - if(BytesPerLine -#include -#include "DebugTools.h" - -void PrintStatusToStream(status_t value) -{ - // Function which simply translates a returned status code into a string - // and dumps it to stdout - cout << "Status: " << TranslateStatusToString(value).String() << endl << flush; -} - -BString TranslateStatusToString(status_t value) -{ - BString outstr; - switch(value) - { - case B_OK: - outstr="B_OK "; - break; - case B_NAME_NOT_FOUND: - outstr="B_NAME_NOT_FOUND "; - break; - case B_BAD_VALUE: - outstr="B_BAD_VALUE "; - break; - case B_ERROR: - outstr="B_ERROR "; - break; - case B_TIMED_OUT: - outstr="B_TIMED_OUT "; - break; - case B_NO_MORE_PORTS: - outstr="B_NO_MORE_PORTS "; - break; - case B_WOULD_BLOCK: - outstr="B_WOULD_BLOCK "; - break; - case B_BAD_PORT_ID: - outstr="B_BAD_PORT_ID "; - break; - case B_BAD_TEAM_ID: - outstr="B_BAD_TEAM_ID "; - break; - default: - outstr="undefined status value in debugtools::PrintStatusToStream() "; - break; - } - return BString(outstr); -} - -void PrintColorSpaceToStream(color_space value) -{ - // Dump a color space to cout - BString outstr; - switch(value) - { - case B_RGB32: - outstr="B_RGB32 "; - break; - case B_RGBA32: - outstr="B_RGBA32 "; - break; - case B_RGB32_BIG: - outstr="B_RGB32_BIG "; - break; - case B_RGBA32_BIG: - outstr=" "; - break; - case B_UVL32: - outstr="B_UVL32 "; - break; - case B_UVLA32: - outstr="B_UVLA32 "; - break; - case B_LAB32: - outstr="B_LAB32 "; - break; - case B_LABA32: - outstr="B_LABA32 "; - break; - case B_HSI32: - outstr="B_HSI32 "; - break; - case B_HSIA32: - outstr="B_HSIA32 "; - break; - case B_HSV32: - outstr="B_HSV32 "; - break; - case B_HSVA32: - outstr="B_HSVA32 "; - break; - case B_HLS32: - outstr="B_HLS32 "; - break; - case B_HLSA32: - outstr="B_HLSA32 "; - break; - case B_CMY32: - outstr="B_CMY32"; - break; - case B_CMYA32: - outstr="B_CMYA32 "; - break; - case B_CMYK32: - outstr="B_CMYK32 "; - break; - case B_RGB24_BIG: - outstr="B_RGB24_BIG "; - break; - case B_RGB24: - outstr="B_RGB24 "; - break; - case B_LAB24: - outstr="B_LAB24 "; - break; - case B_UVL24: - outstr="B_UVL24 "; - break; - case B_HSI24: - outstr="B_HSI24 "; - break; - case B_HSV24: - outstr="B_HSV24 "; - break; - case B_HLS24: - outstr="B_HLS24 "; - break; - case B_CMY24: - outstr="B_CMY24 "; - break; - case B_GRAY1: - outstr="B_GRAY1 "; - break; - case B_CMAP8: - outstr="B_CMAP8 "; - break; - case B_GRAY8: - outstr="B_GRAY8 "; - break; - case B_YUV411: - outstr="B_YUV411 "; - break; - case B_YUV420: - outstr="B_YUV420 "; - break; - case B_YCbCr422: - outstr="B_YCbCr422 "; - break; - case B_YCbCr411: - outstr="B_YCbCr411 "; - break; - case B_YCbCr420: - outstr="B_YCbCr420 "; - break; - case B_YUV422: - outstr="B_YUV422 "; - break; - case B_YUV9: - outstr="B_YUV9 "; - break; - case B_YUV12: - outstr="B_YUV12 "; - break; - case B_RGB15: - outstr="B_RGB15 "; - break; - case B_RGBA15: - outstr="B_RGBA15 "; - break; - case B_RGB16: - outstr="B_RGB16 "; - break; - case B_RGB16_BIG: - outstr="B_RGB16_BIG "; - break; - case B_RGB15_BIG: - outstr="B_RGB15_BIG "; - break; - case B_RGBA15_BIG: - outstr="B_RGBA15_BIG "; - break; - case B_YCbCr444: - outstr="B_YCbCr444 "; - break; - case B_YUV444: - outstr="B_YUV444 "; - break; - case B_NO_COLOR_SPACE: - outstr="B_NO_COLOR_SPACE "; - break; - default: - outstr="Undefined color space "; - break; - } - cout << "Color Space: " << outstr.String() << flush; -} - -void TranslateMessageCodeToStream(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - - cout << "'" - << (char)((code & 0xFF000000) >> 24) - << (char)((code & 0x00FF0000) >> 16) - << (char)((code & 0x0000FF00) >> 8) - << (char)((code & 0x000000FF)) << "' "; -} - -void PrintMessageCode(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - - printf("Message code %c%c%c%c\n", - (char)((code & 0xFF000000) >> 24), - (char)((code & 0x00FF0000) >> 16), - (char)((code & 0x0000FF00) >> 8), - (char)((code & 0x000000FF)) ); -} - diff --git a/src/servers/app/proto6/driverharness/DebugTools.h b/src/servers/app/proto6/driverharness/DebugTools.h deleted file mode 100644 index 7d4ed3db33..0000000000 --- a/src/servers/app/proto6/driverharness/DebugTools.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _DEBUGTOOLS_H_ -#define _DEBUGTOOLS_H_ - -#include -#include -#include - -void PrintColorSpaceToStream(color_space value); -void TranslateMessageCodeToStream(int32 code); -void PrintMessageCode(int32 code); -BString TranslateStatusToString(status_t value); - -#endif diff --git a/src/servers/app/proto6/driverharness/Desktop.h b/src/servers/app/proto6/driverharness/Desktop.h deleted file mode 100644 index b1685b544c..0000000000 --- a/src/servers/app/proto6/driverharness/Desktop.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef _OBDESKTOP_H_ -#define _OBDESKTOP_H_ - - -#include -#include -#include - -class DisplayDriver; -class ServerWindow; -class Layer; - -void init_desktop(int8 workspaces); -void shutdown_desktop(void); -DisplayDriver *get_gfxdriver(void); - -// Workspace access functions -int32 CountWorkspaces(void); -void SetWorkspaceCount(uint32 count); - -int32 CurrentWorkspace(void); -void ActivateWorkspace(uint32 workspace); - -const color_map *SystemColors(void); -status_t SetScreenSpace(uint32 index, uint32 res, bool stick=true); - -void AddWindowToDesktop(ServerWindow *win,uint32 workspace); -void RemoveWindowFromDesktop(ServerWindow *win); -Layer *GetRootLayer(void); -int32 GetViewToken(void); - -typedef struct -{ - color_space mode; - BRect frame; - uint32 spaces; - float min_refresh_rate; - float max_refresh_rate; - float refresh_rate; - uchar h_position; - uchar v_position; - uchar h_size; - uchar v_size; -} screen_info; - -#endif diff --git a/src/servers/app/proto6/driverharness/DirectDriver.cpp b/src/servers/app/proto6/driverharness/DirectDriver.cpp deleted file mode 100644 index 4f72f12422..0000000000 --- a/src/servers/app/proto6/driverharness/DirectDriver.cpp +++ /dev/null @@ -1,322 +0,0 @@ -/* - DriverDriver: - Replacement class for the ViewDriver which utilizes a BDirectWindow for ease - of testing without requiring a second video card for SecondDriver and also - without the limitations (mostly speed) of ViewDriver. - - Note that unlike ViewDriver, this windowed graphics module does NOT emulate - the Input Server. The Router input server filter is required for use. - - The concept is a combination of both SecondDriver and ViewDriver: utilize - PortLink messaging (for better speed than BMessages) and draw directly to the - frame buffer. - - Components: 2 classes, DDriverWin and DirectDriver - - DirectDriver - a wrapper class which enqueues draw requests - DDirectWin - does most of the work. -*/ - -#define DEBUG_DRIVER_MODULE -#include -#include -#include -#include -#include "PortLink.h" -#include "ServerProtocol.h" -#include "DirectDriver.h" -#include "ServerBitmap.h" - -// Message defines for internal use only -enum -{ -DDWIN_SHUTDOWN=100, -DDWIN_CLEAR, -DDWIN_SAFEMODE, -DDWIN_RESET, -DDWIN_SETSCREEN, - -DDWIN_FILLARC, -DDWIN_STROKEARC, -DDWIN_FILLRECT, -DDWIN_STROKERECT, -DDWIN_FILLROUNDRECT, -DDWIN_STROKEROUNDRECT, -DDWIN_FILLELLIPSE, -DDWIN_STROKEELLIPSE, -DDWIN_FILLBEZIER, -DDWIN_STROKEBEZIER, -DDWIN_FILLTRIANGLE, -DDWIN_STROKETRIANGLE, -DDWIN_STROKELINE, -DDWIN_DRAWSTRING, - -DDWIN_SETPENSIZE, -DDWIN_MOVEPENTO, -DDWIN_SHOWCURSOR, -DDWIN_HIDECURSOR, -DDWIN_OBSCURECURSOR, -DDWIN_MOVECURSOR, -DDWIN_SETCURSOR, -DDWIN_SETHIGHCOLOR, -DDWIN_SETLOWCOLOR -}; - -DDriverWin::DDriverWin(BRect frame) - : BDirectWindow(frame,"OBOS App Server, P6",B_TITLED_WINDOW, - B_NOT_ZOOMABLE | B_NOT_RESIZABLE) -{ - msgport=create_port(100,"DDWinPort"); - fConnected=false; - fConnectionDisabled=false; - locker=new BLocker(); - fClipList=NULL; - fNumClipRects=0; - - AddChild(new BView(Bounds(),"BView",B_FOLLOW_ALL,0)); - if(ChildAt(0)) - ChildAt(0)->SetViewColor(B_TRANSPARENT_32_BIT); - - if (!SupportsWindowMode()) - SetFullScreen(true); - framebuffer=NULL; - - fDirty=true; - fDrawThreadID=spawn_thread(DrawingThread, "drawing_thread",B_NORMAL_PRIORITY, (void *) this); - resume_thread(fDrawThreadID); - Show(); -} - -DDriverWin::~DDriverWin(void) -{ - int32 result; - - // In case the update thread is waiting for a message (very likely), - // give it a message to unblock it - fConnectionDisabled=true; - write_port(msgport,DDWIN_SHUTDOWN,NULL,0); - Hide(); - Sync(); - wait_for_thread(fDrawThreadID, &result); - free(fClipList); - if(framebuffer) - delete framebuffer; - delete locker; -} - -void DDriverWin::DirectConnected(direct_buffer_info *info) -{ - if (!fConnected && fConnectionDisabled) - return; - - locker->Lock(); - - switch(info->buffer_state & B_DIRECT_MODE_MASK) - { - case B_DIRECT_START: - { - fConnected=true; - // fall through on purpose - } - case B_DIRECT_MODIFY: - { - // Get clipping information - if (fClipList) - { - free(fClipList); - fClipList=NULL; - } - fNumClipRects=info->clip_list_count; - fClipList=(clipping_rect *) - malloc(fNumClipRects*sizeof(clipping_rect)); - if (fClipList) - { - memcpy(fClipList, info->clip_list, - fNumClipRects*sizeof(clipping_rect)); - fBits=(uint8 *) info->bits; - fRowBytes=info->bytes_per_row; - fFormat=info->pixel_format; - fBounds=info->window_bounds; - fDirty=true; - } - framebuffer=new ServerBitmap(Bounds(),info->pixel_format); - break; - } - case B_DIRECT_STOP: - { - fConnected=false; - delete framebuffer; - framebuffer=NULL; - break; - } - } - locker->Unlock(); -} - -int32 DDriverWin::DrawingThread(void *data) -{ - DDriverWin *w=(DDriverWin *)data; -// port_id dport=w->msgport; - - while (!w->fConnectionDisabled) - { - w->locker->Lock(); - if (w->fConnected) - { - if ( w->framebuffer && (w->fFormat==B_RGB32 || w->fFormat==B_RGBA32) && w->fDirty) -// if ( w->fFormat==B_CMAP8 && w->fDirty) - { - int32 y; - int32 width, height; - int32 adder,bmpadder; - uint8 *p_fbuffer, *p_bitmap; - clipping_rect *clip; - int32 i; - - adder=w->fRowBytes; - bmpadder=w->framebuffer->bytesperline; - - for (i=0; ifNumClipRects; i++) - { - clip=&(w->fClipList[i]); - width=((clip->right-clip->left)+1)*4; - height=(clip->bottom-clip->top)+1; - p_fbuffer=w->fBits+(clip->top*w->fRowBytes)+(clip->left*4); - p_bitmap=w->framebuffer->Buffer()+(clip->top*w->framebuffer->bytesperline)+(clip->left*4); - y=0; - while (y < height) - { -printf("Copy %ld bytes from %p to %p\n",width,p_bitmap, p_fbuffer); - memcpy(p_fbuffer, p_bitmap, width); - p_fbuffer+=adder; - p_bitmap+=bmpadder; - y++; - } - } - } - w->fDirty=false; - } - w->locker->Unlock(); - - // Use BWindow or BView APIs here if you want - - // process messages from port here by calling member function DispatchMessage - - snooze(16000); - } - return B_OK; -} - -bool DDriverWin::QuitRequested(void) -{ - port_id serverport=find_port(SERVER_PORT_NAME); - if(serverport!=B_NAME_NOT_FOUND) - { - write_port(serverport,B_QUIT_REQUESTED,NULL,0); - } - return true; -} - -void DDriverWin::WindowActivated(bool active) -{ - // This is just to hide the regular system cursor so we can see our own - if(active) - be_app->HideCursor(); - else - be_app->ShowCursor(); -} - -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- - -void DDriverWin::SafeMode(void) -{ -} - -void DDriverWin::Reset(void) -{ -} - -void DDriverWin::SetScreen(uint32 space) -{ -} - -void DDriverWin::Clear(clipping_rect *rect,uint8 red,uint8 green,uint8 blue) -{ - int32 width=((rect->right-rect->left)+1)*4; - int32 height=(rect->bottom-rect->top)+1; - uint8 *p=fBits+(rect->top*fRowBytes)+(rect->left*4); - int32 y=0; - - // Loop to clear each row - while (y < height) - { - // loop to clear 1 row belongs here - memset(p, 0x00, width); - - y++; - p+=fRowBytes; - } -} - -DirectDriver::DirectDriver(void) -{ - driverwin=new DDriverWin(BRect(100,60,740,540)); - hide_cursor=0; - drawlink=new PortLink(driverwin->msgport); -} - -DirectDriver::~DirectDriver(void) -{ - if(is_initialized) - { - driverwin->Lock(); - driverwin->Quit(); - } - delete drawlink; -} - -void DirectDriver::Initialize(void) -{ - locker->Lock(); - is_initialized=true; -// SetPenSize(1.0); -// MovePenTo(BPoint(0,0)); - locker->Unlock(); -} - -bool DirectDriver::IsInitialized(void) -{ - return is_initialized; -} - -void DirectDriver::Shutdown(void) -{ - locker->Lock(); - is_initialized=false; - locker->Unlock(); -} - -void DirectDriver::SafeMode(void) -{ -} - -void DirectDriver::Reset(void) -{ -} - -void DirectDriver::Clear(uint8 red,uint8 green,uint8 blue) -{ -} - -void DirectDriver::Clear(rgb_color col) -{ -} - diff --git a/src/servers/app/proto6/driverharness/DirectDriver.h b/src/servers/app/proto6/driverharness/DirectDriver.h deleted file mode 100644 index 01b03ba14c..0000000000 --- a/src/servers/app/proto6/driverharness/DirectDriver.h +++ /dev/null @@ -1,117 +0,0 @@ -#ifndef _DIRECTDRIVER_H_ -#define _DIRECTDRIVER_H_ - -#include -#include -#include -#include -#include -#include -#include // for clipping_rect definition -#include "DisplayDriver.h" - -class BBitmap; -class PortLink; -class VDWindow; -class ServerCursor; -class PortLink; -class ServerBitmap; - -class DDriverWin : public BDirectWindow -{ -public: - DDriverWin(BRect frame); - ~DDriverWin(void); - bool QuitRequested(void); - void WindowActivated(bool active); - void DirectConnected(direct_buffer_info *info); - static int32 DrawingThread(void *data); - port_id msgport; - - void SafeMode(void); - void Reset(void); - void SetScreen(uint32 space); - void Clear(clipping_rect *rect, uint8 red,uint8 green,uint8 blue); - ServerBitmap *framebuffer; -protected: - BLocker *locker; - bool fConnected, fConnectionDisabled, fDirty; - clipping_rect *fClipList,fBounds; - thread_id fDrawThreadID; - color_space fFormat; - uint8 *fBits; - int32 fNumClipRects, fRowBytes; -}; - -class DirectDriver : public DisplayDriver -{ -public: - DirectDriver(void); - virtual ~DirectDriver(void); - - virtual void Initialize(void); - virtual bool IsInitialized(void); - virtual void Shutdown(void); - - virtual void SafeMode(void); - virtual void Reset(void); - virtual void Clear(uint8 red,uint8 green,uint8 blue); - virtual void Clear(rgb_color col); - -/* // Settings functions - virtual void SetScreen(uint32 space); - virtual int32 GetHeight(void); - virtual int32 GetWidth(void); - virtual int GetDepth(void); - - // Drawing functions - virtual void Blit(BRect src, BRect dest); - virtual void DrawBitmap(ServerBitmap *bitmap); - virtual void DrawChar(char c, BPoint point); - virtual void DrawString(char *string, int length, BPoint point); - - virtual void FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void FillBezier(BPoint *points, uint8 *pattern); - virtual void FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void FillPolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void FillRect(BRect rect, uint8 *pattern); - virtual void FillRect(BRect rect, rgb_color col); - virtual void FillRegion(BRegion *region); - virtual void FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void FillShape(BShape *shape); - virtual void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - - virtual void HideCursor(void); - virtual bool IsCursorHidden(void); - virtual void MoveCursorTo(float x, float y); - virtual void MovePenTo(BPoint pt); - virtual void ObscureCursor(void); - virtual BPoint PenPosition(void); - virtual float PenSize(void); - virtual void SetCursor(int32 value); - virtual void SetCursor(ServerCursor *cursor); - virtual void SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetPenSize(float size); - virtual void SetPixel(int x, int y, uint8 *pattern); - virtual void ShowCursor(void); - - virtual void StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void StrokeBezier(BPoint *points, uint8 *pattern); - virtual void StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void StrokeLine(BPoint point, uint8 *pattern); - virtual void StrokeLine(BPoint pt1, BPoint pt2, rgb_color col); - virtual void StrokePolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void StrokeRect(BRect rect,uint8 *pattern); - virtual void StrokeRect(BRect rect,rgb_color col); - virtual void StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void StrokeShape(BShape *shape); - virtual void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); -*/ -protected: - DDriverWin *driverwin; - int hide_cursor; - PortLink *drawlink; -}; - -#endif diff --git a/src/servers/app/proto6/driverharness/DisplayDriver.cpp b/src/servers/app/proto6/driverharness/DisplayDriver.cpp deleted file mode 100644 index 54c8cd5fcd..0000000000 --- a/src/servers/app/proto6/driverharness/DisplayDriver.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/* - DisplayDriver.cpp - Modular class to allow the server to not care what the ultimate output is - for graphics calls. -*/ -#include "DisplayDriver.h" -#include "ColorUtils.h" -#include "SystemPalette.h" -#include "ServerCursor.h" - -DisplayDriver::DisplayDriver(void) -{ - is_initialized=false; - cursor_visible=true; - show_on_move=false; - locker=new BLocker(); - - penpos.Set(0,0); - pensize=0.0; - - // initialize to BView defaults - highcol.red=0; - highcol.green=0; - highcol.blue=0; - highcol.alpha=0; - lowcol.red=255; - lowcol.green=255; - lowcol.blue=255; - lowcol.alpha=255; -} - -DisplayDriver::~DisplayDriver(void) -{ - delete locker; -} - -void DisplayDriver::Initialize(void) -{ // Loading loop to find proper driver or other setup for the driver -} - -bool DisplayDriver::IsInitialized(void) -{ // Let us know whether things worked out ok - return is_initialized; -} - -void DisplayDriver::Shutdown(void) -{ // For use by subclasses -} - -void DisplayDriver::SafeMode(void) -{ // Set video mode to 640x480x256 mode -} - -void DisplayDriver::Reset(void) -{ // Intended to reload and restart driver. Defaults to a safe mode -} - -void DisplayDriver::Clear(uint8 red,uint8 green,uint8 blue) -{ -} - -void DisplayDriver::Clear(rgb_color col) -{ -} - -void DisplayDriver::SetScreen(uint32 space) -{ // Set the screen to a particular mode -} - -int32 DisplayDriver::GetHeight(void) -{ // Gets the height of the current mode - return ginfo->height; -} - -int32 DisplayDriver::GetWidth(void) -{ // Gets the width of the current mode - return ginfo->width; -} - -int DisplayDriver::GetDepth(void) -{ // Gets the color depth of the current mode - return ginfo->bytes_per_row; -} - -void DisplayDriver::AddLine(BPoint pt1, BPoint pt2, rgb_color col) -{ -} - -void DisplayDriver::BeginLineArray(int32 count) -{ -} - -void DisplayDriver::Blit(BRect src, BRect dest) -{ // Screen-to-screen bitmap copying -} - -void DisplayDriver::DrawBitmap(ServerBitmap *bitmap, BRect source, BRect dest) -{ -} - -void DisplayDriver::DrawChar(char c, BPoint point) -{ -} - -void DisplayDriver::DrawLineArray(int32 count,BPoint *start, BPoint *end, rgb_color *color) -{ -} - -void DisplayDriver::DrawString(char *string, int length, BPoint point) -{ -} - -void DisplayDriver::EndLineArray(void) -{ -} - -void DisplayDriver::FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern) -{ -} - -void DisplayDriver::FillBezier(BPoint *points, uint8 *pattern) -{ -} - -void DisplayDriver::FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern) -{ -} - -void DisplayDriver::FillPolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void DisplayDriver::FillRect(BRect rect, uint8 *pattern) -{ -} - -void DisplayDriver::FillRect(BRect rect, rgb_color col) -{ -} - -void DisplayDriver::FillRegion(BRegion *region) -{ -} - -void DisplayDriver::FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ -} - -void DisplayDriver::FillShape(BShape *shape) -{ -} - -void DisplayDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ -} - -void DisplayDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col) -{ -} - -drawing_mode DisplayDriver::GetDrawingMode(void) -{ - return B_OP_COPY; -} - -void DisplayDriver::HideCursor(void) -{ -} - -rgb_color DisplayDriver::HighColor(void) -{ - locker->Lock(); - rgb_color col=highcol; - locker->Unlock(); - return col; -} - -bool DisplayDriver::IsCursorHidden(void) -{ - return false; -} - -rgb_color DisplayDriver::LowColor(void) -{ - locker->Lock(); - rgb_color col=lowcol; - locker->Unlock(); - return col; -} - -void DisplayDriver::ObscureCursor(void) -{ // Hides cursor until mouse is moved -} - -void DisplayDriver::MoveCursorTo(float x, float y) -{ -} - -void DisplayDriver::MovePenTo(BPoint pt) -{ // Moves the graphics pen to this position - penpos=pt; -} - -BPoint DisplayDriver::PenPosition(void) -{ - return penpos; -} - -float DisplayDriver::PenSize(void) -{ - return pensize; -} - -void DisplayDriver::SetCursor(ServerCursor *cursor) -{ -} - -void DisplayDriver::SetDrawingMode(drawing_mode mode) -{ -} - -void DisplayDriver::SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - SetRGBColor(&highcol,r,g,b,a); - high16=FindClosestColor16(highcol); - high8=FindClosestColor(system_palette,highcol); -} - -void DisplayDriver::SetHighColor(rgb_color col) -{ - highcol=col; - high16=FindClosestColor16(highcol); - high8=FindClosestColor(system_palette,highcol); -} - -void DisplayDriver::SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - SetRGBColor(&lowcol,r,g,b,a); - low16=FindClosestColor16(lowcol); - low8=FindClosestColor(system_palette,lowcol); -} - -void DisplayDriver::SetLowColor(rgb_color col) -{ - lowcol=col; - low16=FindClosestColor16(lowcol); - low8=FindClosestColor(system_palette,lowcol); -} - -void DisplayDriver::SetPenSize(float size) -{ - pensize=(size>0)?size:1; -} - -void DisplayDriver::SetPixel(int x, int y, uint8 *pattern) -{ // Internal function utilized by other functions to draw to the buffer - // Will eventually be an inline function -} - -void DisplayDriver::ShowCursor(void) -{ -} - -float DisplayDriver::StringWidth(const char *string, int32 length) -{ - return -1.0; -} - -void DisplayDriver::StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeBezier(BPoint *points, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern) -{ -} - -void DisplayDriver::StrokeLine(BPoint point, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeLine(BPoint pt1, BPoint pt2, rgb_color col) -{ -} - -void DisplayDriver::StrokePolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void DisplayDriver::StrokeRect(BRect rect, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeRect(BRect rect, rgb_color col) -{ -} - -void DisplayDriver::StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeShape(BShape *shape) -{ -} - -void DisplayDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ -} - -void DisplayDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col) -{ -} - -void DisplayDriver::Line32(BPoint pt, BPoint pt2, uint8 *pattern) -{ -} - -void DisplayDriver::Line16(BPoint pt, BPoint pt2, uint8 *pattern) -{ -} - -void DisplayDriver::Line8(BPoint pt, BPoint pt2, uint8 *pattern) -{ -} diff --git a/src/servers/app/proto6/driverharness/DisplayDriver.h b/src/servers/app/proto6/driverharness/DisplayDriver.h deleted file mode 100644 index f453a25bb8..0000000000 --- a/src/servers/app/proto6/driverharness/DisplayDriver.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef _GFX_DRIVER_H_ -#define _GFX_DRIVER_H_ - -#include -#include -#include -#include "Desktop.h" - -class ServerBitmap; -class ServerCursor; - -#ifndef ROUND - #define ROUND(a) ( (a-long(a))>=.5)?(long(a)+1):(long(a)) -#endif - -typedef struct -{ - uchar *xormask, *andmask; - int32 width, height; - int32 hotx, hoty; - -} cursor_data; - -#ifndef HOOK_DEFINE_CURSOR - -#define HOOK_DEFINE_CURSOR 0 -#define HOOK_MOVE_CURSOR 1 -#define HOOK_SHOW_CURSOR 2 -#define HOOK_DRAW_LINE_8BIT 3 -#define HOOK_DRAW_LINE_16BIT 12 -#define HOOK_DRAW_LINE_32BIT 4 -#define HOOK_DRAW_RECT_8BIT 5 -#define HOOK_DRAW_RECT_16BIT 13 -#define HOOK_DRAW_RECT_32BIT 6 -#define HOOK_BLIT 7 -#define HOOK_DRAW_ARRAY_8BIT 8 -#define HOOK_DRAW_ARRAY_16BIT 14 // Not implemented in current R5 drivers -#define HOOK_DRAW_ARRAY_32BIT 9 -#define HOOK_SYNC 10 -#define HOOK_INVERT_RECT 11 - -#endif - -class ServerCursor; - -#define DRAW_COPY 0 -#define DRAW_OVER 1 -#define DRAW_ERASE 2 -#define DRAW_INVERT 3 -#define DRAW_ADD 4 -#define DRAW_SUBTRACT 5 -#define DRAW_BLEND 6 -#define DRAW_MIN 7 -#define DRAW_MAX 8 -#define DRAW_SELECT 9 -#define DRAW_ALPHA 10 - - -class DisplayDriver -{ -public: - DisplayDriver(void); - virtual ~DisplayDriver(void); - - virtual void Initialize(void); // Sets the driver - virtual bool IsInitialized(void); - virtual void Shutdown(void); // You never know when you'll need this - - virtual void SafeMode(void); // Easy-access functions for common tasks - virtual void Reset(void); - virtual void Clear(uint8 red,uint8 green,uint8 blue); - virtual void Clear(rgb_color col); - - // Settings functions - virtual void SetScreen(uint32 space); - virtual int32 GetHeight(void); - virtual int32 GetWidth(void); - virtual int GetDepth(void); - - // Drawing functions - virtual void AddLine(BPoint pt1, BPoint pt2, rgb_color col); - virtual void BeginLineArray(int32 count); - virtual void Blit(BRect src, BRect dest); - virtual void DrawBitmap(ServerBitmap *bitmap, BRect source, BRect dest); - virtual void DrawChar(char c, BPoint point); - virtual void DrawLineArray(int32 count,BPoint *start, BPoint *end, rgb_color *color); - virtual void DrawString(char *string, int length, BPoint point); - virtual void EndLineArray(void); - - virtual void FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void FillBezier(BPoint *points, uint8 *pattern); - virtual void FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void FillPolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void FillRect(BRect rect, uint8 *pattern); - virtual void FillRect(BRect rect, rgb_color col); - virtual void FillRegion(BRegion *region); - virtual void FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void FillShape(BShape *shape); - virtual void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - virtual void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col); - -// virtual void GetBlendingMode(source_alpha *srcmode, alpha_function *funcmode); - virtual drawing_mode GetDrawingMode(void); - virtual void HideCursor(void); - rgb_color HighColor(void); - virtual bool IsCursorHidden(void); - rgb_color LowColor(void); - virtual void MoveCursorTo(float x, float y); - virtual void MovePenTo(BPoint pt); - virtual void ObscureCursor(void); - virtual BPoint PenPosition(void); - virtual float PenSize(void); -// virtual void SetBlendingMode(source_alpha srcmode, alpha_function funcmode); - virtual void SetCursor(ServerCursor *cursor); - virtual void SetDrawingMode(drawing_mode mode); - virtual void ShowCursor(void); - virtual void SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetHighColor(rgb_color col); - virtual void SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - virtual void SetLowColor(rgb_color col); - virtual void SetPenSize(float size); - virtual void SetPixel(int x, int y, uint8 *pattern); - - virtual float StringWidth(const char *string, int32 length); - virtual void StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void StrokeBezier(BPoint *points, uint8 *pattern); - virtual void StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void StrokeLine(BPoint point, uint8 *pattern); - virtual void StrokeLine(BPoint pt1, BPoint pt2, rgb_color col); - virtual void StrokePolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void StrokeRect(BRect rect,uint8 *pattern); - virtual void StrokeRect(BRect rect, rgb_color col); - virtual void StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void StrokeShape(BShape *shape); - virtual void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - virtual void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col); - - graphics_card_hook ghooks[48]; - graphics_card_info *ginfo; - -protected: - virtual void Line32(BPoint pt, BPoint pt2, uint8 *pattern); - virtual void Line16(BPoint pt, BPoint pt2, uint8 *pattern); - virtual void Line8(BPoint pt, BPoint pt2, uint8 *pattern); - - bool is_initialized, cursor_visible, show_on_move; - ServerCursor *current_cursor; - BLocker *locker; - rgb_color highcol, lowcol; - uint16 high16, low16; - uint8 high8, low8; - BPoint penpos; - float pensize; -}; - -#endif diff --git a/src/servers/app/proto6/driverharness/Jamfile b/src/servers/app/proto6/driverharness/Jamfile deleted file mode 100644 index 48be9bab30..0000000000 --- a/src/servers/app/proto6/driverharness/Jamfile +++ /dev/null @@ -1,17 +0,0 @@ -SubDir OBOS_TOP src servers app proto6 driverharness ; - -App DriverHarness : - <$(SOURCE_GRIST)>AppServer.cpp - <$(SOURCE_GRIST)>DebugTools.cpp - <$(SOURCE_GRIST)>DHServerBitmap.cpp - <$(SOURCE_GRIST)>DirectDriver.cpp - <$(SOURCE_GRIST)>DisplayDriver.cpp - <$(SOURCE_GRIST)>PortLink.cpp - <$(SOURCE_GRIST)>ServerCursor.cpp - <$(SOURCE_GRIST)>ViewDriver.cpp - <$(SOURCE_GRIST)>ColorUtils.cc - <$(SOURCE_GRIST)>SystemPalette.cpp - <$(SOURCE_GRIST)>ScreenDriver.cpp -; -LinkSharedOSLibs DriverHarness : be root game tracker translation stdc++.r4 ; - diff --git a/src/servers/app/proto6/driverharness/PortLink.cpp b/src/servers/app/proto6/driverharness/PortLink.cpp deleted file mode 100644 index 8fba724569..0000000000 --- a/src/servers/app/proto6/driverharness/PortLink.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/* - PortLink.cpp: - A helper class for port-based messaging - ------------------------------------------------------------------------- -How it works: - The class utilizes a fixed-size array of PortLinkData object pointers. When -data is attached, a new PortLinkData object is allocated and a copy of the -passed data is created inside it. When the time comes for the message to be sent, -the data is pieced together into a flattened array and written to the port. ------------------------------------------------------------------------- -Data members: - -*attachments[] - fixed-size array of pointers used to hold the attached data -opcode - message value which is sent along with any data -target - port to which the message is sent when Flush() is called -replyport - port used with synchronous messaging - FlushWithReply() -bufferlength - total bytes taken up by attachments -num_attachments - internal variable which is used to track which "slot" - will be the next one to receive an attachment object -*/ - -#include "PortLink.h" -#include -#include -#include - -//#define PLDEBUG - -// Internal data storage class for holding attached data whilst it is waiting -// to be Flattened() and then Flushed(). There is no need for this to be called outside -// the PortLink class. -class PortLinkData -{ -public: - PortLinkData(void); - ~PortLinkData(void); - bool Set(void *data, size_t size); - char *buffer; - size_t buffersize; -}; - -PortLink::PortLink(port_id port) -{ - // For this class to be useful (and to prevent a lot of init problems) - // we require a port in the constructor - target=port; - - // We start out without any data attached to the port message - num_attachments=0; - opcode=0; - bufferlength=0; - replyport=create_port(30,"PortLink reply port"); -} - -PortLink::~PortLink(void) -{ - // If, for some odd reason, this is deleted with something attached, - // free the memory used by the attachments. We do not flush the queue - // because the port may no longer be valid in cases such as the app - // is in the process of quitting - MakeEmpty(); -} - -void PortLink::SetOpCode(int32 code) -{ - // Sets the message code. This does not change once the message is sent. - // Another call to SetOpCode() is required for such things. - opcode=code; -} - -void PortLink::SetPort(port_id port) -{ - // Sets the target port. While not necessary in most uses, this exists - // mostly to prevent flexibility problems - target=port; -} - -port_id PortLink::GetPort(void) -{ - // Simply returns the port at which the object is pointed. - return target; -} - -void PortLink::Flush(bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message off to the target, complete with attachments. NOTE: - // the recipient must delete all attachments, being the PortLink object assumes - // no responsiblity for the attachments once the message is sent. - int8 *msgbuffer; - int32 size; - - if(num_attachments>0) - { - FlattenData(&msgbuffer,&size); - - // Dump message to port, reset attachments, and clean up - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,msgbuffer,size,B_TIMEOUT, timeout); - else - write_port(target,opcode,msgbuffer,size); - MakeEmpty(); - } - else - { - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,NULL,0,B_TIMEOUT, timeout); - else - write_port(target,opcode,NULL,0); - } -} - -int8* PortLink::FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message to the target and then waits for a reply. The target will - // receive a message with the first item being the port_id to reply to. - // NOTE: like Flush(), any attached data must be deleted. - - // Effectively, an Attach() call inlined for changes - - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - { - *status=B_ERROR; - return NULL; - } - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&replyport,sizeof(port_id))) - { - bufferlength+=sizeof(port_id); - } - else - { - delete pld; - *status=B_ERROR; - return NULL; - } - - // Flatten() inlined to make some necessary changes - int8 *buffer=new int8[bufferlength]; - int8 *bufferindex=buffer; - size_t size=0; - - // attach our port_id first - memcpy(bufferindex, pld->buffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - - // attach everything else - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - } - - // Flush the thing....FOOSH! :P - write_port(target,opcode,buffer,size); - MakeEmpty(); - delete buffer; - - // Now we wait for the reply - if(timeout==B_INFINITE_TIMEOUT) - { - *buffersize=port_buffer_size(replyport); - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - else - { - *buffersize=port_buffer_size_etc(replyport,0,timeout); - if(*buffersize==B_TIMED_OUT) - { - *status=*buffersize; - return NULL; - } - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - - // We got this far, so we apparently have some data - *status=B_OK; - return buffer; -} - -void PortLink::Attach(void *data, size_t size) -{ - // This is the member called to attach data to a message. Attachments are - // treated to be in 'Append' mode, tacking on each attached piece of data - // to the end of the list. - - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - if(size==0) - return; - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -// These functions were added for a major convenience in passing common types -// Eventually, I'd like to templatize these, but for now, this'll do - -void PortLink::Attach(int32 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int32); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int16 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int16); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int8 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int8); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(float data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(float); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(bool data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(bool); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BRect data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BRect); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BPoint data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BPoint); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::FlattenData(int8 **buffer,int32 *size) -{ - // This function is where all the magic happens, but it is strictly internal. - // It iterates through each PortLinkData object and copies it to the main buffer - // which ends up, ultimately, being written to the PortLink's target port. - - // skip if there aree no attachments - if(bufferlength<1) - return; - - *buffer=new int8[bufferlength]; - int8 *bufferindex=*buffer; - PortLinkData *pld; - *size=0; - - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - *size+=pld->buffersize; - } -} - -void PortLink::MakeEmpty(void) -{ - // Nukes all the attachments currently held by the PortLink class - if(num_attachments!=0) - { - for(int i=0; i0) - free(buffer); -} - -bool PortLinkData::Set(void *data, size_t size) -{ - // Function copies the passed to the internal buffers for storage - if(size>0 && buffersize==0 && data!=NULL) - { - buffer=(char *)malloc(size); - if(buffer==NULL) - return false; - memcpy(buffer, data, size); - buffersize=size; - return true; - } - return false; -} diff --git a/src/servers/app/proto6/driverharness/PortLink.h b/src/servers/app/proto6/driverharness/PortLink.h deleted file mode 100644 index 429f342024..0000000000 --- a/src/servers/app/proto6/driverharness/PortLink.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _PORTLINK_H_ -#define _PORTLINK_H_ - -#include -#include -#include -#include - -#ifndef _PORTLINK_BUFFERSIZE -#define _PORTLINK_MAX_ATTACHMENTS 50 -#endif - -class PortLinkData; - -class PortLink -{ -public: - PortLink(port_id port); - ~PortLink(void); - void SetOpCode(int32 code); - void SetPort(port_id port); - port_id GetPort(void); - void Flush(bigtime_t timeout=B_INFINITE_TIMEOUT); - int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, - bigtime_t timeout=B_INFINITE_TIMEOUT); - void Attach(void *data, size_t size); - void Attach(int32 data); - void Attach(int16 data); - void Attach(int8 data); - void Attach(float data); - void Attach(bool data); - void Attach(BRect data); - void Attach(BPoint data); - void MakeEmpty(void); -protected: - void FlattenData(int8 **buffer,int32 *size); - port_id target, replyport; - int32 opcode, bufferlength; - int num_attachments; - PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS]; -}; - -#endif diff --git a/src/servers/app/proto6/driverharness/ScreenDriver.cpp b/src/servers/app/proto6/driverharness/ScreenDriver.cpp deleted file mode 100644 index 1928324e9a..0000000000 --- a/src/servers/app/proto6/driverharness/ScreenDriver.cpp +++ /dev/null @@ -1,915 +0,0 @@ -/* - ScreenDriver.cpp - Replacement class for the ViewDriver which utilizes a BWindowScreen for ease - of testing without requiring a second video card for SecondDriver and also - without the limitations (mostly speed) of ViewDriver. - - Note that unlike ViewDriver, this graphics module does NOT emulate - the Input Server. The Router input server filter is required for use. - - The concept is pretty close to the retooled ViewDriver, where each module - call locks a couple BLockers and draws to the buffer. - - Components: - ScreenDriver: actual driver module - FrameBuffer: BWindowScreen derivative which provides the module access - to the video card - Internal functions for doing graphics on the buffer - - Done: - Basic module init and shutdown - Clear() - 8-bit and 32-bit - SetPixel32 - StrokeLine(pt,pt,rgb_color) - StrokeRect - both forms - FillRect - both forms, but not using fastest methods - ToDo: - 16-Bit mode functions - StrokeLine(pt,pattern) needs to utilize patterns - FillRect(rect,pattern) needs to utilize patterns - Implement a lot of functions -*/ -#include "ScreenDriver.h" -#include "ServerCursor.h" -#include "ServerProtocol.h" -#include "ServerBitmap.h" -#include "SystemPalette.h" -#include "ColorUtils.h" -#include "PortLink.h" -#include "DebugTools.h" -#include -#include -#include -#include - -#define DEBUG_DRIVER - -// Define this if you want to use the spacebar to launch the server prototype's -// test application -#define LAUNCH_TESTAPP - -#ifdef LAUNCH_TESTAPP -#include -#include -#endif - -// functions internal to the driver -void Clear_32Bit(void *buffer, int width, int height, rgb_color col); -void Clear_16Bit(void *buffer, int width, int height, uint16 col); -void Clear_8Bit(void *buffer, int width, int height, uint8 col); - -void HLine_32Bit(graphics_card_info i, uint16 x, uint16 y, uint16 length, rgb_color col); -void HLine_16Bit(graphics_card_info i, uint16 x, uint16 y, uint16 length, uint16 col); -void HLine_16Bit(graphics_card_info i, uint16 x, uint16 y, uint16 length, uint8 col); - -FrameBuffer::FrameBuffer(const char *title, uint32 space, status_t *st,bool debug) - : BWindowScreen(title,space,st,debug) -{ - is_connected=false; -} - -FrameBuffer::~FrameBuffer(void) -{ -} - -void FrameBuffer::ScreenConnected(bool connected) -{ - is_connected=connected; - if(connected) - { - // Cache the state just in case - graphics_card_info *info=CardInfo(); - gcinfo=*info; - } -} - -void FrameBuffer::MessageReceived(BMessage *msg) -{ - switch(msg->what) - { - case B_KEY_DOWN: - { - int32 key; - msg->FindInt32("key",&key); - if(key==0x47) // Enter key - { - port_id serverport=find_port(SERVER_PORT_NAME); - write_port(serverport,B_QUIT_REQUESTED,NULL,0); - break; - } - #ifdef LAUNCH_TESTAPP - if(key==0x5e) - { - printf("Launching test app\n"); - status_t value; - BEntry entry("/boot/home/Desktop/openbeos/proto6/OBApplication/OBApplication"); - entry_ref ref; - entry.GetRef(&ref); - value=be_roster->Launch(&ref); - - BString str=TranslateStatusToString(value); - printf("Launch return code: %s",str.String()); - printf("\n"); - } - #endif - } - default: - BWindowScreen::MessageReceived(msg); - } -} - -bool FrameBuffer::QuitRequested(void) -{ - port_id serverport=find_port(SERVER_PORT_NAME); - - if(serverport!=B_NAME_NOT_FOUND) - write_port(serverport,B_QUIT_REQUESTED,NULL,0); - - return true; -} - -ScreenDriver::ScreenDriver(void) -{ - status_t st; - fbuffer=new FrameBuffer("OBAppServer",B_8_BIT_640x480,&st,true); - - drawmode=DRAW_COPY; - // Create our cursor here - cursor=new ServerBitmap(BRect(0,0,16,16),B_CMAP8); -} - -ScreenDriver::~ScreenDriver(void) -{ - delete cursor; -} - -void ScreenDriver::Initialize(void) -{ - fbuffer->Show(); - - // draw on the module's default cursor here to make it look preety - - // wait 1 sec for the window to show... - snooze(500000); -} - -void ScreenDriver::Shutdown(void) -{ - fbuffer->Lock(); - fbuffer->Quit(); -} - -void ScreenDriver::Clear(uint8 red,uint8 green,uint8 blue) -{ - locker->Lock(); - rgb_color c; - SetRGBColor(&c,red,green,blue); - Clear(c); - locker->Unlock(); -} - -void ScreenDriver::Clear(rgb_color col) -{ - locker->Lock(); -#ifdef DEBUG_DRIVER -printf("ScreenDriver::Clear(%u,%u,%u)\n",col.red,col.green,col.blue); -#endif - if(fbuffer->IsConnected()) - { - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 32: - case 24: - { -printf("Clear: 32/24-bit\n"); - Clear_32Bit(fbuffer->gcinfo.frame_buffer, - fbuffer->gcinfo.width,fbuffer->gcinfo.height,col); - break; - } - case 16: - case 15: - { -printf("Clear: 16/15-bit unimplemented\n"); - // Look up color here -// uint16 c; -// Clear_16Bit(gcinfo.frame_buffer,gcinfo.width,gcinfo.height,c); - break; - } - case 8: - { -printf("Clear: 8-bit\n"); - // Look up color here - uint8 c=FindClosestColor(fbuffer->ColorList(),col); - - Clear_8Bit(fbuffer->gcinfo.frame_buffer, - fbuffer->gcinfo.width,fbuffer->gcinfo.height, c); - break; - } - default: - { -#ifdef DEBUG_DRIVER -printf("Clear: unknown bit depth %u\n",fbuffer->gcinfo.bits_per_pixel); -#endif - break; - } - } - } - else - { -#ifdef DEBUG_DRIVER -printf("Clear: driver is disconnected\n"); -#endif - } - locker->Unlock(); -} - -void ScreenDriver::DrawBitmap(ServerBitmap *bitmap, BRect source, BRect dest) -{ - locker->Lock(); -#ifdef DEBUG_DRIVER -printf("ScreenDriver::DrawBitmap(*, (%f,%f,%f,%f),(%f,%f,%f,%f) )\n", - source.left,source.top,source.right,source.bottom, - dest.left,dest.top,dest.right,dest.bottom); -#endif - if(fbuffer->IsConnected()) - { - // Scale bitmap here if source!=dest - - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 32: - case 24: - { - printf("DrawBitmap: 32/24-bit unimplemented\n"); - break; - } - case 16: - case 15: - { - printf("DrawBitmap: 16/15-bit unimplemented\n"); - break; - } - case 8: - { - printf("DrawBitmap: 8-bit unimplemented\n"); - break; - } - default: - { -#ifdef DEBUG_DRIVER -printf("Clear: unknown bit depth %u\n",fbuffer->gcinfo.bits_per_pixel); -#endif - break; - } - } - } - - locker->Unlock(); -} - -void ScreenDriver::FillRect(BRect rect, uint8 *pattern) -{ - locker->Lock(); - - FillRect(rect,highcol); - - locker->Unlock(); -} - -void ScreenDriver::FillRect(BRect rect, rgb_color col) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::FillRect( (%f,%f,%f,%f), {%u,%u,%u,%u}\n",rect.left,rect.top, - rect.right,rect.bottom,col.red,col.green,col.blue,col.alpha); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - // int32 width=rect.IntegerWidth(); - for(int32 i=(int32)rect.top;i<=rect.bottom;i++) - // HLine(fbuffer->gcinfo,(int32)rect.left,i,width,col); - StrokeLine(BPoint(rect.left,i),BPoint(rect.right,i),col); - } - locker->Unlock(); -} - -void ScreenDriver::FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::FillRoundRect( (%f,%f,%f,%f), %llx) ---->Unimplemented<----\n",rect.left,rect.top, - rect.right,rect.bottom,*((uint64*)pattern)); -#endif - FillRect(rect,pattern); -} - -void ScreenDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::FillTriangle(%llx): --->Currently Unimplemented<---\n",*((uint64*)pattern)); -printf("\tFirst: (%f,%f)\n\tSecond: (%f,%f)\n\tThird: (%f,%f)\n",first.x,first.y, - second.x,second.y,third.x,third.y); -rect.PrintToStream(); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - BPoint oldpos=penpos; - MovePenTo(first); StrokeLine(second,pattern); - MovePenTo(second); StrokeLine(third,pattern); - MovePenTo(third); StrokeLine(first,pattern); - penpos=oldpos; - } - locker->Unlock(); -} - -void ScreenDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::FillTriangle({%u,%u,%u,%u}): --->Currently Unimplemented<---\n", - col.red,col.green,col.blue,col.alpha); -printf("\tFirst: (%f,%f)\n\tSecond: (%f,%f)\n\tThird: (%f,%f)\n",first.x,first.y, - second.x,second.y,third.x,third.y); -rect.PrintToStream(); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - StrokeLine(first,second,col); - StrokeLine(first,third,col); - StrokeLine(third,second,col); - } - locker->Unlock(); -} - -void ScreenDriver::SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - rgb_color col={r,g,b,a}; - SetHighColor(col); -} - -void ScreenDriver::SetHighColor(rgb_color col) -{ - highcol=col; - - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 16: - case 15: - high16=FindClosestColor16(highcol); - break; - case 8: - high8=FindClosestColor(system_palette,highcol); - break; - default: - break; - } -} - -void ScreenDriver::SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - rgb_color col={r,g,b,a}; - SetLowColor(col); -} - -void ScreenDriver::SetLowColor(rgb_color col) -{ - lowcol=col; - - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 16: - case 15: - low16=FindClosestColor16(highcol); - break; - case 8: - low8=FindClosestColor(system_palette,highcol); - break; - default: - break; - } -} - -void ScreenDriver::SetPixel(int x, int y, uint8 *pattern) -{ - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 32: - case 24: - SetPixel32(x,y,highcol); - break; - case 16: - case 15: - SetPixel16(x,y,FindClosestColor16(highcol)); - break; - default: - printf("SetPixel8 Unimplemented\n"); -// SetPixel8(x,y,FindClosestColor(highcol)); - break; - } - -} - -void ScreenDriver::SetPixel32(int x, int y, rgb_color col) -{ - // Code courtesy of YNOP's SecondDriver - union - { - uint8 bytes[4]; - uint32 word; - }c1; - - c1.bytes[0]=col.blue; - c1.bytes[1]=col.green; - c1.bytes[2]=col.red; - c1.bytes[3]=col.alpha; - - uint32 *bits=(uint32*)fbuffer->gcinfo.frame_buffer; - *(bits + x + (y*fbuffer->gcinfo.width))=c1.word; -} - -void ScreenDriver::SetPixel16(int x, int y, uint16 col) -{ -#ifdef DEBUG_DRIVER -printf("SetPixel16 unimplemented\n"); -#endif -} - -void ScreenDriver::SetPixel8(int x, int y, uint8 col) -{ - // When the DisplayDriver API changes, we'll use the uint8 highcolor. Until then, - // we'll use *pattern - uint8 *bits=(uint8*)fbuffer->gcinfo.frame_buffer; - *(bits + x + (y*fbuffer->gcinfo.bytes_per_row))=col; -} - -void ScreenDriver::SetScreen(uint32 space) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::SetScreen(%lu}\n",space); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - fbuffer->SetSpace(space); - - // We have changed the frame buffer info, so update the cached info - graphics_card_info *info=fbuffer->CardInfo(); - fbuffer->gcinfo=*info; - } - locker->Unlock(); -} - -void ScreenDriver::StrokeLine(BPoint point, uint8 *pattern) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeLine( (%f,%f), %llx}\n",point.x,point.y,*((uint64*)pattern)); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - // Courtesy YNOP's SecondDriver with minor changes by DW - int oct=0; - int xoff=(int32)penpos.x; - int yoff=(int32)penpos.y; - int32 x2=(int32)point.x-xoff; - int32 y2=(int32)point.y-yoff; - int32 x1=0; - int32 y1=0; - if(y2<0){ y2=-y2; oct+=4; }//bit2=1 - if(x2<0){ x2=-x2; oct+=2;}//bit1=1 - if(x2Unlock(); -} - -void ScreenDriver::StrokeLine(BPoint start, BPoint end, rgb_color col) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeLine( (%f,%f),(%f,%f), {%u,%u,%u,%u}\n",start.x,start.y, - end.x,end.y,col.red,col.green,col.blue,col.alpha); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - // Courtesy YNOP's SecondDriver with minor changes by DW - rgb_color savecol=highcol; - SetHighColor(col.red,col.green,col.blue); - - int oct=0; - int xoff=(int32)start.x; - int yoff=(int32)start.y; - int32 x2=(int32)end.x-xoff; - int32 y2=(int32)end.y-yoff; - int32 x1=0; - int32 y1=0; - if(y2<0){ y2=-y2; oct+=4; }//bit2=1 - if(x2<0){ x2=-x2; oct+=2;}//bit1=1 - if(x2Unlock(); -} - -void ScreenDriver::StrokePolygon(int *x, int *y, int numpoints, bool is_closed) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokePolygon( is_closed=%s)\n",(is_closed==true)?"true":"false"); -for(int debug=0;debugLock(); - if(fbuffer->IsConnected()) - { - for(int32 i=0; i<(numpoints-1); i++) - StrokeLine(BPoint(x[i],y[i]),BPoint(x[i+1],y[i+1]),highcol); - - if(is_closed) - StrokeLine(BPoint(x[numpoints-1],y[numpoints-1]),BPoint(x[0],y[0]),highcol); - } - locker->Unlock(); -} - -void ScreenDriver::StrokeRect(BRect rect,uint8 *pattern) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeRect( (%f,%f,%f,%f), %llx)\n",rect.left,rect.top, - rect.right,rect.bottom,*((uint64*)pattern)); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - BPoint oldpos=penpos; - - MovePenTo(rect.LeftTop()); StrokeLine(BPoint(rect.right,rect.top),pattern); - MovePenTo(BPoint(rect.right,rect.top)); StrokeLine(BPoint(rect.right,rect.bottom),pattern); - MovePenTo(BPoint(rect.right,rect.bottom)); StrokeLine(BPoint(rect.left,rect.bottom),pattern); - MovePenTo(BPoint(rect.left,rect.bottom)); StrokeLine(BPoint(rect.left,rect.top),pattern); - -// Line32(rect.LeftTop(),BPoint(rect.right,rect.top),pattern); -// Line32(BPoint(rect.right,rect.top),BPoint(rect.right,rect.bottom),pattern); -// Line32(BPoint(rect.right,rect.bottom),BPoint(rect.left,rect.bottom),pattern); -// Line32(BPoint(rect.left,rect.bottom),BPoint(rect.left,rect.top),pattern); - - penpos=oldpos; - } - locker->Unlock(); -} - -void ScreenDriver::StrokeRect(BRect rect,rgb_color col) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeRect( (%f,%f,%f,%f), {%u,%u,%u,%u}\n",rect.left,rect.top, - rect.right,rect.bottom,col.red,col.green,col.blue,col.alpha); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - StrokeLine(BPoint(rect.left,rect.top),BPoint(rect.right,rect.top),col); - StrokeLine(BPoint(rect.right,rect.top),BPoint(rect.right,rect.bottom),col); - StrokeLine(BPoint(rect.right,rect.bottom),BPoint(rect.left,rect.bottom),col); - StrokeLine(BPoint(rect.left,rect.bottom),BPoint(rect.left,rect.top),col); - } - locker->Unlock(); -} - -void ScreenDriver::StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeRoundRect( (%f,%f,%f,%f), %llx) ---->Unimplemented<----\n",rect.left,rect.top, - rect.right,rect.bottom,*((uint64*)pattern)); -#endif - StrokeRect(rect,pattern); -} - -void ScreenDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeTriangle(%llx):\n",*((uint64*)pattern)); -printf("\tFirst: (%f,%f)\n\tSecond: (%f,%f)\n\tThird: (%f,%f)\n",first.x,first.y, - second.x,second.y,third.x,third.y); -rect.PrintToStream(); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - BPoint oldpos=penpos; - MovePenTo(first); StrokeLine(second,pattern); - MovePenTo(second); StrokeLine(third,pattern); - MovePenTo(third); StrokeLine(first,pattern); - penpos=oldpos; - } - locker->Unlock(); -} - -void ScreenDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeTriangle({%u,%u,%u,%u}):\n", - col.red,col.green,col.blue,col.alpha); -printf("\tFirst: (%f,%f)\n\tSecond: (%f,%f)\n\tThird: (%f,%f)\n",first.x,first.y, - second.x,second.y,third.x,third.y); -rect.PrintToStream(); -#endif - locker->Lock(); - if(fbuffer->IsConnected()) - { - StrokeLine(first,second,col); - StrokeLine(first,third,col); - StrokeLine(third,second,col); - } - locker->Unlock(); -} - -void ScreenDriver::Line32(BPoint pt, BPoint pt2, uint8 *pattern) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::Line32( (%f,%f),(%f,%f), 0x%llx\n",pt.x,pt.y, - pt2.x,pt2.y,*((int64*)pattern)); -#endif - // Courtesy YNOP's SecondDriver with minor changes by DW - int oct=0; - int xoff=(int32)pt.x; - int yoff=(int32)pt.y; - int32 x2=(int32)pt2.x-xoff; - int32 y2=(int32)pt2.y-yoff; - int32 x1=0; - int32 y1=0; - if(y2<0){ y2=-y2; oct+=4; }//bit2=1 - if(x2<0){ x2=-x2; oct+=2;}//bit1=1 - if(x232) - patindex=0; - } -} - -void ScreenDriver::SetPixelPattern(int x, int y, uint8 *pattern, uint8 patternindex) -{ - // This function is designed to add pattern support to this thing. Should be - // inlined later to add speed lost in the multiple function calls. -#ifdef DEBUG_DRIVER -printf("ScreenDriver::SetPixelPattern(%u,%u,%llx,%u)\n",x,y,*((int64*)pattern),patternindex); -#endif - if(patternindex>32) - return; - - if(fbuffer->IsConnected()) - { - uint64 *p64=(uint64*)pattern; - - // check for transparency in mask. If transparent, we can quit here - - bool transparent_bit= - ( *p64 & ~((uint64)2 << (32-patternindex)))?true:false; -printf("SetPixelPattern: pattern=0x%llx\n",*p64); -printf("SetPixelPattern: bit=0x%llx\n",((uint64)2 << (32-patternindex))); -printf("SetPixelPattern: bit mask=0x%llx\n",~((uint64)2 << (32-patternindex))); -printf("SetPixelPattern: bit value=%s\n",transparent_bit?"true":"false"); - - bool highcolor_bit= - ( *p64 & ~((uint64)2 << (64-patternindex)))?true:false; - - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 32: - case 24: - { - - break; - } - case 16: - case 15: - { - break; - } - case 8: - { - break; - } - default: - { -#ifdef DEBUG_DRIVER -printf("SetPixelPattern: unknown bit depth %u\n",fbuffer->gcinfo.bits_per_pixel); -#endif - break; - } - } - } - else - { -#ifdef DEBUG_DRIVER -printf("SetPixelPattern: driver is disconnected\n"); -#endif - } -} - -void Clear_32Bit(void *buffer, int width, int height, rgb_color col) -{ -#ifdef DEBUG_DRIVER -printf("Clear_32Bit(*,%d,%d,(r=%u,g=%u,b=%u,a=%u)\n",width,height,col.red,col.green, - col.blue,col.alpha); -#endif - - uint32 c=0,*pcolor=(uint32*)buffer; - - // apparently width=bytes per row - uint32 bpr=width; - - // ARGB order - c|=col.alpha * 0x01000000; - c|=col.red * 0x010000; - c|=col.green * 0x0100; - c|=col.blue; - -#ifdef DEBUG_DRIVER -printf("Clear color value: 0x%lx\n",c); -#endif - for(int32 j=0;jbpr)?length-((x+length)-bpr):length; - - pcolor=(uint32*)i.frame_buffer; - pcolor+=(y*bpr)+(x*4); - for(int32 i=0;ibpr)?length-((x+length)-bpr):length; - - memset(pcolor,col,bytes); -} diff --git a/src/servers/app/proto6/driverharness/ScreenDriver.h b/src/servers/app/proto6/driverharness/ScreenDriver.h deleted file mode 100644 index 0f35717241..0000000000 --- a/src/servers/app/proto6/driverharness/ScreenDriver.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef _SCREENDRIVER_H_ -#define _SCREENDRIVER_H_ - -#include -#include -#include -#include -#include -#include -#include -#include // for clipping_rect definition -#include -#include "DisplayDriver.h" - -class VDWindow; -class ServerCursor; -class ServerBitmap; - - -class FrameBuffer : public BWindowScreen -{ -public: - FrameBuffer(const char *title, uint32 space, status_t *st,bool debug); - ~FrameBuffer(void); - void ScreenConnected(bool connected); - void MessageReceived(BMessage *msg); - bool IsConnected(void) const { return is_connected; } - bool QuitRequested(void); - - graphics_card_info gcinfo; -protected: - bool is_connected; -}; - -class ScreenDriver : public DisplayDriver -{ -public: - ScreenDriver(void); - ~ScreenDriver(void); - - void Initialize(void); - void Shutdown(void); - - void Clear(uint8 red,uint8 green,uint8 blue); - void Clear(rgb_color col); - - // Settings functions - void SetScreen(uint32 space); -/* int32 GetHeight(void); - int32 GetWidth(void); - int GetDepth(void); - - // Drawing functions - void Blit(BRect src, BRect dest); -*/ void DrawBitmap(ServerBitmap *bitmap, BRect source, BRect dest); -/* void DrawChar(char c, BPoint point); - void DrawString(char *string, int length, BPoint point); - - void FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - void FillBezier(BPoint *points, uint8 *pattern); - void FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - void FillPolygon(int *x, int *y, int numpoints, bool is_closed); -*/ void FillRect(BRect rect, uint8 *pattern); - void FillRect(BRect rect, rgb_color col); -// void FillRegion(BRegion *region); - void FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); -// void FillShape(BShape *shape); - - void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col); -/* - void HideCursor(void); - bool IsCursorHidden(void); - void MoveCursorTo(float x, float y); - void ObscureCursor(void); - float PenSize(void); - void SetCursor(ServerCursor *cursor); -*/ - void SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - void SetHighColor(rgb_color col); - void SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - void SetLowColor(rgb_color col); - - void SetPixel(int x, int y, uint8 *pattern); - - void SetPixel32(int x, int y, rgb_color col); - void SetPixel16(int x, int y, uint16 col); - void SetPixel8(int x, int y, uint8 col); - void SetPixelPattern(int x, int y, uint8 *pattern, uint8 patternindex); - -// void ShowCursor(void); - -// void StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); -// void StrokeBezier(BPoint *points, uint8 *pattern); -// void StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - void StrokeLine(BPoint point, uint8 *pattern); - void StrokeLine(BPoint pt1, BPoint pt2, rgb_color col); - void StrokePolygon(int *x, int *y, int numpoints, bool is_closed); - void StrokeRect(BRect rect,uint8 *pattern); - void StrokeRect(BRect rect,rgb_color col); - void StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); -// void StrokeShape(BShape *shape); - void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col); - -protected: - void Line32(BPoint pt, BPoint pt2, uint8 *pattern); - FrameBuffer *fbuffer; - int hide_cursor; - ServerBitmap *cursor; - int32 drawmode; -}; - -#endif diff --git a/src/servers/app/proto6/driverharness/SecondDriver.cpp b/src/servers/app/proto6/driverharness/SecondDriver.cpp deleted file mode 100644 index ca99a3b9e5..0000000000 --- a/src/servers/app/proto6/driverharness/SecondDriver.cpp +++ /dev/null @@ -1,836 +0,0 @@ -/******************************************************* -* SecondDriver -* -* Second driver is a Drvier abstraction layer for the -* OBOS app_server. It provides access to the Graphic -* HW via the low level api calls. This provides a -* way to run the app_server on real HW. -* This driver also makes it easy for you to run the -* OBOS app_server in parallel with the Be app_server -* when two or more video cards are installed in your -* computer. -* -* @author YNOP (ynop@beunited.org) -* @version beta1 (p5) -* -* History: -* - Added Ellipse (Stroke & Fill) -* Ran though test app to make sure worked -* Fixed HorizLine to used fill_span instead of fill_rect :P -* Updated the Cursor code to work again. -* Made new cursor (Be-hand like) -* - Added StrokeBezir -* Added HorizLine for speed -* - Added HW acceleration methods -* - Brez Line added -* - Created by YNOP -* -* Todo: -* Clean up src and add more comments :P -* Redo StrokeLine to use PenSize -* Redo StrokeLine to use pattern -* Mouse Cursor seems to be broken in proto5 ? -* Add in a way to read app_server_settings file so we can get the real settings -* Make display mode settings more flexable -* Look into FreeType for DrawString :P fun fun fun -* -* Todo methods: -* Blit() DrawBitmap() DrawString() FillArc() FillBezier() FillPolygon() -* FillRegion() FillRoundRect() FillShape() FillTriangle() -* StrokeArc() StrokeRoundRect() StrokeShpae() -* -*******************************************************/ -#include -#include - -#include - -#include "PortLink.h" -#include "ServerProtocol.h" -#include "ServerBitmap.h" -#include "ServerCursor.h" -#include "DebugTools.h" -#include "SecondDriver.h" -#include "SecondDriverHelper.h" - -/******************************************************* -* @description -*******************************************************/ -SecondDriver::SecondDriver(void):DisplayDriver(){ - SetupBezier(); - hide_cursor = false; - fd = -1; - image = -1; - - gah = NULL; - bits = NULL; - bpr = -1; - - scs = NULL; - mc = NULL; - sc = NULL; - - et = NULL; - re = NULL; - - s2sb = NULL; - fr = NULL; - ir = NULL; - s2stb = NULL; - fs = NULL; - -} - -/******************************************************* -* @description -*******************************************************/ -SecondDriver::~SecondDriver(void){ - if(is_initialized){ - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::Initialize(void){ - et = NULL; - bits = NULL; - - // Find a driver - fd = get_device(); - if(fd < 0){ - printf("No Device settings found.\n"); - fd = find_device(); - }else{ - printf("Device read from settings file\n"); - } - if(fd < 0){ - printf("No device find, trying fallback stub\n"); - fd = fallback_device(); - } - if(fd < 0){ - printf("Didn't find device :(\n"); - is_initialized = false; - } - /* load the accelerant */ - image = load_accelerant(fd, &gah); - if (image >= 0){ - // Set up the display to a valid resolution - if(get_and_set_mode(gah,&dm) == B_OK){ - // Here we are all good - if(dm.space == B_CMAP8){ - set_palette(gah); - } - get_frame_buffer(gah, &fbc); - bits = (uint32*)fbc.frame_buffer/*_dma*/; - bpr = fbc.bytes_per_row/4; // sould be by depth - - if(dm.flags & B_HARDWARE_CURSOR){ - // Lets check out tha hardwar cursoer stuff :P - printf("Mode supports Hardware cursors\n"); - scs = (set_cursor_shape)gah(B_SET_CURSOR_SHAPE,NULL); - mc = (move_cursor)gah(B_MOVE_CURSOR,NULL); - sc = (show_cursor)gah(B_SHOW_CURSOR,NULL); - } - - // Ok. now lets see if we can add some spiffy - // 2D acceleration to this :) - accelerant_engine_count aec = (accelerant_engine_count)gah(B_ACCELERANT_ENGINE_COUNT,NULL); - uint32 count = aec(); - if(count > 0){ - acquire_engine ae = (acquire_engine)gah(B_ACQUIRE_ENGINE,NULL); - re = (release_engine)gah(B_RELEASE_ENGINE,NULL); - if(ae(B_2D_ACCELERATION,1000,&st,&et) == B_OK){ - // Now lets see if we have some functions - printf("You should be verry happy. You have 2D hardware Acceleration\n"); - s2sb = (screen_to_screen_blit)gah(B_SCREEN_TO_SCREEN_BLIT,NULL); - fr = (fill_rectangle)gah(B_FILL_RECTANGLE,NULL); - ir = (invert_rectangle)gah(B_INVERT_RECTANGLE,NULL); - s2stb = (screen_to_screen_transparent_blit)gah(B_SCREEN_TO_SCREEN_TRANSPARENT_BLIT,NULL); - fs = (fill_span)gah(B_FILL_SPAN,NULL); - } - } - is_initialized = true; - }else{ - // failed to set mode - is_initialized = false; - } - }else{ - // image failed to load - is_initialized = false; - } - - if(is_initialized){ - printf("\n\tSecond Driver by YNOP (ynop@beunited.org)\n"); - printf("\tSecond Driver is copyrigth YNOP 2002\n"); - printf("\tHave fun, its all set up :)\n\n"); - } - - SetCursor((ServerCursor*)NULL); - ShowCursor(); - int32 h = GetHeight(); - int32 w = GetWidth(); - MoveCursorTo(w/2,h/2); - -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::Shutdown(void){ - printf("\tShuting down SecondDriver\n"); - if(et){ - if(re(et,&st) != B_OK){ - printf("Failed to release engine\n"); - } - } - - uninit_accelerant ua = (uninit_accelerant)gah(B_UNINIT_ACCELERANT,NULL); - if(ua){ ua();} - - unload_add_on(image); - - // clsoe the file now... - close(fd); - - - is_initialized=false; -} - -/******************************************************* -* @description -*******************************************************/ -bool SecondDriver::IsInitialized(void){ - return is_initialized; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SafeMode(void){ -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::Reset(void){ -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetScreen(uint32 space){ - // Clear(51,102,152); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::Clear(uint8 red, uint8 green, uint8 blue){ - rgb_color r; - r.red = red; - r.blue = blue; - r.green = green; - Clear(r); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::Clear(rgb_color col){ - highcol = col; - FillRect(BRect(0,0,GetHeight()-1,GetWidth()-1),NULL); -} - -/******************************************************* -* @description -*******************************************************/ -int32 SecondDriver::GetHeight(void){ - // Gets the height of the current mode - return dm.virtual_height; -} - -/******************************************************* -* @description -*******************************************************/ -int32 SecondDriver::GetWidth(void){ - // Gets the width of the current mode - return dm.virtual_width; -} - -/******************************************************* -* @description -*******************************************************/ -int SecondDriver::GetDepth(void){ - // Gets the color depth of the current mode - return 0; -} - -/******************************************************* -* @description -*******************************************************/ -#ifdef PROTO_4 - void SecondDriver::Blit(BPoint loc, ServerBitmap *src, ServerBitmap *dest) -#else - void SecondDriver::Blit(BRect src, BRect dest) -#endif -{ - printf("Calling Blit (not wirten yet)\n"); - if(s2sb){ - printf("Accelerated Blit\n"); - }else{ - - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::DrawBitmap(ServerBitmap *bitmap, BRect source, BRect dest){ - printf("Calling DrawBitmap (not writen yet)\n"); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::DrawChar(char c, BPoint point){ - char string[2]; - string[0]=c; - string[1]='\0'; - DrawString(string,2,point); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::DrawString(char *string, int length, BPoint point){ - printf("DrawString is not writen yet\n"); - - // i would say that libtruetype would do some good herer -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern){ - printf("FillArc is not writen yet\n"); - StrokeArc(centerx,centery,xradius,yradius,angle,span,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillBezier(BPoint *points, uint8 *pattern){ - printf("FillBezier is not writen yet\n"); - StrokeBezier(points,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern){ - MidpointEllipse(centerx,centery,x_radius,y_radius,true,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillPolygon(int *x, int *y, int numpoints, bool is_closed){ - printf("FillPolygon is not writen yet\n"); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillRect(BRect rect, uint8 *pattern){ - if(fr){ - // usieng accelertated 2d file - union{ - uint8 bytes[4]; - uint32 word; - }c1; - - //printf("Accelerated Fill\n"); - fill_rect_params frp; - frp.left =(uint16) rect.left; - frp.top =(uint16) rect.top; - frp.right =(uint16) rect.right; - frp.bottom =(uint16) rect.bottom; - c1.bytes[0] = highcol.blue; - c1.bytes[1] = highcol.green; - c1.bytes[2] = highcol.red; - fr(et,c1.word,&frp,1); - }else{ - for(int32 i = 0;i < rect.Height()-1;i++){ - MovePenTo(BPoint(rect.left,rect.top+i)); - StrokeLine(BPoint(rect.right,rect.top+i),pattern); - //HorizLine(rect.left,rect.right,rect.top+i); // uses accel :P - } - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillRect(BRect rect, rgb_color col){ - rgb_color tmpc = highcol; - highcol = col; - FillRect(rect, NULL); - highcol = tmpc; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillRegion(BRegion *region){ - printf("RillRegion is not writen yet\n"); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern){ - printf("FillRoundRect is not writen yet\n"); - StrokeRoundRect(rect,xradius,yradius,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillShape(BShape *shape){ - printf("FillShape is not writen yet\n"); - StrokeShape(shape); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern){ - printf("FillTriangle is not writen yet\n"); - StrokeTriangle(first,second,third,rect,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color color){ - printf("FillTriangle is not writen yet\n"); - StrokeTriangle(first,second,third,rect,color); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::HideCursor(void){ - if(sc){ - sc(false); - cursor_visible = false; - }else{ - printf("Shoftware Hide Cursor\n"); - } -} - -/******************************************************* -* @description -*******************************************************/ -bool SecondDriver::IsCursorHidden(void){ - return cursor_visible; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::ObscureCursor(void){ - // Hides cursor until mouse is moved - HideCursor(); - show_on_move = true; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::MoveCursorTo(float x, float y){ - if(show_on_move){ - ShowCursor(); - } - if(mc){ - mc((short unsigned int)x,(short unsigned int)y); - }else{ - printf("Software move Cursor\n"); - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::MovePenTo(BPoint pt){ - penpos = pt; -} - -/******************************************************* -* @description -*******************************************************/ -BPoint SecondDriver::PenPosition(void){ - return penpos; -} - -/******************************************************* -* @description -*******************************************************/ -float SecondDriver::PenSize(void){ - return pensize; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetCursor(int32 value){ - printf("Setcursoer value?\n"); - // Uh what is this all about? -} - - - - -//0 - 1 = black -//0 - 0 = what -//1 - 0 = trans -//1 - 1 = invert - -// Pointy cursor -/*uint8 andMask[] = { - 63,255,15,255,131,255,128,127,192,31,192,31,224,63,224,63, - 224,31,240,15,243,7,255,131,255,193,255,224,255,240,255,248 -}; -uint8 xorMask[] = { - 192,0,176,0,76,0,67,128,32,96,32,32,16,64,16,64, - 16,32,11,16,12,136,0,68,0,34,0,17,0,9,0,7 -};*/ -// BeOS like cursor -uint8 andMask[] = { - 255,255,255,255,199,255,195,255,195,255,224,31,224,3,240,1, - 240,0,192,0,128,0,128,0,192,0,240,0,252,1,254,7 -}; -uint8 xorMask[] = { - 0,0,0,0,56,0,36,0,36,0,19,224,18,92,9,42, - 8,1,60,0,76,0,66,0,48,0,12,0,2,0,1,0 -}; - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetCursor(ServerCursor *cursor){ - printf("Setting cursor\n"); - current_cursor = cursor; -// uint8 *andMask; - // uint8 *xorMask; - if(scs){ -// scs(cursor->width,cursor->height,(short unsigned int)cursor->hotspot.x,(short unsigned int)cursor->hotspot.y,andMask,xorMask); - scs(16,16,3,3,andMask,xorMask); - }else{ - printf("Setting software cursor\n"); - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetPenSize(float size){ - pensize = size; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::SetPixel(int x, int y, uint8 *pattern){ - union{ - uint8 bytes[4]; - uint32 word; - }c1; - - c1.bytes[0] = highcol.blue; - c1.bytes[1] = highcol.green; - c1.bytes[2] = highcol.red; - c1.bytes[3] = highcol.alpha; - - *(bits + x + y*bpr) = c1.word; -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::ShowCursor(void){ - printf("\tShow Cursor\n"); - show_on_move = false; - cursor_visible = true; - if(sc){ - sc(true); - }else{ - printf("Software show cursor\n"); - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern){ - printf("StrokeArch is not writen yet\n"); -} - - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::StrokeBezier(BPoint *pts, uint8 *pattern){ - BPoint segment[SEGMENTS + 1]; - computeSegments(pts[0], pts[1],pts[2],pts[3], segment); - - MovePenTo(segment[0]); - - for(int32 s = 1 ; s <= SEGMENTS ; ++s ){ - if(segment[s].x != segment[s - 1].x || segment[s].y != segment[s - 1].y ) { - StrokeLine(segment[s],pattern); - } - } -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern){ - MidpointEllipse(centerx,centery,x_radius,y_radius,false,pattern); -} - -/******************************************************* -* @description -*******************************************************/ -void SecondDriver::StrokeLine(BPoint point, uint8 *pattern){ - if(penpos.y == point.y){ - HorizLine(penpos.x,point.x,point.y,pattern); - return; - } - - int oct = 0; - int xoff = (int32)penpos.x; - int yoff = (int32)penpos.y; - int32 x2 = (int32)point.x-xoff; - int32 y2 = (int32)point.y-yoff; - int32 x1 = 0; - int32 y1 = 0; -// if(y2==0){ if (x1>x2){int t=x1;x1=x2;x2=t;}HorizLine(x1+xoff,x2+xoff,y1+yoff); return;} - if(y2<0){ y2 = -y2; oct+=4; }//bit2=1 - if(x2<0){ x2 = -x2; oct+=2;}//bit1=1 - if(x2 x2){ int32 t=x1;x1=x2;x2=t; } - if(fr){ - union{ - uint8 bytes[4]; - uint32 word; - }c1; - - //printf("Accelerated HorizLine\n"); - uint16 list[3]; - list[0] = y; - list[1] = x1; - list[2] = x2; - c1.bytes[0] = highcol.blue; - c1.bytes[1] = highcol.green; - c1.bytes[2] = highcol.red; - fs(et,c1.word,list,1); - }else{ - //software hline - printf("\t!!HorizLine without HWaccel is a waist\n"); - for(int32 i = x1; i <= x2;i++){ - SetPixel(i,y,pattern); - } - } - -} - -//void EllipsePoints(float cx,float cy,int32 x, int32 y){ -// view->StrokeLine(BPoint(x+cent.x,y+cent.y),BPoint(x+cent.x,y+cent.y)); -// view->StrokeLine(BPoint(-x+cent.x,y+cent.y),BPoint(-x+cent.x,y+cent.y)); -// view->StrokeLine(BPoint(x+cent.x,-y+cent.y),BPoint(x+cent.x,-y+cent.y)); -// view->StrokeLine(BPoint(-x+cent.x,-y+cent.y),BPoint(-x+cent.x,-y+cent.y)); -#define EllipsePoints(cx,cy,x,y,pattern){ \ - SetPixel( x+cx, y+cx,pattern); \ - SetPixel(-x+cx, y+cx,pattern); \ - SetPixel( x+cx,-y+cx,pattern); \ - SetPixel(-x+cx,-y+cx,pattern); \ -} - - -//void EllipsePointsFill(BPoint cent,int32 x, int32 y,pattern){ -// view->StrokeLine(BPoint(-x+cent.x,y+cent.y),BPoint(x+cent.x,y+cent.y)); -// view->StrokeLine(BPoint(-x+cent.x,-y+cent.y),BPoint(x+cent.x,-y+cent.y)); - - #define EllipsePointsFill(cx,cy,x,y,pattern){ \ - HorizLine(-x+cx,x+cx, y+cy, pattern); \ - HorizLine(-x+cx,x+cx, -y+cy, pattern); \ -} - - -/******************************************************* -* -*******************************************************/ -void SecondDriver::MidpointEllipse(float centx,float centy,int32 xrad, int32 yrad,bool fill,uint8 *pattern){ - if(xrad < 0){ xrad = -xrad; } - if(yrad < 0){ yrad = -yrad; } - double d2; - int32 x = 0; - int32 y = yrad; - - int32 xradSqr = xrad*xrad; - int32 yradSqr = yrad*yrad; - - double dl = yradSqr - (xradSqr*yrad) + (0.25 *xradSqr); - - if(fill){ EllipsePointsFill(centx,centy,x,y,pattern); }else{ EllipsePoints(centx,centy,x,y,pattern); } - - // Test gradient if still in region 1 - while((xradSqr*(y-.5)) > (yradSqr*(x+1))){ - if(dl < 0){ // Select E - dl += yradSqr*(2*x + 3); - }else{ // Select SE - dl += yradSqr*(2*x + 3) + xradSqr*(-2*y + 2); - y--; - } - x++; - if(fill){ EllipsePointsFill(centx,centy,x,y,pattern); }else{ EllipsePoints(centx,centy,x,y,pattern); } - } - - d2 = (yradSqr*(x + .5)*(x + .5)) + (xradSqr*(y-1)*(y-1)) - xradSqr*yradSqr; - while(y > 0){ - if(d2 < 0){ // Select SE - d2 += yradSqr*(2*x + 2) + xradSqr*(-2*y + 3); - x++; - }else{ // Select E - d2 += xradSqr*(-2*y + 3); - } - y--; - if(fill){ EllipsePointsFill(centx,centy,x,y,pattern); }else{ EllipsePoints(centx,centy,x,y,pattern); } - } -} - - - -#ifdef DEBUG_DRIVER_MODULE -#undef DEBUG_DRIVER_MODULE -#endif diff --git a/src/servers/app/proto6/driverharness/SecondDriver.h b/src/servers/app/proto6/driverharness/SecondDriver.h deleted file mode 100644 index 68fd6fd3f9..0000000000 --- a/src/servers/app/proto6/driverharness/SecondDriver.h +++ /dev/null @@ -1,123 +0,0 @@ -#ifndef _SECDRIVER_H_ -#define _SECDRIVER_H_ - -#include -#include -#include -#include -#include // for pattern struct -#include -#include -#include "DisplayDriver.h" - -#include -#include -#include - -class BBitmap; -class PortLink; -class VDWindow; -class ServerCursor; - - -class SecondDriver:public DisplayDriver{ -public: - SecondDriver(void); - virtual ~SecondDriver(void); - - virtual void Initialize(void); // Sets the driver - virtual bool IsInitialized(void); - virtual void Shutdown(void); // You never know when you'll need this - - virtual void SafeMode(void); // Easy-access functions for common tasks - virtual void Reset(void); - virtual void Clear(uint8 red,uint8 green,uint8 blue); - virtual void Clear(rgb_color col); - - // Settings functions - virtual void SetScreen(uint32 space); - virtual int32 GetHeight(void); - virtual int32 GetWidth(void); - virtual int GetDepth(void); - - // Drawing functions - #ifdef PROTO_4 - virtual void Blit(BPoint loc, ServerBitmap *src, ServerBitmap *dest); - #else - virtual void Blit(BRect src, BRect dest); - #endif - virtual void DrawBitmap(ServerBitmap *bitmap, BRect source, BRect dest); - virtual void DrawChar(char c, BPoint point); - virtual void DrawString(char *string, int length, BPoint point); - - virtual void FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void FillBezier(BPoint *points, uint8 *pattern); - virtual void FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void FillPolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void FillRect(BRect rect, uint8 *pattern); - virtual void FillRect(BRect rect, rgb_color col); - virtual void FillRegion(BRegion *region); - virtual void FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void FillShape(BShape *shape); - virtual void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - virtual void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color color); - - virtual void HideCursor(void); - virtual bool IsCursorHidden(void); - virtual void MoveCursorTo(float x, float y); - virtual void MovePenTo(BPoint pt); - virtual void ObscureCursor(void); - virtual BPoint PenPosition(void); - virtual float PenSize(void); - virtual void SetCursor(int32 value); - virtual void SetCursor(ServerCursor *cursor); - virtual void SetPenSize(float size); - virtual void SetPixel(int x, int y, uint8 *pattern); - virtual void ShowCursor(void); - - virtual void StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - virtual void StrokeBezier(BPoint *points, uint8 *pattern); - virtual void StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - virtual void StrokeLine(BPoint point, uint8 *pattern); - virtual void StrokeLine(BPoint pt1, BPoint pt2, rgb_color col); - virtual void StrokePolygon(int *x, int *y, int numpoints, bool is_closed); - virtual void StrokeRect(BRect rect,uint8 *pattern); - virtual void StrokeRect(BRect rect,rgb_color col); - virtual void StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - virtual void StrokeShape(BShape *shape); - virtual void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - virtual void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color color); -private: - void HorizLine(int32 x1,int32 x2,int32 y, uint8 *pattern); - void MidpointEllipse(float centerx, float centery,int32 xrad, int32 yrad,bool fill,uint8 *pattern); -protected: - int hide_cursor; - - int fd; - image_id image; - GetAccelerantHook gah; - display_mode dm; - - frame_buffer_config fbc; - - uint32 *bits; - int32 bpr; - - set_cursor_shape scs; - move_cursor mc; - show_cursor sc; - - sync_token st; - engine_token *et; - release_engine re; - - screen_to_screen_blit s2sb; - fill_rectangle fr; - invert_rectangle ir; - screen_to_screen_transparent_blit s2stb; - fill_span fs; - - -}; - -#endif diff --git a/src/servers/app/proto6/driverharness/SecondDriverHelper.h b/src/servers/app/proto6/driverharness/SecondDriverHelper.h deleted file mode 100644 index ff3ee288d7..0000000000 --- a/src/servers/app/proto6/driverharness/SecondDriverHelper.h +++ /dev/null @@ -1,435 +0,0 @@ -/******************************************************* -* SecondDriver -* -* Helper methods for SecondDriver. This is where we -* put all the code that inits the real HW and -* seaches for the acceleration methods an all that -* other stuff. -* -* @author YNOP (ynop@beunited.org) -*******************************************************/ -#ifndef _SECDRIVER_HELPER_H_ -#define _SECDRIVER_HELPER_H_ - -//#include -#include -#include - -#include -#include -#include // has ioctl ?:P -//#include -#include - -#define DEV_GRAPHICS "/dev/graphics/" -#define ACCELERANTS_DIR "/accelerants/" -#define DEV_STUB "stub" - -/******************************************************* -* @description Loads the driver from settings ... -*******************************************************/ -int get_device(){ -// 102b_0519_001300 102b_051a_001400 stub - return open(DEV_GRAPHICS"102b_051a_001400", B_READ_WRITE); -// return -1; -} - -/******************************************************* -* @description Loads the stub driver - never fun -*******************************************************/ -int fallback_device(){ - return open(DEV_GRAPHICS DEV_STUB, B_READ_WRITE); -} - -/******************************************************* -* @description Find the first device that it can open -* in the /dev/graphics dir and returns it. -*******************************************************/ -int find_device(){ - DIR *d; - struct dirent *e; - char name_buf[1024]; - int fd = -1; - //bool foundfirst = false; // hacky way of finding second video card in your box - - printf("Probeing %s for device...\n",DEV_GRAPHICS); - - /* open directory apath */ - d = opendir(DEV_GRAPHICS); - if(!d){ return B_ERROR; } - while((e = readdir(d)) != NULL){ - if (!strcmp(e->d_name, ".") || !strcmp(e->d_name, "..") || !strcmp(e->d_name, "stub")){ - continue; - } - strcpy(name_buf, DEV_GRAPHICS); -// strcat(name_buf, "/"); - strcat(name_buf, e->d_name); - fd = open(name_buf, B_READ_WRITE); - ///printf("Opening device %s\n",name_buf); - if(fd >= 0){ - //printf("Open wend ok\n"); - /*if(!foundfirst){ - foundfirst = true; - printf("\tbut we are not going to use it as app_server is\n"); - }else{ - // found it :) - */ printf("\tOpened device %s\n",name_buf); - closedir(d); - return fd; - //} - }else{ - //foundfirst = true; // this is a proper find as the app_server should let us open the dev - printf("\tCouldn't open device %s\n",name_buf); - } - } - closedir(d); - return B_ERROR; -} - -/******************************************************* -* @description Finds and loads the Accelerant for -* this device -*******************************************************/ -image_id load_accelerant(int fd, GetAccelerantHook *hook) { - status_t result; - image_id image = -1; - char - signature[1024], - path[PATH_MAX]; - struct stat st; - const static directory_which vols[] = { - B_USER_ADDONS_DIRECTORY, - B_COMMON_ADDONS_DIRECTORY, - B_BEOS_ADDONS_DIRECTORY - }; - - /* get signature from driver */ - result = ioctl(fd, B_GET_ACCELERANT_SIGNATURE, &signature, sizeof(signature)); - if (result != B_OK){ - printf("Failed to get accelerant signature from drived!\n"); - return result; - } - - printf("Searching for Accelerant named \"%s\"\n",signature); - - // note failure by default - for(int32 i=0; i < (int32)(sizeof (vols) / sizeof (vols[0])); i++) { - //printf("attempting to get path for %ld (%d)\n", i, vols[i]); - if(find_directory(vols[i], -1, false, path, PATH_MAX) != B_OK) { - printf("warning: find directory failed (continueing)\n"); - continue; - } - - strcat (path, ACCELERANTS_DIR); - strcat (path, signature); - printf("\tTrying %s\n",path); - - // don't try to load non-existant files - if (stat(path, &st) != 0) continue; - - // try and load it up.. - image = load_add_on(path); - if (image >= 0) { - printf("\tAccelerant loaded - trying to init\n"); - // get entrypoint from accelerant - result = get_image_symbol(image, B_ACCELERANT_ENTRY_POINT, -#if defined(__INTEL__) - B_SYMBOL_TYPE_ANY, -#else - B_SYMBOL_TYPE_TEXT, -#endif - (void **)hook); - if (result == B_OK) { - init_accelerant ia; - ia = (init_accelerant)(*hook)(B_INIT_ACCELERANT, NULL); - if(ia && ((result = ia(fd)) == B_OK)) { - // we have a winner! - //printf("Accelerant %s \n", path); - printf("\tAccelerant Init() was B_OK\n"); - break; - } else { - printf("\tAccelerant Init() failed: %ld\n", result); - } - } else { - printf("\tCouldn't find the entry point :-(\n"); - } - // unload the accelerant, as we must be able to init! - unload_add_on(image); - } - if (image < 0) printf("\tLoad Image failure. ID: %.8lx (%s)\n", image, strerror(image)); - // mark failure to load image - image = -1; - } - - //printf("Add-on image id: %ld\n", image); - return image; -} - -/******************************************************* -* @description -*******************************************************/ -static const char *spaceToString(uint32 cs) { - const char *s; - switch (cs) { -#define s2s(a) case a: s = #a ; break - s2s(B_RGB32); - s2s(B_RGBA32); - s2s(B_RGB32_BIG); - s2s(B_RGBA32_BIG); - s2s(B_RGB16); - s2s(B_RGB16_BIG); - s2s(B_RGB15); - s2s(B_RGBA15); - s2s(B_RGB15_BIG); - s2s(B_RGBA15_BIG); - s2s(B_CMAP8); - s2s(B_GRAY8); - s2s(B_GRAY1); - s2s(B_YCbCr422); - s2s(B_YCbCr420); - s2s(B_YUV422); - s2s(B_YUV411); - s2s(B_YUV9); - s2s(B_YUV12); - default: - s = "unknown"; break; -#undef s2s - } - return s; -} - -/******************************************************* -* @description -*******************************************************/ -void dump_mode(display_mode *dm) { - display_timing *t = &(dm->timing); - printf(" pixel_clock: %ldKHz\n", t->pixel_clock); - printf(" H: %4d %4d %4d %4d\n", t->h_display, t->h_sync_start, t->h_sync_end, t->h_total); - printf(" V: %4d %4d %4d %4d\n", t->v_display, t->v_sync_start, t->v_sync_end, t->v_total); - printf(" timing flags:"); - if (t->flags & B_BLANK_PEDESTAL) printf(" B_BLANK_PEDESTAL"); - if (t->flags & B_TIMING_INTERLACED) printf(" B_TIMING_INTERLACED"); - if (t->flags & B_POSITIVE_HSYNC) printf(" B_POSITIVE_HSYNC"); - if (t->flags & B_POSITIVE_VSYNC) printf(" B_POSITIVE_VSYNC"); - if (t->flags & B_SYNC_ON_GREEN) printf(" B_SYNC_ON_GREEN"); - if (!t->flags) printf(" (none)\n"); - else printf("\n"); - printf(" refresh rate: %4.2f\n", ((double)t->pixel_clock * 1000) / ((double)t->h_total * (double)t->v_total)); - printf(" color space: %s\n", spaceToString(dm->space)); - printf(" virtual size: %dx%d\n", dm->virtual_width, dm->virtual_height); - printf("dispaly start: %d,%d\n", dm->h_display_start, dm->v_display_start); - - printf(" mode flags:"); - if (dm->flags & B_SCROLL) printf(" B_SCROLL"); - if (dm->flags & B_8_BIT_DAC) printf(" B_8_BIT_DAC"); - if (dm->flags & B_HARDWARE_CURSOR) printf(" B_HARDWARE_CURSOR"); - if (dm->flags & B_PARALLEL_ACCESS) printf(" B_PARALLEL_ACCESS"); -// if (dm->flags & B_SUPPORTS_OVERLAYS) printf(" B_SUPPORTS_OVERLAYS"); - if (!dm->flags) printf(" (none)\n"); - else printf("\n"); -} - -/******************************************************* -* @description -*******************************************************/ -void simple_dump_mode(display_mode *dm){ - //printf("H: %4d\n", t->h_display); - //printf("V: %4d\n", t->v_display); - display_timing *t = &(dm->timing); - printf("Virtual size: %d x %d\n", dm->virtual_width, dm->virtual_height); - printf("Color space: %s\n", spaceToString(dm->space)); - printf("Refresh rate: %4.2f\n", ((double)t->pixel_clock * 1000) / ((double)t->h_total * (double)t->v_total)); -} - -/******************************************************* -* @description -*******************************************************/ -void mode_from_settings(display_mode *dm){ - // display_timing *t = &(dm->timing); - dm->space = B_RGB32; - dm->virtual_width = 800; - dm->virtual_height = 600; - dm->h_display_start = 0; - dm->v_display_start = 0; -} - -/******************************************************* -* @description -*******************************************************/ -status_t get_and_set_mode(GetAccelerantHook gah, display_mode *dm) { - printf("Setting up display mode\n"); - accelerant_mode_count gmc; - uint32 mode_count; - get_mode_list gml; - display_mode *mode_list, target, high, low; - propose_display_mode pdm; - status_t result = B_ERROR; - set_display_mode sdm; - - /* find the propose mode hook */ - pdm = (propose_display_mode)gah(B_PROPOSE_DISPLAY_MODE, NULL); - if (!pdm) { - printf("No B_PROPOSE_DISPLAY_MODE\n"); - goto exit0; - } - /* and the set mode hook */ - sdm = (set_display_mode)gah(B_SET_DISPLAY_MODE, NULL); - if (!sdm) { - printf("No B_SET_DISPLAY_MODE\n"); - goto exit0; - } - - /* how many modes does the driver support */ - gmc = (accelerant_mode_count)gah(B_ACCELERANT_MODE_COUNT, NULL); - if (!gmc) { - printf("No B_ACCELERANT_MODE_COUNT\n"); - goto exit0; - } - mode_count = gmc(); - printf("\tDriver supports %lu differnat video modes\n", mode_count); - if (mode_count == 0) goto exit0; - - /* get a list of graphics modes from the driver */ - gml = (get_mode_list)gah(B_GET_MODE_LIST, NULL); - if (!gml) { - printf("No B_GET_MODE_LIST\n"); - goto exit0; - } - mode_list = (display_mode *)calloc(sizeof(display_mode), mode_count); - if (!mode_list) { - printf("Couldn't calloc() for mode list\n"); - goto exit0; - } - if (gml(mode_list) != B_OK) { - printf("mode list retrieval failed\n"); - goto free_mode_list; - } - - /* take the first mode in the list */ - //printf("\tPropose Display Mode\n------------------------\n"); - //simple_dump_mode(&mode_list[69]); - //mode_from_settings(&mode_list[69]); - target = mode_list[69]; - high = mode_list[69]; - low = mode_list[69]; - /* make as tall a virtual height as possible */ - //target.virtual_height = high.virtual_height = 0xffff; - // virtual hight should only be used if a res larger than - // the screen can handle - /* propose the display mode */ - if (pdm(&target, &low, &high) == B_ERROR) { - printf("propose_display_mode failed\n"); - goto free_mode_list; - } - printf("------Target display mode------\n"); - simple_dump_mode(&target); - printf("-------------------------------\n"); - /* we got a display mode, now set it */ - if (sdm(&target) == B_ERROR) { - printf("set display mode failed\n"); - goto free_mode_list; - } - /* note the mode and success */ - *dm = target; - result = B_OK; - -free_mode_list: - free(mode_list); -exit0: - return result; -} - - -/******************************************************* -* @description -*******************************************************/ -void get_frame_buffer(GetAccelerantHook gah, frame_buffer_config *fbc) { - get_frame_buffer_config gfbc; - gfbc = (get_frame_buffer_config)gah(B_GET_FRAME_BUFFER_CONFIG, NULL); - gfbc(fbc); -} - -/******************************************************* -* @description -*******************************************************/ -sem_id get_sem(GetAccelerantHook gah) { - accelerant_retrace_semaphore ars; - ars = (accelerant_retrace_semaphore)gah(B_ACCELERANT_RETRACE_SEMAPHORE, NULL); - return ars(); -} - -/******************************************************* -* @description -*******************************************************/ -void set_palette(GetAccelerantHook gah) { - set_indexed_colors sic; - sic = (set_indexed_colors)gah(B_SET_INDEXED_COLORS, NULL); - if (sic) { - /* booring grey ramp for now */ - uint8 map[3 * 256]; - uint8 *p = map; - int i; - for (i = 0; i < 256; i++) { - *p++ = i; - *p++ = i; - *p++ = i; - } - sic(256, 0, map, 0); - } -} - -// This is a ll the stuff needed to stroke a Bezier Curve.. -// Note that we should probably wait and alloc this data latter -// on when we stroke our first Curve. That way if no curve ever -// gets render (unlikely i know) then this space would be saved. -#define SEGMENTS 32 -#define Fixed float -static Fixed weight1[SEGMENTS + 1]; -static Fixed weight2[SEGMENTS + 1]; -#define w1(s) weight1[s] -#define w2(s) weight2[s] -#define w3(s) weight2[SEGMENTS - s] -#define w4(s) weight1[SEGMENTS - s] -#define FixMul(a,b) (a)*(b) -#define FixRound(a) ((a-int32(a))>=.5)?(int32(a)+1):(int32(a)) -#define FixRatio(a,b) ((a)/float(b)) - -/******************************************************* -* @description Creats the two Bernstien Pollynomials -* We only need to creat two becase the 1 & 4 are -* mirrors and the 2 & 3 are mirros. -*******************************************************/ -void SetupBezier(){ - Fixed t, zero, one; - int s; - zero = FixRatio(0, 1); - one = FixRatio(1, 1); - - weight1[0] = one; - weight2[0] = zero; - for(s = 1 ;s < SEGMENTS ;++s){ - t = FixRatio(s, SEGMENTS); - weight1[s] = FixMul(one - t, FixMul(one - t, one - t)); - weight2[s] = 3 * FixMul(t, FixMul(t - one, t - one)); - } - weight1[SEGMENTS] = zero; - weight2[SEGMENTS] = zero; -} - -/******************************************************* -* @description Useing the weights of the 4 bernstein -* pollynomials calc the segment endpoints. This is -* the real worker method -*******************************************************/ -static void computeSegments(BPoint p1,BPoint p2, BPoint p3, BPoint p4, BPoint *segment){ - int s; - segment[0] = p1; - for(s = 1;s < SEGMENTS;++s){ - segment[s].y = FixRound(w1(s) * p1.y + w2(s) * p2.y + w3(s) * p3.y + w4(s) * p4.y); - segment[s].x = FixRound(w1(s) * p1.x + w2(s) * p2.x + w3(s) * p3.x + w4(s) * p4.x); - } - segment[SEGMENTS] = p4; -} - -#endif - diff --git a/src/servers/app/proto6/driverharness/ServerBitmap.h b/src/servers/app/proto6/driverharness/ServerBitmap.h deleted file mode 100644 index 5452f05332..0000000000 --- a/src/servers/app/proto6/driverharness/ServerBitmap.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef _SERVER_BITMAP_H_ -#define _SERVER_BITMAP_H_ - -#include -#include -#include -#include "DisplayDriver.h" - -class ServerBitmap -{ -public: - ServerBitmap(BRect rect,color_space space,int32 BytesPerLine=0); - ServerBitmap(int32 w,int32 h,color_space space,int32 BytesPerLine=0); - ServerBitmap(int32 w,int32 h,color_space space, area_id areaID, int32 BytesPerLine=0); - ServerBitmap(void); - ServerBitmap(const char *path); - ~ServerBitmap(void); - void UpdateSettings(void); - void SetBuffer(void *buffer); - uint8 *Buffer(void); - void SetArea(area_id ID); - area_id Area(void); - uint32 BitsLength(void); - BRect Bounds() { return BRect(0,0,width-1,height-1); }; - int32 BytesPerRow(void) { return bytesperline; }; - - int32 width,height; - int32 bytesperline; - color_space cspace; - int bpp; - -protected: - void HandleSpace(color_space space, int32 BytesPerLine); - DisplayDriver *driver; - bool is_vram,is_area; - area_id areaid; - uint8 *buffer; -}; - -#endif diff --git a/src/servers/app/proto6/driverharness/ServerCursor.cpp b/src/servers/app/proto6/driverharness/ServerCursor.cpp deleted file mode 100644 index bb11e51760..0000000000 --- a/src/servers/app/proto6/driverharness/ServerCursor.cpp +++ /dev/null @@ -1,136 +0,0 @@ -/* - ServerCursor.cpp - This is the server-side class used to handle cursors. Note that it - will handle the R5 cursor API, but it will also handle taking a bitmap. - - ServerCursors are 32-bit. Eventually, we will be mapping colors to fit - when the set is called. - - This is new code, and there may be changes to the API before it settles - in. -*/ - -#include "ServerCursor.h" -#include "ServerBitmap.h" -#include -#include - -int8 default_cursor[]={ - 16,1,0,0, - - // data - 0xff, 0x80, 0x80, 0x80, 0x81, 0x00, 0x80, 0x80, 0x80, 0x40, 0x80, 0x80, 0x81, 0x00, 0xa2, 0x00, - 0xd4, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - - // mask - 0xff, 0x80, 0xff, 0x80, 0xff, 0x00, 0xff, 0x80, 0xff, 0xc0, 0xff, 0x80, 0xff, 0x00, 0xfe, 0x00, - 0xdc, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -long pow2(int power) -{ - if(power==0) - return 1; - return long(2 << (power-1)); -} - -ServerCursor::ServerCursor(void) -{ - // For when an application is started. This will probably disappear once I - // get the stuff for default cursors established - is_initialized=false; - position.Set(0,0); -} - -ServerCursor::ServerCursor(ServerBitmap *bmp, ServerBitmap *cmask=NULL) -{ - // The OpenBeOS R1 API uses Bitmaps to create cursors - more flexibility that way. - is_initialized=false; - position.Set(0,0); - SetCursor(bmp); -} - -ServerCursor::ServerCursor(int8 *data) -{ - // For handling the idiot R5 API data format - is_initialized=false; - position.Set(0,0); - SetCursor(data); -} - -ServerCursor::~ServerCursor(void) -{ - if(is_initialized) - delete bitmap; -} - -void ServerCursor::SetCursor(int8 *data) -{ - // 68-byte array used in R5 for holding cursors. - // This API has serious problems and should be deprecated(but supported) - // in a future release, perhaps right after the first one - - if(is_initialized) - { - delete bitmap; - } - cspace=B_RGBA32; - - bitmap=new ServerBitmap(16,16,B_RGBA32); - width=16; - height=16; - bounds.Set(0,0,15,15); - - // Now that we have all the setup, we're going to map (for now) the cursor - // to RGBA32. Eventually, there will be support for 16 and 8-bit depths - uint32 black=0xFF000000, - white=0xFFFFFFFF, - *bmppos; - uint16 *cursorpos, *maskpos,cursorflip, maskflip, - cursorval, maskval; - uint8 i,j; - - cursorpos=(uint16*)(data+4); - maskpos=(uint16*)(data+36); - - // for each row in the cursor data - for(j=0;j<16;j++) - { - bmppos=(uint32*)(bitmap->Buffer()+ (j*bitmap->bytesperline) ); - - // On intel, our bytes end up swapped, so we must swap them back - cursorflip=(cursorpos[j] & 0xFF) << 8; - cursorflip |= (cursorpos[j] & 0xFF00) >> 8; - maskflip=(maskpos[j] & 0xFF) << 8; - maskflip |= (maskpos[j] & 0xFF00) >> 8; - - // for each column in each row of cursor data - for(i=0;i<16;i++) - { - // Get the values and dump them to the bitmap - cursorval=cursorflip & pow2(15-i); - maskval=maskflip & pow2(15-i); - bmppos[i]=((cursorval!=0)?black:white) & ((maskval>0)?0xFFFFFFFF:0x00FFFFFF); - } - } -} - -// Currently unimplemented -void ServerCursor::SetCursor(ServerBitmap *bmp, ServerBitmap *cmask=NULL) -{ -/* if(is_initialized) - delete bitmap; - cspace=bmp->cspace; - - bitmap=new ServerBitmap(bmp->width,bmp->height,cspace); - - width=bmp->width; - height=bmp->height; - bounds.Set(0,0,bmp->width-1,bmp->height-1); -*/ -} - -void ServerCursor::MoveTo(int32 x, int32 y) -{ - position.Set(x,y); -} diff --git a/src/servers/app/proto6/driverharness/ServerCursor.h b/src/servers/app/proto6/driverharness/ServerCursor.h deleted file mode 100644 index b49352c2eb..0000000000 --- a/src/servers/app/proto6/driverharness/ServerCursor.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _SERVER_SPRITE_H -#define _SERVER_SPRITE_H - -#include -#include - -class ServerBitmap; - -class ServerCursor -{ -public: - ServerCursor(ServerBitmap *bmp,ServerBitmap *cmask=NULL); - ServerCursor(int8 *data); - ServerCursor(void); - ~ServerCursor(void); - void MoveTo(int32 x, int32 y); - void SetCursor(int8 *data); - void SetCursor(ServerBitmap *bmp, ServerBitmap *cmask=NULL); - - ServerBitmap *bitmap; - - color_space cspace; - BRect bounds; - int width,height; - BPoint position,hotspot; - bool is_initialized; -}; - -extern int8 default_cursor[]; - -#endif diff --git a/src/servers/app/proto6/driverharness/ServerProtocol.h b/src/servers/app/proto6/driverharness/ServerProtocol.h deleted file mode 100644 index 5ec43dc441..0000000000 --- a/src/servers/app/proto6/driverharness/ServerProtocol.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef _APPSERVER_PROTOCOL_ -#define _APPSERVER_PROTOCOL_ - -#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' - -#define SERVER_PORT_NAME "OBappserver" -#define SERVER_INPUT_PORT "OBinputport" - -#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 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' - -#define GFX_SET_HIGH_COLOR 'gshc' -#define GFX_SET_LOW_COLOR 'gslc' -#define GFX_SET_VIEW_COLOR 'gsvc' - -#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' - -#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' - -#define GFX_MOVEPENBY 'gmpb' -#define GFX_MOVEPENTO 'gmpt' -#define GFX_SETPENSIZE 'gsps' - -#define GFX_DRAW_STRING 'gdst' -#define GFX_SET_FONT 'gsft' -#define GFX_SET_FONT_SIZE 'gsfs' - -#define GFX_FLUSH 'gfsh' -#define GFX_SYNC 'gsyn' - -#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 BEGIN_RECT_TRACKING 'rtbg' -#define END_RECT_TRACKING 'rten' - -#define VIEW_GET_TOKEN 'vgtk' -#define VIEW_ADD 'vadd' -#define VIEW_REMOVE 'vrem' -#endif diff --git a/src/servers/app/proto6/driverharness/SystemPalette.cpp b/src/servers/app/proto6/driverharness/SystemPalette.cpp deleted file mode 100644 index dc3fdcd40f..0000000000 --- a/src/servers/app/proto6/driverharness/SystemPalette.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/* - SystemPalette.cpp - One global function to generate the palette which is the default BeOS - System palette and the variable to go with it -*/ - -#include "SystemPalette.h" - -rgb_color system_palette[256]; - -void GenerateSystemPalette(rgb_color *palette) -{ - int i,j,index=0; - int indexvals1[]={ 255,229,204,179,154,129,105,80,55,30 }, - indexvals2[]={ 255,203,152,102,51,0 }; - rgb_color *currentcol; - - // Grays 0,0,0 -> 248,248,248 by 8's - for(i=0; i<=248; i+=8,index++) - { - currentcol=&(palette[index]); - currentcol->red=i; - currentcol->green=i; - currentcol->blue=i; - currentcol->alpha=255; - } - - // Blues, following indexvals1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=0; - currentcol->blue=indexvals1[i]; - currentcol->alpha=255; - } - - // Reds, following indexvals1 - 1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals1[i] - 1; - currentcol->green=0; - currentcol->blue=0; - currentcol->alpha=255; - } - - // Greens, following indexvals1 - 1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=indexvals1[i] - 1; - currentcol->blue=0; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=152; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=255; - currentcol->blue=255; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=0;i<4;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=152; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=0; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=255; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=203; - index++; - - // Mostly array runs from here on out - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=203; - currentcol->green=203; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=152; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=102; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=51; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=152; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=102; - index++; - - // knocks out 4 assignment loops at once :) - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=152; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - currentcol+=sizeof(rgb_color); - currentcol->red=230; - currentcol->green=134; - currentcol->blue=0; - index++; - - for(i=1;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=0; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=102; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=175; - currentcol->blue=19; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=255; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=203; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=3;i>=0;i--,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - for(i=2;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - for(i=0;i<5;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=203; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=227; - currentcol->blue=70; - index++; - - for(j=2;j<6;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=0; - index++; - - for(i=5;i<=0;i--,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - -} diff --git a/src/servers/app/proto6/driverharness/SystemPalette.h b/src/servers/app/proto6/driverharness/SystemPalette.h deleted file mode 100644 index 18f1d4542e..0000000000 --- a/src/servers/app/proto6/driverharness/SystemPalette.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _SYSTEM_PALETTE_H_ -#define _SYSTEM_PALETTE_H_ - -#include - -void GenerateSystemPalette(rgb_color *palette); -extern rgb_color system_palette[]; - -#endif diff --git a/src/servers/app/proto6/driverharness/ViewDriver.cpp b/src/servers/app/proto6/driverharness/ViewDriver.cpp deleted file mode 100644 index 584e344f6c..0000000000 --- a/src/servers/app/proto6/driverharness/ViewDriver.cpp +++ /dev/null @@ -1,1080 +0,0 @@ -/* - ViewDriver: - First, slowest, and easiest driver class in the app_server which is designed - to utilize the BeOS graphics functions to cut out a lot of junk in getting the - drawing infrastructure in this server. - - The concept is to have VDView::Draw() draw a bitmap, which is a "frame buffer" - of sorts, utilize a second view to write to it. This cuts out - the most problems with having a crapload of code to get just right without - having to write a bunch of unit tests - - Components: 3 classes, VDView, VDWindow, and ViewDriver - - ViewDriver - a wrapper class which mostly posts messages to the VDWindow - VDWindow - does most of the work. - VDView - doesn't do all that much except display the rendered bitmap -*/ - -#define DEBUG_DRIVER_MODULE -//#define DEBUG_SERVER_EMU - -//#define DISABLE_SERVER_EMU - -#include -#include -#include -#include -#include -#include -#include -#include "PortLink.h" -#include "ServerProtocol.h" -#include "ServerBitmap.h" -#include "ViewDriver.h" -#include "ServerCursor.h" -#include "DebugTools.h" - -enum -{ -VDWIN_CLEAR=100, - -VDWIN_SHOWCURSOR, -VDWIN_HIDECURSOR, -VDWIN_OBSCURECURSOR, -VDWIN_MOVECURSOR, -VDWIN_SETCURSOR, -}; - -ViewDriver *viewdriver_global; - -VDView::VDView(BRect bounds) - : BView(bounds,"viewdriver_view",B_FOLLOW_ALL, B_WILL_DRAW) -{ - viewbmp=new BBitmap(bounds,B_RGB32,true); - - // This link for sending mouse messages to the OBAppServer. - // This is only to take the place of the Input Server. I suppose I could write - // an addon filter to be more like the Input Server, but then I wouldn't be working - // on this thing! :P - serverlink=new PortLink(find_port(SERVER_INPUT_PORT)); - -#ifdef DEBUG_DRIVER_MODULE - printf("VDView: app_server input port: %ld\n",serverlink->GetPort()); -#endif - - // Create a cursor which isn't just a box - cursor=new BBitmap(BRect(0,0,20,20),B_RGBA32,true); - BView *v=new BView(cursor->Bounds(),"v", B_FOLLOW_NONE, B_WILL_DRAW); - hide_cursor=0; - - cursor->Lock(); - cursor->AddChild(v); - - v->SetHighColor(255,255,255,0); - v->FillRect(cursor->Bounds()); - v->SetHighColor(255,0,0,255); - v->FillTriangle(cursor->Bounds().LeftTop(),cursor->Bounds().RightTop(),cursor->Bounds().LeftBottom()); - - cursor->RemoveChild(v); - cursor->Unlock(); - - cursorframe=cursor->Bounds(); - oldcursorframe=cursor->Bounds(); -} - -VDView::~VDView(void) -{ - delete serverlink; - delete viewbmp; - delete cursor; -} - -void VDView::AttachedToWindow(void) -{ -} - -void VDView::Draw(BRect rect) -{ - if(viewbmp) - { - DrawBitmapAsync(viewbmp,oldcursorframe,oldcursorframe); - DrawBitmapAsync(viewbmp,rect,rect); - - if(hide_cursor==0 && obscure_cursor==false) - { - SetDrawingMode(B_OP_ALPHA); - DrawBitmapAsync(cursor,cursor->Bounds(),cursorframe); - SetDrawingMode(B_OP_COPY); - } - Sync(); - } -} - -// These functions emulate the Input Server by sending the *exact* same kind of messages -// to the server's port. Being we're using a regular window, it would make little sense -// to do anything else. - -void VDView::MouseDown(BPoint pt) -{ -#ifdef DEBUG_SERVER_EMU -printf("ViewDriver::MouseDown\t"); -#endif - // 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 -#ifndef DISABLE_SERVER_EMU - BPoint p; - - uint32 buttons, - mod=modifiers(), - clicks=1; // can't get the # of clicks without a *lot* of extra work :( - - int64 time=(int64)real_time_clock(); - - GetMouse(&p,&buttons); - - serverlink->SetOpCode(B_MOUSE_DOWN); - serverlink->Attach(&time, sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - serverlink->Attach(&mod, sizeof(uint32)); - serverlink->Attach(&buttons, sizeof(uint32)); - serverlink->Attach(&clicks, sizeof(uint32)); - serverlink->Flush(); -#endif -} - -void VDView::MouseMoved(BPoint pt, uint32 transit, const BMessage *msg) -{ - // Attach 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 -#ifndef DISABLE_SERVER_EMU - BPoint p; - uint32 buttons; - int64 time=(int64)real_time_clock(); - - serverlink->SetOpCode(B_MOUSE_MOVED); - serverlink->Attach(&time,sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - GetMouse(&p,&buttons); - serverlink->Attach(&buttons,sizeof(int32)); - serverlink->Flush(); -#endif -} - -void VDView::MouseUp(BPoint pt) -{ -#ifdef DEBUG_SERVER_EMU -printf("ViewDriver::MouseUp\t"); -#endif - // 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 -#ifndef DISABLE_SERVER_EMU - BPoint p; - - uint32 buttons, - mod=modifiers(); - - int64 time=(int64)real_time_clock(); - - GetMouse(&p,&buttons); - - serverlink->SetOpCode(B_MOUSE_UP); - serverlink->Attach(&time, sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - serverlink->Attach(&mod, sizeof(uint32)); - serverlink->Flush(); -#endif -} - -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- - -VDWindow::VDWindow(void) - : BWindow(BRect(100,60,740,540),"OBOS App Server, P6",B_TITLED_WINDOW, - B_NOT_ZOOMABLE | B_NOT_RESIZABLE) -{ - view=new VDView(Bounds()); - AddChild(view); -} - -VDWindow::~VDWindow(void) -{ -} - -void VDWindow::MessageReceived(BMessage *msg) -{ - switch(msg->what) - { - case VDWIN_SHOWCURSOR: - { - if(view->hide_cursor>0) - { - view->hide_cursor--; -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: ShowCursor() - still hidden\n"); -#endif - } - if(view->hide_cursor==0) - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: ShowCursor() - cursor shown\n"); -#endif - view->Invalidate(view->cursorframe); - } - break; - } - case VDWIN_HIDECURSOR: - { - view->hide_cursor++; -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: HideCursor()\n"); -#endif - if(view->hide_cursor==1) - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: HideCursor() - cursor was hidden\n"); -#endif - view->Invalidate(view->cursorframe); - } - break; - } - case VDWIN_OBSCURECURSOR: - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: ObscureCursor()\n"); -#endif - view->obscure_cursor=true; - view->Invalidate(view->cursorframe); - break; - } - case VDWIN_MOVECURSOR: - { - float x,y; - msg->FindFloat("x",&x); - msg->FindFloat("y",&y); - - // this was changed because an extra message was - // sent even though the mouse was never moved - if(view->cursorframe.left!=x || view->cursorframe.top!=y) - { - if(view->obscure_cursor) - view->obscure_cursor=false; - - view->oldcursorframe=view->cursorframe; - view->cursorframe.OffsetTo(x,y); - } - - if(view->hide_cursor==0) - view->Invalidate(view->oldcursorframe); - break; - } - case VDWIN_SETCURSOR: - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: SetCursor()\n"); -#endif - ServerCursor *cdata; - msg->FindPointer("SCursor",(void**)&cdata); - - if(cdata!=NULL) - { - BBitmap *bmp=new BBitmap(BRect(0,0,cdata->width-1,cdata->height-1), - cdata->cspace); - - // Copy the server bitmap in the cursor to a BBitmap - uint8 *sbmppos=(uint8*)cdata->bitmap->Buffer(), - *bbmppos=(uint8*)bmp->Bits(); - - int32 bytes=cdata->bitmap->bytesperline, - bbytes=bmp->BytesPerRow(); - - for(int i=0;iheight;i++) - memcpy(bbmppos+(i*bbytes), sbmppos+(i*bytes), bytes); - - // Replace the bitmap - delete view->cursor; - view->cursor=bmp; - view->Invalidate(view->cursorframe); - break; - } - break; - } - default: - BWindow::MessageReceived(msg); - break; - } -} - -bool VDWindow::QuitRequested(void) -{ - port_id serverport=find_port(SERVER_PORT_NAME); - - if(serverport!=B_NAME_NOT_FOUND) - write_port(serverport,B_QUIT_REQUESTED,NULL,0); - - return true; -} - -void VDWindow::WindowActivated(bool active) -{ - // This is just to hide the regular system cursor so we can see our own - if(active) - be_app->HideCursor(); - else - be_app->ShowCursor(); -} - -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- - -ViewDriver::ViewDriver(void) -{ - viewdriver_global=this; - screenwin=new VDWindow(); - framebuffer=screenwin->view->viewbmp; - serverlink=screenwin->view->serverlink; - hide_cursor=0; -} - -ViewDriver::~ViewDriver(void) -{ - if(is_initialized) - { - screenwin->Lock(); - screenwin->Quit(); - } -} - -void ViewDriver::Initialize(void) -{ - drawview=new BView(framebuffer->Bounds(),"drawview",B_FOLLOW_ALL, B_WILL_DRAW); - framebuffer->AddChild(drawview); - - hide_cursor=0; - obscure_cursor=false; - - SetPenSize(1.0); - MovePenTo(BPoint(0,0)); - is_initialized=true; - - // We can afford to call the above functions without locking - // because the window is locked until Show() is first called - screenwin->Show(); -} - -void ViewDriver::Shutdown(void) -{ - locker->Lock(); - is_initialized=false; - locker->Unlock(); -} - -bool ViewDriver::IsInitialized(void) -{ - return is_initialized; -} - -void ViewDriver::SafeMode(void) -{ - SetScreen(B_8_BIT_640x480); -} - -void ViewDriver::Reset(void) -{ - SafeMode(); - Clear(255,255,255); -} - -void ViewDriver::SetScreen(uint32 space) -{ - screenwin->Lock(); - int16 w=640,h=480; - color_space s; - - switch(space) - { - case B_32_BIT_800x600: - case B_16_BIT_800x600: - case B_8_BIT_800x600: - { - w=800; h=600; - break; - } - case B_32_BIT_1024x768: - case B_16_BIT_1024x768: - case B_8_BIT_1024x768: - { - w=1024; h=768; - break; - } - default: - break; - } - screenwin->ResizeTo(w-1,h-1); - - switch(space) - { - case B_32_BIT_640x480: - case B_32_BIT_800x600: - case B_32_BIT_1024x768: - s=B_RGBA32; - break; - case B_16_BIT_640x480: - case B_16_BIT_800x600: - case B_16_BIT_1024x768: - s=B_RGBA15; - break; - case B_8_BIT_640x480: - case B_8_BIT_800x600: - case B_8_BIT_1024x768: - s=B_CMAP8; - break; - default: - break; - } - - - delete framebuffer; - - screenwin->view->viewbmp=new BBitmap(BRect(0,0,w-1,h-1),s,true); - framebuffer=screenwin->view->viewbmp; - drawview=new BView(framebuffer->Bounds(),"drawview",B_FOLLOW_ALL, B_WILL_DRAW); - framebuffer->AddChild(drawview); - - screenwin->Unlock(); -} - -void ViewDriver::Clear(uint8 red, uint8 green, uint8 blue) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(red,green,blue); - drawview->FillRect(drawview->Bounds()); - drawview->Sync(); - screenwin->view->Invalidate(); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::Clear(rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(col); - drawview->FillRect(drawview->Bounds()); - drawview->Sync(); - screenwin->view->Invalidate(); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -int32 ViewDriver::GetHeight(void) -{ - screenwin->Lock(); - int32 h=framebuffer->Bounds().IntegerHeight(); - screenwin->Unlock(); - - return h; -} - -int32 ViewDriver::GetWidth(void) -{ - screenwin->Lock(); - int32 w=framebuffer->Bounds().IntegerWidth(); - screenwin->Unlock(); - - return w; -} - -int ViewDriver::GetDepth(void) -{ - return 0; -} - -void ViewDriver::AddLine(BPoint pt1, BPoint pt2, rgb_color col) -{ - drawview->AddLine(pt1,pt2,col); - laregion.Include(BRect(pt1,pt2)); -} - -void ViewDriver::BeginLineArray(int32 count) -{ - // NOTE: the unlocking is done in EndLineArray()! - screenwin->Lock(); - framebuffer->Lock(); - laregion.MakeEmpty(); - drawview->BeginLineArray(count); -} - -void ViewDriver::Blit(BRect src, BRect dest) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->CopyBits(src,dest); - drawview->Sync(); - screenwin->view->Invalidate(dest); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::DrawBitmap(ServerBitmap *bitmap) -{ -} - -void ViewDriver::DrawLineArray(int32 count,BPoint *start, BPoint *end, rgb_color *color) -{ - screenwin->Lock(); - framebuffer->Lock(); - - BRegion invalid; - drawview->BeginLineArray(count+1); - for(int32 i=0;iAddLine(start[i],end[i],color[i]); - invalid.Include(BRect(start[i],end[i])); - } - drawview->EndLineArray(); - drawview->Sync(); - screenwin->view->Invalidate(invalid.Frame()); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::DrawChar(char c, BPoint point) -{ - char string[2]; - string[0]=c; - string[1]='\0'; - DrawString(string,2,point); -} - -void ViewDriver::DrawString(char *string, int length, BPoint point) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->DrawString(string,length,point); - font_height fheight; - drawview->GetFontHeight(&fheight); - BRect invalid(point,BPoint(point.x+drawview->StringWidth(string,length), - fheight.ascent+5)); - drawview->Sync(); - screenwin->view->Invalidate(invalid); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::EndLineArray(void) -{ - // NOTE: the locking is done in BeginLineArray()! - drawview->EndLineArray(); - drawview->Sync(); - screenwin->view->Invalidate(laregion.Frame()); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->FillArc(BPoint(centerx,centery),xradius,yradius,angle,span,*((pattern*)pat)); - else - drawview->FillArc(BPoint(centerx,centery),xradius,yradius,angle,span); - drawview->Sync(); - screenwin->view->Invalidate(BRect(centerx-xradius,centery-yradius, - centerx+xradius,centery+yradius)); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillBezier(BPoint *points, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->FillBezier(points,*((pattern*)pat)); - else - drawview->FillBezier(points); - drawview->Sync(); - - // Invalidate the whole view until I get around to adding in the invalid rect calc code - screenwin->view->Invalidate(); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->FillEllipse(BPoint(centerx,centery),x_radius,y_radius,*((pattern*)pat)); - else - drawview->FillEllipse(BPoint(centerx,centery),x_radius,y_radius); - drawview->Sync(); - screenwin->view->Invalidate(BRect(centerx-x_radius,centery-y_radius, - centerx+x_radius,centery+y_radius)); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillPolygon(int *x, int *y, int numpoints, bool is_closed) -{ -} - -void ViewDriver::FillRect(BRect rect, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->FillRect(rect,*((pattern*)pat)); - else - drawview->FillRect(rect); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillRect(BRect rect, rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(col); - drawview->FillRect(rect); - drawview->SetHighColor(highcolor); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillRegion(BRegion *region) -{ -} - -void ViewDriver::FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->FillRoundRect(rect,xradius,yradius,*((pattern*)pat)); - else - drawview->FillRoundRect(rect,xradius,yradius); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillShape(BShape *shape) -{ -} - -void ViewDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->FillTriangle(first,second,third,rect,*((pattern*)pat)); - else - drawview->FillTriangle(first,second,third,rect); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(col); - drawview->FillTriangle(first,second,third,rect); - drawview->SetHighColor(highcolor); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::HideCursor(void) -{ - screenwin->Lock(); - locker->Lock(); - - hide_cursor++; - screenwin->PostMessage(VDWIN_HIDECURSOR); - - locker->Unlock(); - screenwin->Unlock(); - -} - -bool ViewDriver::IsCursorHidden(void) -{ - screenwin->Lock(); - bool value=(hide_cursor>0)?true:false; - screenwin->Unlock(); - return value; -} - -void ViewDriver::ObscureCursor(void) -{ - screenwin->Lock(); - screenwin->PostMessage(VDWIN_OBSCURECURSOR); - screenwin->Unlock(); -} - -void ViewDriver::MoveCursorTo(float x, float y) -{ - screenwin->Lock(); - BMessage *msg=new BMessage(VDWIN_MOVECURSOR); - msg->AddFloat("x",x); - msg->AddFloat("y",y); - screenwin->PostMessage(msg); - screenwin->Unlock(); -} - -void ViewDriver::MovePenTo(BPoint pt) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->MovePenTo(pt); - penpos=pt; - framebuffer->Unlock(); - screenwin->Unlock(); -} - -BPoint ViewDriver::PenPosition(void) -{ - return penpos; -} - -float ViewDriver::PenSize(void) -{ - return pensize; -} - -void ViewDriver::SetCursor(ServerCursor *cursor) -{ - if(cursor!=NULL) - { - screenwin->Lock(); - BBitmap *bmp=new BBitmap(BRect(0,0,cursor->width-1,cursor->height-1), - cursor->cspace); - - // Copy the server bitmap in the cursor to a BBitmap - uint8 *sbmppos=(uint8*)cursor->bitmap->Buffer(), - *bbmppos=(uint8*)bmp->Bits(); - - int32 bytes=cursor->bitmap->bytesperline, - bbytes=bmp->BytesPerRow(); - - for(int i=0;iheight;i++) - memcpy(bbmppos+(i*bbytes), sbmppos+(i*bytes), bytes); - - // Replace the bitmap - delete screenwin->view->cursor; - screenwin->view->cursor=bmp; - screenwin->view->Invalidate(screenwin->view->cursorframe); - screenwin->Unlock(); - } -} - -void ViewDriver::SetPenSize(float size) -{ - screenwin->Lock(); - framebuffer->Lock(); - pensize=size; - drawview->SetPenSize(size); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(r,g,b,a); - highcolor.red=r; - highcolor.green=g; - highcolor.blue=b; - highcolor.alpha=a; - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::SetHighColor(rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(col); - highcolor=col; - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetLowColor(r,g,b,a); - lowcolor.red=r; - lowcolor.green=g; - lowcolor.blue=b; - lowcolor.alpha=a; - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::SetLowColor(rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetLowColor(col); - lowcolor=col; - framebuffer->Unlock(); - screenwin->Unlock(); -} - -drawing_mode ViewDriver::GetDrawingMode(void) -{ - drawing_mode dm; - - screenwin->Lock(); - framebuffer->Lock(); - dm=drawview->DrawingMode(); - framebuffer->Unlock(); - screenwin->Unlock(); - return dm; -} - -void ViewDriver::SetDrawingMode(drawing_mode dmode) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetDrawingMode(dmode); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::SetPixel(int x, int y, uint8 *pattern) -{ -} - -void ViewDriver::ShowCursor(void) -{ - screenwin->Lock(); - if(hide_cursor>0) - { - hide_cursor--; - screenwin->PostMessage(VDWIN_SHOWCURSOR); - } - screenwin->Unlock(); -} - -float ViewDriver::StringWidth(const char *string, int32 length) -{ - return drawview->StringWidth(string,length); -} - -void ViewDriver::StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->StrokeArc(BPoint(centerx,centery),xradius,yradius,angle,span,*((pattern*)pat)); - else - drawview->StrokeArc(BPoint(centerx,centery),xradius,yradius,angle,span); - drawview->Sync(); - screenwin->view->Invalidate(BRect(centerx-xradius,centery-yradius, - centerx+xradius,centery+yradius)); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeBezier(BPoint *points, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->StrokeBezier(points,*((pattern*)pat)); - else - drawview->StrokeBezier(points); - drawview->Sync(); - - // Invalidate the whole view until I get around to adding in the invalid rect calc code - screenwin->view->Invalidate(); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->StrokeEllipse(BPoint(centerx,centery),x_radius,y_radius,*((pattern*)pat)); - else - drawview->StrokeEllipse(BPoint(centerx,centery),x_radius,y_radius); - drawview->Sync(); - screenwin->view->Invalidate(BRect(centerx-x_radius,centery-y_radius, - centerx+x_radius,centery+y_radius)); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeLine(BPoint point, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->StrokeLine(point,*((pattern*)pat)); - else - drawview->StrokeLine(point); - drawview->Sync(); - screenwin->view->Invalidate(BRect(penpos,point)); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeLine(BPoint pt1, BPoint pt2, rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(col); - drawview->StrokeLine(pt1,pt2); - drawview->SetHighColor(highcolor); - drawview->Sync(); - screenwin->view->Invalidate(BRect(pt1,pt2)); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokePolygon(int *x, int *y, int numpoints, bool is_closed) -{ - screenwin->Lock(); - framebuffer->Lock(); - - BRegion invalid; - - drawview->BeginLineArray(numpoints+2); - BPoint start,end; - for(int i=1;iAddLine(start,end,highcolor); - invalid.Include(BRect(start,end)); - } - - if(is_closed) - { - start.Set(x[numpoints-1],y[numpoints-1]); - end.Set(x[0],y[0]); - drawview->AddLine(start,end,highcolor); - invalid.Include(BRect(start,end)); - } - drawview->EndLineArray(); - - drawview->Sync(); - screenwin->view->Invalidate(invalid.Frame()); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeRect(BRect rect, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->StrokeRect(rect,*((pattern*)pat)); - else - drawview->StrokeRect(rect); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeRect(BRect rect, rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(col); - drawview->StrokeRect(rect); - drawview->SetHighColor(highcolor); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->StrokeRoundRect(rect,xradius,yradius,*((pattern*)pat)); - else - drawview->StrokeRoundRect(rect,xradius,yradius); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeShape(BShape *shape) -{ -} - -void ViewDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pat) -{ - screenwin->Lock(); - framebuffer->Lock(); - if(pat!=NULL) - drawview->StrokeTriangle(first,second,third,rect,*((pattern*)pat)); - else - drawview->StrokeTriangle(first,second,third,rect); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col) -{ - screenwin->Lock(); - framebuffer->Lock(); - drawview->SetHighColor(col); - drawview->StrokeTriangle(first,second,third,rect); - drawview->SetHighColor(highcolor); - drawview->Sync(); - screenwin->view->Invalidate(rect); - framebuffer->Unlock(); - screenwin->Unlock(); -} diff --git a/src/servers/app/proto6/driverharness/ViewDriver.h b/src/servers/app/proto6/driverharness/ViewDriver.h deleted file mode 100644 index 88202e8486..0000000000 --- a/src/servers/app/proto6/driverharness/ViewDriver.h +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef _VIEWDRIVER_H_ -#define _VIEWDRIVER_H_ - -#include -#include -#include -#include -#include // for pattern struct -#include -#include -#include -#include "DisplayDriver.h" - -class BBitmap; -class PortLink; -class VDWindow; -class ServerCursor; - -class VDView : public BView -{ -public: - VDView(BRect bounds); - ~VDView(void); - void AttachedToWindow(void); - void Draw(BRect rect); - void MouseDown(BPoint pt); - void MouseMoved(BPoint pt, uint32 transit, const BMessage *msg); - void MouseUp(BPoint pt); - - BBitmap *viewbmp; - PortLink *serverlink; - - int hide_cursor; - BBitmap *cursor; - - BRect cursorframe, oldcursorframe; - bool obscure_cursor; -}; - -class VDWindow : public BWindow -{ -public: - VDWindow(void); - ~VDWindow(void); - void MessageReceived(BMessage *msg); - bool QuitRequested(void); - void WindowActivated(bool active); - - VDView *view; -}; - -class ViewDriver : public DisplayDriver -{ -public: - ViewDriver(void); - ~ViewDriver(void); - - void Initialize(void); // Sets the driver - bool IsInitialized(void); - void Shutdown(void); // You never know when you'll need this - - void SafeMode(void); // Easy-access functions for common tasks - void Reset(void); - void Clear(uint8 red,uint8 green,uint8 blue); - void Clear(rgb_color col); - - // Settings functions - void SetScreen(uint32 space); - int32 GetHeight(void); - int32 GetWidth(void); - int GetDepth(void); - - // Drawing functions - void AddLine(BPoint pt1, BPoint pt2, rgb_color col); - void BeginLineArray(int32 count); - void Blit(BRect src, BRect dest); - void DrawBitmap(ServerBitmap *bitmap); - void DrawLineArray(int32 count,BPoint *start, BPoint *end, rgb_color *color); - void DrawChar(char c, BPoint point); - void DrawString(char *string, int length, BPoint point); - void EndLineArray(void); - - void FillArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - void FillBezier(BPoint *points, uint8 *pattern); - void FillEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - void FillPolygon(int *x, int *y, int numpoints, bool is_closed); - void FillRect(BRect rect, uint8 *pattern); - void FillRect(BRect rect, rgb_color col); - void FillRegion(BRegion *region); - void FillRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - void FillShape(BShape *shape); - void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - void FillTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col); - - void HideCursor(void); - bool IsCursorHidden(void); - void MoveCursorTo(float x, float y); - void MovePenTo(BPoint pt); - void ObscureCursor(void); - BPoint PenPosition(void); - float PenSize(void); - void SetCursor(ServerCursor *cursor); - drawing_mode GetDrawingMode(void); - void SetDrawingMode(drawing_mode mode); - void SetHighColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - void SetHighColor(rgb_color col); - void SetLowColor(uint8 r,uint8 g,uint8 b,uint8 a=255); - void SetLowColor(rgb_color col); - void SetPenSize(float size); - void SetPixel(int x, int y, uint8 *pattern); - void ShowCursor(void); - - float StringWidth(const char *string, int32 length); - void StrokeArc(int centerx, int centery, int xradius, int yradius, float angle, float span, uint8 *pattern); - void StrokeBezier(BPoint *points, uint8 *pattern); - void StrokeEllipse(float centerx, float centery, float x_radius, float y_radius,uint8 *pattern); - void StrokeLine(BPoint point, uint8 *pattern); - void StrokeLine(BPoint pt1, BPoint pt2, rgb_color col); - void StrokePolygon(int *x, int *y, int numpoints, bool is_closed); - void StrokeRect(BRect rect,uint8 *pattern); - void StrokeRect(BRect rect,rgb_color col); - void StrokeRoundRect(BRect rect,float xradius, float yradius, uint8 *pattern); - void StrokeShape(BShape *shape); - void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, uint8 *pattern); - void StrokeTriangle(BPoint first, BPoint second, BPoint third, BRect rect, rgb_color col); - VDWindow *screenwin; -protected: - int hide_cursor; - bool obscure_cursor; - BBitmap *framebuffer; - BView *drawview; - BRegion laregion; - - PortLink *serverlink; - - rgb_color highcolor,lowcolor; -}; - -#endif diff --git a/src/servers/app/proto6/router/Jamfile b/src/servers/app/proto6/router/Jamfile deleted file mode 100644 index 6fb9e42c21..0000000000 --- a/src/servers/app/proto6/router/Jamfile +++ /dev/null @@ -1,9 +0,0 @@ -SubDir OBOS_TOP src servers app proto6 router ; - -SubDirHdrs [ FDirName $(OBOS_TOP) src servers app proto6 ] ; - -Addon router : input_server : - ../PortLink.cpp - router.cpp -; -LinkSharedOSLibs router : be root /system/servers/input_server ; diff --git a/src/servers/app/proto6/router/router.cpp b/src/servers/app/proto6/router/router.cpp deleted file mode 100644 index 9752065dfd..0000000000 --- a/src/servers/app/proto6/router/router.cpp +++ /dev/null @@ -1,146 +0,0 @@ -#include "router.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#include "PortLink.h" -#include "ServerProtocol.h" -//#define SERVER_PORT_NAME "OBappserver" -//#define SERVER_INPUT_PORT "OBinputport" - - -/******************************************************* -* -*******************************************************/ -BInputServerFilter* instantiate_input_filter(){ - return (new RouterInputFilter()); -} - -/******************************************************* -* -*******************************************************/ -RouterInputFilter::RouterInputFilter():BInputServerFilter(){ - port_id pid = find_port(SERVER_INPUT_PORT); - serverlink = new PortLink(pid); - -} - -/******************************************************* -* -*******************************************************/ -RouterInputFilter::~RouterInputFilter(){ -} - -/******************************************************* -* Everthing went just find .. right? -*******************************************************/ -status_t RouterInputFilter::InitCheck(){ - return B_OK; -} - - - -/******************************************************* -* -*******************************************************/ -filter_result RouterInputFilter::Filter(BMessage *message, BList *outList){ - if(serverlink == NULL){ - return B_DISPATCH_MESSAGE; - } - port_id pid = find_port(SERVER_INPUT_PORT); - if(pid < 0){ - return B_DISPATCH_MESSAGE; - } - serverlink->SetPort(pid); - - switch(message->what){ - case B_MOUSE_MOVED:{ - port_id pid = find_port(SERVER_INPUT_PORT); - if(pid==B_NAME_NOT_FOUND) - break; - serverlink->SetPort(pid); - BPoint p; - uint32 buttons = 0; - // get piont and button from msg - if(message->FindPoint("where",&p) != B_OK){ - - } - int64 time=(int64)real_time_clock(); - - serverlink->SetOpCode(B_MOUSE_MOVED); - serverlink->Attach(&time,sizeof(int64)); - serverlink->Attach(&p.x,sizeof(float)); - serverlink->Attach(&p.y,sizeof(float)); - serverlink->Attach(&buttons,sizeof(int32)); - - // prevent server crashes from hanging the Input Server - serverlink->Flush(50000); - }break; - case B_MOUSE_UP:{ - port_id pid = find_port(SERVER_INPUT_PORT); - if(pid==B_NAME_NOT_FOUND) - break; - serverlink->SetPort(pid); - BPoint p; - - uint32 mod=modifiers(); - // Eventually, we will also be sending a uint32 buttons. - - int64 time=(int64)real_time_clock(); - - message->FindPoint("where",&p); - - serverlink->SetOpCode(B_MOUSE_UP); - serverlink->Attach(&time, sizeof(int64)); - serverlink->Attach(&p.x,sizeof(float)); - serverlink->Attach(&p.y,sizeof(float)); - serverlink->Attach(&mod, sizeof(uint32)); - - // prevent server crashes from hanging the Input Server - serverlink->Flush(50000); - }break; - case B_MOUSE_DOWN:{ - port_id pid = find_port(SERVER_INPUT_PORT); - if(pid==B_NAME_NOT_FOUND) - break; - serverlink->SetPort(pid); - BPoint p; - - uint32 buttons, - mod=modifiers(); - int32 clicks; - message->FindInt32("clicks",&clicks); - message->FindPoint("where",&p); - message->FindInt32("buttons",(int32*)&buttons); - - int64 time=(int64)real_time_clock(); - - serverlink->SetOpCode(B_MOUSE_DOWN); - serverlink->Attach(&time, sizeof(int64)); - serverlink->Attach(&p.x,sizeof(float)); - serverlink->Attach(&p.y,sizeof(float)); - serverlink->Attach(&mod, sizeof(uint32)); - serverlink->Attach(&buttons, sizeof(uint32)); - serverlink->Attach(&clicks, sizeof(uint32)); - - // prevent server crashes from hanging the Input Server - serverlink->Flush(50000); - }break; - - // Should be some Mouse Down and Up code here .. - // Along with some Key Down and up codes .. - default: - break; - } - - //delete serverlink; - - // Let all msg flow normally to the - // Be app_server - return B_DISPATCH_MESSAGE; -} diff --git a/src/servers/app/proto6/router/router.h b/src/servers/app/proto6/router/router.h deleted file mode 100644 index 16b3b6ac79..0000000000 --- a/src/servers/app/proto6/router/router.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _ROUTER_H -#define _ROUTER_H - -#include -#include -#include -#include - -class PortLink; - -// export this for the input_server -extern "C" _EXPORT BInputServerFilter* instantiate_input_filter(); - -class RouterInputFilter : public BInputServerFilter { - public: - RouterInputFilter(); - virtual ~RouterInputFilter(); - virtual status_t InitCheck(); - virtual filter_result Filter(BMessage *message, BList *outList); -private: - PortLink *serverlink; -}; -#endif diff --git a/src/servers/app/proto6/testobapp/DebugTools.cpp b/src/servers/app/proto6/testobapp/DebugTools.cpp deleted file mode 100644 index 0a0c6aed1d..0000000000 --- a/src/servers/app/proto6/testobapp/DebugTools.cpp +++ /dev/null @@ -1,219 +0,0 @@ -#include -#include -#include -#include "DebugTools.h" - -void PrintStatusToStream(status_t value) -{ - // Function which simply translates a returned status code into a string - // and dumps it to stdout - BString outstr; - switch(value) - { - case B_OK: - outstr="B_OK "; - break; - case B_NAME_NOT_FOUND: - outstr="B_NAME_NOT_FOUND "; - break; - case B_BAD_VALUE: - outstr="B_BAD_VALUE "; - break; - case B_ERROR: - outstr="B_ERROR "; - break; - case B_TIMED_OUT: - outstr="B_TIMED_OUT "; - break; - case B_NO_MORE_PORTS: - outstr="B_NO_MORE_PORTS "; - break; - case B_WOULD_BLOCK: - outstr="B_WOULD_BLOCK "; - break; - case B_BAD_PORT_ID: - outstr="B_BAD_PORT_ID "; - break; - case B_BAD_TEAM_ID: - outstr="B_BAD_TEAM_ID "; - break; - default: - outstr="undefined status value in debugtools::PrintStatusToStream() "; - break; - } - cout << "Status: " << outstr.String() << endl << flush; - -} - -void PrintColorSpaceToStream(color_space value) -{ - // Dump a color space to cout - BString outstr; - switch(value) - { - case B_RGB32: - outstr="B_RGB32 "; - break; - case B_RGBA32: - outstr="B_RGBA32 "; - break; - case B_RGB32_BIG: - outstr="B_RGB32_BIG "; - break; - case B_RGBA32_BIG: - outstr=" "; - break; - case B_UVL32: - outstr="B_UVL32 "; - break; - case B_UVLA32: - outstr="B_UVLA32 "; - break; - case B_LAB32: - outstr="B_LAB32 "; - break; - case B_LABA32: - outstr="B_LABA32 "; - break; - case B_HSI32: - outstr="B_HSI32 "; - break; - case B_HSIA32: - outstr="B_HSIA32 "; - break; - case B_HSV32: - outstr="B_HSV32 "; - break; - case B_HSVA32: - outstr="B_HSVA32 "; - break; - case B_HLS32: - outstr="B_HLS32 "; - break; - case B_HLSA32: - outstr="B_HLSA32 "; - break; - case B_CMY32: - outstr="B_CMY32"; - break; - case B_CMYA32: - outstr="B_CMYA32 "; - break; - case B_CMYK32: - outstr="B_CMYK32 "; - break; - case B_RGB24_BIG: - outstr="B_RGB24_BIG "; - break; - case B_RGB24: - outstr="B_RGB24 "; - break; - case B_LAB24: - outstr="B_LAB24 "; - break; - case B_UVL24: - outstr="B_UVL24 "; - break; - case B_HSI24: - outstr="B_HSI24 "; - break; - case B_HSV24: - outstr="B_HSV24 "; - break; - case B_HLS24: - outstr="B_HLS24 "; - break; - case B_CMY24: - outstr="B_CMY24 "; - break; - case B_GRAY1: - outstr="B_GRAY1 "; - break; - case B_CMAP8: - outstr="B_CMAP8 "; - break; - case B_GRAY8: - outstr="B_GRAY8 "; - break; - case B_YUV411: - outstr="B_YUV411 "; - break; - case B_YUV420: - outstr="B_YUV420 "; - break; - case B_YCbCr422: - outstr="B_YCbCr422 "; - break; - case B_YCbCr411: - outstr="B_YCbCr411 "; - break; - case B_YCbCr420: - outstr="B_YCbCr420 "; - break; - case B_YUV422: - outstr="B_YUV422 "; - break; - case B_YUV9: - outstr="B_YUV9 "; - break; - case B_YUV12: - outstr="B_YUV12 "; - break; - case B_RGB15: - outstr="B_RGB15 "; - break; - case B_RGBA15: - outstr="B_RGBA15 "; - break; - case B_RGB16: - outstr="B_RGB16 "; - break; - case B_RGB16_BIG: - outstr="B_RGB16_BIG "; - break; - case B_RGB15_BIG: - outstr="B_RGB15_BIG "; - break; - case B_RGBA15_BIG: - outstr="B_RGBA15_BIG "; - break; - case B_YCbCr444: - outstr="B_YCbCr444 "; - break; - case B_YUV444: - outstr="B_YUV444 "; - break; - case B_NO_COLOR_SPACE: - outstr="B_NO_COLOR_SPACE "; - break; - default: - outstr="Undefined color space "; - break; - } - cout << "Color Space: " << outstr.String() << flush; -} - -void TranslateMessageCodeToStream(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - - cout << "'" - << (char)((code & 0xFF000000) >> 24) - << (char)((code & 0x00FF0000) >> 16) - << (char)((code & 0x0000FF00) >> 8) - << (char)((code & 0x000000FF)) << "' "; -} - -void PrintMessageCode(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - - printf("Message code %c%c%c%c\n", - (char)((code & 0xFF000000) >> 24), - (char)((code & 0x00FF0000) >> 16), - (char)((code & 0x0000FF00) >> 8), - (char)((code & 0x000000FF)) ); -} - diff --git a/src/servers/app/proto6/testobapp/DebugTools.h b/src/servers/app/proto6/testobapp/DebugTools.h deleted file mode 100644 index db278e9e2d..0000000000 --- a/src/servers/app/proto6/testobapp/DebugTools.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _DEBUGTOOLS_H_ -#define _DEBUGTOOLS_H_ - -#include -#include - -void PrintStatusToStream(status_t value); -void PrintColorSpaceToStream(color_space value); -void TranslateMessageCodeToStream(int32 code); -void PrintMessageCode(int32 code); - -#endif diff --git a/src/servers/app/proto6/testobapp/Jamfile b/src/servers/app/proto6/testobapp/Jamfile deleted file mode 100644 index b382525578..0000000000 --- a/src/servers/app/proto6/testobapp/Jamfile +++ /dev/null @@ -1,13 +0,0 @@ -SubDir OBOS_TOP src servers app proto6 testobapp ; - -#SubDirHdrs [ FDirName $(OBOS_TOP) src servers app proto6 ] ; - -App OBApplication : - <$(SOURCE_GRIST)>DebugTools.cpp - <$(SOURCE_GRIST)>OBApplication.cpp - <$(SOURCE_GRIST)>OBTestApp.cpp - <$(SOURCE_GRIST)>OBView.cpp - <$(SOURCE_GRIST)>OBWindow.cpp - <$(SOURCE_GRIST)>PortLink.cpp -; -LinkSharedOSLibs OBApplication : be stdc++.r4 ; diff --git a/src/servers/app/proto6/testobapp/OBApplication.cpp b/src/servers/app/proto6/testobapp/OBApplication.cpp deleted file mode 100644 index 2a214c10e3..0000000000 --- a/src/servers/app/proto6/testobapp/OBApplication.cpp +++ /dev/null @@ -1,382 +0,0 @@ -/* - OBApplication.cpp: - Beginning framework for a *real* BApplication replacement for the prototypes - -*/ - -#include -#include // for the pattern struct and screen mode defs -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ServerProtocol.h" -#include "PortLink.h" -#include "OBApplication.h" -#include "OBWindow.h" -#include "DebugTools.h" - -OBApplication *obe_app; - -#define DEBUG_OBAPP - -OBApplication::OBApplication(const char *sig) : BApplication(sig) -{ - if(sig) - signature=new BString(sig); - else - signature=new BString("application/x-vnd.obos-OBApplication"); - -#ifdef DEBUG_OBAPP -printf("OBApplication(%s)\n",signature->String()); -#endif - - // A BApplication is locked on start, but because this is not a "real" - // one, we do not actually lock it. - - initcheckval=B_OK; - - // Receives messages from server and others - messageport=create_port(50,"msgport"); - if(messageport==B_BAD_VALUE || messageport==B_NO_MORE_PORTS) - { - printf("OBApplication: Couldn't create message port\n"); - initcheckval=B_ERROR; - } - - // Find the port for the app_server - serverport=find_port("OBappserver"); - if(serverport==B_NAME_NOT_FOUND) - { - printf("OBApplication: Couldn't find server port\n"); - serverlink=NULL; - write_port(messageport,B_QUIT_REQUESTED,NULL,0); - initcheckval=B_ERROR; - } - else - { - serverlink=new PortLink(serverport); -#ifdef DEBUG_OBAPP -printf("OBApplication(%s): App Server Port %ld\n",signature->String(),serverport); -#endif - - // Notify server of app's existence - int32 replycode; - status_t replystat; - ssize_t replysize; - int8 *replybuffer; - - serverlink->SetOpCode(CREATE_APP); - serverlink->Attach(&messageport,sizeof(port_id)); -// serverlink.Attach(PID); - serverlink->Attach((char*)signature->String(),strlen(signature->String())); - - // Send and wait for ServerApp port. Necessary here (as opposed to start - // of message loop) in case any windows are created in application constructor - replybuffer=serverlink->FlushWithReply(&replycode,&replystat,&replysize); - serverport=*((port_id*)replybuffer); - serverlink->SetPort(serverport); - delete replybuffer; -#ifdef DEBUG_OBAPP -printf("OBApplication(%s): ServerApp Port %ld\n",signature->String(),serverport); -#endif - ReadyToRun(); - } - - obe_app=this; - windowlist=new BList(0); -} - -OBApplication::~OBApplication(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::~OBApplication()\n",signature->String()); -#endif - delete signature; - - if(serverlink) - delete serverlink; - -// OBWindow *win; -// for(int32 i=0; iCountItems(); i++) -// { -// win=(OBWindow*)windowlist->RemoveItem(i); -// if(win) -// win->Quit(); -// } - - delete windowlist; -} - -status_t OBApplication::InitCheck(void) const -{ - // Called to make sure everything in the constructor turned out ok. If it didn't, - // the application falls through and the process ends. - return initcheckval; -} - -void OBApplication::MainLoop(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::MainLoop()\n",signature->String()); -#endif - - int32 msgcode; - uint8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - // Modified this slightly so that OBApplications will eventually time out - // if the server crashes. Saves on a lot of Ctrl-Alt-Del's. :) CPU time is - // saved by setting the timeout to 3 seconds - more than enough time. - if(find_thread("OBAppServer")==B_NAME_NOT_FOUND) - { - printf("%s lost connection with server. Quitting.\n",signature->String()); - break; - } - - buffersize=port_buffer_size_etc(messageport,B_TIMEOUT,300000); - if(buffersize==B_TIMED_OUT) - continue; - - if(buffersize>0) - { - // buffers are flattened messages. Allocate necessary buffer and - // we'll cast it as a BMessage. - msgbuffer=new uint8[buffersize]; - bytesread=read_port(messageport,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(messageport,&msgcode,NULL,0); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case B_QUIT_REQUESTED: - { - // Attached data: - // None -// printf("%s: Quit requested\n",signature); - serverlink->SetOpCode(msgcode); - serverlink->Flush(); - break; - } - case ADDWINDOW: - { - // This message is received by a window's constructor so that it - // can be added to the window list - - // Attached Data: - // 1) OBWindow *window - - // I hope this is the right syntax... - windowlist->AddItem(msgbuffer); -#ifdef DEBUG_OBAPP -printf("%s: Add Window @ %p\n",signature->String(),msgbuffer); -#endif - break; - } - case REMOVEWINDOW: - { - // This message is received by a window's constructor so that it - // can be added to the window list - - // Attached Data: - // 1) OBWindow *window - - // I hope this is the right syntax... - windowlist->RemoveItem(msgbuffer); -#ifdef DEBUG_OBAPP -printf("%s: Remove Window @ %p\n",signature->String(),msgbuffer); -#endif - break; - } - case B_MOUSE_MOVED: - case B_MOUSE_DOWN: - case B_MOUSE_UP: - DispatchMessage(msgcode, (int8*)msgbuffer); - break; - - // Later on, this will default to passing the message to - // DispatchMessage(BMessage*, BHandler*) - default: - printf("OBApplication received unexpected code %ld - ",msgcode); - PrintMessageCode(msgcode); - break; - } - - if(msgcode==B_QUIT_REQUESTED) - { - printf("Quitting %s\n",signature->String()); - break; - } - } - - if(buffersize>0) - delete msgbuffer; - } -} - -void OBApplication::DispatchMessage(BMessage *msg, BHandler *handler) -{ -#ifdef DEBUG_OBAPP -printf("%s::DispatchMessage(BMessage*,BHandler*)\n",signature->String()); -#endif - BApplication::DispatchMessage(msg,handler); -} - -void OBApplication::DispatchMessage(int32 code, int8 *buffer) -{ - // This function will be necessary to handle server messages. - switch(code) - { - case B_MOUSE_DOWN: - case B_MOUSE_UP: - case B_MOUSE_MOVED: - break; - default: - printf("OBApplication %s received unknown code %ld\n",signature->String(),code); - break; - } -} - -void OBApplication::MessageReceived(BMessage *msg) -{ -#ifdef DEBUG_OBAPP -printf("%s::MessageReceived()\n",signature->String()); -#endif -} - -void OBApplication::ShowCursor(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::ShowCursor()\n",signature->String()); -#endif - serverlink->SetOpCode(SHOW_CURSOR); - serverlink->Flush(); -} - -void OBApplication::HideCursor(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::HideCursor()\n",signature->String()); -#endif - serverlink->SetOpCode(HIDE_CURSOR); - serverlink->Flush(); -} - -void OBApplication::ObscureCursor(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::ObscureCursor()\n",signature->String()); -#endif - serverlink->SetOpCode(OBSCURE_CURSOR); - serverlink->Flush(); -} - -bool OBApplication::IsCursorHidden(void) const -{ - return false; -} - -void OBApplication::SetCursor(const void *cursor) -{ -#ifdef DEBUG_OBAPP -printf("%s::SetCursor()\n",signature->String()); -#endif - // attach & send the 68-byte chunk - serverlink->SetOpCode(SET_CURSOR_DATA); - serverlink->Attach((void*)cursor, 68); - serverlink->Flush(); -} - -thread_id OBApplication::Run(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::Run()\n",signature->String()); -#endif - if(initcheckval==B_OK) - MainLoop(); - - return 0; -} - -status_t OBApplication::Archive(BMessage *data, bool deep = true) const -{ - return B_ERROR; -} - -void OBApplication::Quit(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::Quit()\n",signature->String()); -#endif - OBWindow *win; - while(windowlist->CountItems()>0) - { - win=(OBWindow*)windowlist->RemoveItem(0L); - if(win) - win->Quit(); - } - - BApplication::Quit(); -} - -bool OBApplication::QuitRequested(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::QuitRequested()\n",signature->String()); -#endif - return true; -} - -void OBApplication::Pulse(void) -{ -} - -void OBApplication::ArgvReceived(int32 argc, char **argv) -{ -} - -void OBApplication::AppActivated(bool active) -{ -} - -void OBApplication::RefsReceived(BMessage *a_message) -{ -} - -void OBApplication::AboutRequested(void) -{ -} - -BHandler *OBApplication::ResolveSpecifier(BMessage *msg,int32 index,BMessage *specifier, - int32 form,const char *property) -{ - return NULL; -} - -status_t OBApplication::GetSupportedSuites(BMessage *data) -{ - return B_ERROR; -} - -status_t OBApplication::Perform(perform_code d, void *arg) -{ - return B_ERROR; -} - -void OBApplication::ReadyToRun(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::ReadyToRun()\n",signature->String()); -#endif -} diff --git a/src/servers/app/proto6/testobapp/OBApplication.h b/src/servers/app/proto6/testobapp/OBApplication.h deleted file mode 100644 index 2fd9b2e76b..0000000000 --- a/src/servers/app/proto6/testobapp/OBApplication.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef _OBOS_APPLICATION_H_ -#define _OBOS_APPLICATION_H_ - -#include -#include - -class PortLink; -class BList; -class OBWindow; - -class OBApplication : private BApplication -{ -public: - -OBApplication(const char *signature); -OBApplication(const char *signature, status_t *error); -virtual ~OBApplication(void); - -OBApplication(BMessage *data); -static BArchivable *Instantiate(BMessage *data); -virtual status_t Archive(BMessage *data, bool deep = true) const; - -status_t InitCheck() const; - -virtual thread_id Run(void); -virtual void Quit(void); -virtual bool QuitRequested(void); -virtual void Pulse(void); -virtual void ReadyToRun(void); -virtual void MessageReceived(BMessage *msg); -virtual void ArgvReceived(int32 argc, char **argv); -virtual void AppActivated(bool active); -virtual void RefsReceived(BMessage *a_message); -virtual void AboutRequested(void); - -virtual BHandler *ResolveSpecifier(BMessage *msg,int32 index, -BMessage *specifier,int32 form,const char *property); - -void ShowCursor(void); -void HideCursor(void); -void ObscureCursor(void); -bool IsCursorHidden(void) const; -void SetCursor(const void *cursor); -void SetCursor(const BCursor *cursor, bool sync=true); -int32 CountWindows(void) const; -BWindow *WindowAt(int32 index) const; -int32 CountLoopers(void) const; -BLooper *LooperAt(int32 index) const; -bool IsLaunching(void) const; -status_t GetAppInfo(app_info *info) const; -static BResources *AppResources(void); -virtual void DispatchMessage(BMessage *an_event,BHandler *handler); -void SetPulseRate(bigtime_t rate); -virtual status_t GetSupportedSuites(BMessage *data); -virtual status_t Perform(perform_code d, void *arg); - -protected: -friend OBWindow; - -void MainLoop(void); -void DispatchMessage(int32 code, int8 *buffer); - -port_id messageport, serverport; -BString *signature; -PortLink *serverlink; -BList *windowlist; -status_t initcheckval; -}; - -extern OBApplication *obe_app; -#endif diff --git a/src/servers/app/proto6/testobapp/OBTestApp.cpp b/src/servers/app/proto6/testobapp/OBTestApp.cpp deleted file mode 100644 index ebbe8c24bf..0000000000 --- a/src/servers/app/proto6/testobapp/OBTestApp.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include "OBApplication.h" -#include "OBWindow.h" -#include "OBView.h" - -class OBTestApp : public OBApplication -{ -public: - OBTestApp(void); - ~OBTestApp(void); -}; - -OBWindow *win; - -OBTestApp::OBTestApp(void) : OBApplication("application/OBTestApp") -{ - win=new OBWindow(BRect(100,100,200,200), "OBWindow1",B_BORDERED_WINDOW_LOOK, - B_NORMAL_WINDOW_FEEL,0); - win->Show(); - - win=new OBWindow(BRect(200,200,300,300), "OBWindow2",B_DOCUMENT_WINDOW_LOOK, - B_NORMAL_WINDOW_FEEL,0); - win->Show(); -} - -OBTestApp::~OBTestApp(void) -{ -} - -int main(void) -{ - OBTestApp *app=new OBTestApp(); - app->Run(); - delete app; -} diff --git a/src/servers/app/proto6/testobapp/OBView.cpp b/src/servers/app/proto6/testobapp/OBView.cpp deleted file mode 100644 index 1132f77db5..0000000000 --- a/src/servers/app/proto6/testobapp/OBView.cpp +++ /dev/null @@ -1,872 +0,0 @@ -#include -#include -#include "PortLink.h" -#include "ServerProtocol.h" -#include "OBView.h" -#include "OBWindow.h" - -//#define DEBUG_VIEW - -#ifndef SET_RGB_COLOR - #define SET_RGB_COLOR(a,b,c,d,e) a.red=b; a.green=c; a.blue=d; a.alpha=e; -#endif - -OBView::OBView(BRect frame,const char *name,uint32 resizeMask,uint32 flags) - : BHandler(name) -{ - viewflags=flags; - resizeflags=resizeMask; - origin_h=0.0; - origin_v=0.0; - - owner=NULL; - parent=NULL; - uppersibling=NULL; - lowersibling=NULL; - topchild=NULL; - bottomchild=NULL; - hidelevel=0; - - // This will be changed when added to a BWindow as the top view - topview=false; - - SET_RGB_COLOR(highcol,0,0,0,255); - SET_RGB_COLOR(lowcol,255,255,255,255); - SET_RGB_COLOR(viewcol,255,255,255,255); - - // We need to align to the nearest pixel, rounded down - // There's probably a better way to do this, but it'll work for now... - vframe.left=(int32)frame.left; - vframe.top=(int32)frame.top; - vframe.right=(int32)frame.right; - vframe.bottom=(int32)frame.bottom; -} - -OBView::~OBView() -{ - // Be Book says it's an error to delete while attached to a window. - // We'll just prevent that problem... - if(owner) - { - // No, this isn't an error to utilize parent and not owner. We - // aren't actually attached to the window class itself. We're - // attached to a view which is a member of the window. - parent->RemoveChild(this); - } - - - OBView *v; - for(v=topchild; v!=NULL; v=v->lowersibling) - delete v; -} - -void OBView::AttachedToWindow() -{ - // Hook function -} - -void OBView::AllAttached() -{ - // Hook function -} - -void OBView::DetachedFromWindow() -{ - // Hook function -} - -void OBView::AllDetached() -{ - // Hook function -} - -void OBView::MessageReceived(BMessage *msg) -{ - // Adds scripting support to the BHandler version. This is - // only a skeleton implementation, so it has been skipped - BHandler::MessageReceived(msg); -} - -void OBView::AddChild(OBView *child, OBView *before = NULL) -{ - if(!child) - return; - if(child->parent || child->owner) - { - printf("%s::AddChild(): child already has a parent\n",Name()); - return; - } - if(child->parent==this) - { - printf("%s::AddChild(): child already belongs to view\n",Name()); - return; - } - - // Adds a layer to the top of the layer's children -#ifdef DEBUG_VIEW - printf("%s::AddChild(%s)\n", Name(), child->Name()); -#endif - - child->parent=this; - child->owner=owner; - - // View specified. Add new child above the specified view - if(before) - { - if(before->parent==this) - { - child->lowersibling=before; - child->uppersibling=before->uppersibling; - before->uppersibling->lowersibling=child; - before->uppersibling=child; - - // If we're attached to a window, notify all child views of - // their attachment - if(owner) - { - CallAttached(child); - child->AllAttached(); - } - - } - else - { - printf("%s::AddChild(): Can't add %s before %s - different parents\n", - Name(), child->Name(), before->Name()); - } - return; - } - - // If we haven't specified, child is added to bottom of list - if(bottomchild!=NULL) - { - child->uppersibling=bottomchild; - bottomchild->lowersibling=child; - } - bottomchild=child; - -} - -bool OBView::RemoveChild(OBView *child) -{ - if(!child) - return false; - - if(child->parent!=this) - { - printf("%s::RemoveChild(): %s not child of this view\n",Name(),child->Name()); - return false; - } - - // Adds a layer to the top of the layer's children -#ifdef DEBUG_VIEW - printf("%s::RemoveChild(%s)\n", Name(), child->Name()); -#endif - - if(owner) - { - CallDetached(child); - - // We only need to tell the server to prune the layer tree - // at the child's level - PortLink *link=new PortLink(owner->outport); - link->SetOpCode(LAYER_DELETE); - link->Attach(child->id); - link->Flush(); - delete link; - } - - // Note that we do the pointer reassignments last because the other - // function calls made in RemoveChild() depend on these pointers - if(topchild==child) - topchild=child->lowersibling; - if(bottomchild==child) - bottomchild=child->lowersibling; - - if(child->uppersibling!=NULL) - child->uppersibling->lowersibling=child->lowersibling; - if(child->lowersibling!=NULL) - child->lowersibling->uppersibling=child->uppersibling; - - child->parent=NULL; - child->owner=NULL; - child->lowersibling=NULL; - child->uppersibling=NULL; - return true; -} - -bool OBView::RemoveSelf() -{ - return false; -} - -int32 OBView::CountChildren() const -{ - OBView *v=topchild; - int32 children=0; - - while(v!=NULL) - { - v=v->lowersibling; - children++; - } - - return children; -} - -OBView *OBView::ChildAt(int32 index) const -{ - // We're using a tree, so traverse the tree - OBView *v=topchild; - - for(int32 i=0;ilowersibling; - } - - return v; -} - -OBView *OBView::NextSibling() const -{ - return lowersibling; -} - -OBView *OBView::PreviousSibling() const -{ - return uppersibling; -} - -OBWindow *OBView::Window() const -{ - return owner; -} - -void OBView::Draw(BRect updateRect) -{ -} - -void OBView::MouseDown(BPoint where) -{ - // Hook function -} - -void OBView::MouseUp(BPoint where) -{ - // Hook function -} - -void OBView::MouseMoved(BPoint where,uint32 code,const BMessage *a_message) -{ - // Hook function -} - -void OBView::WindowActivated(bool state) -{ - // Hook function -} - -void OBView::KeyDown(const char *bytes, int32 numBytes) -{ - // Hook function -} - -void OBView::KeyUp(const char *bytes, int32 numBytes) -{ - // Hook function -} - -void OBView::Pulse() -{ - // Hook function -} - -void OBView::FrameMoved(BPoint new_position) -{ - // Hook function -} - -void OBView::FrameResized(float new_width, float new_height) -{ - // Hook function -} - -void OBView::TargetedByScrollView(BScrollView *scroll_view) -{ - // Hook function -} - -void OBView::BeginRectTracking(BRect startRect,uint32 style = B_TRACK_WHOLE_RECT) -{ - if(!owner) - { - printf("BeginRectTracking(): view must be attached to a window\n"); - return; - } - owner->serverlink->SetOpCode(BEGIN_RECT_TRACKING); - owner->serverlink->Attach(&startRect, sizeof(BRect)); - owner->serverlink->Attach(&style, sizeof(uint32)); - owner->serverlink->Flush(); -} - -void OBView::EndRectTracking(void) -{ - if(!owner) - { - printf("EndRectTracking(): view must be attached to a window\n"); - return; - } - owner->serverlink->SetOpCode(END_RECT_TRACKING); - owner->serverlink->Flush(); -} - -void OBView::GetMouse(BPoint *location, uint32 *buttons, - bool checkMessageQueue=true) -{ -} - -OBView *OBView::FindView(const char *name) -{ - OBView *v; - v=FindViewInChildren(name); - - return v; -} - -OBView *OBView::Parent() const -{ - return parent; -} - -BRect OBView::Bounds() const -{ - BRect rframe=vframe; - rframe.OffsetTo(0,0); - return rframe; -} - -BRect OBView::Frame() const -{ - return vframe; -} - -void OBView::ConvertToScreen(BPoint* pt) const -{ -} - -BPoint OBView::ConvertToScreen(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBView::ConvertFromScreen(BPoint* pt) const -{ -} - -BPoint OBView::ConvertFromScreen(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBView::ConvertToScreen(BRect *r) const -{ -} - -BRect OBView::ConvertToScreen(BRect r) const -{ - return BRect(0,0,0,0); -} - -void OBView::ConvertFromScreen(BRect *r) const -{ -} - -BRect OBView::ConvertFromScreen(BRect r) const -{ - return BRect(0,0,0,0); -} - -void OBView::ConvertToParent(BPoint *pt) const -{ -} - -BPoint OBView::ConvertToParent(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBView::ConvertFromParent(BPoint *pt) const -{ -} - -BPoint OBView::ConvertFromParent(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBView::ConvertToParent(BRect *r) const -{ -} - -BRect OBView::ConvertToParent(BRect r) const -{ - return BRect(0,0,0,0); -} - -void OBView::ConvertFromParent(BRect *r) const -{ -} - -BRect OBView::ConvertFromParent(BRect r) const -{ - return BRect(0,0,0,0); -} - -BPoint OBView::LeftTop() const -{ - return BPoint(-1,-1); -} - -void OBView::GetClippingRegion(BRegion *region) const -{ -} - -void OBView::ConstrainClippingRegion(BRegion *region) -{ -} - -void OBView::SetDrawingMode(drawing_mode mode) -{ -} - -drawing_mode OBView::DrawingMode() const -{ - return B_OP_COPY; -} - -void OBView::SetBlendingMode(source_alpha srcAlpha, alpha_function alphaFunc) -{ -} - -void OBView::GetBlendingMode(source_alpha *srcAlpha, alpha_function *alphaFunc) const -{ -} - -void OBView::SetPenSize(float size) -{ -} - -float OBView::PenSize() const -{ - return 0.0; -} - -void OBView::SetViewColor(rgb_color c) -{ - SET_RGB_COLOR(viewcol,c.red,c.green,c.blue,c.alpha); - owner->drawmsglink->Attach((int32)GFX_SET_VIEW_COLOR); - owner->drawmsglink->Attach((int8)c.red); - owner->drawmsglink->Attach((int8)c.green); - owner->drawmsglink->Attach((int8)c.blue); - owner->drawmsglink->Attach((int8)c.alpha); -} - -void OBView::SetViewColor(uchar r, uchar g, uchar b, uchar a=255) -{ - SET_RGB_COLOR(viewcol,r,g,b,a); - owner->drawmsglink->Attach((int32)GFX_SET_VIEW_COLOR); - owner->drawmsglink->Attach((int8)r); - owner->drawmsglink->Attach((int8)g); - owner->drawmsglink->Attach((int8)b); - owner->drawmsglink->Attach((int8)a); -} - -rgb_color OBView::ViewColor() const -{ - return viewcol; -} - -void OBView::SetHighColor(rgb_color c) -{ - SET_RGB_COLOR(highcol,c.red,c.green,c.blue,c.alpha); - owner->drawmsglink->Attach((int32)GFX_SET_HIGH_COLOR); - owner->drawmsglink->Attach((int8)c.red); - owner->drawmsglink->Attach((int8)c.green); - owner->drawmsglink->Attach((int8)c.blue); - owner->drawmsglink->Attach((int8)c.alpha); -} - -void OBView::SetHighColor(uchar r, uchar g, uchar b, uchar a=255) -{ - SET_RGB_COLOR(highcol,r,g,b,a); - owner->drawmsglink->Attach((int32)GFX_SET_HIGH_COLOR); - owner->drawmsglink->Attach((int8)r); - owner->drawmsglink->Attach((int8)g); - owner->drawmsglink->Attach((int8)b); - owner->drawmsglink->Attach((int8)a); -} - -rgb_color OBView::HighColor() const -{ - return highcol; -} - -void OBView::SetLowColor(rgb_color c) -{ - SET_RGB_COLOR(lowcol,c.red,c.green,c.blue,c.alpha); - owner->drawmsglink->Attach((int32)GFX_SET_LOW_COLOR); - owner->drawmsglink->Attach((int8)c.red); - owner->drawmsglink->Attach((int8)c.green); - owner->drawmsglink->Attach((int8)c.blue); - owner->drawmsglink->Attach((int8)c.alpha); -} - -void OBView::SetLowColor(uchar r, uchar g, uchar b, uchar a=255) -{ - SET_RGB_COLOR(lowcol,r,g,b,a); - owner->drawmsglink->Attach((int32)GFX_SET_LOW_COLOR); - owner->drawmsglink->Attach((int8)r); - owner->drawmsglink->Attach((int8)g); - owner->drawmsglink->Attach((int8)b); - owner->drawmsglink->Attach((int8)a); -} - -rgb_color OBView::LowColor() const -{ - return lowcol; -} - -void OBView::Invalidate(BRect invalRect) -{ - if(!owner) - { - printf("Invalidate(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach(invalRect); -} - -void OBView::Invalidate(const BRegion *invalRegion) -{ - // undocumented function -} - -void OBView::Invalidate() -{ - if(!owner) - { - printf("Invalidate(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach(Bounds()); -} - -void OBView::SetFlags(uint32 flags) -{ -} - -uint32 OBView::Flags() const -{ - return viewflags; -} - -void OBView::SetResizingMode(uint32 mode) -{ -} - -uint32 OBView::ResizingMode() const -{ - return resizeflags; -} - -void OBView::MoveBy(float dh, float dv) -{ -} - -void OBView::MoveTo(BPoint where) -{ -} - -void OBView::MoveTo(float x, float y) -{ -} - -void OBView::ResizeBy(float dh, float dv) -{ -} - -void OBView::ResizeTo(float width, float height) -{ -} - -void OBView::MakeFocus(bool focusState = true) -{ -} - -bool OBView::IsFocus() const -{ - return has_focus; -} - -void OBView::Show() -{ - hidelevel--; - - for(OBView *v=topchild; v!=NULL; v=v->lowersibling ) - v->Show(); -} - -void OBView::Hide() -{ - hidelevel++; - - for(OBView *v=topchild; v!=NULL; v=v->lowersibling ) - v->Show(); -} - -bool OBView::IsHidden() const -{ - return (hidelevel>0)?true:false; -} - -bool OBView::IsHidden(const OBView* looking_from) const -{ - // undocumented function - return false; -} - -void OBView::Flush() const -{ - // When attachment count inclusion is implemented, it needs to go - // in this function - - owner->drawmsglink->SetOpCode(GFX_FLUSH); - owner->drawmsglink->Flush(); -} - -void OBView::Sync() const -{ - // When attachment count inclusion is implemented, it needs to go - // in this function - - int32 code; - status_t status; - ssize_t buffersize; - - owner->drawmsglink->SetOpCode(GFX_SYNC); - - // Reply received: - - // Code: SYNC - // Attached data: none - // Buffersize: 0 - owner->drawmsglink->FlushWithReply(&code,&status,&buffersize); -} - -void OBView::StrokeRect(BRect r, pattern p=B_SOLID_HIGH) -{ - if(!owner) - { - printf("StrokeRect(): view must be attached to a window\n"); - return; - } - - owner->drawmsglink->Attach((int32)GFX_STROKE_RECT); - owner->drawmsglink->Attach(r); - owner->drawmsglink->Attach(&p, sizeof(pattern)); -} - -void OBView::FillRect(BRect r, pattern p=B_SOLID_HIGH) -{ - if(!owner) - { - printf("FillRect(): view must be attached to a window\n"); - return; - } - - owner->drawmsglink->Attach((int32)GFX_FILL_RECT); - owner->drawmsglink->Attach(r); - owner->drawmsglink->Attach(&p, sizeof(pattern)); -} - -void OBView::MovePenTo(BPoint pt) -{ - if(!owner) - { - printf("MovePenTo(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach((int32)GFX_MOVEPENTO); - owner->drawmsglink->Attach(pt); -} - -void OBView::MovePenTo(float x, float y) -{ - if(!owner) - { - printf("MovePenTo(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach((int32)GFX_MOVEPENTO); - owner->drawmsglink->Attach(BPoint(x,y)); -} - -void OBView::MovePenBy(float x, float y) -{ - if(!owner) - { - printf("MovePenBy(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach((int32)GFX_MOVEPENBY); - owner->drawmsglink->Attach(x); - owner->drawmsglink->Attach(y); -} - -BPoint OBView::PenLocation() const -{ - return BPoint(0,0); -} - -void OBView::StrokeLine(BPoint toPt,pattern p=B_SOLID_HIGH) -{ - if(!owner) - { - printf("StrokeLine(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach((int32)GFX_STROKE_LINE); - owner->drawmsglink->Attach(toPt); - owner->drawmsglink->Attach((pattern *)&p, sizeof(pattern)); -} - -void OBView::StrokeLine(BPoint pt0,BPoint pt1,pattern p=B_SOLID_HIGH) -{ - if(!owner) - { - printf("StrokeLine(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach((int32)GFX_MOVEPENTO); - owner->drawmsglink->Attach(pt0); - - owner->drawmsglink->Attach((int32)GFX_STROKE_LINE); - owner->drawmsglink->Attach(pt1); - owner->drawmsglink->Attach((pattern *)&p, sizeof(pattern)); -} - -// Protected members - -int32 OBView::GetServerToken(void) -{ - // Function which asks the app_server for an ID value - // NOTE that it requires an owner - - if(!owner) - { - printf("GetServerToken(): view must be attached to a window\n"); - return -1; - } - - int32 code; - status_t status; - ssize_t buffersize; - int32 *buffer; - - owner->serverlink->SetOpCode(VIEW_GET_TOKEN); - - // Reply received: - - // Code: GET_VIEW_TOKEN - // Attached data: - // 1) int32 view ID - buffer=(int32*)owner->drawmsglink->FlushWithReply(&code,&status,&buffersize); - id=*buffer; - - // necessary because each reply allocates memory from the heap for - // the returned buffer - delete buffer; - - return id; -} - -void OBView::CallAttached(OBView *view) -{ - // Recursively calls AttachedToWindow() for all children of the view - AddedToWindow(); - AttachedToWindow(); - - for(OBView *v=topchild; v!=NULL; v=v->lowersibling) - { - if(v->topchild) - CallAttached(v->topchild); - } -} - -void OBView::CallDetached(OBView *view) -{ - // Recursively calls DetachedFromWindow() for all children of the view - DetachedFromWindow(); - - for(OBView *v=topchild; v!=NULL; v=v->lowersibling) - { - if(v->topchild) - CallDetached(v->topchild); - } -} - -void OBView::AddedToWindow(void) -{ - // Hook function called during AddChild to take care of setup in server - // of adding a bunch of views at once, not just one - - // Theoretically, shouldn't be needed, but this is here in case I do - // something really stupid. ;) - if(!owner) - return; - - // If we're finally attached to a window, then the child needs to become - // known to the server - - // Create View message. Layers are app_server's view counterparts - - // Attach Data: - // 1) (int32) id of the parent view - // 2) (int32) id of the child view - // 3) (BRect) frame in parent's coordinates - // 4) (int32) resize flags - // 5) (int32) view flags - // 6) (uint16) view's hide level - id=GetServerToken(); - - PortLink *link=new PortLink(owner->outport); - link->SetOpCode(LAYER_CREATE); - link->Attach(parent->id); - link->Attach(id); - link->Attach(vframe); - link->Attach((int32)resizeflags); - link->Attach((int32)viewflags); - link->Attach(&hidelevel,sizeof(uint16)); - link->Flush(); - delete link; -} - -OBView *OBView::FindViewInChildren(const char *name) -{ - // Looks in all children of a view and returns the first view - // with a matching name. - - // Process: - // 1) Search this view's children starting with topchild - // 2) If not found, cycle through them again, this second time - // recursively searching each child. - // 3) If the view is found in the first child search, assign the ** - // and return the *. - // 4) If the view is found in the second child search, break out of the - // search loop by assigning and returning the * - // 5) If we complete the loop, it means that the view was not found. - // We should, thus, return NULL - return NULL; -} diff --git a/src/servers/app/proto6/testobapp/OBView.h b/src/servers/app/proto6/testobapp/OBView.h deleted file mode 100644 index 86a2448d8c..0000000000 --- a/src/servers/app/proto6/testobapp/OBView.h +++ /dev/null @@ -1,168 +0,0 @@ -#ifndef _OBVIEW_H_ -#define _OBVIEW_H_ - -#include -#include -#include -#include -#include -#include - -class BMessage; -class BString; -class BWindow; -class OBWindow; - -class OBView : public BHandler -{ -public: -OBView( BRect frame,const char *name,uint32 resizeMask,uint32 flags); -virtual ~OBView(); - -virtual void AttachedToWindow(); -virtual void AllAttached(); -virtual void DetachedFromWindow(); -virtual void AllDetached(); - -virtual void MessageReceived(BMessage *msg); - -void AddChild(OBView *child, OBView *before = NULL); -bool RemoveChild(OBView *child); -bool RemoveSelf(); -int32 CountChildren() const; -OBView *ChildAt(int32 index) const; -OBView *NextSibling() const; -OBView *PreviousSibling() const; - -OBWindow *Window() const; - -virtual void Draw(BRect updateRect); -virtual void MouseDown(BPoint where); -virtual void MouseUp(BPoint where); -virtual void MouseMoved( BPoint where,uint32 code,const BMessage *a_message); -virtual void WindowActivated(bool state); -virtual void KeyDown(const char *bytes, int32 numBytes); -virtual void KeyUp(const char *bytes, int32 numBytes); -virtual void Pulse(); -virtual void FrameMoved(BPoint new_position); -virtual void FrameResized(float new_width, float new_height); - -virtual void TargetedByScrollView(BScrollView *scroll_view); -void BeginRectTracking( BRect startRect,uint32 style = B_TRACK_WHOLE_RECT); -void EndRectTracking(); - -void GetMouse(BPoint *location,uint32 *buttons,bool checkMessageQueue=true); - -OBView *FindView(const char *name); -OBView *Parent() const; -BRect Bounds() const; -BRect Frame() const; -void ConvertToScreen(BPoint* pt) const; -BPoint ConvertToScreen(BPoint pt) const; -void ConvertFromScreen(BPoint* pt) const; -BPoint ConvertFromScreen(BPoint pt) const; -void ConvertToScreen(BRect *r) const; -BRect ConvertToScreen(BRect r) const; -void ConvertFromScreen(BRect *r) const; -BRect ConvertFromScreen(BRect r) const; -void ConvertToParent(BPoint *pt) const; -BPoint ConvertToParent(BPoint pt) const; -void ConvertFromParent(BPoint *pt) const; -BPoint ConvertFromParent(BPoint pt) const; -void ConvertToParent(BRect *r) const; -BRect ConvertToParent(BRect r) const; -void ConvertFromParent(BRect *r) const; -BRect ConvertFromParent(BRect r) const; -BPoint LeftTop() const; - -void GetClippingRegion(BRegion *region) const; -virtual void ConstrainClippingRegion(BRegion *region); - -virtual void SetDrawingMode(drawing_mode mode); -drawing_mode DrawingMode() const; - -void SetBlendingMode(source_alpha srcAlpha, alpha_function alphaFunc); -void GetBlendingMode(source_alpha *srcAlpha, alpha_function *alphaFunc) const; - -virtual void SetPenSize(float size); -float PenSize() const; - -virtual void SetViewColor(rgb_color c); -void SetViewColor(uchar r, uchar g, uchar b, uchar a = 255); -rgb_color ViewColor() const; - -virtual void SetHighColor(rgb_color a_color); -void SetHighColor(uchar r, uchar g, uchar b, uchar a = 255); -rgb_color HighColor() const; - -virtual void SetLowColor(rgb_color a_color); -void SetLowColor(uchar r, uchar g, uchar b, uchar a = 255); -rgb_color LowColor() const; - -void Invalidate(BRect invalRect); -void Invalidate(const BRegion *invalRegion); -void Invalidate(); - -virtual void SetFlags(uint32 flags); -uint32 Flags() const; -virtual void SetResizingMode(uint32 mode); -uint32 ResizingMode() const; -void MoveBy(float dh, float dv); -void MoveTo(BPoint where); -void MoveTo(float x, float y); -void ResizeBy(float dh, float dv); -void ResizeTo(float width, float height); -virtual void MakeFocus(bool focusState = true); -bool IsFocus() const; - -virtual void Show(); -virtual void Hide(); -bool IsHidden() const; -bool IsHidden(const OBView* looking_from) const; - -void Flush() const; -void Sync() const; - -void StrokeRect(BRect r, pattern p = B_SOLID_HIGH); -void FillRect(BRect r, pattern p = B_SOLID_HIGH); -void MovePenTo(BPoint pt); -void MovePenTo(float x, float y); -void MovePenBy(float x, float y); -BPoint PenLocation() const; -void StrokeLine( BPoint toPt,pattern p = B_SOLID_HIGH); -void StrokeLine( BPoint pt0,BPoint pt1,pattern p = B_SOLID_HIGH); - -protected: - friend OBWindow; - -int32 GetServerToken(void); -void CallAttached(OBView *view); -void CallDetached(OBView *view); -OBView *FindViewInChildren(const char *name); -void AddedToWindow(void); - -int32 id; -uint32 viewflags, resizeflags; -float origin_h; -float origin_v; -OBWindow* owner; - -OBView* parent; -OBView* uppersibling; -OBView* lowersibling; -OBView* topchild; -OBView* bottomchild; - -uint16 hidelevel; -bool topview; -bool has_focus; - -BRect vframe; -BRegion *clipregion; - -rgb_color highcol; -rgb_color lowcol; -rgb_color viewcol; -}; - -#endif diff --git a/src/servers/app/proto6/testobapp/OBWindow.cpp b/src/servers/app/proto6/testobapp/OBWindow.cpp deleted file mode 100644 index 0409391af1..0000000000 --- a/src/servers/app/proto6/testobapp/OBWindow.cpp +++ /dev/null @@ -1,523 +0,0 @@ -#include -#include -#include -#include "OBApplication.h" -#include "OBView.h" -#include "OBWindow.h" -#include "ServerProtocol.h" -#include "PortLink.h" - -#define DEBUG_OBWINDOW - -OBWindow::OBWindow(BRect frame,const char *title, window_type type, -uint32 flags,uint32 workspace = B_CURRENT_WORKSPACE) -{ -} - -OBWindow::OBWindow(BRect frame,const char *title, window_look look,window_feel feel, -uint32 flags,uint32 workspace = B_CURRENT_WORKSPACE) -{ -#ifdef DEBUG_OBWINDOW -printf("OBWindow(%s)\n",title); -#endif - Lock(); - - // Window starts hidden by default - hidelevel=1; - - wframe=frame; - wlook=look; - wfeel=feel; - wflags=flags; - wkspace=workspace; - - wtitle=new BString(title); - - // Receives messages from server and others - inport=create_port(50,"msgport"); - if(inport==B_BAD_VALUE || inport==B_NO_MORE_PORTS) - printf("OBWindow: Couldn't create message port\n"); - - // Notify app that we exist - OBWindow *win=this; - PortLink *link=new PortLink(obe_app->messageport); - link->SetOpCode(ADDWINDOW); - link->Attach(&win,sizeof(OBWindow*)); - link->Flush(); - delete link; - - // we set this flag because the window starts locked. When Show() is - // called it will unlock the looper and show the window - startlocked=true; - - // We create our serverlink utilizing our application's server port - // because the server's ServerApp will handle window creation - serverlink=new PortLink(obe_app->serverport); - - // make sure that the server port is valid. It will == B_NAME_NOT_FOUND if the - // OBApplication couldn't find the server - - if(obe_app->serverport!=B_NAME_NOT_FOUND) - { - // Notify server of window's existence - serverlink->SetOpCode(CREATE_WINDOW); - serverlink->Attach(wframe); - serverlink->Attach((int32)WindowLookToInteger(wlook)); - serverlink->Attach((int32)WindowFeelToInteger(wfeel)); - serverlink->Attach((int32)wflags); - serverlink->Attach(&inport,sizeof(port_id)); - serverlink->Attach((int32)wkspace); - serverlink->Attach((char*)wtitle->String(),wtitle->Length()); - - // Send and wait for ServerWindow port. Necessary here so we can respond to - // messages as soon as Show() is called. - - int32 replycode; - status_t replystat; - ssize_t replysize; - int8 *replybuffer; - - replybuffer=serverlink->FlushWithReply(&replycode,&replystat,&replysize); - outport=*((port_id*)replybuffer); - serverlink->SetPort(outport); - delete replybuffer; - -#ifdef DEBUG_OBWINDOW -printf("OBWindow(%s): ServerWindow Port %ld\n",wtitle->String(),outport); -#endif - - // Create and attach the top view - top_view=new OBView(wframe.OffsetToCopy(0,0),"top_view",B_FOLLOW_ALL, B_WILL_DRAW); - top_view->owner=this; - top_view->topview=true; - } - else - PostMessage(B_QUIT_REQUESTED); -} - -OBWindow::~OBWindow() -{ -#ifdef DEBUG_OBWINDOW -printf("~OBWindow(%s)\n",wtitle->String()); -#endif - // delete all children. How? OBView recursively deletes its children - delete top_view; - - delete wtitle; - delete serverlink; - delete drawmsglink; - -} - -void OBWindow::Quit() -{ -#ifdef DEBUG_OBWINDOW -printf("%s::Quit()\n",wtitle->String()); -#endif - // I hope this works. If it doesn't, we'll need to do a synchronous msg - OBWindow *win=this; - PortLink *link=new PortLink(obe_app->messageport); - link->SetOpCode(REMOVEWINDOW); - link->Attach(&win,sizeof(OBWindow *)); - link->Flush(); - delete link; - - // Server will need to be notified of window destruction - serverlink->SetOpCode(DELETE_WINDOW); - serverlink->Attach(&ID,sizeof(int32)); - serverlink->Flush(); - - // Quit our looper and delete our self :) - Quit(); -} - -void OBWindow::Close() -{ - Quit(); -} - -void OBWindow::AddChild(OBView *child, OBView *before = NULL) -{ -#ifdef DEBUG_OBWINDOW -printf("%s::AddChild()\n",wtitle->String()); -#endif - top_view->AddChild(child,before); -} - -bool OBWindow::RemoveChild(OBView *child) -{ -#ifdef DEBUG_OBWINDOW -printf("%s::RemoveChild()\n",wtitle->String()); -#endif - return top_view->RemoveChild(child); -} - -int32 OBWindow::CountChildren() const -{ - return top_view->CountChildren(); -} - -OBView *OBWindow::ChildAt(int32 index) const -{ - return top_view->ChildAt(index); -} - -void OBWindow::DispatchMessage(BMessage *message, BHandler *handler) -{ -} - -void OBWindow::MessageReceived(BMessage *message) -{ - // Not sure right now what needs to be handled. - switch(message->what) - { - default: - BLooper::MessageReceived(message); - } -} - -void OBWindow::FrameMoved(BPoint new_position) -{ -} - -void OBWindow::WorkspacesChanged(uint32 old_ws, uint32 new_ws) -{ -} - -void OBWindow::WorkspaceActivated(int32 ws, bool state) -{ -} - -void OBWindow::FrameResized(float new_width, float new_height) -{ -} - -void OBWindow::Minimize(bool minimize) -{ -} - -void OBWindow::Zoom(BPoint rec_position,float rec_width,float rec_height) -{ -} - -void OBWindow::Zoom() -{ -} - -void OBWindow::ScreenChanged(BRect screen_size, color_space depth) -{ -} - -bool OBWindow::NeedsUpdate() const -{ - return false; -} - -void OBWindow::UpdateIfNeeded() -{ -} - -OBView *OBWindow::FindView(const char *view_name) const -{ - return top_view->FindView(view_name); -} - -OBView *OBWindow::FindView(BPoint) const -{ - return NULL; -} - -OBView *OBWindow::CurrentFocus() const -{ - return focusedview; -} - -void OBWindow::Activate(bool=true) -{ -} - -void OBWindow::WindowActivated(bool state) -{ -} - -void OBWindow::ConvertToScreen(BPoint *pt) const -{ -} - -BPoint OBWindow::ConvertToScreen(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBWindow::ConvertFromScreen(BPoint *pt) const -{ -} - -BPoint OBWindow::ConvertFromScreen(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBWindow::ConvertToScreen(BRect *rect) const -{ -} - -BRect OBWindow::ConvertToScreen(BRect rect) const -{ - return BRect(0,0,0,0); -} - -void OBWindow::ConvertFromScreen(BRect *rect) const -{ -} - -BRect OBWindow::ConvertFromScreen(BRect rect) const -{ - return BRect(0,0,0,0); -} - -void OBWindow::MoveBy(float dx, float dy) -{ -} - -void OBWindow::MoveTo(BPoint) -{ -} - -void OBWindow::MoveTo(float x, float y) -{ -} - -void OBWindow::ResizeBy(float dx, float dy) -{ -} - -void OBWindow::ResizeTo(float width, float height) -{ -} - -void OBWindow::Show() -{ - if(startlocked) - { - startlocked=false; - Unlock(); - } - hidelevel--; - if(hidelevel==0) - { - serverlink->SetOpCode(SHOW_WINDOW); - serverlink->Flush(); - } -} - -void OBWindow::Hide() -{ - if(hidelevel==0) - { - serverlink->SetOpCode(HIDE_WINDOW); - serverlink->Flush(); - } - hidelevel++; -} - -bool OBWindow::IsHidden() const -{ - return false; -} - -bool OBWindow::IsMinimized() const -{ - return false; -} - -void OBWindow::Flush() const -{ - // When attachment count inclusion is implemented, it needs to go - // in this function - - drawmsglink->SetOpCode(GFX_FLUSH); - drawmsglink->Flush(); -} - -void OBWindow::Sync() const -{ - // When attachment count inclusion is implemented, it needs to go - // in this function - - int32 code; - status_t status; - ssize_t buffersize; - - drawmsglink->SetOpCode(GFX_SYNC); - - // Reply received: - - // Code: SYNC - // Attached data: none - // Buffersize: 0 - drawmsglink->FlushWithReply(&code,&status,&buffersize); -} - -status_t OBWindow::SendBehind(const OBWindow *window) -{ - return B_ERROR; -} - -void OBWindow::DisableUpdates() -{ -} - -void OBWindow::EnableUpdates() -{ -} - -void OBWindow::BeginViewTransaction() -{ -} - -void OBWindow::EndViewTransaction() -{ -} - -BRect OBWindow::Bounds() const -{ - return BRect(0,0,0,0); -} - -BRect OBWindow::Frame() const -{ - return BRect(0,0,0,0); -} - -const char *OBWindow::Title() const -{ - return NULL; -} - -void OBWindow::SetTitle(const char *title) -{ -} - -bool OBWindow::IsFront() const -{ - return false; -} - -bool OBWindow::IsActive() const -{ - return false; -} - -uint32 OBWindow::Workspaces() const -{ - return 0; -} - -void OBWindow::SetWorkspaces(uint32) -{ -} - -OBView *OBWindow::LastMouseMovedView() const -{ - return NULL; -} - -status_t OBWindow::AddToSubset(OBWindow *window) -{ - return B_ERROR; -} - -status_t OBWindow::RemoveFromSubset(OBWindow *window) -{ - return B_ERROR; -} - -bool OBWindow::QuitRequested() -{ - return false; -} - -thread_id OBWindow::Run() -{ - return 0; -} - -uint32 OBWindow::WindowLookToInteger(window_look wl) -{ - switch(wl) - { - case B_BORDERED_WINDOW_LOOK: - return 1; - case B_TITLED_WINDOW_LOOK: - return 2; - case B_DOCUMENT_WINDOW_LOOK: - return 3; - case B_MODAL_WINDOW_LOOK: - return 4; - case B_FLOATING_WINDOW_LOOK: - return 5; - case B_NO_BORDER_WINDOW_LOOK: - default: - return 0; - } -} - -uint32 OBWindow::WindowFeelToInteger(window_feel wf) -{ - switch(wf) - { - case B_MODAL_SUBSET_WINDOW_FEEL: - return 1; - case B_MODAL_APP_WINDOW_FEEL: - return 2; - case B_MODAL_ALL_WINDOW_FEEL: - return 3; - case B_FLOATING_SUBSET_WINDOW_FEEL: - return 4; - case B_FLOATING_APP_WINDOW_FEEL: - return 5; - case B_FLOATING_ALL_WINDOW_FEEL: - return 6; - - case B_NORMAL_WINDOW_FEEL: - default: - return 0; - } -} - -window_look OBWindow::WindowLookFromType(window_type t) -{ - switch(t) - { - case B_TITLED_WINDOW: - return B_TITLED_WINDOW_LOOK; - case B_DOCUMENT_WINDOW: - return B_DOCUMENT_WINDOW_LOOK; - case B_MODAL_WINDOW: - return B_MODAL_WINDOW_LOOK; - case B_FLOATING_WINDOW: - return B_FLOATING_WINDOW_LOOK; - case B_BORDERED_WINDOW: - return B_BORDERED_WINDOW_LOOK; - case B_UNTYPED_WINDOW: - default: - return B_NO_BORDER_WINDOW_LOOK; - } -} - -window_feel OBWindow::WindowFeelFromType(window_type t) -{ - switch(t) - { - case B_MODAL_WINDOW: - return B_MODAL_APP_WINDOW_FEEL; - case B_FLOATING_WINDOW: - return B_FLOATING_APP_WINDOW_FEEL; - - // includes B_UNTYPED_WINDOW, B_BORDERED_WINDOW, B_DOCUMENT_WINDOW, - // and B_TITLED_WINDOW - default: - return B_NORMAL_WINDOW_FEEL; - } -} diff --git a/src/servers/app/proto6/testobapp/OBWindow.h b/src/servers/app/proto6/testobapp/OBWindow.h deleted file mode 100644 index 5c11164191..0000000000 --- a/src/servers/app/proto6/testobapp/OBWindow.h +++ /dev/null @@ -1,145 +0,0 @@ -#ifndef _OBWINDOW_H -#define _OBWINDOW_H - -#include -#include -#include -#include -#include -#include -#include -#include - -class BButton; -class BMenuBar; -class BMenuItem; -class BMessage; -class BMessageRunner; -class BMessenger; -class OBView; -class PortLink; - -struct message; -struct _cmd_key_; -struct _view_attr_; - -#define ADDWINDOW '_adw' -#define REMOVEWINDOW '_rmw' - -class OBWindow : public BLooper -{ -public: -OBWindow(BRect frame,const char *title, window_type type, -uint32 flags,uint32 workspace = B_CURRENT_WORKSPACE); - -OBWindow(BRect frame,const char *title, window_look look,window_feel feel, -uint32 flags,uint32 workspace = B_CURRENT_WORKSPACE); - -virtual ~OBWindow(); - -virtual void Quit(); -void Close(); - -void AddChild(OBView *child, OBView *before = NULL); -bool RemoveChild(OBView *child); -int32 CountChildren() const; -OBView *ChildAt(int32 index) const; - -virtual void DispatchMessage(BMessage *message, BHandler *handler); -virtual void MessageReceived(BMessage *message); -virtual void FrameMoved(BPoint new_position); -virtual void WorkspacesChanged(uint32 old_ws, uint32 new_ws); -virtual void WorkspaceActivated(int32 ws, bool state); -virtual void FrameResized(float new_width, float new_height); -virtual void Minimize(bool minimize); -virtual void Zoom( BPoint rec_position, - float rec_width, - float rec_height); -void Zoom(); -virtual void ScreenChanged(BRect screen_size, color_space depth); -bool NeedsUpdate() const; -void UpdateIfNeeded(); -OBView *FindView(const char *view_name) const; -OBView *FindView(BPoint) const; -OBView *CurrentFocus() const; -void Activate(bool = true); -virtual void WindowActivated(bool state); -void ConvertToScreen(BPoint *pt) const; -BPoint ConvertToScreen(BPoint pt) const; -void ConvertFromScreen(BPoint *pt) const; -BPoint ConvertFromScreen(BPoint pt) const; -void ConvertToScreen(BRect *rect) const; -BRect ConvertToScreen(BRect rect) const; -void ConvertFromScreen(BRect *rect) const; -BRect ConvertFromScreen(BRect rect) const; -void MoveBy(float dx, float dy); -void MoveTo(BPoint); -void MoveTo(float x, float y); -void ResizeBy(float dx, float dy); -void ResizeTo(float width, float height); -virtual void Show(); -virtual void Hide(); -bool IsHidden() const; -bool IsMinimized() const; - -void Flush() const; -void Sync() const; - -status_t SendBehind(const OBWindow *window); - -void DisableUpdates(); -void EnableUpdates(); - -void BeginViewTransaction(); -void EndViewTransaction(); - -BRect Bounds() const; -BRect Frame() const; -const char *Title() const; -void SetTitle(const char *title); -bool IsFront() const; -bool IsActive() const; -uint32 Workspaces() const; -void SetWorkspaces(uint32); -OBView *LastMouseMovedView() const; - - -status_t AddToSubset(OBWindow *window); -status_t RemoveFromSubset(OBWindow *window); - -virtual bool QuitRequested(); -virtual thread_id Run(); - -protected: -friend OBView; - -uint32 WindowLookToInteger(window_look wl); -uint32 WindowFeelToInteger(window_feel wf); -window_look WindowLookFromType(window_type t); -window_feel WindowFeelFromType(window_type t); - -BString *wtitle; -int32 ID; -int32 topview_ID; -uint8 hidelevel; -uint32 wflags; - -PortLink *drawmsglink, *serverlink; -port_id inport; -port_id outport; - -OBView *top_view; -OBView *focusedview; -OBView *fLastMouseMovedView; -BRect wframe; - -window_look wlook; -window_feel wfeel; - -bool startlocked; -bool in_update; -bool is_active; -int32 wkspace; -}; - -#endif diff --git a/src/servers/app/proto6/testobapp/PortLink.cpp b/src/servers/app/proto6/testobapp/PortLink.cpp deleted file mode 100644 index 8fba724569..0000000000 --- a/src/servers/app/proto6/testobapp/PortLink.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/* - PortLink.cpp: - A helper class for port-based messaging - ------------------------------------------------------------------------- -How it works: - The class utilizes a fixed-size array of PortLinkData object pointers. When -data is attached, a new PortLinkData object is allocated and a copy of the -passed data is created inside it. When the time comes for the message to be sent, -the data is pieced together into a flattened array and written to the port. ------------------------------------------------------------------------- -Data members: - -*attachments[] - fixed-size array of pointers used to hold the attached data -opcode - message value which is sent along with any data -target - port to which the message is sent when Flush() is called -replyport - port used with synchronous messaging - FlushWithReply() -bufferlength - total bytes taken up by attachments -num_attachments - internal variable which is used to track which "slot" - will be the next one to receive an attachment object -*/ - -#include "PortLink.h" -#include -#include -#include - -//#define PLDEBUG - -// Internal data storage class for holding attached data whilst it is waiting -// to be Flattened() and then Flushed(). There is no need for this to be called outside -// the PortLink class. -class PortLinkData -{ -public: - PortLinkData(void); - ~PortLinkData(void); - bool Set(void *data, size_t size); - char *buffer; - size_t buffersize; -}; - -PortLink::PortLink(port_id port) -{ - // For this class to be useful (and to prevent a lot of init problems) - // we require a port in the constructor - target=port; - - // We start out without any data attached to the port message - num_attachments=0; - opcode=0; - bufferlength=0; - replyport=create_port(30,"PortLink reply port"); -} - -PortLink::~PortLink(void) -{ - // If, for some odd reason, this is deleted with something attached, - // free the memory used by the attachments. We do not flush the queue - // because the port may no longer be valid in cases such as the app - // is in the process of quitting - MakeEmpty(); -} - -void PortLink::SetOpCode(int32 code) -{ - // Sets the message code. This does not change once the message is sent. - // Another call to SetOpCode() is required for such things. - opcode=code; -} - -void PortLink::SetPort(port_id port) -{ - // Sets the target port. While not necessary in most uses, this exists - // mostly to prevent flexibility problems - target=port; -} - -port_id PortLink::GetPort(void) -{ - // Simply returns the port at which the object is pointed. - return target; -} - -void PortLink::Flush(bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message off to the target, complete with attachments. NOTE: - // the recipient must delete all attachments, being the PortLink object assumes - // no responsiblity for the attachments once the message is sent. - int8 *msgbuffer; - int32 size; - - if(num_attachments>0) - { - FlattenData(&msgbuffer,&size); - - // Dump message to port, reset attachments, and clean up - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,msgbuffer,size,B_TIMEOUT, timeout); - else - write_port(target,opcode,msgbuffer,size); - MakeEmpty(); - } - else - { - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,NULL,0,B_TIMEOUT, timeout); - else - write_port(target,opcode,NULL,0); - } -} - -int8* PortLink::FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message to the target and then waits for a reply. The target will - // receive a message with the first item being the port_id to reply to. - // NOTE: like Flush(), any attached data must be deleted. - - // Effectively, an Attach() call inlined for changes - - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - { - *status=B_ERROR; - return NULL; - } - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&replyport,sizeof(port_id))) - { - bufferlength+=sizeof(port_id); - } - else - { - delete pld; - *status=B_ERROR; - return NULL; - } - - // Flatten() inlined to make some necessary changes - int8 *buffer=new int8[bufferlength]; - int8 *bufferindex=buffer; - size_t size=0; - - // attach our port_id first - memcpy(bufferindex, pld->buffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - - // attach everything else - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - } - - // Flush the thing....FOOSH! :P - write_port(target,opcode,buffer,size); - MakeEmpty(); - delete buffer; - - // Now we wait for the reply - if(timeout==B_INFINITE_TIMEOUT) - { - *buffersize=port_buffer_size(replyport); - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - else - { - *buffersize=port_buffer_size_etc(replyport,0,timeout); - if(*buffersize==B_TIMED_OUT) - { - *status=*buffersize; - return NULL; - } - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - - // We got this far, so we apparently have some data - *status=B_OK; - return buffer; -} - -void PortLink::Attach(void *data, size_t size) -{ - // This is the member called to attach data to a message. Attachments are - // treated to be in 'Append' mode, tacking on each attached piece of data - // to the end of the list. - - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - if(size==0) - return; - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -// These functions were added for a major convenience in passing common types -// Eventually, I'd like to templatize these, but for now, this'll do - -void PortLink::Attach(int32 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int32); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int16 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int16); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int8 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int8); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(float data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(float); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(bool data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(bool); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BRect data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BRect); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BPoint data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BPoint); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::FlattenData(int8 **buffer,int32 *size) -{ - // This function is where all the magic happens, but it is strictly internal. - // It iterates through each PortLinkData object and copies it to the main buffer - // which ends up, ultimately, being written to the PortLink's target port. - - // skip if there aree no attachments - if(bufferlength<1) - return; - - *buffer=new int8[bufferlength]; - int8 *bufferindex=*buffer; - PortLinkData *pld; - *size=0; - - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - *size+=pld->buffersize; - } -} - -void PortLink::MakeEmpty(void) -{ - // Nukes all the attachments currently held by the PortLink class - if(num_attachments!=0) - { - for(int i=0; i0) - free(buffer); -} - -bool PortLinkData::Set(void *data, size_t size) -{ - // Function copies the passed to the internal buffers for storage - if(size>0 && buffersize==0 && data!=NULL) - { - buffer=(char *)malloc(size); - if(buffer==NULL) - return false; - memcpy(buffer, data, size); - buffersize=size; - return true; - } - return false; -} diff --git a/src/servers/app/proto6/testobapp/PortLink.h b/src/servers/app/proto6/testobapp/PortLink.h deleted file mode 100644 index 429f342024..0000000000 --- a/src/servers/app/proto6/testobapp/PortLink.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _PORTLINK_H_ -#define _PORTLINK_H_ - -#include -#include -#include -#include - -#ifndef _PORTLINK_BUFFERSIZE -#define _PORTLINK_MAX_ATTACHMENTS 50 -#endif - -class PortLinkData; - -class PortLink -{ -public: - PortLink(port_id port); - ~PortLink(void); - void SetOpCode(int32 code); - void SetPort(port_id port); - port_id GetPort(void); - void Flush(bigtime_t timeout=B_INFINITE_TIMEOUT); - int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, - bigtime_t timeout=B_INFINITE_TIMEOUT); - void Attach(void *data, size_t size); - void Attach(int32 data); - void Attach(int16 data); - void Attach(int8 data); - void Attach(float data); - void Attach(bool data); - void Attach(BRect data); - void Attach(BPoint data); - void MakeEmpty(void); -protected: - void FlattenData(int8 **buffer,int32 *size); - port_id target, replyport; - int32 opcode, bufferlength; - int num_attachments; - PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS]; -}; - -#endif diff --git a/src/servers/app/proto6/testobapp/ServerProtocol.h b/src/servers/app/proto6/testobapp/ServerProtocol.h deleted file mode 100644 index 5ec43dc441..0000000000 --- a/src/servers/app/proto6/testobapp/ServerProtocol.h +++ /dev/null @@ -1,95 +0,0 @@ -#ifndef _APPSERVER_PROTOCOL_ -#define _APPSERVER_PROTOCOL_ - -#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' - -#define SERVER_PORT_NAME "OBappserver" -#define SERVER_INPUT_PORT "OBinputport" - -#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 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' - -#define GFX_SET_HIGH_COLOR 'gshc' -#define GFX_SET_LOW_COLOR 'gslc' -#define GFX_SET_VIEW_COLOR 'gsvc' - -#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' - -#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' - -#define GFX_MOVEPENBY 'gmpb' -#define GFX_MOVEPENTO 'gmpt' -#define GFX_SETPENSIZE 'gsps' - -#define GFX_DRAW_STRING 'gdst' -#define GFX_SET_FONT 'gsft' -#define GFX_SET_FONT_SIZE 'gsfs' - -#define GFX_FLUSH 'gfsh' -#define GFX_SYNC 'gsyn' - -#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 BEGIN_RECT_TRACKING 'rtbg' -#define END_RECT_TRACKING 'rten' - -#define VIEW_GET_TOKEN 'vgtk' -#define VIEW_ADD 'vadd' -#define VIEW_REMOVE 'vrem' -#endif diff --git a/src/servers/app/proto7/Angle.cpp b/src/servers/app/proto7/Angle.cpp deleted file mode 100644 index 744d8e77bc..0000000000 --- a/src/servers/app/proto7/Angle.cpp +++ /dev/null @@ -1,292 +0,0 @@ -#include "Angle.h" - -#ifndef ANGLE_PI - #define ANGLE_PI 3.14159265358979323846 -#endif - -bool tables_initialized=false; -float sintable[360], costable[360], tantable[360]; - -Angle::Angle(float angle) -{ - angle_value=angle; - if(tables_initialized==false) - { - InitTrigTables(); - tables_initialized=true; - } -} - -Angle::Angle(void) -{ - angle_value=0; - if(tables_initialized==false) - { - InitTrigTables(); - tables_initialized=true; - } -} - -Angle::~Angle(void) -{ -} - -void Angle::Normalize(void) -{ - // if the value of the angle is >=360 or <0, make it so that it is - // within those bounds - - if(angle_value>359) - { - while(angle_value>359) - angle_value-=360; - return; - } - if(angle_value<0) - { - while(angle_value<0) - angle_value+=360; - } -} - -float Angle::Sine(void) -{ - return sintable[(int)angle_value]; -} - -Angle Angle::InvSine(float value) -{ - // Returns the inverse sine of a value in the range 0 <= value <= 1 via - // reverse-lookup any value out of range causes the function to return 0 - uint16 i=90; - - // Filter out bad values - if(value<0) - value*=-1; - - if(value > 1) - return 0; - - while(value < sintable[i]) - i--; - - // current sintable[i] is less than value. Pick the degree value which is closer - // to the passed value - if( (value - sintable[i]) > (sintable[i+1] - value) ) - return (i+1); - - return Angle(i); // value is closer to previous -} - - -float Angle::Cosine(void) -{ - return costable[(int)angle_value]; -} - -Angle Angle::InvCosine(float value) -{ - // Returns the inverse cosine of a value in the range 0 <= value <= 1 via - // reverse-lookup any value out of range causes the function to return 0 - uint16 i=90; - - // Filter out bad values - if(value<0) - value*=-1; - - if(value > 1) - return 0; - - while(value > costable[i]) - i--; - - // current costable[i] is less than value. Pick the degree value which is closer - // to the passed value - if( (value - costable[i]) < (costable[i+1] - value) ) - return (i+1); - - return Angle(i); // value is closer to previous -} - -float Angle::Tangent(int *status=NULL) -{ - if(angle_value==90 || angle_value==270) - { - if(status) - *status=0; - return 0.0; - } - - return tantable[(int)angle_value]; -} - -Angle Angle::InvTangent(float value) -{ - // Returns the inverse cosine of a value in the range 0 <= value <= 1 via - // reverse-lookup any value out of range causes the function to return 0 - uint16 i=90; - - // Filter out bad values - if(value<0) - value*=-1; - - if(value > 1) - return 0; - - while(value > tantable[i]) - i--; - - // current costable[i] is less than value. Pick the degree value which is closer - // to the passed value - if( (value - tantable[i]) < (tantable[i+1] - value) ) - return (i+1); - - return Angle(i); // value is closer to previous -} - -uint8 Angle::Quadrant(void) -{ - // Returns a value based on what quadrant the angle is in. - // 1: 0 <= angle <90 - // 2: 90 <= angle < 180 - // 3: 180 <= angle < 270 - // 4: 270 <= angle < 360 - - - // We can get away with not doing extra value checks because of the order in - // which the checks are done. - if(angle_value < 90) - return 1; - - if(angle_value < 180) - return 2; - - if(angle_value < 270) - return 3; - - return 4; -} - -Angle Angle::Constrain180(void) -{ - // Constrains angle to 0 <= angle < 180 - float val=angle_value; - - if(angle_value<180) - return Angle(angle_value); - - while(!(val<180)) - val-=90; - return Angle(val); -} - -Angle Angle::Constrain90(void) -{ - // Constrains angle to 0 <= angle < 90 - float val=angle_value; - - if(angle_value<90) - return Angle(angle_value); - - while(!(val<90)) - val-=90; - return Angle(val); -} - -void Angle::SetValue(float angle) -{ - angle_value=angle; - Normalize(); -} - -float Angle::Value(void) const -{ - return angle_value; -} - -void Angle::InitTrigTables(void) -{ - int8 i; - double sval,cval,tval,current_radian; - - for(i=0;i<90; i++) - { - current_radian=(i * ANGLE_PI)/180.0; - - // Get these so that we can do some superfast assignments - sval=(float)sin(current_radian); - cval=(float)cos(current_radian); - - // Do 4 assignments, taking advantage of sin/cos symmetry - sintable[i]=sval; - sintable[i+90]=cval; - sintable[i+180]=sval * -1; - sintable[i+270]=cval * -1; - - costable[i]=cval; - costable[i+90]=sval * -1; - costable[i+180]=cval * -1; - costable[i+270]=sval; - - tval=sval/cval; - - tantable[i]=tval; - tantable[i+90]=tval; - tantable[i+180]=tval; - tantable[i+270]=tval; - } -} - -Angle & Angle::operator=(const Angle &from) -{ - angle_value=from.angle_value; - return *this; -} - -Angle & Angle::operator=(const float &from) -{ - angle_value=from; - return *this; -} - -Angle & Angle::operator=(const long &from) -{ - angle_value=(float)from; - return *this; -} - -Angle & Angle::operator=(const int &from) -{ - angle_value=(float)from; - return *this; -} - -bool Angle::operator==(const Angle &from) -{ - return (angle_value==from.angle_value)?true:false; -} - -bool Angle::operator!=(const Angle &from) -{ - return (angle_value!=from.angle_value)?true:false; -} - -bool Angle::operator>(const Angle &from) -{ - return (angle_value>from.angle_value)?true:false; -} - -bool Angle::operator<(const Angle &from) -{ - return (angle_value=(const Angle &from) -{ - return (angle_value>=from.angle_value)?true:false; -} - -bool Angle::operator<=(const Angle &from) -{ - return (angle_value<=from.angle_value)?true:false; -} diff --git a/src/servers/app/proto7/Angle.h b/src/servers/app/proto7/Angle.h deleted file mode 100644 index d6d4d9163c..0000000000 --- a/src/servers/app/proto7/Angle.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef _ANGLE_H_ -#define _ANGLE_H_ - -#include - -class Angle -{ -public: - Angle(float angle); - Angle(void); - virtual ~Angle(void); - - void Normalize(void); - - float Sine(void); - Angle InvSine(float value); - - float Cosine(void); - Angle InvCosine(float value); - - float Tangent(int *status=NULL); - Angle InvTangent(float value); - - uint8 Quadrant(void); - Angle Constrain180(void); - Angle Constrain90(void); - - void SetValue(float angle); - float Value(void) const; - Angle &operator=(const Angle &from); - Angle &operator=(const float &from); - Angle &operator=(const long &from); - Angle &operator=(const int &from); - bool operator==(const Angle &from); - bool operator!=(const Angle &from); - bool operator<(const Angle &from); - bool operator>(const Angle &from); - bool operator>=(const Angle &from); - bool operator<=(const Angle &from); - -protected: - float angle_value; - void InitTrigTables(void); -}; - -#endif diff --git a/src/servers/app/proto7/AppServer.cpp b/src/servers/app/proto7/AppServer.cpp deleted file mode 100644 index 78460b293f..0000000000 --- a/src/servers/app/proto7/AppServer.cpp +++ /dev/null @@ -1,674 +0,0 @@ -/* - AppServer.cpp - File for the main app_server thread. This particular thread monitors for - application start and quit messages. It also starts the housekeeping threads - and initializes most of the server's globals. -*/ -#include -#include -#include "scheduler.h" -#include -#include -#include -#include -#include "AppServer.h" -#include "FontServer.h" -#include "Layer.h" -#include "ServerApp.h" -#include "ServerWindow.h" -#include "Desktop.h" -#include "ServerProtocol.h" -#include "PortLink.h" -#include "DisplayDriver.h" -#include "DebugTools.h" -#include "BeDecorator.h" - -//#define DEBUG_APPSERVER_THREAD -//#define DEBUG_POLLER_THREAD - -// This bad boy holds only the top layer for each workspace -//BList *layerlist; - -// Used for mediating access to the layer lists -//BLocker *layerlock; - -// Used for access via instantiate_decorator -AppServer *app_server; - -AppServer::AppServer(void) : BApplication("application/x-vnd.obe-OBAppServer") -{ -#ifdef DEBUG_APPSERVER_THREAD - printf("AppServer()\n"); -#endif - - mouseport=create_port(100,SERVER_INPUT_PORT); - messageport=create_port(100,SERVER_PORT_NAME); -#ifdef DEBUG_APPSERVER_THREAD -printf("Server message port: %ld\n",messageport); -printf("Server input port: %ld\n",mouseport); -#endif - applist=new BList(0); - quitting_server=false; - exit_poller=false; - - fontserver=new FontServer; - fontserver->Lock(); - fontserver->ScanDirectory("/boot/beos/etc/fonts/ttfonts/"); -// fontserver->ScanDirectory("/boot/beos/etc/fonts/PS-Type1/"); -// fontserver->ScanDirectory("/boot/home/config/fonts/ttfonts/"); -// fontserver->ScanDirectory("/boot/home/config/fonts/psfonts/"); - fontserver->SaveList(); - - if(!fontserver->SetSystemPlain("Swis721 BT","Roman",12)) - printf("Couldn't set plain to Swis721 BT, Roman 12 pt\n"); - if(!fontserver->SetSystemBold("Dutch801 Rm BT","Bold",12)) - printf("Couldn't set bold to Dutch801 Rm BT, Bold 12 pt\n"); - if(!fontserver->SetSystemFixed("Courier10 BT","Roman",12)) - printf("Couldn't set fixed to Courier10 BT, Roman 12 pt\n"); - fontserver->Unlock(); - - // Set up the Desktop - init_desktop(3); - - // This is necessary to mediate access between the Poller and app_server threads - active_lock=new BLocker; - - // This locker is for app_server and Picasso to vy for control of the ServerApp list - applist_lock=new BLocker; - - // This locker is to mediate access to the make_decorator pointer - decor_lock=new BLocker; - - // Get the driver first - Poller thread utilizes the thing - driver=get_gfxdriver(); - - // Spawn our input-polling thread - 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); - if (picasso_id >= 0) - resume_thread(picasso_id); - - active_app=-1; - p_active_app=NULL; - - make_decorator=NULL; -// layerlock=new BLocker; -// layerlist=new BList(1); - LoadGUIColors(); -} - -AppServer::~AppServer(void) -{ - shutdown_desktop(); - - ServerApp *tempapp; -// Layer *templayer; - int32 i; - applist_lock->Lock(); - for(i=0;iCountItems();i++) - { - tempapp=(ServerApp *)applist->ItemAt(i); - if(tempapp!=NULL) - delete tempapp; - } - delete applist; - applist_lock->Unlock(); - -/* layerlock->Lock(); - for(i=0;iCountItems();i++) - { - templayer=(Layer *)layerlist->ItemAt(i); - - if(templayer!=NULL) - { - templayer->PruneTree(); - delete templayer; - } - } - delete layerlist; - layerlock->Unlock(); - - delete layerlock; -*/ delete active_lock; - delete applist_lock; - - // If these threads are still running, kill them - after this, if exit_poller - // is deleted, who knows what will happen... These things will just return an - // error and fail if the threads have already exited. - kill_thread(poller_id); - kill_thread(picasso_id); - - delete decor_lock; - delete fontserver; - - make_decorator=NULL; -} - -thread_id AppServer::Run(void) -{ -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer::Run()\n"); -#endif - - MainLoop(); - return 0; -} - -void AppServer::MainLoop(void) -{ - // Main loop (duh). Monitors the message queue and dispatches as appropriate. - // Input messages are handled by the poller, however. - -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer::MainLoop()\n"); -#endif - - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(messageport); - if(buffersize>0) - msgbuffer=new int8[buffersize]; - bytesread=read_port(messageport,&msgcode,msgbuffer,buffersize); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case CREATE_APP: - case DELETE_APP: - case GET_SCREEN_MODE: - case B_QUIT_REQUESTED: - case UPDATED_CLIENT_FONTLIST: - case QUERY_FONTS_CHANGED: - DispatchMessage(msgcode,msgbuffer); - break; - default: - { -#ifdef DEBUG_APPSERVER_THREAD -printf("Server received unexpected code %ld\n",msgcode); -#endif - break; - } - } - - } - - if(buffersize>0) - delete msgbuffer; - if(msgcode==DELETE_APP || msgcode==B_QUIT_REQUESTED) - { - 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); - -} - - -void AppServer::DispatchMessage(int32 code, int8 *buffer) -{ - int8 *index=buffer; - switch(code) - { - case CREATE_APP: - { - // Create the ServerApp to node monitor a new BApplication - -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer: Create App\n"); -#endif - - // Attached data: - // 1) port_id - port to reply to - // 2) port_id - receiver port of a regular app - // 3) char * - signature of the regular app - - // Find the necessary data - port_id reply_port=*((port_id*)index); index+=sizeof(port_id); -#ifdef DEBUG_APPSERVER_THREAD -printf("\tCreate App: reply port is %lu\n",reply_port); -#endif - port_id app_port=*((port_id*)index); index+=sizeof(port_id); -#ifdef DEBUG_APPSERVER_THREAD -printf("\tCreate App: ServerApp port is %lu\n", app_port); -#endif - - char *app_signature=(char *)index; -#ifdef DEBUG_APPSERVER_THREAD -printf("\tCreate App: Signature received is %s\n", app_signature); -#endif - - // Create the ServerApp subthread for this app - applist_lock->Lock(); - ServerApp *newapp=new ServerApp(app_port,app_signature); - applist->AddItem(newapp); - applist_lock->Unlock(); - - active_lock->Lock(); - p_active_app=newapp; - active_app=applist->CountItems()-1; - - PortLink *replylink=new PortLink(reply_port); - replylink->SetOpCode(SET_SERVER_PORT); - replylink->Attach((int32)newapp->receiver); - replylink->Flush(); - - delete replylink; - - active_lock->Unlock(); - - newapp->Run(); - - break; - } - case DELETE_APP: - { - // Delete a ServerApp. Received only from the respective ServerApp when a - // BApplication asks it to quit. - -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer: Delete App\n"); -#endif - - // Attached Data: - // 1) thread_id - thread ID of the ServerApp to be deleted - - int32 i, appnum=applist->CountItems(); - ServerApp *srvapp; - thread_id srvapp_id=*((thread_id*)buffer); - - // Run through the list of apps and nuke the proper one - for(i=0;iItemAt(i); - - if(srvapp!=NULL && srvapp->monitor_thread==srvapp_id) - { - applist_lock->Lock(); - srvapp=(ServerApp *)applist->RemoveItem(i); - if(srvapp) - { - delete srvapp; - srvapp=NULL; - } - applist_lock->Unlock(); - active_lock->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; - active_lock->Unlock(); - break; // jump out of our for() loop - } - - } - break; - } - case UPDATED_CLIENT_FONTLIST: - { - // received when the client-side global font list has been - // refreshed - fontserver->Lock(); - fontserver->FontsUpdated(); - fontserver->Unlock(); - break; - } - case QUERY_FONTS_CHANGED: - { - // Client application is asking if the font list has changed since - // the last client-side refresh - - // Attached data: - // 1) port_id reply port - - fontserver->Lock(); - bool needs_update=fontserver->FontsNeedUpdated(); - fontserver->Unlock(); - - PortLink *pl=new PortLink(*((port_id*)index)); - pl->SetOpCode( (needs_update)?SERVER_TRUE:SERVER_FALSE ); - pl->Flush(); - delete pl; - - break; - } - case 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 - // BScreens are done. - -#ifdef DEBUG_APPSERVER_THREAD -printf("AppServer: Get Screen Mode\n"); -#endif - // Attached Data: - // 1) port_id - port to reply to - - // Returned Data: - // 1) int32 width - // 2) int32 height - // 3) int depth - - PortLink *replylink=new PortLink(*((port_id*)index)); - replylink->SetOpCode(GET_SCREEN_MODE); - replylink->Attach((int16)driver->GetWidth()); - replylink->Attach((int16)driver->GetHeight()); - replylink->Attach((int16)driver->GetDepth()); - replylink->Flush(); - delete replylink; - break; - } - case B_QUIT_REQUESTED: - { -#ifdef DEBUG_APPSERVER_THREAD -printf("Shutdown sequence initiated.\n"); -#endif - - // Attached Data: - // none - - // 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. - PortLink *applink=new PortLink(0); - ServerApp *srvapp; - - applist_lock->Lock(); - int32 i,appnum=applist->CountItems(); - - applink->SetOpCode(QUIT_APP); - for(i=0;iItemAt(i); - if(srvapp!=NULL) - { - applink->SetPort(srvapp->receiver); - applink->Flush(); - } - } - applist_lock->Unlock(); - - delete applink; - // So when we delete the last ServerApp, we can exit the server - quitting_server=true; - exit_poller=true; - break; - } - default: - //printf("Unexpected message %ld (%lx) in AppServer::DispatchMessage()\n",code,code); - break; - } -} - -bool AppServer::LoadDecorator(BString path) -{ - // Loads a window decorator based on the supplied path and forces a decorator update. - // If it cannot load the specified decorator, it will retain the current one and - // return false. - - create_decorator *pcreatefunc=NULL; - get_version *pversionfunc=NULL; - status_t stat; - image_id addon; - - addon=load_add_on(path.String()); - - stat=get_image_symbol(addon, "get_decorator_version", B_SYMBOL_TYPE_TEXT, (void**)&pversionfunc); - if(stat!=B_OK) - { - printf("ERROR: Could not get version for Decorator %s\n", path.String()); - unload_add_on(addon); - return false; - } - - // As of now, we do nothing with decorator versions, but the possibility exists - // that the API will change even though I cannot forsee any reason to do so. If - // we *did* do anything with decorator versions, the assignment to a global would - // go here. - - stat=get_image_symbol(addon, "instantiate_decorator", B_SYMBOL_TYPE_TEXT, (void**)&pversionfunc); - if(stat!=B_OK) - { - printf("ERROR: Could not get allocator for Decorator %s\n", path.String()); - unload_add_on(addon); - return false; - } - decor_lock->Lock(); - make_decorator=pcreatefunc; - decorator_id=addon; - decor_lock->Unlock(); - return true; -} - -void AppServer::LoadDefaultDecorator(void) -{ - // This function is called on server startup to provide a fallback decorator in - // case the decorator specified in the config file cannot be loaded. It just - // wouldn't do to have windows with no borders. ;) It also unloads any loaded - // decorator addons. We can specify that we want the default. It is no less - // functional - just internal. - -} - -Decorator *instantiate_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel, int32 wflags, - DisplayDriver *ddriver) -{ - Decorator *decor=NULL; - - app_server->LockDecorator(); - if(app_server->make_decorator!=NULL) - decor=app_server->make_decorator(rect,wlook,wfeel,wflags); - else - decor=new BeDecorator(rect,title,wlook,wfeel,wflags,ddriver); - - decor->SetDriver(get_gfxdriver()); - app_server->UnlockDecorator(); - return decor; -} - -void AppServer::Poller(void) -{ - // This thread handles nothing but input messages for mouse and keyboard - int32 msgcode; - int8 *msgbuffer=NULL,*index; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(mouseport); - if(buffersize>0) - msgbuffer=new int8[buffersize]; - bytesread=read_port(mouseport,&msgcode,msgbuffer,buffersize); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - // We don't need to do anything with these two, so just pass them - // onto the active application. Eventually, we will pass them onto - // the window which is currently under the cursor. - case B_MOUSE_DOWN: - { - if(!msgbuffer) - { -#ifdef DEBUG_POLLER_THREAD -printf("Poller: MouseDown() - Empty buffer\n"); -#endif - ServerWindow::HandleMouseEvent(msgcode,msgbuffer); - break; - } - -#ifdef DEBUG_POLLER_THREAD -printf("Poller: MouseDown\n"); -#endif - ServerWindow::HandleMouseEvent(msgcode,msgbuffer); - break; - } - case B_MOUSE_UP: - { - if(!msgbuffer) - { -#ifdef DEBUG_POLLER_THREAD -printf("Poller: MouseUp() - Empty buffer\n"); -#endif - break; - } -/* - active_lock->Lock(); - if(active_app>-1 && p_active_app!=NULL) - write_port(p_active_app->receiver, msgcode,msgbuffer,buffersize); - active_lock->Unlock(); -*/ -#ifdef DEBUG_POLLER_THREAD -printf("Poller: MouseUp\n"); -#endif - ServerWindow::HandleMouseEvent(msgcode,msgbuffer); - 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 - - index=msgbuffer; - if(!index) - { -#ifdef DEBUG_POLLER_THREAD -printf("Poller: MouseMoved() - Empty buffer\n"); -#endif - break; - } - - // Time sent is not necessary for cursor processing. - index += sizeof(int64); - - float tempx=0,tempy=0; - tempx=*((float*)index); - index+=sizeof(float); - tempy=*((float*)index); - index+=sizeof(float); -#ifdef DEBUG_POLLER_THREAD -printf("Poller: MouseMoved(%f,%f)\n",tempx,tempy); -#endif - driver->MoveCursorTo(tempx,tempy); - -/* active_lock->Lock(); - if(active_app>-1 && p_active_app!=NULL) - write_port(p_active_app->receiver, msgcode,msgbuffer,buffersize); - active_lock->Unlock(); -*/ - ServerWindow::HandleMouseEvent(msgcode,msgbuffer); - break; - } - default: - //printf("Server::Poller received unexpected code %ld\n",msgcode); - break; - } - - } - - if(buffersize>0) - delete msgbuffer; - - if(exit_poller) - break; - } -} - -int32 AppServer::PollerThread(void *data) -{ -#ifdef DEBUG_POLLER_THREAD -printf("Starting Poller thread...\n"); -#endif - AppServer *server=(AppServer *)data; - - // This won't return until it's told to - server->Poller(); - -#ifdef DEBUG_POLLER_THREAD -printf("Exiting Poller thread...\n"); -#endif - exit_thread(B_OK); - return B_OK; -} - -void AppServer::Picasso(void) -{ - int32 i; - ServerApp *app; - for(;;) - { - applist_lock->Lock(); - for(i=0;iCountItems(); i++) - { - app=(ServerApp*)applist->ItemAt(i); - ASSERT(app!=NULL); - app->PingTarget(); - } - applist_lock->Unlock(); - - // if poller thread has to exit, so do we - I just was too lazy - // to rename the variable name. ;) - if(exit_poller) - break; - - // we do this every other second so as not to suck *too* many CPU cycles - snooze(2000000); - } -} - -int32 AppServer::PicassoThread(void *data) -{ -#ifdef DEBUG_APPSERVER_THREAD -printf("Starting Picasso thread...\n"); -#endif - AppServer *server=(AppServer *)data; - - // This won't return until it's told to - server->Picasso(); - -#ifdef DEBUG_APPSERVER_THREAD -printf("Exiting Picasso thread...\n"); -#endif - exit_thread(B_OK); - return B_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(); - app_server->Run(); - delete app_server; - return 0; -} diff --git a/src/servers/app/proto7/AppServer.h b/src/servers/app/proto7/AppServer.h deleted file mode 100644 index 5c03eb9186..0000000000 --- a/src/servers/app/proto7/AppServer.h +++ /dev/null @@ -1,52 +0,0 @@ -#ifndef _OPENBEOS_APP_SERVER_H_ -#define _OPENBEOS_APP_SERVER_H_ - -#include -#include -#include -#include -//#include // for window_look -#include "Decorator.h" - -class Layer; -class BMessage; -class ServerApp; -class DisplayDriver; - -class AppServer : public BApplication -{ -public: - AppServer(void); - ~AppServer(void); - thread_id Run(void); - void MainLoop(void); - port_id messageport,mouseport; - void Poller(void); - void Picasso(void); - void LockDecorator(void) { if(decor_lock) decor_lock->Lock(); } - void UnlockDecorator(void) { if(decor_lock) decor_lock->Unlock(); } - create_decorator *make_decorator; // global function pointer -private: - friend Decorator *instantiate_decorator(Layer *lay, const char *title, uint32 dflags, uint32 wlook); - - void DispatchMessage(int32 code, int8 *buffer); - static int32 PollerThread(void *data); - static int32 PicassoThread(void *data); - bool LoadDecorator(BString path); - void LoadDefaultDecorator(void); - - image_id decorator_id; - bool quitting_server; - BList *applist; - int32 active_app; - ServerApp *p_active_app; - thread_id poller_id, picasso_id; - - BLocker *active_lock, *applist_lock, *decor_lock; - bool exit_poller; - DisplayDriver *driver; -}; - -Decorator *instantiate_decorator(BRect rect, const char *title, int32 wlook, int32 wfeel, - int32 wflags, DisplayDriver *ddriver); -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/BeDecorator.cpp b/src/servers/app/proto7/BeDecorator.cpp deleted file mode 100644 index 188185cbe7..0000000000 --- a/src/servers/app/proto7/BeDecorator.cpp +++ /dev/null @@ -1,549 +0,0 @@ -#include "DisplayDriver.h" -#include -#include -#include "LayerData.h" -#include "ColorUtils.h" -#include "ColorSet.h" -#include "BeDecorator.h" -#include "RGBColor.h" -#include "Desktop.h" - -//#define DEBUG_DECOR - -#ifdef DEBUG_DECOR -#include -#endif - -BeDecorator::BeDecorator(BRect rect, const char *title, int32 wlook, int32 wfeel, int32 wflags, - DisplayDriver *ddriver) - : Decorator(rect,title,wlook,wfeel,wflags,ddriver) -{ -#ifdef DEBUG_DECOR -printf("BeDecorator()\n"); -#endif - taboffset=0; - - // These hard-coded assignments will go bye-bye when the system colors - // API is implemented - - // commented these out because they are taken care of by the SetFocus() call - *colors=GetGUIColors(); - SetFocus(false); - - frame_highercol.SetColor(216,216,216); - frame_lowercol.SetColor(110,110,110); - - textcol.SetColor(0,0,0); - - frame_highcol=frame_lowercol.MakeBlendColor(frame_highercol,0.75); - frame_midcol=frame_lowercol.MakeBlendColor(frame_highercol,0.5); - frame_lowcol=frame_lowercol.MakeBlendColor(frame_highercol,0.25); - - _DoLayout(); - - // This flag is used to determine whether or not we're moving the tab - solidhigh=0xFFFFFFFFFFFFFFFFLL; - solidlow=0; - - tab_highcol=colors->window_tab; - tab_lowcol=colors->window_tab; -} - -BeDecorator::~BeDecorator(void) -{ -#ifdef DEBUG_DECOR -printf("~BeDecorator()\n"); -#endif -} - -click_type BeDecorator::Clicked(BPoint pt, int32 buttons, int32 modifiers) -{ - if(closerect.Contains(pt) && (flags & B_NOT_CLOSABLE)==0) - { - -#ifdef DEBUG_DECOR -printf("BeDecorator():Clicked() - Close\n"); -#endif - - return CLICK_CLOSE; - } - - if(zoomrect.Contains(pt) && (flags & B_NOT_ZOOMABLE)==0) - { - -#ifdef DEBUG_DECOR -printf("BeDecorator():Clicked() - Zoom\n"); -#endif - - return CLICK_ZOOM; - } - - if(resizerect.Contains(pt) && look==WLOOK_DOCUMENT && (flags & B_NOT_RESIZABLE)==0) - { - -#ifdef DEBUG_DECOR -printf("BeDecorator():Clicked() - Resize thumb\n"); -#endif - - return CLICK_RESIZE; - } - - // Clicking in the tab? - if(tabrect.Contains(pt) && (flags & B_NOT_MOVABLE)==0) - { - if(buttons && (modifiers & B_SHIFT_KEY)) - return CLICK_SLIDETAB; - - // Here's part of our window management stuff - if(buttons==B_PRIMARY_MOUSE_BUTTON && !GetFocus()) - return CLICK_MOVETOFRONT; - if(buttons==B_SECONDARY_MOUSE_BUTTON) - return CLICK_MOVETOBACK; - return CLICK_DRAG; - } - - // We got this far, so user is clicking on the border? - BRect brect(frame); - brect.top+=19; - BRect clientrect(brect.InsetByCopy(3,3)); - if(brect.Contains(pt) && !clientrect.Contains(pt)) - { -#ifdef DEBUG_DECOR -printf("BeDecorator():Clicked() - Drag\n"); -#endif - if(resizerect.Contains(pt) && (flags & B_NOT_RESIZABLE)==0) - return CLICK_RESIZE; - - if((flags & B_NOT_MOVABLE)==0) - return CLICK_DRAG; - } - - // Guess user didn't click anything -#ifdef DEBUG_DECOR -printf("BeDecorator():Clicked()\n"); -#endif - return CLICK_NONE; -} - -void BeDecorator::_DoLayout(void) -{ - // Here we determine the size of every rectangle that we use - // internally when we are given the size of the client rectangle. - - // Current version simply makes everything fit inside the rect - // instead of building around it. This will change. - -#ifdef DEBUG_DECOR -printf("BeDecorator()::_DoLayout()"); rect.PrintToStream(); -#endif - tabrect=frame; - resizerect=frame; - borderrect=frame; - closerect=frame; - - closerect.left+=(look==WLOOK_FLOATING)?2:4; - closerect.top+=(look==WLOOK_FLOATING)?6:4; - closerect.right=closerect.left+10; - closerect.bottom=closerect.top+10; - closerect.OffsetBy(taboffset,0); - - borderrect.top+=19; - - resizerect.top=resizerect.bottom-18; - resizerect.left=resizerect.right-18; - - tabrect.bottom=tabrect.top+18; - if(titlewidth>0) - { - tabrect.right=closerect.right+textoffset+titlewidth+15; - } - else - tabrect.right=tabrect.left+tabrect.Width()/2; - tabrect.OffsetBy(taboffset,0); - if(tabrect.right>frame.right) - tabrect.right=frame.right; - - - if(look==WLOOK_FLOATING) - tabrect.top+=4; - - zoomrect=tabrect; - zoomrect.top+=(look==WLOOK_FLOATING)?2:4; - zoomrect.right-=4; - zoomrect.bottom-=4; - zoomrect.left=zoomrect.right-10; - zoomrect.bottom=zoomrect.top+10; - - textoffset=(look==WLOOK_FLOATING)?5:7; -// titlechars=_ClipTitle(zoomrect.left-(closerect.right+textoffset)); - titlechars=_ClipTitle(zoomrect.left-closerect.right); -} - -void BeDecorator::SetTitle(const char *string) -{ - Decorator::SetTitle(string); - if(string && driver) - titlewidth=driver->StringWidth(GetTitle(),strlen(GetTitle()),&layerdata); - else - titlewidth=0; -} - -void BeDecorator::MoveBy(float x, float y) -{ - MoveBy(BPoint(x,y)); -} - -void BeDecorator::MoveBy(BPoint pt) -{ - // Move all internal rectangles the appropriate amount - frame.OffsetBy(pt); - closerect.OffsetBy(pt); - tabrect.OffsetBy(pt); - resizerect.OffsetBy(pt); - borderrect.OffsetBy(pt); - zoomrect.OffsetBy(pt); -} - -BRect BeDecorator::SlideTab(float dx, float dy=0) -{ - // Check to see if we would slide it out of bounde - if( (tabrect.right+dx) > frame.right) - dx=frame.right-tabrect.right; - if( (tabrect.left+dx) < frame.left) - dx=frame.left-tabrect.left; - - taboffset+=int32(dx); - if(taboffset<0) - { - dx-=taboffset; - taboffset=0; - } - - BRect oldrect(tabrect); - tabrect.OffsetBy(dx,0); - closerect.OffsetBy(dx,0); - zoomrect.OffsetBy(dx,0); - - if(dx>0) - { - if(tabrect.leftoldrect.left) - oldrect.left=tabrect.right; - } - - return oldrect; -} - -void BeDecorator::ResizeBy(float x, float y) -{ - ResizeBy(BPoint(x,y)); -} - -void BeDecorator::ResizeBy(BPoint pt) -{ - frame.right+=pt.x; - frame.bottom+=pt.y; - _DoLayout(); -} - -BRegion *BeDecorator::GetFootprint(void) -{ - // This function calculates the decorator's footprint in coordinates - // relative to the layer. This is most often used to set a WindowBorder - // object's visible region. - - BRegion *reg=new BRegion(borderrect); - reg->Include(tabrect); - return reg; -} - -void BeDecorator::_DrawTitle(BRect r) -{ - // Designed simply to redraw the title when it has changed on - // the client side. - layerdata.draw_mode=B_OP_OVER; - layerdata.highcolor=colors->window_tab_text; - driver->DrawString(GetTitle(),titlechars, - BPoint(closerect.right+textoffset,closerect.bottom),&layerdata); - layerdata.draw_mode=B_OP_COPY; - -} - -void BeDecorator::_SetFocus(void) -{ - // SetFocus() performs necessary duties for color swapping and - // other things when a window is deactivated or activated. - - if(GetFocus()) - { -// tab_highcol.SetColor(255,236,33); -// tab_lowcol.SetColor(234,181,0); - tab_highcol=colors->window_tab; - tab_lowcol=colors->window_tab; - - button_highcol.SetColor(255,255,0); - button_lowcol.SetColor(255,203,0); - } - else - { - tab_highcol.SetColor(235,235,235); - tab_lowcol.SetColor(160,160,160); - - button_highcol.SetColor(229,229,229); - button_lowcol.SetColor(153,153,153); - } - -} - -void BeDecorator::Draw(BRect update) -{ - // We need to draw a few things: the tab, the resize thumb, the borders, - // and the buttons - - _DrawTab(update); - - // Draw the top view's client area - just a hack :) - RGBColor blue(100,100,255); - - layerdata.highcolor=blue; - - if(borderrect.Intersects(update)) - driver->FillRect(borderrect,&layerdata,(int8*)&solidhigh); - - _DrawFrame(update); -} - -void BeDecorator::Draw(void) -{ - // Easy way to draw everything - no worries about drawing only certain - // things - - // Draw the top view's client area - just a hack :) - RGBColor blue(100,100,255); - - layerdata.highcolor=blue; - - driver->FillRect(borderrect,&layerdata,(int8*)&solidhigh); - DrawFrame(); - - DrawTab(); - -} - -void BeDecorator::_DrawZoom(BRect r) -{ - // If this has been implemented, then the decorator has a Zoom button - // which should be drawn based on the state of the member zoomstate - BRect zr=r; - zr.left+=zr.Width()/3; - zr.top+=zr.Height()/3; - - DrawBlendedRect(zr,GetZoom()); - DrawBlendedRect(zr.OffsetToCopy(r.LeftTop()),GetZoom()); -} - -void BeDecorator::_DrawClose(BRect r) -{ - // Just like DrawZoom, but for a close button - DrawBlendedRect(r,GetClose()); -} - -void BeDecorator::_DrawTab(BRect r) -{ - // If a window has a tab, this will draw it and any buttons which are - // in it. - if(look==WLOOK_NO_BORDER) - return; - - layerdata.highcolor=frame_lowcol; - driver->StrokeRect(tabrect,&layerdata,(int8*)&solidhigh); - - layerdata.highcolor=colors->window_tab; - driver->FillRect(tabrect.InsetByCopy(1,1),&layerdata,(int8*)&solidhigh); - - // Draw the buttons if we're supposed to - if(!(flags & B_NOT_CLOSABLE)) - _DrawClose(closerect); - if(!(flags & B_NOT_ZOOMABLE)) - _DrawZoom(zoomrect); -} - -void BeDecorator::DrawBlendedRect(BRect r, bool down) -{ - // This bad boy is used to draw a rectangle with a gradient. - // Note that it is not part of the Decorator API - it's specific - // to just the BeDecorator. Called by DrawZoom and DrawClose - - // Actually just draws a blended square - int32 w=r.IntegerWidth(), h=r.IntegerHeight(); - - rgb_color tmpcol,halfcol, startcol, endcol; - float rstep,gstep,bstep,i; - - int steps=(wStrokeLine(BPoint(r.left,r.top+i), - BPoint(r.left+i,r.top),&layerdata,(int8*)&solidhigh); - - SetRGBColor(&tmpcol, uint8(halfcol.red-(i*rstep)), - uint8(halfcol.green-(i*gstep)), - uint8(halfcol.blue-(i*bstep))); - - layerdata.highcolor=tmpcol; - driver->StrokeLine(BPoint(r.left+steps,r.top+i), - BPoint(r.left+i,r.top+steps),&layerdata,(int8*)&solidhigh); - - } - -// layerdata.highcolor=startcol; -// driver->FillRect(r,&layerdata,(int8*)&solidhigh); - layerdata.highcolor=frame_lowcol; - driver->StrokeRect(r,&layerdata,(int8*)&solidhigh); -} - -void BeDecorator::_DrawFrame(BRect rect) -{ - // Duh, draws the window frame, I think. ;) - - if(look==WLOOK_NO_BORDER) - return; - - BRect r=borderrect; - - layerdata.highcolor=frame_midcol; - driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top), - &layerdata,(int8*)&solidhigh); - layerdata.highcolor=frame_lowcol; - driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom), - &layerdata,(int8*)&solidhigh); - layerdata.highcolor=frame_lowercol; - driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top), - &layerdata,(int8*)&solidhigh); - layerdata.highcolor=frame_lowercol; - driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom), - &layerdata,(int8*)&solidhigh); - - r.InsetBy(1,1); - layerdata.highcolor=frame_highercol; - driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top), - &layerdata,(int8*)&solidhigh); - layerdata.highcolor=frame_highercol; - driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom), - &layerdata,(int8*)&solidhigh); - layerdata.highcolor=frame_midcol; - driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top), - &layerdata,(int8*)&solidhigh); - layerdata.highcolor=frame_midcol; - driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom), - &layerdata,(int8*)&solidhigh); - - r.InsetBy(1,1); - layerdata.highcolor=frame_highcol; - driver->StrokeRect(r,&layerdata,(int8*)&solidhigh); - - r.InsetBy(1,1); - layerdata.highcolor=frame_lowercol; - driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.right-1,r.top), - &layerdata,(int8*)&solidhigh); - layerdata.highcolor=frame_lowercol; - driver->StrokeLine(BPoint(r.left,r.top),BPoint(r.left,r.bottom), - &layerdata,(int8*)&solidhigh); - layerdata.highcolor=frame_highercol; - driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.right,r.top), - &layerdata,(int8*)&solidhigh); - layerdata.highcolor=frame_highercol; - driver->StrokeLine(BPoint(r.right,r.bottom),BPoint(r.left,r.bottom), - &layerdata,(int8*)&solidhigh); - driver->StrokeRect(borderrect,&layerdata,(int8*)&solidhigh); - - // Draw the resize thumb if we're supposed to - if(!(flags & B_NOT_RESIZABLE)) - { - r=resizerect; - - int32 w=r.IntegerWidth(), h=r.IntegerHeight(); - - // This code is strictly for B_DOCUMENT_WINDOW looks - if(look==WLOOK_DOCUMENT) - { - rgb_color halfcol, startcol, endcol; - float rstep,gstep,bstep,i; - - int steps=(wStrokeLine(BPoint(r.left,r.top+i), - BPoint(r.left+i,r.top),&layerdata,(int8*)&solidhigh); - - layerdata.highcolor.SetColor(uint8(halfcol.red-(i*rstep)), - uint8(halfcol.green-(i*gstep)), - uint8(halfcol.blue-(i*bstep))); - driver->StrokeLine(BPoint(r.left+steps,r.top+i), - BPoint(r.left+i,r.top+steps),&layerdata,(int8*)&solidhigh); - } - layerdata.highcolor=frame_lowercol; - driver->StrokeRect(r,&layerdata,(int8*)&solidhigh); - } - else - { - layerdata.highcolor=frame_lowercol; - driver->StrokeLine(BPoint(r.right,r.top),BPoint(r.right-3,r.top), - &layerdata,(int8*)&solidhigh); - driver->StrokeLine(BPoint(r.left,r.bottom),BPoint(r.left,r.bottom-3), - &layerdata,(int8*)&solidhigh); - } - } -} - -extern "C" float get_decorator_version(void) -{ - return 1.00; -} - -extern "C" Decorator *instantiate_decorator(BRect rect, const char *title, - int32 wlook, int32 wfeel, int32 wflags,DisplayDriver *ddriver) -{ - return new BeDecorator(rect,title, wlook,wfeel,wflags,ddriver); -} \ No newline at end of file diff --git a/src/servers/app/proto7/BeDecorator.h b/src/servers/app/proto7/BeDecorator.h deleted file mode 100644 index 601d7dc63a..0000000000 --- a/src/servers/app/proto7/BeDecorator.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef _BEOS_DECORATOR_H_ -#define _BEOS_DECORATOR_H_ - -#include -#include "Decorator.h" - -class BeDecorator: public Decorator -{ -public: - BeDecorator(BRect frame, const char *title, int32 wlook, int32 wfeel, int32 wflags, - DisplayDriver *ddriver); - ~BeDecorator(void); - - void SetTitle(const char *string); - void MoveBy(float x, float y); - void MoveBy(BPoint pt); - void ResizeBy(float x, float y); - void ResizeBy(BPoint pt); - void Draw(BRect r); - void Draw(void); - BRegion *GetFootprint(void); - click_type Clicked(BPoint pt, int32 buttons, int32 modifiers); - BRect SlideTab(float dx, float dy=0); - -protected: - void _DrawClose(BRect r); - void _DrawFrame(BRect r); - void _DrawTab(BRect r); - void _DrawTitle(BRect r); - void _DrawZoom(BRect r); - void _DoLayout(void); - void _SetFocus(void); - void DrawBlendedRect(BRect r, bool down); - int32 taboffset; - - RGBColor tab_highcol, tab_lowcol; - RGBColor button_highcol, button_lowcol; - RGBColor frame_highcol, frame_midcol, frame_lowcol, frame_highercol, - frame_lowercol; - RGBColor textcol; - uint64 solidhigh, solidlow; - float titlewidth; - - int textoffset, titlechars; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/ColorSet.cpp b/src/servers/app/proto7/ColorSet.cpp deleted file mode 100644 index e0064a0eca..0000000000 --- a/src/servers/app/proto7/ColorSet.cpp +++ /dev/null @@ -1,87 +0,0 @@ -#include -#include "ColorSet.h" - -ColorSet::ColorSet(void) -{ -} - -ColorSet::ColorSet(const ColorSet &cs) -{ - panel_background=cs.panel_background; - panel_text=cs.panel_text; - document_background=cs.document_background; - document_text=cs.document_text; - control_background=cs.control_background; - control_text=cs.control_text; - control_border=cs.control_border; - control_highlight=cs.control_highlight; - tooltip_background=cs.tooltip_background; - tooltip_text=cs.tooltip_text; - menu_background=cs.menu_background; - menu_selected_background=cs.menu_selected_background; - menu_text=cs.menu_text; - menu_selected_text=cs.menu_selected_text; - menu_separator_high=cs.menu_separator_high; - menu_separator_low=cs.menu_separator_low; - menu_triggers=cs.menu_triggers; - window_tab=cs.window_tab; - window_tab_text=cs.window_tab_text; - keyboard_navigation=cs.keyboard_navigation; - desktop=cs.desktop; -} - -ColorSet & ColorSet::operator=(const ColorSet &cs) -{ - SetColors(cs); - return *this; -} - -void ColorSet::SetColors(const ColorSet &cs) -{ - panel_background=cs.panel_background; - panel_text=cs.panel_text; - document_background=cs.document_background; - document_text=cs.document_text; - control_background=cs.control_background; - control_text=cs.control_text; - control_border=cs.control_border; - control_highlight=cs.control_highlight; - tooltip_background=cs.tooltip_background; - tooltip_text=cs.tooltip_text; - menu_background=cs.menu_background; - menu_selected_background=cs.menu_selected_background; - menu_text=cs.menu_text; - menu_selected_text=cs.menu_selected_text; - menu_separator_high=cs.menu_separator_high; - menu_separator_low=cs.menu_separator_low; - menu_triggers=cs.menu_triggers; - window_tab=cs.window_tab; - window_tab_text=cs.window_tab_text; - keyboard_navigation=cs.keyboard_navigation; - desktop=cs.desktop; -} - -void ColorSet::PrintToStream(void) -{ - printf("panel_background "); panel_background.PrintToStream(); - printf("panel_text "); panel_text.PrintToStream(); - printf("document_background "); document_background.PrintToStream(); - printf("document_text "); document_text.PrintToStream(); - printf("control_background "); control_background.PrintToStream(); - printf("control_text "); control_text.PrintToStream(); - printf("control_border "); control_border.PrintToStream(); - printf("control_highlight "); control_highlight.PrintToStream(); - printf("tooltip_background "); tooltip_background.PrintToStream(); - printf("tooltip_text "); tooltip_text.PrintToStream(); - printf("menu_background "); menu_background.PrintToStream(); - printf("menu_selected_background "); menu_selected_background.PrintToStream(); - printf("menu_text "); menu_text.PrintToStream(); - printf("menu_selected_text "); menu_selected_text.PrintToStream(); - printf("menu_separator_high "); menu_separator_high.PrintToStream(); - printf("menu_separator_low "); menu_separator_low.PrintToStream(); - printf("menu_triggers "); menu_triggers.PrintToStream(); - printf("window_tab "); window_tab.PrintToStream(); - printf("window_tab_text "); window_tab_text.PrintToStream(); - printf("keyboard_navigation "); keyboard_navigation.PrintToStream(); - printf("desktop "); desktop.PrintToStream(); -} diff --git a/src/servers/app/proto7/ColorSet.h b/src/servers/app/proto7/ColorSet.h deleted file mode 100644 index 5eac8d7ebc..0000000000 --- a/src/servers/app/proto7/ColorSet.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef COLORSET_H_ -#define COLORSET_H_ - -#include "RGBColor.h" - -class ColorSet -{ -public: - ColorSet(void); - ColorSet(const ColorSet &cs); - ColorSet & operator=(const ColorSet &cs); - void SetColors(const ColorSet &cs); - void PrintToStream(void); - - RGBColor panel_background, - panel_text, - document_background, - document_text, - control_background, - control_text, - control_border, - control_highlight, - tooltip_background, - tooltip_text, - menu_background, - menu_selected_background, - menu_text, - menu_selected_text, - menu_separator_high, - menu_separator_low, - menu_triggers, - window_tab, - window_tab_text, - keyboard_navigation, - desktop; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/ColorUtils.cc b/src/servers/app/proto7/ColorUtils.cc deleted file mode 100644 index 510476eca9..0000000000 --- a/src/servers/app/proto7/ColorUtils.cc +++ /dev/null @@ -1,101 +0,0 @@ -#include "ColorUtils.h" -#include -#include - -//#define DEBUG_COLOR_UTILS - -void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a=255) -{ - col->red=r; - col->green=g; - col->blue=b; - col->alpha=a; -} - -uint8 FindClosestColor(rgb_color *palette, rgb_color color) -{ - // We will be passed a 256-color palette and a 24-bit color - uint16 cindex=0,cdelta=765,delta=765; - rgb_color *c; - - for(uint16 i=0;i<256;i++) - { - c=&(palette[i]); - delta=abs(c->red-color.red)+abs(c->green-color.green)+ - abs(c->blue-color.blue); - - if(delta==0) - { - cindex=i; - break; - } - - if(delta1) - return newcol; - - delta=int16(col2.red)-int16(col.red); - mod=col.red + (position * delta); - newcol.red=uint8(mod); - if(mod>255 ) - newcol.red=255; - if(mod<0 ) - newcol.red=0; - - delta=int16(col2.green)-int16(col.green); - mod=col.green + (position * delta); - newcol.green=uint8(mod); - if(mod>255 ) - newcol.green=255; - if(mod<0 ) - newcol.green=0; - - delta=int16(col2.blue)-int16(col.blue); - mod=col.blue + (position * delta); - newcol.blue=uint8(mod); - if(mod>255 ) - newcol.blue=255; - if(mod<0 ) - newcol.blue=0; - - delta=int8(col2.alpha)-int8(col.alpha); - mod=col.alpha + (position * delta); - newcol.alpha=uint8(mod); - if(mod>255 ) - newcol.alpha=255; - if(mod<0 ) - newcol.alpha=0; -#ifdef DEBUG_COLOR_UTILS -printf("MakeBlendColor( {%u,%u,%u,%u}, {%u,%u,%u,%u}, %f) : {%u,%u,%u,%u}\n", - col.red,col.green,col.blue,col.alpha, - col2.red,col2.green,col2.blue,col2.alpha, - position, - newcol.red,newcol.green,newcol.blue,newcol.alpha); -#endif - return newcol; -} diff --git a/src/servers/app/proto7/ColorUtils.h b/src/servers/app/proto7/ColorUtils.h deleted file mode 100644 index c4002d2357..0000000000 --- a/src/servers/app/proto7/ColorUtils.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef COLORUTILS_H_ -#define COLORUTILS_H_ - -#include - -// Quick assignment for rgb_color structs -void SetRGBColor(rgb_color *col,uint8 r, uint8 g, uint8 b, uint8 a=255); - -// Given a color palette, returns the index of the closest match to -// the color passed to it. Alpha values are not considered -uint8 FindClosestColor(rgb_color *palette, rgb_color color); -uint16 FindClosestColor16(rgb_color color); - -// Function which could be used to calculate gradient colors. Position is -// a floating point number such that 0.0 <= position <= 1.0. Any number outside -// this range will cause the function to fail and return the color (0,0,0,0) -// Alpha components are included in the calculations. 0 yields color #1 -// and 1 yields color #2. -rgb_color MakeBlendColor(rgb_color col, rgb_color col2, float position); -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/DebugTools.cpp b/src/servers/app/proto7/DebugTools.cpp deleted file mode 100644 index f626e927be..0000000000 --- a/src/servers/app/proto7/DebugTools.cpp +++ /dev/null @@ -1,222 +0,0 @@ -#include -#include -#include "DebugTools.h" - -void PrintStatusToStream(status_t value) -{ - // Function which simply translates a returned status code into a string - // and dumps it to stdout - cout << "Status: " << TranslateStatusToString(value).String() << endl << flush; -} - -BString TranslateStatusToString(status_t value) -{ - BString outstr; - switch(value) - { - case B_OK: - outstr="B_OK "; - break; - case B_NAME_NOT_FOUND: - outstr="B_NAME_NOT_FOUND "; - break; - case B_BAD_VALUE: - outstr="B_BAD_VALUE "; - break; - case B_ERROR: - outstr="B_ERROR "; - break; - case B_TIMED_OUT: - outstr="B_TIMED_OUT "; - break; - case B_NO_MORE_PORTS: - outstr="B_NO_MORE_PORTS "; - break; - case B_WOULD_BLOCK: - outstr="B_WOULD_BLOCK "; - break; - case B_BAD_PORT_ID: - outstr="B_BAD_PORT_ID "; - break; - case B_BAD_TEAM_ID: - outstr="B_BAD_TEAM_ID "; - break; - default: - outstr="undefined status value in debugtools::PrintStatusToStream() "; - break; - } - return BString(outstr); -} - -void PrintColorSpaceToStream(color_space value) -{ - // Dump a color space to cout - BString outstr; - switch(value) - { - case B_RGB32: - outstr="B_RGB32 "; - break; - case B_RGBA32: - outstr="B_RGBA32 "; - break; - case B_RGB32_BIG: - outstr="B_RGB32_BIG "; - break; - case B_RGBA32_BIG: - outstr=" "; - break; - case B_UVL32: - outstr="B_UVL32 "; - break; - case B_UVLA32: - outstr="B_UVLA32 "; - break; - case B_LAB32: - outstr="B_LAB32 "; - break; - case B_LABA32: - outstr="B_LABA32 "; - break; - case B_HSI32: - outstr="B_HSI32 "; - break; - case B_HSIA32: - outstr="B_HSIA32 "; - break; - case B_HSV32: - outstr="B_HSV32 "; - break; - case B_HSVA32: - outstr="B_HSVA32 "; - break; - case B_HLS32: - outstr="B_HLS32 "; - break; - case B_HLSA32: - outstr="B_HLSA32 "; - break; - case B_CMY32: - outstr="B_CMY32"; - break; - case B_CMYA32: - outstr="B_CMYA32 "; - break; - case B_CMYK32: - outstr="B_CMYK32 "; - break; - case B_RGB24_BIG: - outstr="B_RGB24_BIG "; - break; - case B_RGB24: - outstr="B_RGB24 "; - break; - case B_LAB24: - outstr="B_LAB24 "; - break; - case B_UVL24: - outstr="B_UVL24 "; - break; - case B_HSI24: - outstr="B_HSI24 "; - break; - case B_HSV24: - outstr="B_HSV24 "; - break; - case B_HLS24: - outstr="B_HLS24 "; - break; - case B_CMY24: - outstr="B_CMY24 "; - break; - case B_GRAY1: - outstr="B_GRAY1 "; - break; - case B_CMAP8: - outstr="B_CMAP8 "; - break; - case B_GRAY8: - outstr="B_GRAY8 "; - break; - case B_YUV411: - outstr="B_YUV411 "; - break; - case B_YUV420: - outstr="B_YUV420 "; - break; - case B_YCbCr422: - outstr="B_YCbCr422 "; - break; - case B_YCbCr411: - outstr="B_YCbCr411 "; - break; - case B_YCbCr420: - outstr="B_YCbCr420 "; - break; - case B_YUV422: - outstr="B_YUV422 "; - break; - case B_YUV9: - outstr="B_YUV9 "; - break; - case B_YUV12: - outstr="B_YUV12 "; - break; - case B_RGB15: - outstr="B_RGB15 "; - break; - case B_RGBA15: - outstr="B_RGBA15 "; - break; - case B_RGB16: - outstr="B_RGB16 "; - break; - case B_RGB16_BIG: - outstr="B_RGB16_BIG "; - break; - case B_RGB15_BIG: - outstr="B_RGB15_BIG "; - break; - case B_RGBA15_BIG: - outstr="B_RGBA15_BIG "; - break; - case B_YCbCr444: - outstr="B_YCbCr444 "; - break; - case B_YUV444: - outstr="B_YUV444 "; - break; - case B_NO_COLOR_SPACE: - outstr="B_NO_COLOR_SPACE "; - break; - default: - outstr="Undefined color space "; - break; - } - cout << "Color Space: " << outstr.String() << flush; -} - -void TranslateMessageCodeToStream(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - - cout << "'" - << (char)((code & 0xFF000000) >> 24) - << (char)((code & 0x00FF0000) >> 16) - << (char)((code & 0x0000FF00) >> 8) - << (char)((code & 0x000000FF)) << "' "; -} - -void PrintMessageCode(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - - printf("Message code %c%c%c%c\n", - (char)((code & 0xFF000000) >> 24), - (char)((code & 0x00FF0000) >> 16), - (char)((code & 0x0000FF00) >> 8), - (char)((code & 0x000000FF)) ); -} - diff --git a/src/servers/app/proto7/DebugTools.h b/src/servers/app/proto7/DebugTools.h deleted file mode 100644 index 55bf1b0635..0000000000 --- a/src/servers/app/proto7/DebugTools.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _DEBUGTOOLS_H_ -#define _DEBUGTOOLS_H_ - -#include -#include -#include - -void PrintColorSpaceToStream(color_space value); -void TranslateMessageCodeToStream(int32 code); -void PrintMessageCode(int32 code); -BString TranslateStatusToString(status_t value); - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/Decorator.cpp b/src/servers/app/proto7/Decorator.cpp deleted file mode 100644 index 2973d5cb3a..0000000000 --- a/src/servers/app/proto7/Decorator.cpp +++ /dev/null @@ -1,257 +0,0 @@ -#include -#include "Decorator.h" -#include "DisplayDriver.h" - -Decorator::Decorator(BRect rect, const char *title, int32 wlook, int32 wfeel, int32 wflags, - DisplayDriver *ddriver) -{ - close_state=false; - minimize_state=false; - zoom_state=false; - title_string=new BString(title); - driver=ddriver; - - closerect.Set(0,0,1,1); - zoomrect.Set(0,0,1,1); - minimizerect.Set(0,0,1,1); - resizerect.Set(0,0,1,1); - frame=rect; - tabrect.Set(rect.left,rect.top,rect.right, rect.top+((rect.bottom-rect.top)/4)); - - look=wlook; - feel=wfeel; - flags=wflags; - - colors=new ColorSet(); -} - -Decorator::~Decorator(void) -{ - if(colors!=NULL) - { - delete colors; - colors=NULL; - } - if(title_string) - delete title_string; -} - -void Decorator::SetColors(ColorSet cset) -{ - colors->SetColors(cset); -} - -void Decorator::SetDriver(DisplayDriver *d) -{ - // lots of subclasses will depend on the driver for text support, so call - // _DoLayout() after this - driver=d; - _DoLayout(); -} - -void Decorator::SetClose(bool is_down) -{ - close_state=is_down; -} - -void Decorator::SetMinimize(bool is_down) -{ - zoom_state=is_down; -} - -void Decorator::SetZoom(bool is_down) -{ - minimize_state=is_down; -} - -void Decorator::SetFlags(int32 wflags) -{ - flags=wflags; -} - -void Decorator::SetFeel(int32 wfeel) -{ - feel=wfeel; -} - -void Decorator::SetLook(int32 wlook) -{ - look=wlook; -} - -bool Decorator::GetClose(void) -{ - return close_state; -} - -bool Decorator::GetMinimize(void) -{ - return minimize_state; -} - -bool Decorator::GetZoom(void) -{ - return zoom_state; -} - -int32 Decorator::GetLook(void) -{ - return look; -} - -int32 Decorator::GetFeel(void) -{ - return feel; -} - -int32 Decorator::GetFlags(void) -{ - return flags; -} - -void Decorator::SetTitle(const char *string) -{ - title_string->SetTo(string); -} - -const char *Decorator::GetTitle(void) -{ - return title_string->String(); -} - -void Decorator::SetFocus(bool is_active) -{ - has_focus=is_active; - _SetFocus(); -} - -/* -void Decorator::SetFont(SFont *sf) -{ -} -*/ -int32 Decorator::_ClipTitle(float width) -{ - if(driver) - { - int32 strlength=title_string->CountChars(); - float pixwidth=driver->StringWidth(title_string->String(),strlength,&layerdata); - - while(strlength>=0) - { - if(pixwidthStringWidth(title_string->String(),strlength,&layerdata); - } - - return strlength; - } - return 0; -} - -//------------------------------------------------------------------------- -// Virtual Methods -//------------------------------------------------------------------------- -void Decorator::MoveBy(float x, float y) -{ -} - -void Decorator::MoveBy(BPoint pt) -{ -} - -BRect Decorator::SlideTab(float dx, float dy=0) -{ - return BRect(0,0,0,0); -} - -void Decorator::ResizeBy(float x, float y) -{ -} - -void Decorator::ResizeBy(BPoint pt) -{ -} - -void Decorator::Draw(BRect r) -{ - _DrawTab(r & tabrect); - _DrawFrame(r & frame); -} - -void Decorator::Draw(void) -{ - _DrawTab(tabrect); - _DrawFrame(frame); -} - -void Decorator::DrawClose(void) -{ - _DrawClose(closerect); -} - -void Decorator::DrawFrame(void) -{ - _DrawFrame(frame); -} - -void Decorator::DrawMinimize(void) -{ - _DrawTab(minimizerect); -} - -void Decorator::DrawTab(void) -{ - _DrawTab(tabrect); - _DrawZoom(zoomrect); - _DrawMinimize(minimizerect); - _DrawTitle(tabrect); - _DrawClose(closerect); -} - -void Decorator::DrawTitle(void) -{ - _DrawTitle(tabrect); -} - -void Decorator::DrawZoom(void) -{ - _DrawZoom(zoomrect); -} - -void Decorator::_DrawClose(BRect r) -{ -} - -void Decorator::_DrawFrame(BRect r) -{ -} - -void Decorator::_DrawMinimize(BRect r) -{ -} - -void Decorator::_DrawTab(BRect r) -{ -} - -void Decorator::_DrawTitle(BRect r) -{ -} - -void Decorator::_DrawZoom(BRect r) -{ -} - - -BRegion *Decorator::GetFootprint(void) -{ - return NULL; -} - -click_type Decorator::Clicked(BPoint pt, int32 buttons, int32 modifiers) -{ - return CLICK_NONE; -} - diff --git a/src/servers/app/proto7/Decorator.h b/src/servers/app/proto7/Decorator.h deleted file mode 100644 index 40f0d14825..0000000000 --- a/src/servers/app/proto7/Decorator.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef _DECORATOR_H_ -#define _DECORATOR_H_ - -#include -#include -#include -#include "ColorSet.h" -#include "LayerData.h" - -class Layer; -class DisplayDriver; - -typedef enum { CLICK_NONE=0, CLICK_ZOOM, CLICK_CLOSE, CLICK_MINIMIZE, - CLICK_TAB, CLICK_DRAG, CLICK_MOVETOBACK, CLICK_MOVETOFRONT, CLICK_SLIDETAB, - - CLICK_RESIZE, CLICK_RESIZE_L, CLICK_RESIZE_T, - CLICK_RESIZE_R, CLICK_RESIZE_B, CLICK_RESIZE_LT, CLICK_RESIZE_RT, - CLICK_RESIZE_LB, CLICK_RESIZE_RB } click_type; - -// Definitions which are used in place of including Window.h -// window_look and window_feel are enumerated types, so we convert them -// to uint32's in order to ensure a constant size when sending via PortLink -// instead of depending on magic numbers in the header file. - -#define WLOOK_NO_BORDER 0 -#define WLOOK_BORDERED 1 -#define WLOOK_TITLED 2 -#define WLOOK_DOCUMENT 3 -#define WLOOK_MODAL 4 -#define WLOOK_FLOATING 5 - -#define WFEEL_NORMAL 0 -#define WFEEL_MODAL_SUBSET 1 -#define WFEEL_MODAL_APP 2 -#define WFEEL_MODAL_WINDOW 3 -#define WFEEL_FLOATING_SUBSET 4 -#define WFEEL_FLOATING_APP 5 -#define WFEEL_FLOATING_WINDOW 6 -/* -#define NOT_MOVABLE 0x00000001 -#define NOT_CLOSABLE 0x00000020 -#define NOT_ZOOMABLE 0x00000040 -#define NOT_MINIMIZABLE 0x00004000 -#define NOT_RESIZABLE 0x00000002 -#define NOT_H_RESIZABLE 0x00000004 -#define NOT_V_RESIZABLE 0x00000008 -#define AVOID_FRONT 0x00000080 -#define AVOID_FOCUS 0x00002000 -#define WILL_ACCEPT_FIRST_CLICK 0x00000010 -#define OUTLINE_RESIZE 0x00001000 -#define NO_WORKSPACE_ACTIVATION 0x00000100 -#define NOT_ANCHORED_ON_ACTIVATE 0x00020000 -#define ASYNCHRONOUS_CONTROLS 0x00080000 -#define QUIT_ON_WINDOW_CLOSE 0x00100000 -*/ -class Decorator -{ -public: - Decorator(BRect rect, const char *title, int32 wlook, int32 wfeel, int32 wflags, - DisplayDriver *ddriver); - virtual ~Decorator(void); - void SetColors(ColorSet cset); - void SetDriver(DisplayDriver *d); - void SetClose(bool is_down); - void SetMinimize(bool is_down); - void SetZoom(bool is_down); - void SetFlags(int32 wflags); - void SetFeel(int32 wfeel); - void SetLook(int32 wlook); - bool GetClose(void); - bool GetMinimize(void); - bool GetZoom(void); - int32 GetLook(void); - int32 GetFeel(void); - int32 GetFlags(void); - virtual void SetTitle(const char *string); - void SetFocus(bool is_active); - bool GetFocus(void) { return has_focus; }; - const char *GetTitle(void); -// void SetFont(SFont *sf); - ColorSet GetColors(void) { if(colors) return *colors; else return ColorSet(); } - - virtual void MoveBy(float x, float y); - virtual void MoveBy(BPoint pt); - virtual BRect SlideTab(float dx, float dy=0); - virtual void ResizeBy(float x, float y); - virtual void ResizeBy(BPoint pt); - virtual void Draw(BRect r); - virtual void Draw(void); - virtual void DrawClose(void); - virtual void DrawFrame(void); - virtual void DrawMinimize(void); - virtual void DrawTab(void); - virtual void DrawTitle(void); - virtual void DrawZoom(void); - virtual BRegion *GetFootprint(void); - virtual click_type Clicked(BPoint pt, int32 buttons, int32 modifiers); - -protected: - int32 _ClipTitle(float width); - int32 TitleWidth(void) { return (title_string)?title_string->CountChars():0; } - virtual void _DrawClose(BRect r); - virtual void _DrawFrame(BRect r); - virtual void _DrawMinimize(BRect r); - virtual void _DrawTab(BRect r); - virtual void _DrawTitle(BRect r); - virtual void _DrawZoom(BRect r); - virtual void _SetFocus(void)=0; - virtual void _DoLayout(void)=0; - ColorSet *colors; - int32 look, feel, flags; - DisplayDriver *driver; - LayerData layerdata; - BRect zoomrect,closerect,minimizerect,tabrect,frame, - resizerect,borderrect; -private: - bool close_state, zoom_state, minimize_state; - bool has_focus; - BString *title_string; -}; - -typedef float get_version(void); -typedef Decorator *create_decorator(BRect rect, int32 wlook, int32 wfeel, int32 wflags); - -#endif diff --git a/src/servers/app/proto7/Desktop.cpp b/src/servers/app/proto7/Desktop.cpp deleted file mode 100644 index 7bfd3b299d..0000000000 --- a/src/servers/app/proto7/Desktop.cpp +++ /dev/null @@ -1,619 +0,0 @@ -/* - Desktop.cpp: - Code necessary to handle the Desktop, defined as the collection of workspaces. -*/ - -//#define DEBUG_WORKSPACES - -#include -#include -#include -#include -#include -#include -#include -#include "ServerProtocol.h" -#include "ColorUtils.h" -#include "SystemPalette.h" -#include "ServerBitmap.h" -#include "ServerWindow.h" -#include "Layer.h" -#include "DisplayDriver.h" -#include "ViewDriver.h" -#include "ScreenDriver.h" -#include "Desktop.h" -#include "WindowBorder.h" -#include "ColorSet.h" -#include "RGBColor.h" - -class ServerWindow; -class ServerBitmap; -class Workspace; - -rgb_color GetColorFromMessage(BMessage *msg, const char *name, int32 index=0); - -// Temporarily necessary. Will not be present in the app_server. -int8 default_cursor[]={ - 16,1,0,0, - - // data - 0xff, 0x80, 0x80, 0x80, 0x81, 0x00, 0x80, 0x80, 0x80, 0x40, 0x80, 0x80, 0x81, 0x00, 0xa2, 0x00, - 0xd4, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - - // mask - 0xff, 0x80, 0xff, 0x80, 0xff, 0x00, 0xff, 0x80, 0xff, 0xc0, 0xff, 0x80, 0xff, 0x00, 0xfe, 0x00, - 0xdc, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -//--------------------GLOBALS------------------------- -uint32 workspace_count, active_workspace; -BList *desktop; -ServerBitmap *startup_cursor; -Workspace *pactive_workspace; -DisplayDriver *gfxdriver; -int32 token_count=-1; -BLocker *workspacelock; -BLocker *layerlock; -BLocker *colorlock; -UpdateNode *upnode; -ColorSet *gui_colors; -//---------------------------------------------------- - - -//-------------------INTERNAL CLASS DEFS-------------- -class Workspace -{ -public: - Workspace(void); - Workspace(BPath imagepath); - ~Workspace(); - void SetBGColor(rgb_color col); - rgb_color BGColor(void); - thread_id tid; - - RootLayer *toplayer; - BList focuslist; - rgb_color bgcolor; - screen_info screendata, - olddata; -}; - -DisplayDriver *get_gfxdriver(void) -{ - return gfxdriver; -} - -Workspace::Workspace(void) -{ - workspace_count++; - - // default values - focuslist.MakeEmpty(); - bgcolor.red=51; - bgcolor.green=102; - bgcolor.blue=160; - screendata.mode=B_CMAP8; - screendata.spaces=B_8_BIT_640x480; - screendata.refresh_rate=60.0; - screendata.min_refresh_rate=60.0; - screendata.max_refresh_rate=60.0; - screendata.h_position=(uchar)50; - screendata.v_position=(uchar)50; - screendata.h_size=(uchar)50; - screendata.v_size=(uchar)50; - olddata=screendata; - - // We need one top layer for each workspace times the number of monitors - ick. - // Currently, we only have 1 monitor. *Whew* - char wspace_name[128]; - sprintf(wspace_name,"workspace %ld root",workspace_count); - toplayer=new RootLayer(BRect(0,0,639,439),wspace_name); -} - -Workspace::~Workspace(void) - { - workspace_count--; - toplayer->PruneTree(); -} - -void Workspace::SetBGColor(rgb_color col) -{ - bgcolor=col; - toplayer->SetColor(col); -#ifdef DEBUG_WORKSPACES -printf("Workspace::SetBGColor(%d,%d,%d,%d)\n",bgcolor.red,bgcolor.green, - bgcolor.blue,bgcolor.alpha); -#endif -} - -rgb_color Workspace::BGColor(void) -{ - return bgcolor; -} -//--------------------------------------------------- - - -//-----------------GLOBAL FUNCTION DEFS--------------- - -void init_desktop(int8 workspaces) -{ -#ifdef DEBUG_WORKSPACES -printf("init_desktop(%d)\n",workspaces); -#endif - workspace_count=workspaces; - if(workspace_count==0) - workspace_count++; - - // Instantiate and initialize display driver -// gfxdriver=new ViewDriver(); -// gfxdriver=new SecondDriver(); - gfxdriver=new ScreenDriver(); - gfxdriver->Initialize(); - - workspacelock=new BLocker(); - layerlock=new BLocker(); - colorlock=new BLocker(); - gui_colors=new ColorSet; - -#ifdef DEBUG_WORKSPACES -printf("Driver %s\n", (gfxdriver->IsInitialized()==true)?"initialized":"NOT initialized"); -#endif - - desktop=new BList(0); - - // Create the workspaces we're supposed to have - for(int8 i=0; iAddItem(new Workspace()); - - // Load workspace preferences here - - // We're going to punch in some hardcoded settings for testing purposes. - // There are 3 workspaces hardcoded in for now, but we'll only use the - // second one. - Workspace *wksp=(Workspace*)desktop->ItemAt(1); - if(wksp!=NULL) // in case I forgot something - { - rgb_color bcol; - SetRGBColor(&bcol,0,200,236); - -// SetRGBColor(&(wksp->bgcolor),0,200,236); - wksp->SetBGColor(bcol); - screen_info *tempsd=&(wksp->screendata); - tempsd->mode=B_CMAP8; - tempsd->spaces=B_8_BIT_800x600; - tempsd->frame.Set(0,0,799,599); - } - else - printf("DW goofed on the workspace index :P\n"); - - // Activate workspace 0 - pactive_workspace=(Workspace *)desktop->ItemAt(0); - pactive_workspace->screendata.spaces=B_32_BIT_640x480; - gfxdriver->SetMode(pactive_workspace->screendata.spaces); - - // Clear the screen - pactive_workspace->toplayer->SetColor(RGBColor(80,85,152)); -// gfxdriver->Clear(pactive_workspace->toplayer->GetColor()); - - // CURSOR_ARROW - startup_cursor=new ServerBitmap('CURS',"CURSOR_DEFAULT"); - if(!startup_cursor->InitCheck()) - { - // Apparently, something is screwed up beyond recognition in loading the cursor, - // so we'll put in one just so we have something usable. - delete startup_cursor; - startup_cursor=new ServerBitmap(default_cursor); - } - gfxdriver->SetCursor(startup_cursor, BPoint(0,0)); - gfxdriver->ShowCursor(); - - pactive_workspace->toplayer->SetVisible(true); -#ifdef DEBUG_WORKSPACES -printf("Desktop initialized\n"); -#endif -} - -void shutdown_desktop(void) -{ - int32 i,count=desktop->CountItems(); - Workspace *w; - for(i=0;iItemAt(i); - if(w!=NULL) - delete w; - } - desktop->MakeEmpty(); - delete desktop; - gfxdriver->Shutdown(); - delete gfxdriver; - delete workspacelock; - delete layerlock; - delete colorlock; - delete startup_cursor; - delete gui_colors; -} - - -int32 CountWorkspaces(void) -{ -#ifdef DEBUG_WORKSPACES -printf("CountWorkspaces() returned %ld\n",workspace_count); -#endif - return workspace_count; -} - -void SetWorkspaceCount(uint32 count) -{ - if(count<0) - { -#ifdef DEBUG_WORKSPACES -printf("SetWorkspaceCount(value<0) - DOH!\n"); -#endif - return; - } - if(count==workspace_count) - return; - - // Activate last workspace in new set if we're using one to be nuked - if(countItemAt(i)!=NULL) - { - delete (Workspace*)desktop->ItemAt(i); - desktop->RemoveItem(i); - } - } - } - else - { - // count > workspace_count here - - // Once we have default workspace preferences which can be set by the - // user, we'll end up having to initialize newly-added workspaces to that - // data. In the mean time, the defaults in the constructor will do. :) - for(uint32 i=count;iAddItem(new Workspace()); - } - } - - // don't forget to update our global! - workspace_count=desktop->CountItems(); - -#ifdef DEBUG_WORKSPACES -printf("SetWorkspaceCount(%ld)\n",workspace_count); -#endif - -} - -int32 CurrentWorkspace(void) -{ -#ifdef DEBUG_WORKSPACES -printf("CurrentWorkspace() returned %ld\n",active_workspace); -#endif - return active_workspace; -} - -void ActivateWorkspace(uint32 workspace) -{ - // In order to change workspaces, we'll need to make all the necessary - // changes to the screen to fit the new one, such as resolution, - // background color, color depth, refresh rate, etc. - - if(workspace>workspace_count || workspace<0) - return; - - Workspace *proposed=(Workspace *)desktop->ItemAt(workspace); - - if(proposed==NULL) - return; - - // Here's where we update all the screen stuff -// if(pactive_workspace->screendata.spaces != proposed->screendata.spaces) -// { - gfxdriver->SetMode(proposed->screendata.spaces); -// gfxdriver->Clear(proposed->bgcolor); - pactive_workspace->toplayer->SetVisible(false); - proposed->toplayer->SetVisible(true); -// } - // more if != then change code goes here. Currently, a lot of the code which - // uses this stuff is not implemented, so it's kind of moot. However, when we - // use the real graphics HW, it'll become important. - - // actually set our active workspace data to reflect the change in workspaces - pactive_workspace=proposed; - active_workspace=workspace; -#ifdef DEBUG_WORKSPACES -printf("ActivateWorkspace(%ld)\n",active_workspace); -#endif -} - -const color_map *SystemColors(void) -{ - return (const color_map *)&system_palette; -} - -status_t SetScreenSpace(uint32 index, uint32 res, bool stick = true) -{ -#ifdef DEBUG_WORKSPACES -printf("SetScreenSpace(%ld,%lu, %s)\n",index,res,(stick==true)?"true":"false"); -#endif - - if(index>workspace_count-1) - { - printf("SetScreenSpace was passed invalid workspace value %ld\n",index); - return B_ERROR; - } - if(res>0x800000) // the last "normal" screen mode defined in GraphicsDefs.h - { - printf("SetScreenSpace was passed invalid screen value %lu\n",res); - return B_ERROR; - } - - // When we actually use app_server preferences, we'll save the screen mode to - // the preferences so that we use this mode next boot. For now, we treat stick==false - if(stick==true) - { - // save the screen data here - } - if(index==active_workspace) - { - gfxdriver->SetMode(res); -// gfxdriver->Clear(pactive_workspace->bgcolor); - } - else - { - // just set the workspace's data here. right now, do nothing. - } - return B_OK; -} - -int32 GetViewToken(void) -{ - // Used to generate view and layer tokens - return ++token_count; -} - -void AddWindowToDesktop(ServerWindow *win,uint32 workspace) -{ - // Adds the top layer of each window to the root layer in the specified workspace. - // Note that in calling AddChild, a redraw is invoked - if(!win || workspace>workspace_count-1) - return; - - workspacelock->Lock(); - Workspace *w=(Workspace *)desktop->ItemAt(workspace); - if(w) - { - // a check for the B_CURRENT_WORKSPACE or B_ALL_WORKSPACES specifiers will - // go here later - - w->toplayer->AddChild(win->winborder); - } - workspacelock->Unlock(); -} - -void RemoveWindowFromDesktop(ServerWindow *win) -{ - // A little more time-consuming than AddWindow - if(!win) - return; - - workspacelock->Lock(); - - // a check for the B_CURRENT_WORKSPACE or B_ALL_WORKSPACES specifiers will - // go here later - - // If the window belongs on only 1 workspace, calling RemoveSelf is the most - // elegant solution. - win->winborder->RemoveSelf(); - workspacelock->Unlock(); -} - -Layer *GetRootLayer(void) -{ - layerlock->Lock(); - Layer *lay=(workspace_count>0)?pactive_workspace->toplayer:NULL; - layerlock->Unlock(); - - return lay; -} - -ServerWindow *GetActiveWindow(int32 workspace) -{ - Layer *root=GetRootLayer(); - if(!root) - return NULL; - Layer *lay=root->topchild, *nextlay; - while(lay!=NULL) - { - if(lay->serverwin && lay->serverwin->HasFocus()) - return lay->serverwin; - nextlay=lay->lowersibling; - lay=nextlay; - } - return NULL; -} - -rgb_color GetColorFromMessage(BMessage *msg, const char *name, int32 index=0) -{ - // Simple function to do the dirty work of getting an rgb_color from - // a message - rgb_color *col,rcolor={0,0,0,0}; - ssize_t size; - - if(msg->FindData(name,(type_code)'RGBC',index,(const void**)&col,&size)==B_OK) - rcolor=*col; - return rcolor; -} - -void SetGUIColor(color_which attr, RGBColor color) -{ - colorlock->Lock(); - - switch(attr) - { - case B_PANEL_BACKGROUND_COLOR: - { - gui_colors->panel_background=color; - break; - } - case B_MENU_BACKGROUND_COLOR: - { - gui_colors->menu_background=color; - break; - } - case B_MENU_SELECTION_BACKGROUND_COLOR: - { - gui_colors->menu_selected_background=color; - break; - } - case B_MENU_ITEM_TEXT_COLOR: - { - gui_colors->menu_text=color; - break; - } - case B_MENU_SELECTED_ITEM_TEXT_COLOR: - { - gui_colors->menu_selected_text=color; - break; - } - case B_WINDOW_TAB_COLOR: - { - gui_colors->window_tab=color; - break; - } - case B_KEYBOARD_NAVIGATION_COLOR: - { - gui_colors->keyboard_navigation=color; - break; - } - case B_DESKTOP_COLOR: - { - gui_colors->desktop=color; - break; - } - default: - break; - } - - colorlock->Unlock(); -} - -RGBColor GetGUIColor(color_which attr) -{ - colorlock->Lock(); - - RGBColor c; - - switch(attr) - { - case B_PANEL_BACKGROUND_COLOR: - { - c=gui_colors->panel_background; - break; - } - case B_MENU_BACKGROUND_COLOR: - { - c=gui_colors->menu_background; - break; - } - case B_MENU_SELECTION_BACKGROUND_COLOR: - { - c=gui_colors->menu_selected_background; - break; - } - case B_MENU_ITEM_TEXT_COLOR: - { - c=gui_colors->menu_text; - break; - } - case B_MENU_SELECTED_ITEM_TEXT_COLOR: - { - c=gui_colors->menu_selected_text; - break; - } - case B_WINDOW_TAB_COLOR: - { - c=gui_colors->window_tab; - break; - } - case B_KEYBOARD_NAVIGATION_COLOR: - { - c=gui_colors->keyboard_navigation; - break; - } - case B_DESKTOP_COLOR: - { - c=gui_colors->desktop; - break; - } - default: - break; - } - - colorlock->Unlock(); - return c; -} - -void SetGUIColors(ColorSet set) -{ - colorlock->Lock(); - *gui_colors=set; - colorlock->Unlock(); -} - -ColorSet GetGUIColors(void) -{ - colorlock->Lock(); - ColorSet cs(*gui_colors); - colorlock->Unlock(); - - return cs; -} - -void LoadGUIColors(void) -{ - // Load the current GUI color settings from a color set file. - - BString path(SERVER_SETTINGS_DIR); - path+=COLOR_SETTINGS_NAME; - - BFile file(path.String(),B_READ_ONLY); - BMessage msg; - - if(file.InitCheck()==B_OK) - { - if(msg.Unflatten(&file)==B_OK) - { - // Just get the "official" GUI colors for now - gui_colors->panel_background=GetColorFromMessage(&msg,"PANEL_BACKGROUND"); - gui_colors->menu_background=GetColorFromMessage(&msg,"MENU_BACKGROUND"); - gui_colors->menu_selected_background=GetColorFromMessage(&msg,"MENU_SELECTION_BACKGROUND"); - gui_colors->menu_text=GetColorFromMessage(&msg,"MENU_ITEM_TEXT"); - gui_colors->menu_selected_text=GetColorFromMessage(&msg,"MENU_SELECTED_ITEM_TEXT"); - gui_colors->window_tab=GetColorFromMessage(&msg,"WINDOW_TAB"); - gui_colors->keyboard_navigation=GetColorFromMessage(&msg,"KEYBOARD_NAVIGATION"); - gui_colors->desktop=GetColorFromMessage(&msg,"DESKTOP"); - - // fake the rest - } - else - printf("app_server couldn't get GUI color settings from %s%s. Resetting to defaults\n", - SERVER_SETTINGS_DIR,COLOR_SETTINGS_NAME); - } - else - printf("app_server couldn't open %s%s. Resetting GUI colors to defaults\n", - SERVER_SETTINGS_DIR,COLOR_SETTINGS_NAME); -} - -// Another "just in case DW screws up again" section -#ifdef DEBUG_WORKSPACES -#undef DEBUG_WORKSPACES -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/Desktop.h b/src/servers/app/proto7/Desktop.h deleted file mode 100644 index 4e637e9ba9..0000000000 --- a/src/servers/app/proto7/Desktop.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef _OBDESKTOP_H_ -#define _OBDESKTOP_H_ - - -#include -#include -#include - -class RGBColor; -class ColorSet; -class DisplayDriver; -class ServerWindow; -class Layer; - -void init_desktop(int8 workspaces); -void shutdown_desktop(void); -DisplayDriver *get_gfxdriver(void); - -// Workspace access functions -int32 CountWorkspaces(void); -void SetWorkspaceCount(uint32 count); - -int32 CurrentWorkspace(void); -void ActivateWorkspace(uint32 workspace); - -const color_map *SystemColors(void); -status_t SetScreenSpace(uint32 index, uint32 res, bool stick=true); - -void AddWindowToDesktop(ServerWindow *win,uint32 workspace); -void RemoveWindowFromDesktop(ServerWindow *win); -ServerWindow *GetActiveWindow(int32 workspace); -Layer *GetRootLayer(void); -int32 GetViewToken(void); - -void LoadGUIColors(void); -void SetGUIColor(color_which attr, RGBColor color); -RGBColor GetGUIColor(color_which attr); -void SetGUIColors(ColorSet set); -ColorSet GetGUIColors(void); - -typedef struct -{ - color_space mode; - BRect frame; - uint32 spaces; - float min_refresh_rate; - float max_refresh_rate; - float refresh_rate; - uchar h_position; - uchar v_position; - uchar h_size; - uchar v_size; -} screen_info; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/DisplayDriver.cpp b/src/servers/app/proto7/DisplayDriver.cpp deleted file mode 100644 index 43ad97cc23..0000000000 --- a/src/servers/app/proto7/DisplayDriver.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - DisplayDriver.cpp - Modular class to allow the server to not care what the ultimate output is - for graphics calls. -*/ -#include "DisplayDriver.h" -#include "LayerData.h" - -DisplayDriver::DisplayDriver(void) -{ - lock_sem=create_sem(1,"displaydriver_lock"); - buffer_depth=0; - buffer_width=0; - buffer_height=0; - buffer_mode=-1; -// drawmode = DRAW_COPY; - is_cursor_hidden = false; - is_cursor_obscured = false; - cursor_state_changed = false; -} - -DisplayDriver::~DisplayDriver(void) -{ - delete_sem(lock_sem); -} - -bool DisplayDriver::Initialize(void) -{ - return false; -} - -uint8 DisplayDriver::GetDepth(void) -{ - return buffer_depth; -} - -uint16 DisplayDriver::GetHeight(void) -{ - return buffer_height; -} - -uint16 DisplayDriver::GetWidth(void) -{ - return buffer_width; -} - -int32 DisplayDriver::GetMode(void) -{ - return buffer_mode; -} - -float DisplayDriver::StringWidth(const char *string, int32 length, LayerData *d) -{ - return 0.0; -} - -float DisplayDriver::StringHeight(const char *string, int32 length, LayerData *d) -{ - return 0.0; -} - -bool DisplayDriver::DumpToFile(const char *path) -{ - return false; -} - -bool DisplayDriver::IsCursorHidden(void) -{ - return is_cursor_hidden; -} - -void DisplayDriver::HideCursor(void) -{ - SetCursorHidden(true); -} - -void DisplayDriver::ShowCursor(void) -{ - SetCursorHidden(false); -} - -void DisplayDriver::ObscureCursor(void) -{ - SetCursorObscured(true); -} - -void DisplayDriver::SetCursor(ServerBitmap *cursor, const BPoint &hotspot) -{ - SetHotSpot(hotspot); -} - -void DisplayDriver::SetHotSpot(const BPoint &pt) -{ - cursor_hotspot=pt; -} - -BPoint DisplayDriver::GetHotSpot(void) -{ - return cursor_hotspot; -} - -//--------------------------------------------------------- -// Private Methods -//--------------------------------------------------------- - -bool DisplayDriver::Lock(bigtime_t timeout) // defaults to B_INIFINITE_TIMEOUT -{ -// acquire_sem(lock_sem); - if(acquire_sem_etc(lock_sem,1,B_RELATIVE_TIMEOUT,timeout)!=B_NO_ERROR) - return false; - return true; -} - -void DisplayDriver::Unlock(void) -{ - release_sem(lock_sem); -} - -void DisplayDriver::SetDepthInternal(uint8 d) -{ - buffer_depth=d; -} - -void DisplayDriver::SetHeightInternal(uint16 h) -{ - buffer_height=h; -} - -void DisplayDriver::SetWidthInternal(uint16 w) -{ - buffer_width=w; -} - -void DisplayDriver::SetModeInternal(int32 m) -{ - buffer_mode=m; -} - -void DisplayDriver::SetCursorHidden(bool state) -{ - cursor_state_changed = (is_cursor_hidden != state); - is_cursor_hidden = state; -} - -bool DisplayDriver::CursorStateChanged(void) -{ - return cursor_state_changed; -} -bool DisplayDriver::IsCursorObscured(bool state) -{ - return is_cursor_obscured; -} - -void DisplayDriver::SetCursorObscured(bool state) -{ - is_cursor_obscured=state; -} - -//--------------------------------------------------------- -// Empty Methods -//--------------------------------------------------------- - -void DisplayDriver::Shutdown(void) {} -void DisplayDriver::CopyBits(BRect src, BRect dest) {} -void DisplayDriver::DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest) {} -void DisplayDriver::DrawChar(char c, BPoint pt, LayerData *d) {} -//void DisplayDriver::DrawPicture(SPicture *pic, BPoint pt) {} -void DisplayDriver::DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL) {} - -void DisplayDriver::FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat) {} -void DisplayDriver::FillBezier(BPoint *pts, LayerData *d, int8 *pat) {} -void DisplayDriver::FillEllipse(BRect r, LayerData *d, int8 *pat) {} -void DisplayDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat) {} -void DisplayDriver::FillRect(BRect r, LayerData *d, int8 *pat) {} -void DisplayDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) {} -//void DisplayDriver::FillShape(SShape *sh, LayerData *d, int8 *pat) {} -void DisplayDriver::FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) {} - -void DisplayDriver::MoveCursorTo(float x, float y) {} -void DisplayDriver::InvertRect(BRect r) {} - -void DisplayDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat) {} -void DisplayDriver::StrokeBezier(BPoint *pts, LayerData *d, int8 *pat) {} -void DisplayDriver::StrokeEllipse(BRect r, LayerData *d, int8 *pat) {} -void DisplayDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat) {} -void DisplayDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true) {} -void DisplayDriver::StrokeRect(BRect r, LayerData *d, int8 *pat) {} -void DisplayDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) {} -//void DisplayDriver::StrokeShape(SShape *sh, LayerData *d, int8 *pat) {} -void DisplayDriver::StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) {} -void DisplayDriver::StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d) {} -void DisplayDriver::SetMode(int32 mode) {} diff --git a/src/servers/app/proto7/DisplayDriver.h b/src/servers/app/proto7/DisplayDriver.h deleted file mode 100644 index 0088c4b7b2..0000000000 --- a/src/servers/app/proto7/DisplayDriver.h +++ /dev/null @@ -1,136 +0,0 @@ -#ifndef _DISPLAY_DRIVER_H_ -#define _DISPLAY_DRIVER_H_ - -#include -#include -#include - -#include -#include -#include "RGBColor.h" - -class ServerCursor; -class ServerBitmap; -class LayerData; - -#ifndef ROUND - #define ROUND(a) ( (a-long(a))>=.5)?(long(a)+1):(long(a)) -#endif - -typedef struct -{ - uchar *xormask, *andmask; - int32 width, height; - int32 hotx, hoty; - -} cursor_data; - -#ifndef HOOK_DEFINE_CURSOR - -#define HOOK_DEFINE_CURSOR 0 -#define HOOK_MOVE_CURSOR 1 -#define HOOK_SHOW_CURSOR 2 -#define HOOK_DRAW_LINE_8BIT 3 -#define HOOK_DRAW_LINE_16BIT 12 -#define HOOK_DRAW_LINE_32BIT 4 -#define HOOK_DRAW_RECT_8BIT 5 -#define HOOK_DRAW_RECT_16BIT 13 -#define HOOK_DRAW_RECT_32BIT 6 -#define HOOK_BLIT 7 -#define HOOK_DRAW_ARRAY_8BIT 8 -#define HOOK_DRAW_ARRAY_16BIT 14 // Not implemented in current R5 drivers -#define HOOK_DRAW_ARRAY_32BIT 9 -#define HOOK_SYNC 10 -#define HOOK_INVERT_RECT 11 - -#endif - -#define DRAW_COPY 0 -#define DRAW_OVER 1 -#define DRAW_ERASE 2 -#define DRAW_INVERT 3 -#define DRAW_ADD 4 -#define DRAW_SUBTRACT 5 -#define DRAW_BLEND 6 -#define DRAW_MIN 7 -#define DRAW_MAX 8 -#define DRAW_SELECT 9 -#define DRAW_ALPHA 10 - -class DisplayDriver -{ -public: - DisplayDriver(void); - virtual ~DisplayDriver(void); - virtual bool Initialize(void); - virtual void Shutdown(void); - virtual void CopyBits(BRect src, BRect dest); - virtual void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest); - virtual void DrawChar(char c, BPoint pt, LayerData *d); -// virtual void DrawPicture(SPicture *pic, BPoint pt); - virtual void DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL); - - virtual void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat); - virtual void FillBezier(BPoint *pts, LayerData *d, int8 *pat); - virtual void FillEllipse(BRect r, LayerData *d, int8 *pat); - virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat); - virtual void FillRect(BRect r, LayerData *d, int8 *pat); - virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// virtual void FillShape(SShape *sh, LayerData *d, int8 *pat); - virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); - - virtual void HideCursor(void); - virtual bool IsCursorHidden(void); - virtual void MoveCursorTo(float x, float y); - virtual void InvertRect(BRect r); - virtual void ShowCursor(void); - virtual void ObscureCursor(void); - virtual void SetCursor(ServerBitmap *cursor, const BPoint &hotspot); - - virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat); - virtual void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat); - virtual void StrokeEllipse(BRect r, LayerData *d, int8 *pat); - virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat); - virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true); - virtual void StrokeRect(BRect r, LayerData *d, int8 *pat); - virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// virtual void StrokeShape(SShape *sh, LayerData *d, int8 *pat); - virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); - virtual void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d); - virtual void SetMode(int32 mode); - virtual float StringWidth(const char *string, int32 length, LayerData *d); - virtual float StringHeight(const char *string, int32 length, LayerData *d); - virtual bool DumpToFile(const char *path); - - uint8 GetDepth(void); - uint16 GetHeight(void); - uint16 GetWidth(void); - int32 GetMode(void); - void SetHotSpot(const BPoint &pt); - BPoint GetHotSpot(void); - -protected: - bool Lock(bigtime_t timeout=B_INFINITE_TIMEOUT); - void Unlock(void); - void SetDepthInternal(uint8 d); - void SetHeightInternal(uint16 h); - void SetWidthInternal(uint16 w); - void SetModeInternal(int32 m); - void SetCursorHidden(bool state); - void SetCursorObscured(bool state); - bool IsCursorObscured(bool state); - bool CursorStateChanged(void); - -private: - sem_id lock_sem; - uint8 buffer_depth; - uint16 buffer_width; - uint16 buffer_height; - int32 buffer_mode; - drawing_mode drawmode; - bool is_cursor_hidden; - bool is_cursor_obscured, cursor_state_changed; - BPoint cursor_hotspot; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/FontFamily.cpp b/src/servers/app/proto7/FontFamily.cpp deleted file mode 100644 index bfde92dbff..0000000000 --- a/src/servers/app/proto7/FontFamily.cpp +++ /dev/null @@ -1,190 +0,0 @@ -#include "FontFamily.h" -#include "ServerFont.h" -#include FT_CACHE_H - -extern FTC_Manager ftmanager; - -FontStyle::FontStyle(const char *filepath, FT_Face face) -{ - name=new BString(face->style_name); - cachedface=new CachedFaceRec; - cachedface->file_path=filepath; - family=NULL; - instances=new BList(0); - has_bitmaps=(face->num_fixed_sizes>0)?true:false; - is_fixedwidth=(face->face_flags & FT_FACE_FLAG_FIXED_WIDTH)?true:false; - is_scalable=(face->face_flags & FT_FACE_FLAG_SCALABLE)?true:false; - has_kerning=(face->face_flags & FT_FACE_FLAG_KERNING)?true:false; - glyphcount=face->num_glyphs; - charmapcount=face->num_charmaps; - path=new BString(filepath); - fbounds.Set(0,0,0,0); -} - -FontStyle::~FontStyle(void) -{ - delete name; - delete path; - delete cachedface; - - // Mark all instances as Free here - int32 index=0; - - ServerFont *fs=(ServerFont*)instances->ItemAt(index); - - while(fs) - { - fs->fstyle=NULL; - index++; - fs=(ServerFont*)instances->ItemAt(index); - } - - instances->MakeEmpty(); - delete instances; -} - -const char *FontStyle::Style(void) -{ - return path->String(); -} - -FT_Face FontStyle::GetFace(void) -{ - FT_Face f; - return (FTC_Manager_Lookup_Face(ftmanager,cachedface,&f)!=0)?f:NULL; -} - -const char *FontStyle::GetPath(void) -{ - return path->String(); -} - -int16 FontStyle::ConvertToUnicode(uint16 c) -{ - FT_Face f; - if(FTC_Manager_Lookup_Face(ftmanager,cachedface,&f)!=0) - return 0; - - return FT_Get_Char_Index(f,c); -} - -ServerFont *FontStyle::Instantiate(float size, float rotation=0.0, float shear=90.0) -{ - ServerFont *f=new ServerFont(this, size, rotation, shear); - instances->AddItem(f); - return f; -} - -FontFamily::FontFamily(const char *namestr) -{ - name=new BString(namestr); - styles=new BList(0); -} - -FontFamily::~FontFamily(void) -{ - delete name; - - BString *string; - for(int32 i=0; iCountItems(); i++) - { - string=(BString *)styles->RemoveItem(i); - if(string) - delete string; - } - styles->MakeEmpty(); // should be empty, but just in case... - delete styles; -} - -const char *FontFamily::GetName(void) -{ - return name->String(); -} - -void FontFamily::AddStyle(const char *path,FT_Face face) -{ - if(!path) - return; - - BString style(face->style_name); - FontStyle *item; - - // Don't add if it already is in the family. - int32 count=styles->CountItems(); - for(int32 i=0; iItemAt(i); - if(item->name->Compare(face->style_name)==0) - return; - } - - item=new FontStyle(path, face); - item->family=this; - styles->AddItem(item); - AddDependent(); -} - -void FontFamily::RemoveStyle(const char *style) -{ - int32 count=styles->CountItems(); - if(!style || count<1) - return; - - FontStyle *fs; - for(int32 i=0; iItemAt(i); - if(fs && fs->name->Compare(style)==0) - { - fs=(FontStyle *)styles->RemoveItem(i); - if(fs) - { - delete fs; - RemoveDependent(); - } - } - } -} - -int32 FontFamily::CountStyles(void) -{ - return styles->CountItems(); -} - -bool FontFamily::HasStyle(const char *style) -{ - int32 count=styles->CountItems(); - if(!style || count<1) - return false; - FontStyle *fs; - for(int32 i=0; iItemAt(i); - if(fs && fs->name->Compare(style)==0) - return true; - } - return false; -} - -const char *FontFamily::GetStyle(int32 index) -{ - FontStyle *fs=(FontStyle*)styles->ItemAt(index); - if(!fs) - return NULL; - return fs->Style(); -} - -FontStyle *FontFamily::GetStyle(const char *style) -{ - int32 count=styles->CountItems(); - if(!style || count<1) - return NULL; - FontStyle *fs; - for(int32 i=0; iItemAt(i); - if(fs && fs->name->Compare(style)==0) - return fs; - } - return NULL; -} diff --git a/src/servers/app/proto7/FontFamily.h b/src/servers/app/proto7/FontFamily.h deleted file mode 100644 index 7e46f593d6..0000000000 --- a/src/servers/app/proto7/FontFamily.h +++ /dev/null @@ -1,84 +0,0 @@ -#ifndef FONT_FAMILY_H_ -#define FONT_FAMILY_H_ - -#include -#include -#include -#include -#include -#include FT_FREETYPE_H -#include "SharedObject.h" - -class FontFamily; -class ServerFont; - -enum font_format -{ - FONT_TRUETYPE=0, - FONT_TYPE_1, - FONT_OPENTYPE, - FONT_BDF, - FONT_CFF, - FONT_CID, - FONT_PCF, - FONT_PFR, - FONT_SFNT, - FONT_TYPE_42, - FONT_WINFONT, -}; - - -// data structure used by the FreeType cache manager -typedef struct CachedFaceRec_ -{ - BString file_path; - int face_index; -} CachedFaceRec, *CachedFace; - -class FontStyle : public SharedObject -{ -public: - FontStyle(const char *filepath, FT_Face face); - ~FontStyle(void); - ServerFont *Instantiate(float size, float rotation=0.0, float shear=90.0); - bool IsFixedWidth(void) { return is_fixedwidth; } - bool IsScalable(void) { return is_scalable; } - bool HasKerning(void) { return has_kerning; } - bool HasTuned(void) { return has_bitmaps; } - uint16 GlyphCount(void) { return glyphcount; } - uint16 CharMapCount(void) { return charmapcount; } - const char *Style(void); - FontFamily *Family(void) { return family; } - FT_Face GetFace(void); - const char *GetPath(void); - int16 ConvertToUnicode(uint16 c); -protected: - friend FontFamily; - FontFamily *family; - uint16 glyphcount, charmapcount; - BString *name, *path; - BList *instances; - bool is_fixedwidth, is_scalable, has_kerning, has_bitmaps; - CachedFace cachedface; - uint8 format; - BRect fbounds; -}; - -class FontFamily : public SharedObject -{ -public: - FontFamily(const char *namestr); - ~FontFamily(void); - const char *GetName(void); - void AddStyle(const char *path, FT_Face face); - void RemoveStyle(const char *style); - bool HasStyle(const char *style); - int32 CountStyles(void); - const char *GetStyle(int32 index); - FontStyle *GetStyle(const char *style); -protected: - BString *name; - BList *styles; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/FontServer.cpp b/src/servers/app/proto7/FontServer.cpp deleted file mode 100644 index 0676d4e25d..0000000000 --- a/src/servers/app/proto7/FontServer.cpp +++ /dev/null @@ -1,489 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include "FontFamily.h" -#include "FontServer.h" -#include "ServerFont.h" -#include "ServerProtocol.h" - -//#define DEBUG_FONTSERVER -//#define DEBUG_SCANDIR - -#ifdef DEBUG_FONTSERVER -#include -#else - #ifdef DEBUG_SCANDIR - #include - #endif -#endif - -FTC_Manager ftmanager; -FT_Library ftlib; -FontServer *fontserver; - -static FT_Error face_requester(FTC_FaceID face_id, FT_Library library, - FT_Pointer request_data, FT_Face *aface) -{ - CachedFace face = (CachedFace) face_id; - return FT_New_Face(ftlib,face->file_path.String(),face->face_index,aface); -} - - -FontServer::FontServer(void) -{ - lock=create_sem(1,"fontserver_lock"); - init=(FT_Init_FreeType(&ftlib)==0)?true:false; - -/* - Fire up the font caching subsystem. - The three zeros tell FreeType to use the defaults, which are 2 faces, - 4 face sizes, and a maximum of 200000 bytes. I will probably change - these numbers in the future to maximize performance for your "average" - application. -*/ - if(FTC_Manager_New(ftlib,0,0,0,&face_requester,NULL,&ftmanager)!=0 - && init) - init=false; - - families=new BList(0); - plain=NULL; - bold=NULL; - fixed=NULL; - -#ifdef DEBUG_FONTSERVER -if(!init) - printf("Couldn't initialize FreeType library\n"); -#endif -} - -FontServer::~FontServer(void) -{ - delete_sem(lock); - delete families; - FTC_Manager_Done(ftmanager); - FT_Done_FreeType(ftlib); -} - -void FontServer::Lock(void) -{ - acquire_sem(lock); -} - -void FontServer::Unlock(void) -{ - release_sem(lock); -} - -int32 FontServer::CountFamilies(void) -{ - if(init) - return families->CountItems(); - return 0; -} - -int32 FontServer::CountStyles(const char *family) -{ - FontFamily *f=_FindFamily(family); - if(f) - { - return f->CountStyles(); - } - return 0; -} - -void FontServer::RemoveFamily(const char *family) -{ - FontFamily *f=_FindFamily(family); - if(f) - { - families->RemoveItem(f); - delete f; - } -#ifdef DEBUG_FONTSERVER - else - printf("FontServer::RemoveFamily(): Couldn't remove %s\n",family); -#endif -} - -FontFamily *FontServer::_FindFamily(const char *name) -{ - if(!init) - return NULL; - int32 count=families->CountItems(), i; - FontFamily *family; - for(i=0; iItemAt(i); - if(strcmp(family->GetName(),name)==0) - return family; - } -//#ifdef DEBUG_FONTSERVER -//printf("FontServer::_FindFamily(): Couldn't find %s\n",name); -//#endif - return NULL; -} - -status_t FontServer::ScanDirectory(const char *fontspath) -{ - // This bad boy does all the real work. It loads each entry in the - // directory. If a valid font file, it adds both the family and the style. - // Both family and style are stored internally as BStrings. Once everything - -#ifdef DEBUG_SCANDIR -printf("FontServer::ScanDirectory(%s)\n",fontspath); -#endif - BDirectory dir; - BEntry entry; - BPath path; - entry_ref ref; - status_t stat; - int32 refcount,i, validcount=0; - FT_Face face; - FT_Error error; - FT_CharMap charmap; - FontFamily *family; -// int32 familycount; - - stat=dir.SetTo(fontspath); - if(stat!=B_OK) - { -#ifdef DEBUG_SCANDIR -printf("FontServer::ScanDirectory(): couldn't open path\n"); -#endif - return stat; - } - refcount=dir.CountEntries(); -#ifdef DEBUG_SCANDIR -printf("FontServer::ScanDirectory(): %ld entries\n",refcount); -#endif - - for(i=0;icharmap=charmap; - - family=_FindFamily(face->family_name); - - if(!family) - { - family=new FontFamily(face->family_name); - families->AddItem(family); - } - - if(family->HasStyle(face->style_name)) - { -#ifdef DEBUG_SCANDIR -printf("FontServer::ScanDirectory(): %s : %s already loaded\n", face->family_name,face->style_name); -#endif - FT_Done_Face(face); - continue; - } - - // Has vertical metrics? -#ifdef DEBUG_SCANDIR - if(FT_HAS_VERTICAL(face)) - printf("%s : %s has vertical metrics\n",face->family_name, face->style_name); -#endif - family->AddStyle(path.Path(),face); - validcount++; - -#ifdef DEBUG_SCANDIR -printf( "FontServer::ScanDirectory: Added %s : %s\n", face->family_name, face->style_name); -if(face->num_fixed_sizes>0) -{ - for(int32 j=0;jnum_fixed_sizes;++j) - printf( " Fixed size #%ld : %dx%d\n", j, face->available_sizes[j].width, face->available_sizes[j].height ); -} -#endif - - FT_Done_Face(face); - } // end for(iCountItems(); - for(i=0;iItemAt(i); - if(family) - { - if(family->CountStyles()<1) - { -#ifdef DEBUG_SCANDIR -printf("FontServer::ScanDirectory(): deleting empty family %s\n", family->GetName()); -#endif - families->RemoveItem(family); - delete family; - } - } - } -*/ - need_update=true; - return B_OK; -} - -FT_CharMap FontServer::_GetSupportedCharmap(const FT_Face &face) -{ - int32 i; - FT_CharMap charmap; - for(i=0; i< face->num_charmaps; i++) - { - charmap=face->charmaps[i]; - switch(charmap->platform_id) - { - case 3: - { - // if Windows Symbol or Windows Unicode - if(charmap->encoding_id==0 || charmap->encoding_id==1) - return charmap; - break; - } - case 1: - { - // if Apple Unicode - if(charmap->encoding_id==0) - return charmap; - break; - } - case 0: - { - // if Apple Roman - if(charmap->encoding_id==0) - return charmap; - break; - } - default: - { -#ifdef DEBUG_SCANDIR -printf("Font %s:%s has unknown platform id %d\n",face->family_name,face->style_name, charmap->platform_id); -#endif - break; - } - } - } - return NULL; - -} - -/* -This saves all family names and styles to the file -/boot/home/config/app_server/fontlist as a flattened BMessage - -This operation is not done very often because the access to disk adds a significant -performance hit. - -The format for storage consists of two things: an array of strings with the name 'family' -and a number of small string arrays which have the name of the font family. These are -the style lists. - -Additionally, any fonts which have bitmap strikes contained in them or any fonts which -are fixed-width are named in the arrays 'tuned' and 'fixed' - -*/ -void FontServer::SaveList(void) -{ -#ifdef DEBUG_FONTSERVER - printf("FontServer::SaveList()\n"); -#endif - int32 famcount=0, stycount=0,i=0,j=0; - FontFamily *fam; - FontStyle *sty; - BMessage fontmsg, familymsg('FONT'); - BString famname, styname, extraname; - bool fixed,tuned; - - famcount=families->CountItems(); - for(i=0; iItemAt(i); - fixed=false; - tuned=false; - if(!fam) - continue; - - famname=fam->GetName(); - - // Add the family to the message - familymsg.AddString("name",famname); - - stycount=fam->CountStyles(); - for(j=0;jGetStyle(j)); - if(styname.CountChars()>0) - { - // Add to list - familymsg.AddString("styles", styname); - - // Check to see if it has prerendered strikes (has "tuned" fonts) - sty=fam->GetStyle(styname.String()); - if(!sty) - continue; - - if(sty->HasTuned() && sty->IsScalable()) - tuned=true; - - // Check to see if it is fixed-width - if(sty->IsFixedWidth()) - fixed=true; - } - } - if(tuned) - familymsg.AddBool("tuned",true); - if(fixed) - familymsg.AddBool("fixed",true); - - fontmsg.AddMessage("family",&familymsg); -#ifdef DEBUG_FONTSERVER -familymsg.PrintToStream(); -#endif - familymsg.MakeEmpty(); - } - - BFile file(SERVER_FONT_LIST,B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); - if(file.InitCheck()==B_OK) - fontmsg.Flatten(&file); -#ifdef DEBUG_FONTSERVER - else - { - printf("FontServer::SaveList(): Couldn't open %s for write\n",SERVER_FONT_LIST); - } -#endif -} - -FontStyle *FontServer::GetStyle(font_family family, font_style face) -{ - FontFamily *ffam=_FindFamily(family); - - if(ffam) - { - FontStyle *fsty=ffam->GetStyle(face); - return fsty; - } - return NULL; -} - -ServerFont *FontServer::GetSystemPlain(void) -{ - if(plain) - { - ServerFont *f=new ServerFont(*plain); - return f; - } - return NULL; -} - -ServerFont *FontServer::GetSystemBold(void) -{ - if(bold) - { - ServerFont *f=new ServerFont(*bold); - return f; - } - return NULL; -} - -ServerFont *FontServer::GetSystemFixed(void) -{ - if(fixed) - { - ServerFont *f=new ServerFont(*fixed); - return f; - } - return NULL; -} - -bool FontServer::SetSystemPlain(const char *family, const char *style, float size) -{ - FontFamily *fam=_FindFamily(family); - if(!fam) - return false; - FontStyle *sty=fam->GetStyle(style); - if(!sty) - return false; - - if(plain) - delete plain; - plain=sty->Instantiate(size); - return true; -} - -bool FontServer::SetSystemBold(const char *family, const char *style, float size) -{ - FontFamily *fam=_FindFamily(family); - if(!fam) - return false; - FontStyle *sty=fam->GetStyle(style); - if(!sty) - return false; - - if(bold) - delete bold; - bold=sty->Instantiate(size); - return true; -} - -bool FontServer::SetSystemFixed(const char *family, const char *style, float size) -{ - FontFamily *fam=_FindFamily(family); - if(!fam) - return false; - FontStyle *sty=fam->GetStyle(style); - if(!sty) - return false; - - if(fixed) - delete fixed; - fixed=sty->Instantiate(size); - return true; -} - diff --git a/src/servers/app/proto7/FontServer.h b/src/servers/app/proto7/FontServer.h deleted file mode 100644 index e1f99496cf..0000000000 --- a/src/servers/app/proto7/FontServer.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef FONTSERVER_H_ -#define FONTSERVER_H_ - -#include -#include -#include -#include -#include -#include FT_FREETYPE_H -#include FT_CACHE_H - -class FontFamily; -class FontStyle; -class ServerFont; - -class FontServer -{ -public: - FontServer(void); - ~FontServer(void); - void Lock(void); - void Unlock(void); - bool IsInitialized(void) { return init; } - int32 CountFamilies(void); - int32 CountStyles(const char *family); - void RemoveFamily(const char *family); - status_t ScanDirectory(const char *path); - void SaveList(void); - FontStyle *GetStyle(font_family family, font_style face); - ServerFont *GetSystemPlain(void); - ServerFont *GetSystemBold(void); - ServerFont *GetSystemFixed(void); - bool SetSystemPlain(const char *family, const char *style, float size); - bool SetSystemBold(const char *family, const char *style, float size); - bool SetSystemFixed(const char *family, const char *style, float size); - bool FontsNeedUpdated(void) { return need_update; } - void FontsUpdated(void) { need_update=false; } -// FontInstance *GetInstance(font_family family, font_style face, int16 size, int16 rotation, int16 shear); - - FontFamily *_FindFamily(const char *name); - FT_CharMap _GetSupportedCharmap(const FT_Face &face); - bool init; - sem_id lock; - BList *families; - ServerFont *plain, *bold, *fixed; - bool need_update; -}; - -extern FTC_Manager ftmanager; -extern FT_Library ftlib; -extern FontServer *fontserver; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/Globals.h b/src/servers/app/proto7/Globals.h deleted file mode 100644 index 2753cad1aa..0000000000 --- a/src/servers/app/proto7/Globals.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _SERVER_GLOBALS_H_ -#define _SERVER_GLOBALS_H_ - -#include -BList *gBitmaplist, *gLayerlist; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/Jamfile b/src/servers/app/proto7/Jamfile deleted file mode 100644 index 7b72feed4e..0000000000 --- a/src/servers/app/proto7/Jamfile +++ /dev/null @@ -1,41 +0,0 @@ -SubDir OBOS_TOP src servers app proto7 ; - -UseFreeTypeHeaders ; - -Server OBAppServer : - # Misc. Sources - Angle.cpp - BeDecorator.cpp - ColorUtils.cc - ColorSet.cpp - DebugTools.cpp - Decorator.cpp - PortLink.cpp - SystemPalette.cpp - RGBColor.cpp - - # Operating Classes - AppServer.cpp - Desktop.cpp - Layer.cpp - ServerApp.cpp - ServerBitmap.cpp - ServerWindow.cpp - WindowBorder.cpp - - # Font Classes - FontFamily.cpp - FontServer.cpp - ServerFont.cpp - - # Display Modules - DisplayDriver.cpp - LineCalc.cpp - ScreenDriver.cpp - ViewDriver.cpp -; -LinkSharedOSLibs OBAppServer : be root game translation stdc++.r4 - libfreetype.so ; - -SubInclude OBOS_TOP src servers app proto7 testobapp ; - diff --git a/src/servers/app/proto7/Layer.cpp b/src/servers/app/proto7/Layer.cpp deleted file mode 100644 index 016c82e5ac..0000000000 --- a/src/servers/app/proto7/Layer.cpp +++ /dev/null @@ -1,1034 +0,0 @@ -/* - Layer.cpp - Class used for rendering to the frame buffer. One layer per view on screen and - also for window decorators -*/ -#include "Layer.h" -#include "ServerWindow.h" -#include "Desktop.h" -#include "PortLink.h" -#include "DisplayDriver.h" -#include -#include -#include -#include -#include - -//#define DEBUG_LAYERS -//#define DEBUG_REDRAW - -int64 solidhigh64=0xFFFFFFFFFFFFFFFFLL; -int64 solidlow64=0LL; -int64 mixedpat64=0xCCCCCCCCCCCCCCCCLL; -int8 *solidhigh=(int8*)&solidhigh64; -int8 *solidlow=(int8*)&solidlow64; -int8 *mixedpat=(int8*)&mixedpat64; - -bool TestLineIntersect(const BRect&r, float x1, float y1, float x2, float y2,bool vertical=true); -bool TestRectIntersection(const BRect &r,const BRect &r2); -bool TestRegionIntersection(BRegion *r,const BRect &r2); -void IntersectRegionWith(BRegion *r,const BRect &r2); - -Layer::Layer(BRect rect, const char *layername, ServerWindow *srvwin, - int32 viewflags, int32 token) -{ - if(rect.IsValid()) - // frame is in parent layer's coordinates - frame=rect; - else - { -#ifdef DEBUG_LAYERS -printf("Invalid BRect: "); rect.PrintToStream(); -#endif - frame.Set(0,0,1,1); - } - - name=new BString(layername); - - // Layer does not start out as a part of the tree - parent=NULL; - uppersibling=NULL; - lowersibling=NULL; - topchild=NULL; - bottomchild=NULL; - - visible=new BRegion(Bounds()); - full=new BRegion(Bounds()); - invalid=NULL; - - serverwin=srvwin; - - view_token=token; - - flags=viewflags; - - hidecount=0; - is_dirty=false; - is_updating=false; - - level=0; - layerdata=new LayerData; -#ifdef DEBUG_LAYERS - PrintToStream(); -#endif -} - -Layer::Layer(BRect rect, const char *layername) -{ - // This constructor is used for the top layer in each workspace - if(rect.IsValid()) - frame=rect; - else - frame.Set(0,0,1,1); - - name=new BString(layername); - - // Layer is the root for the workspace - parent=NULL; - uppersibling=NULL; - lowersibling=NULL; - topchild=NULL; - bottomchild=NULL; - - visible=new BRegion(Bounds()); - full=new BRegion(Bounds()); - invalid=NULL; - - serverwin=NULL; - flags=0; - hidecount=0; - is_dirty=false; - - level=0; - - view_token=-1; - layerdata=new LayerData; -#ifdef DEBUG_LAYERS - PrintToStream(); -#endif -} - -Layer::~Layer(void) -{ -#ifdef DEBUG_LAYERS -printf("Layer Destructor for %s\n",name->String()); -#endif - if(visible) - { - delete visible; - visible=NULL; - } - if(full) - { - delete full; - full=NULL; - } - if(invalid) - { - delete invalid; - invalid=NULL; - } - if(name) - { - delete name; - name=NULL; - } - if(layerdata) - { - delete layerdata; - layerdata=NULL; - } -} - -// Tested for adding children with 1 and 2 child cases, but not more -void Layer::AddChild(Layer *layer) -{ - // Adds a layer to the top of the layer's children -#ifdef DEBUG_LAYERS -printf("AddChild %s\n",layer->name->String()); -printf("Before AddChild: \n"); -PrintNode(); -if(parent) - parent->PrintNode(); -if(uppersibling) - uppersibling->PrintNode(); -if(lowersibling) - lowersibling->PrintNode(); -if(topchild) - topchild->PrintNode(); -if(bottomchild) - bottomchild->PrintNode(); -#endif - - - if(layer->parent!=NULL) - { - printf("ERROR: AddChild(): View already has a parent\n"); - return; - } - layer->parent=this; - if(layer->visible && layer->hidecount==0 && visible) - { - // Technically, we could safely take the address of ConvertToParent(BRegion) - // but we don't just to avoid a compiler nag - BRegion *reg=new BRegion(layer->ConvertToParent(layer->visible)); - visible->Exclude(reg); - delete reg; - } - - // we need to change this to a loop for each lowersibling of the layer - if(topchild!=NULL) - { - // we're adding to the back side of the stack?? - layer->lowersibling=topchild; - - // added layer will be at the bottom of the stack - topchild->uppersibling=layer; - for(Layer *lay=layer->lowersibling; lay!=NULL; lay=lay->lowersibling) - { - if(layer->frame.Intersects(lay->frame)) - { - if(lay->visible && lay->hidecount==0) - { - // reg is what is visible in the layer's parent's coordinate system - BRegion *reg=new BRegion(ConvertToParent(layer->visible)); - // reg2 is the layer's visible region in the sibling's coordinate system - BRegion *reg2=new BRegion(lay->ConvertFromParent(reg)); - delete reg; - - // layer->lowersibling->visible->Exclude(reg2); - // lowersiblings occupy screen space _above_ a layer, so the layer itself - // must remove from its visible region - layer->visible->Exclude(reg2); - delete reg2; - } - } - } - } - else - bottomchild=layer; - topchild=layer; - layer->level=level+1; - -#ifdef DEBUG_LAYERS -printf("After AddChild: \n"); -PrintNode(); -if(parent) - parent->PrintNode(); -if(uppersibling) - uppersibling->PrintNode(); -if(lowersibling) - lowersibling->PrintNode(); -if(topchild) - topchild->PrintNode(); -if(bottomchild) - bottomchild->PrintNode(); -#endif -} - -// Tested for cases with 1 and 2 children, but no more than that -void Layer::RemoveChild(Layer *layer) -{ - // Remove a layer from the tree -#ifdef DEBUG_LAYERS -printf("RemoveChild %s\n",layer->name->String()); -printf("Before RemoveChild: \n"); -PrintNode(); -if(parent) - parent->PrintNode(); -if(uppersibling) - uppersibling->PrintNode(); -if(lowersibling) - lowersibling->PrintNode(); -if(topchild) - topchild->PrintNode(); -if(bottomchild) - bottomchild->PrintNode(); -#endif - - if(layer->parent==NULL) - { - printf("ERROR: RemoveChild(): View doesn't have a parent\n"); - return; - } - if(layer->parent!=this) - { - printf("ERROR: RemoveChild(): View is not a child of this layer\n"); - return; - } - - if(hidecount==0 && layer->visible && layer->parent->visible) - { - BRegion *reg=new BRegion(ConvertToParent(visible)); - layer->parent->visible->Include(reg); - delete reg; - } - - // Take care of parent - layer->parent=NULL; - if(topchild==layer) - topchild=layer->lowersibling; - if(bottomchild==layer) - bottomchild=layer->uppersibling; - - // Take care of siblings - if(layer->uppersibling!=NULL) - layer->uppersibling->lowersibling=layer->lowersibling; - if(layer->lowersibling!=NULL) - layer->lowersibling->uppersibling=layer->uppersibling; - layer->SetLevel(0); - layer->uppersibling=NULL; - layer->lowersibling=NULL; - - RebuildRegions(); - -#ifdef DEBUG_LAYERS -printf("After RemoveChild: \n"); -PrintNode(); -if(parent) - parent->PrintNode(); -if(uppersibling) - uppersibling->PrintNode(); -if(lowersibling) - lowersibling->PrintNode(); -if(topchild) - topchild->PrintNode(); -if(bottomchild) - bottomchild->PrintNode(); -#endif -} - -void Layer::RemoveSelf(void) -{ - // A Layer removes itself from the tree (duh) -#ifdef DEBUG_LAYERS -printf("RemoveSelf %s\n",name->String()); -#endif - if(parent==NULL) - { - printf("ERROR: RemoveSelf(): View doesn't have a parent\n"); - return; - } - parent->RemoveChild(this); -} - -Layer *Layer::GetChildAt(BPoint pt, bool recursive=false) -{ - // 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 *child; - if(recursive) - { - for(child=bottomchild; child!=NULL; child=child->uppersibling) - { - if(child->bottomchild!=NULL) - child->GetChildAt(pt,true); - - if(child->hidecount>0) - continue; - - if(child->frame.Contains(pt)) - return child; - } - } - else - { - for(child=bottomchild; child!=NULL; child=child->uppersibling) - { - if(child->hidecount>0) - continue; -// if(child->visible && child->visible->Contains(ConvertFromTop(pt))) -// printf("child hit by mouse. News at 11\n"); - if(child->frame.Contains(pt)) - return child; - } - } - return NULL; -} - -BRect Layer::Bounds(void) -{ - return frame.OffsetToCopy(0,0); -} - -BRect Layer::Frame(void) -{ - return frame; -} - -void Layer::SetLevel(int32 value) -{ - // Sets hierarchy level of layer and all children -#ifdef DEBUG_LAYERS - printf("SetLevel %ld\n",value); -#endif - level=value; - - Layer *lay; - - lay=topchild; - - while(lay!=NULL) - { - if(lay->topchild!=NULL) - lay->topchild->SetLevel(value+1); - lay=lay->lowersibling; - } -} - -void Layer::PruneTree(void) -{ - // recursively deletes all children (and grandchildren, etc) of the passed layer - // This is mostly used for server shutdown or deleting a workspace -#ifdef DEBUG_LAYERS - printf("PruneTree() at level %ld\n", level); -#endif - Layer *lay,*nextlay; - - lay=topchild; - topchild=NULL; - - while(lay!=NULL) - { - if(lay->topchild!=NULL) - { -// lay->topchild->PruneTree(); - lay->PruneTree(); - } - nextlay=lay->lowersibling; - lay->lowersibling=NULL; - delete lay; - lay=nextlay; - } - // Man, this thing is short. Elegant, ain't it? :P -} - -Layer *Layer::FindLayer(int32 token) -{ - // recursive search for a layer based on its view token - Layer *lay, *trylay; - - // Search child layers first - for(lay=topchild; lay!=NULL; lay=lay->lowersibling) - { - if(lay->view_token==token) - return lay; - } - - // Hmmm... not in this layer's children. Try lower descendants - for(lay=topchild; lay!=NULL; lay=lay->lowersibling) - { - trylay=lay->FindLayer(token); - if(trylay) - return trylay; - } - - // Well, we got this far in the function, so apparently there is no match to be found - return NULL; -} - -// Tested -void Layer::Invalidate(BRegion region) -{ - int32 i; - BRect r; - - // See if the region intersects with our current area - if(region.Intersects(Bounds()) && hidecount==0) - { - BRegion clippedreg(region); - clippedreg.IntersectWith(visible); - if(clippedreg.CountRects()>0) - { - is_dirty=true; - if(invalid) - invalid->Include(&clippedreg); - else - invalid=new BRegion(clippedreg); - } - } - - BRegion *reg; - for(Layer *lay=topchild;lay!=NULL; lay=lay->lowersibling) - { - if(lay->hidecount==0) - { - reg=new BRegion(lay->ConvertFromParent(®ion)); - - for(i=0;iCountRects();i++) - { - r=reg->RectAt(i); - if(frame.Intersects(r)) - lay->Invalidate(r); - } - - delete reg; - } - } -} - -// Tested -void Layer::Invalidate(BRect rect) -{ - // Make our own section dirty and pass it on to any children, if necessary.... - // YES, WE ARE SHARING DIRT! Mudpies anyone? :D -#ifdef DEBUG_REDRAW -printf("Layer %s::Invalidate(%f,%f,%f,%f)\n",name->String(),rect.left,rect.top, - rect.right,rect.bottom); -#endif -// if(Frame().Intersects(rect) || Frame().Contains(rect)) - if(TestRectIntersection(Frame(),rect)) - { - // Clip the rectangle to the visible region of the layer -// if(visible->Intersects(rect)) - if(TestRegionIntersection(visible,rect)) - { -// BRegion reg(rect); -// reg.IntersectWith(visible); - BRegion reg(*visible); - IntersectRegionWith(®,rect); - if(reg.CountRects()>0) - { - is_dirty=true; - if(invalid) - invalid->Include(®); - else - invalid=new BRegion(reg); - } - else - { -#ifdef DEBUG_REDRAW -printf("\tRegion intersection had no rectangles\n");rect.PrintToStream(); -#endif - } - } - else - { -#ifdef DEBUG_REDRAW -printf("\tRectangle did not intersect frame(%.1f,%.1f,%.1f,%.1f)\n", Frame().left, -Frame().top,Frame().right,Frame().bottom); -#endif - } - } - for(Layer *lay=topchild;lay!=NULL; lay=lay->lowersibling) - lay->Invalidate(lay->ConvertFromParent(rect)); -} - -void Layer::RequestDraw(void) -{ - if(visible==NULL || hidecount>0) - return; - - if(serverwin) - { - if(invalid==NULL) - invalid=new BRegion(*visible); - serverwin->RequestDraw(invalid->Frame()); - delete invalid; - invalid=NULL; - } - - is_dirty=false; - for(Layer *lay=topchild; lay!=NULL; lay=lay->lowersibling) - { - if(lay->IsDirty()) - lay->RequestDraw(); - } - -} - -bool Layer::IsDirty(void) const -{ -// return is_dirty; - return (!invalid)?true:false; -} - -void Layer::ShowLayer(void) -{ - if(hidecount==0) - return; - - hidecount--; - if(hidecount==0) - { - BRegion *reg=new BRegion(ConvertToParent(visible)); - parent->visible->Exclude(reg); - delete reg; - is_dirty=true; - } - - Layer *child; - for(child=topchild; child!=NULL; child=child->lowersibling) - child->ShowLayer(); -} - -void Layer::HideLayer(void) -{ - if(hidecount==0) - { - BRegion *reg=new BRegion(ConvertToParent(visible)); - parent->visible->Include(reg); - delete reg; - parent->is_dirty=true; - is_dirty=true; - } - hidecount++; - - Layer *child; - for(child=topchild; child!=NULL; child=child->lowersibling) - child->HideLayer(); -} - -// Tested -uint32 Layer::CountChildren(void) -{ - uint32 i=0; - Layer *lay=topchild; - while(lay!=NULL) - { - lay=lay->lowersibling; - i++; - } - return i; -} - -void Layer::MoveBy(float x, float y) -{ - BRect oldframe(frame); - frame.OffsetBy(x,y); - - if(parent) - { - if(parent->invalid==NULL) - parent->invalid=new BRegion(oldframe); - else - parent->invalid->Include(oldframe); - } - -// for(Layer *lay=topchild; lay!=NULL; lay=lay->lowersibling) -// lay->MoveBy(x,y); -// Invalidate(Frame()); -} - -void Layer::ResizeBy(float x, float y) -{ - BRect oldframe=frame; - frame.right+=x; - frame.bottom+=y; - - if(parent) - parent->RebuildRegions(); - else - RebuildRegions(); - -// for(Layer *lay=topchild; lay!=NULL; lay=lay->lowersibling) -// lay->ResizeBy(x,y); - if(x<0 || y<0) - parent->Invalidate(oldframe); -// Invalidate(Frame()); -} - -void Layer::RebuildRegions(bool include_children=true) -{ - BRegion *reg,*reg2; - if(full) - full->Include(Bounds()); - else - full=new BRegion(Bounds()); - - if(visible) - visible->Include(Bounds()); - else - visible=new BRegion(Bounds()); - - // Remove child footprints from visible region - for(Layer *childlay=topchild; childlay!=NULL; childlay=childlay->lowersibling) - { - if(childlay->visible && childlay->hidecount==0) - { - // reg is what is visible in the layer's parent's coordinate system - reg=new BRegion(ConvertToParent(visible)); - // reg2 is the layer's visible region in the sibling's coordinate system - reg2=new BRegion(childlay->ConvertFromParent(reg)); - delete reg; - - // lowersiblings occupy screen space _above_ a layer, so the layer itself - // must remove from its visible region - visible->Exclude(reg2); - delete reg2; - } - } - - // Remove lowersibling footprints, which are on top of the layer on screen - for(Layer *siblay=lowersibling; siblay!=NULL; siblay=siblay->lowersibling) - { - if(frame.Intersects(siblay->frame)) - { - if(siblay->visible && siblay->hidecount==0) - { - // reg is what is visible in the layer's parent's coordinate system - reg=new BRegion(ConvertToParent(visible)); - // reg2 is the layer's visible region in the sibling's coordinate system - reg2=new BRegion(siblay->ConvertFromParent(reg)); - delete reg; - - // lowersiblings occupy screen space _above_ a layer, so the layer itself - // must remove from its visible region - visible->Exclude(reg2); - delete reg2; - } - } - } - - if(include_children) - { - for(Layer *lay=topchild; lay!=NULL; lay=lay->lowersibling) - { - if(lay->topchild) - lay->RebuildRegions(true); - } - } -} - -void Layer::PrintToStream(void) -{ - printf("-----------\nLayer %s\n",name->String()); - if(parent) - printf("Parent: %s (%p)\n",parent->name->String(), parent); - else - printf("Parent: NULL\n"); - if(uppersibling) - printf("Upper sibling: %s (%p)\n",uppersibling->name->String(), uppersibling); - else - printf("Upper sibling: NULL\n"); - if(lowersibling) - printf("Lower sibling: %s (%p)\n",lowersibling->name->String(), lowersibling); - else - printf("Lower sibling: NULL\n"); - if(topchild) - printf("Top child: %s (%p)\n",topchild->name->String(), topchild); - else - printf("Top child: NULL\n"); - if(bottomchild) - printf("Bottom child: %s (%p)\n",bottomchild->name->String(), bottomchild); - else - printf("Bottom child: NULL\n"); - printf("Frame: "); frame.PrintToStream(); - printf("Token: %ld\nLevel: %ld\n",view_token, level); - printf("Hide count: %u\n",hidecount); - if(invalid) - { - printf("Invalid Areas: "); invalid->PrintToStream(); - } - else - printf("Invalid Areas: NULL\n"); - if(visible) - { - printf("Visible Areas: "); visible->PrintToStream(); - } - else - printf("Visible Areas: NULL\n"); - printf("Is updating = %s\n",(is_updating)?"yes":"no"); -} - -void Layer::PrintNode(void) -{ - printf("-----------\nLayer %s\n",name->String()); - if(parent) - printf("Parent: %s (%p)\n",parent->name->String(), parent); - else - printf("Parent: NULL\n"); - if(uppersibling) - printf("Upper sibling: %s (%p)\n",uppersibling->name->String(), uppersibling); - else - printf("Upper sibling: NULL\n"); - if(lowersibling) - printf("Lower sibling: %s (%p)\n",lowersibling->name->String(), lowersibling); - else - printf("Lower sibling: NULL\n"); - if(topchild) - printf("Top child: %s (%p)\n",topchild->name->String(), topchild); - else - printf("Top child: NULL\n"); - if(bottomchild) - printf("Bottom child: %s (%p)\n",bottomchild->name->String(), bottomchild); - else - printf("Bottom child: NULL\n"); - if(visible) - { - printf("Visible Areas: "); visible->PrintToStream(); - } - else - printf("Visible Areas: NULL\n"); -} - -// Tested -BRect Layer::ConvertToParent(BRect rect) -{ - return (rect.OffsetByCopy(frame.LeftTop())); -} - -// Tested -BPoint Layer::ConvertToParent(BPoint point) -{ - float x=point.x + frame.left, - y=point.y+frame.top; - return (BPoint(x,y)); -} - -// Tested -BRegion Layer::ConvertToParent(BRegion *reg) -{ - BRegion newreg; - for(int32 i=0; iCountRects();i++) - newreg.Include(ConvertToParent(reg->RectAt(i))); - return BRegion(newreg); -} - -// Tested -BRect Layer::ConvertFromParent(BRect rect) -{ - return (rect.OffsetByCopy(frame.left*-1,frame.top*-1)); -} - -// Tested -BPoint Layer::ConvertFromParent(BPoint point) -{ - return ( point-frame.LeftTop()); -} - -// Tested -BRegion Layer::ConvertFromParent(BRegion *reg) -{ - BRegion newreg; - for(int32 i=0; iCountRects();i++) - newreg.Include(ConvertFromParent(reg->RectAt(i))); - return BRegion(newreg); -} - -// Tested -BRegion Layer::ConvertToTop(BRegion *reg) -{ - BRegion newreg; - for(int32 i=0; iCountRects();i++) - newreg.Include(ConvertToTop(reg->RectAt(i))); - return BRegion(newreg); -} - -// Tested -BRect Layer::ConvertToTop(BRect rect) -{ - if (parent!=NULL) - return(parent->ConvertToTop(rect.OffsetByCopy(frame.LeftTop())) ); - else - return(rect); -} - -// Tested -BPoint Layer::ConvertToTop(BPoint point) -{ - if (parent!=NULL) - return(parent->ConvertToTop(point + frame.LeftTop()) ); - else - return(point); -} - -// Tested -BRegion Layer::ConvertFromTop(BRegion *reg) -{ - BRegion newreg; - for(int32 i=0; iCountRects();i++) - newreg.Include(ConvertFromTop(reg->RectAt(i))); - return BRegion(newreg); -} - -// Tested -BRect Layer::ConvertFromTop(BRect rect) -{ - if (parent!=NULL) - return(parent->ConvertFromTop(rect.OffsetByCopy(frame.LeftTop().x*-1, - frame.LeftTop().y*-1)) ); - else - return(rect); -} - -// Tested -BPoint Layer::ConvertFromTop(BPoint point) -{ - if (parent!=NULL) - return(parent->ConvertFromTop(point - frame.LeftTop()) ); - else - return(point); -} - -RootLayer::RootLayer(BRect rect, const char *layername, ServerWindow *srvwin, - int32 viewflags, int32 token) - : Layer(rect,layername,srvwin,viewflags,token) -{ - updater_id=-1; -} - -RootLayer::RootLayer(BRect rect, const char *layername) - : Layer(rect,layername) -{ - updater_id=-1; - driver=get_gfxdriver(); -} - -RootLayer::~RootLayer(void) -{ -} - -void RootLayer::SetVisible(bool fVisible) -{ - if(is_visible!=fVisible) - { - is_visible=fVisible; -/* if(visible) - { - updater_id=spawn_thread(UpdaterThread,name->String(),B_NORMAL_PRIORITY,this); - if(updater_id!=B_NO_MORE_THREADS && updater_id!=B_NO_MEMORY) - resume_thread(updater_id); - } -*/ - } -} - -bool RootLayer::IsVisible(void) const -{ - return is_visible; -} - -int32 RootLayer::UpdaterThread(void *data) -{ - // Updater thread which checks to see if its layer needs updating. If so, then - // call the recursive function RequestDraw. - - RootLayer *root=(RootLayer*)data; - - while(1) - { - if(!root->is_visible) - { - return 0; - exit_thread(1); - } - - if(root->IsDirty()) - { - layerlock->Lock(); - root->RequestDraw(); - layerlock->Unlock(); - } - } -} - -void RootLayer::RequestDraw(void) -{ - if(!invalid) - return; - - ASSERT(driver!=NULL); - -#ifdef DEBUG_REDRAW -printf("Root::RequestDraw: invalid rects: %ld\n",invalid->CountRects()); -#endif - - - // Redraw the base - for(int32 i=0; invalid->CountRects();i++) - { - if(invalid->RectAt(i).IsValid()) - { -#ifdef DEBUG_REDRAW -printf("Root::RequestDraw:FillRect, color "); layerdata->lowcolor.PrintToStream(); -#endif - driver->FillRect(invalid->RectAt(i),layerdata, solidlow); - } - else - break; - } - - delete invalid; - invalid=NULL; - is_dirty=false; - - // force redraw of all dirty windows - for(Layer *lay=topchild; lay!=NULL; lay=lay->lowersibling) - { - if(lay->IsDirty()) - lay->RequestDraw(); - } - -} - -void RootLayer::SetColor(RGBColor col) -{ - layerdata->lowcolor=col; -#ifdef DEBUG_LAYERS -printf("Root::SetColor - "); col.PrintToStream(); -#endif -} - -RGBColor RootLayer::GetColor(void) const -{ - return layerdata->lowcolor; -} - -// Code stolen from the OBOS version of Rect.cpp. BeOS R5 version returns false -// if the rectangles are exactly equal -bool TestRectIntersection(const BRect &r,const BRect &r2) -{ - return TestLineIntersect(r, r2.left, r2.top, r2.left, r2.bottom) || - TestLineIntersect(r, r2.left, r2.top, r2.right, r2.top, false) || - TestLineIntersect(r, r2.right, r2.top, r2.right, r2.bottom) || - TestLineIntersect(r, r2.left, r2.bottom, r2.right, r2.bottom, false) || - r.Contains(r2) || - r2.Contains(r); -} - -bool TestRegionIntersection(BRegion *r,const BRect &r2) -{ - for(int32 i=0; iCountRects(); i++) - if(TestRectIntersection(r->RectAt(i),r2)); - return true; - return false; -} - -void IntersectRegionWith(BRegion *r,const BRect &r2) -{ - // We have three conditions: - // 1) Region frame contains rect. Action: call Include() - // 2) Rect intersects region frame. Action: call IntersectWith - // 3) Region frame does not intersect rectangle. Make the region empty - if(r->Frame().Contains(r2)) - r->Include(r2); - if(r->Frame().Intersects(r2)) - { - BRegion reg(r2); - r->IntersectWith(®); - } - else - r->MakeEmpty(); -} - -bool TestLineIntersect(const BRect& r, float x1, float y1, float x2, float y2, - bool vertical) -{ - if (vertical) - { - return (x1 >= r.left && x1 <= r.right) && - ((y1 >= r.top && y1 <= r.bottom) || - (y2 >= r.top && y2 <= r.bottom)); - } - else - { - return (y1 >= r.top && y1 <= r.bottom) && - ((x1 >= r.left && x1 <= r.right) || - (x2 >= r.left && x2 <= r.right)); - } -} \ No newline at end of file diff --git a/src/servers/app/proto7/Layer.h b/src/servers/app/proto7/Layer.h deleted file mode 100644 index 8e57b3fb70..0000000000 --- a/src/servers/app/proto7/Layer.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef _LAYER_H_ -#define _LAYER_H_ - -#include -#include -#include -#include -#include -#include -#include "LayerData.h" - -class ServerWindow; -class UpdateNode; -class DisplayDriver; - -class Layer -{ -public: - Layer(BRect rect, const char *layername, ServerWindow *srvwin, - int32 viewflags, int32 token); - Layer(BRect rect, const char *layername); - virtual ~Layer(void); - - void ShowLayer(void); - void HideLayer(void); - Layer *FindLayer(int32 token); - void MoveLayer(BPoint delta, bool include_children=true); - void AddChild(Layer *child); - void RemoveChild(Layer *child); - void RemoveSelf(void); - uint32 CountChildren(void); - Layer *GetChildAt(BPoint pt, bool recursive=false); - BRect Bounds(void); - BRect Frame(void); - - void MoveBy(float x, float y); - void ResizeBy(float x, float y); - - void RebuildRegions(bool include_children=true); - bool IsDirty(void) const; - void PrintToStream(void); - void PrintNode(void); - void PruneTree(void); - void SetLevel(int32 value); - void Invalidate(BRect rect); - void Invalidate(BRegion region); - virtual void RequestDraw(void); - - BRect ConvertToParent(BRect rect); - BPoint ConvertToParent(BPoint point); - BRegion ConvertToParent(BRegion *reg); - BRect ConvertFromParent(BRect rect); - BPoint ConvertFromParent(BPoint point); - BRegion ConvertFromParent(BRegion *reg); - BRegion ConvertToTop(BRegion *reg); - BRect ConvertToTop(BRect rect); - BPoint ConvertToTop(BPoint point); - BRegion ConvertFromTop(BRegion *reg); - BRect ConvertFromTop(BRect rect); - BPoint ConvertFromTop(BPoint point); - - BRect frame; - - Layer *parent, - *uppersibling, - *lowersibling, - *topchild, - *bottomchild; - - BRegion *visible, - *invalid, - *full; - - ServerWindow *serverwin; - - BString *name; - int32 view_token; // identifier for the corresponding view - int32 level; // how far layer is from root - int32 flags; // view flags - uint8 hidecount; - bool is_dirty; // true if we need to redraw - bool is_updating; - LayerData *layerdata; -}; - -class RootLayer : public Layer -{ -public: - RootLayer(BRect rect, const char *layername, ServerWindow *srvwin, - int32 viewflags, int32 token); - RootLayer(BRect rect, const char *layername); - ~RootLayer(void); - virtual void RequestDraw(void); - void SetVisible(bool is_visible); - bool IsVisible(void) const; - - void SetColor(RGBColor col); - RGBColor GetColor(void) const; - - static int32 UpdaterThread(void *data); -private: - thread_id updater_id; - bool is_visible; - DisplayDriver *driver; -}; - -extern BLocker *layerlock; -extern BList *layerlist; -extern Layer *rootlayer; -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/LayerData.h b/src/servers/app/proto7/LayerData.h deleted file mode 100644 index 6d5ed51a85..0000000000 --- a/src/servers/app/proto7/LayerData.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef LAYERDATA_H_ -#define LAYERDATA_H_ - -#include -#include -#include "RGBColor.h" -#include "ServerFont.h" -#include "FontServer.h" - -class ServerBitmap; - -class LayerData -{ -public: -LayerData(void) - { - pensize=1.0; - penlocation.Set(0,0); - draw_mode=B_OP_COPY; - blending_mode=B_ALPHA_OVERLAY; - alpha_mode=B_CONSTANT_ALPHA; - bitmap_background=NULL; - bitmap_overlay=NULL; - highcolor.SetColor(0,0,0,255); - lowcolor.SetColor(255,255,255,255); - font=fontserver->GetSystemPlain(); - scale=1.0; - edelta.space=0; - edelta.nonspace=0; - } -~LayerData(void) - { - if(font) - { - delete font; - font=NULL; - } - } -float pensize; -BPoint penlocation; -drawing_mode draw_mode; -source_alpha alpha_mode; -alpha_function blending_mode; -ServerBitmap *bitmap_background; -ServerBitmap *bitmap_overlay; -RGBColor highcolor, lowcolor; -ServerFont *font; -float scale; -escapement_delta edelta; -}; - -extern int8 *solidhigh; -extern int8 *solidlow; -extern int8 *mixedpat; -extern int64 solidhigh64; -extern int64 solidlow64; -extern int64 mixedpat64; -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/LineCalc.cpp b/src/servers/app/proto7/LineCalc.cpp deleted file mode 100644 index 3e2742d2c1..0000000000 --- a/src/servers/app/proto7/LineCalc.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "LineCalc.h" - -LineCalc::LineCalc(const BPoint &pta, const BPoint &ptb) -{ - start=pta; - end=ptb; - slope=(start.y-end.y)/(start.x-end.x); - offset=start.y-(slope * start.x); -} - -float LineCalc::GetX(float y) -{ - return ( (y-offset)/slope ); -} - -float LineCalc::GetY(float x) -{ - return ( (slope * x) + offset ); -} - diff --git a/src/servers/app/proto7/LineCalc.h b/src/servers/app/proto7/LineCalc.h deleted file mode 100644 index 82d3ed86ad..0000000000 --- a/src/servers/app/proto7/LineCalc.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef LINECALC_H_ -#define LINECALC_H_ - -#include - -class LineCalc -{ -public: - LineCalc(const BPoint &pta, const BPoint &ptb); - float GetX(float y); - float GetY(float x); - float Slope(void) { return slope; } - float Offset(void) { return offset; } -private: - float slope; - float offset; - BPoint start, end; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/PortLink.cpp b/src/servers/app/proto7/PortLink.cpp deleted file mode 100644 index 8fba724569..0000000000 --- a/src/servers/app/proto7/PortLink.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/* - PortLink.cpp: - A helper class for port-based messaging - ------------------------------------------------------------------------- -How it works: - The class utilizes a fixed-size array of PortLinkData object pointers. When -data is attached, a new PortLinkData object is allocated and a copy of the -passed data is created inside it. When the time comes for the message to be sent, -the data is pieced together into a flattened array and written to the port. ------------------------------------------------------------------------- -Data members: - -*attachments[] - fixed-size array of pointers used to hold the attached data -opcode - message value which is sent along with any data -target - port to which the message is sent when Flush() is called -replyport - port used with synchronous messaging - FlushWithReply() -bufferlength - total bytes taken up by attachments -num_attachments - internal variable which is used to track which "slot" - will be the next one to receive an attachment object -*/ - -#include "PortLink.h" -#include -#include -#include - -//#define PLDEBUG - -// Internal data storage class for holding attached data whilst it is waiting -// to be Flattened() and then Flushed(). There is no need for this to be called outside -// the PortLink class. -class PortLinkData -{ -public: - PortLinkData(void); - ~PortLinkData(void); - bool Set(void *data, size_t size); - char *buffer; - size_t buffersize; -}; - -PortLink::PortLink(port_id port) -{ - // For this class to be useful (and to prevent a lot of init problems) - // we require a port in the constructor - target=port; - - // We start out without any data attached to the port message - num_attachments=0; - opcode=0; - bufferlength=0; - replyport=create_port(30,"PortLink reply port"); -} - -PortLink::~PortLink(void) -{ - // If, for some odd reason, this is deleted with something attached, - // free the memory used by the attachments. We do not flush the queue - // because the port may no longer be valid in cases such as the app - // is in the process of quitting - MakeEmpty(); -} - -void PortLink::SetOpCode(int32 code) -{ - // Sets the message code. This does not change once the message is sent. - // Another call to SetOpCode() is required for such things. - opcode=code; -} - -void PortLink::SetPort(port_id port) -{ - // Sets the target port. While not necessary in most uses, this exists - // mostly to prevent flexibility problems - target=port; -} - -port_id PortLink::GetPort(void) -{ - // Simply returns the port at which the object is pointed. - return target; -} - -void PortLink::Flush(bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message off to the target, complete with attachments. NOTE: - // the recipient must delete all attachments, being the PortLink object assumes - // no responsiblity for the attachments once the message is sent. - int8 *msgbuffer; - int32 size; - - if(num_attachments>0) - { - FlattenData(&msgbuffer,&size); - - // Dump message to port, reset attachments, and clean up - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,msgbuffer,size,B_TIMEOUT, timeout); - else - write_port(target,opcode,msgbuffer,size); - MakeEmpty(); - } - else - { - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,NULL,0,B_TIMEOUT, timeout); - else - write_port(target,opcode,NULL,0); - } -} - -int8* PortLink::FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message to the target and then waits for a reply. The target will - // receive a message with the first item being the port_id to reply to. - // NOTE: like Flush(), any attached data must be deleted. - - // Effectively, an Attach() call inlined for changes - - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - { - *status=B_ERROR; - return NULL; - } - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&replyport,sizeof(port_id))) - { - bufferlength+=sizeof(port_id); - } - else - { - delete pld; - *status=B_ERROR; - return NULL; - } - - // Flatten() inlined to make some necessary changes - int8 *buffer=new int8[bufferlength]; - int8 *bufferindex=buffer; - size_t size=0; - - // attach our port_id first - memcpy(bufferindex, pld->buffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - - // attach everything else - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - } - - // Flush the thing....FOOSH! :P - write_port(target,opcode,buffer,size); - MakeEmpty(); - delete buffer; - - // Now we wait for the reply - if(timeout==B_INFINITE_TIMEOUT) - { - *buffersize=port_buffer_size(replyport); - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - else - { - *buffersize=port_buffer_size_etc(replyport,0,timeout); - if(*buffersize==B_TIMED_OUT) - { - *status=*buffersize; - return NULL; - } - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - - // We got this far, so we apparently have some data - *status=B_OK; - return buffer; -} - -void PortLink::Attach(void *data, size_t size) -{ - // This is the member called to attach data to a message. Attachments are - // treated to be in 'Append' mode, tacking on each attached piece of data - // to the end of the list. - - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - if(size==0) - return; - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -// These functions were added for a major convenience in passing common types -// Eventually, I'd like to templatize these, but for now, this'll do - -void PortLink::Attach(int32 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int32); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int16 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int16); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int8 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int8); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(float data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(float); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(bool data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(bool); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BRect data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BRect); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BPoint data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BPoint); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::FlattenData(int8 **buffer,int32 *size) -{ - // This function is where all the magic happens, but it is strictly internal. - // It iterates through each PortLinkData object and copies it to the main buffer - // which ends up, ultimately, being written to the PortLink's target port. - - // skip if there aree no attachments - if(bufferlength<1) - return; - - *buffer=new int8[bufferlength]; - int8 *bufferindex=*buffer; - PortLinkData *pld; - *size=0; - - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - *size+=pld->buffersize; - } -} - -void PortLink::MakeEmpty(void) -{ - // Nukes all the attachments currently held by the PortLink class - if(num_attachments!=0) - { - for(int i=0; i0) - free(buffer); -} - -bool PortLinkData::Set(void *data, size_t size) -{ - // Function copies the passed to the internal buffers for storage - if(size>0 && buffersize==0 && data!=NULL) - { - buffer=(char *)malloc(size); - if(buffer==NULL) - return false; - memcpy(buffer, data, size); - buffersize=size; - return true; - } - return false; -} diff --git a/src/servers/app/proto7/PortLink.h b/src/servers/app/proto7/PortLink.h deleted file mode 100644 index 9f5432daab..0000000000 --- a/src/servers/app/proto7/PortLink.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _PORTLINK_H_ -#define _PORTLINK_H_ - -#include -#include -#include -#include - -#ifndef _PORTLINK_BUFFERSIZE -#define _PORTLINK_MAX_ATTACHMENTS 50 -#endif - -class PortLinkData; - -class PortLink -{ -public: - PortLink(port_id port); - ~PortLink(void); - void SetOpCode(int32 code); - void SetPort(port_id port); - port_id GetPort(void); - void Flush(bigtime_t timeout=B_INFINITE_TIMEOUT); - int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, - bigtime_t timeout=B_INFINITE_TIMEOUT); - void Attach(void *data, size_t size); - void Attach(int32 data); - void Attach(int16 data); - void Attach(int8 data); - void Attach(float data); - void Attach(bool data); - void Attach(BRect data); - void Attach(BPoint data); - void MakeEmpty(void); -protected: - void FlattenData(int8 **buffer,int32 *size); - port_id target, replyport; - int32 opcode, bufferlength; - int num_attachments; - PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS]; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/RGBColor.cpp b/src/servers/app/proto7/RGBColor.cpp deleted file mode 100644 index 6b8751fbe7..0000000000 --- a/src/servers/app/proto7/RGBColor.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - RGBColor.cpp - Color encapsulation class for app_server. -*/ - -#include -#include "RGBColor.h" - -RGBColor::RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255) -{ - SetColor(r,g,b,a); -} - -RGBColor::RGBColor(int r, int g, int b, int a=255) -{ - SetColor(r,g,b,a); -} - -RGBColor::RGBColor(rgb_color col) -{ - SetColor(col); -} - -RGBColor::RGBColor(uint16 col) -{ - SetColor(col); -} - -RGBColor::RGBColor(uint8 col) -{ - SetColor(col); -} - -RGBColor::RGBColor(const RGBColor &col) -{ - color32=col.color32; - color16=col.color16; - color8=col.color8; -} - -RGBColor::RGBColor(void) -{ - SetColor(0,0,0,0); -} - -uint8 RGBColor::GetColor8(void) -{ - return color8; -} - -uint16 RGBColor::GetColor16(void) -{ - return color16; -} - -rgb_color RGBColor::GetColor32(void) -{ - return color32; -} - -void RGBColor::SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255) -{ - color32.red=r; - color32.green=g; - color32.blue=b; - color32.alpha=a; -} - -void RGBColor::SetColor(int r, int g, int b, int a=255) -{ - color32.red=(uint8)r; - color32.green=(uint8)g; - color32.blue=(uint8)b; - color32.alpha=(uint8)a; -} - -void RGBColor::SetColor(uint16 col16) -{ - // Pared-down version from what is used in the app_server to - // eliminate some dependencies - color16=col16; -} - -void RGBColor::SetColor(uint8 col8) -{ - // Pared-down version from what is used in the app_server to - // eliminate some dependencies - color8=col8; -} - -void RGBColor::SetColor(rgb_color color) -{ - // Pared-down version from what is used in the app_server to - // eliminate some dependencies - color32=color; -} - -void RGBColor::SetColor(const RGBColor &col) -{ - color32=col.color32; - color16=col.color16; - color8=col.color8; -} - - -RGBColor & RGBColor::operator=(const RGBColor &col) -{ - color32=col.color32; - color16=col.color16; - color8=col.color8; - return *this; -} - -RGBColor & RGBColor::operator=(rgb_color col) -{ - color32=col; - return *this; -} - -RGBColor RGBColor::MakeBlendColor(RGBColor color, float position) -{ - rgb_color col=color32; - rgb_color col2=color.color32; - - rgb_color newcol={0,0,0,0}; - float mod=0; - int16 delta; - if(position<0 || position>1) - return newcol; - - delta=int16(col2.red)-int16(col.red); - mod=col.red + (position * delta); - newcol.red=uint8(mod); - if(mod>255 ) - newcol.red=255; - if(mod<0 ) - newcol.red=0; - - delta=int16(col2.green)-int16(col.green); - mod=col.green + (position * delta); - newcol.green=uint8(mod); - if(mod>255 ) - newcol.green=255; - if(mod<0 ) - newcol.green=0; - - delta=int16(col2.blue)-int16(col.blue); - mod=col.blue + (position * delta); - newcol.blue=uint8(mod); - if(mod>255 ) - newcol.blue=255; - if(mod<0 ) - newcol.blue=0; - - delta=int8(col2.alpha)-int8(col.alpha); - mod=col.alpha + (position * delta); - newcol.alpha=uint8(mod); - if(mod>255 ) - newcol.alpha=255; - if(mod<0 ) - newcol.alpha=0; -#ifdef DEBUG_COLOR_UTILS -printf("MakeBlendColor( {%u,%u,%u,%u}, {%u,%u,%u,%u}, %f) : {%u,%u,%u,%u}\n", - col.red,col.green,col.blue,col.alpha, - col2.red,col2.green,col2.blue,col2.alpha, - position, - newcol.red,newcol.green,newcol.blue,newcol.alpha); -#endif - - return RGBColor(newcol); -} - -void RGBColor::PrintToStream(void) -{ - printf("RGBColor (%u,%u,%u,%u)\n", color32.red,color32.green,color32.blue,color32.alpha); -} - -bool RGBColor::operator==(const rgb_color &col) -{ - return (color32.red==col.red && color32.green==col.green - && color32.blue==col.blue)?true:false; -} - -bool RGBColor::operator==(const RGBColor &col) -{ - return (color32.red==col.color32.red && color32.green==col.color32.green - && color32.blue==col.color32.blue)?true:false; -} diff --git a/src/servers/app/proto7/RGBColor.h b/src/servers/app/proto7/RGBColor.h deleted file mode 100644 index 7be035d09d..0000000000 --- a/src/servers/app/proto7/RGBColor.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef RGBCOLOR_H_ -#define RGBCOLOR_H_ - -#include - -class RGBColor -{ -public: - RGBColor(uint8 r, uint8 g, uint8 b, uint8 a=255); - RGBColor(int r, int g, int b, int a=255); - RGBColor(rgb_color col); - RGBColor(uint16 col); - RGBColor(uint8 col); - RGBColor(const RGBColor &col); - RGBColor(void); - void PrintToStream(void); - uint8 GetColor8(void); - uint16 GetColor16(void); - rgb_color GetColor32(void); - void SetColor(uint8 r, uint8 g, uint8 b, uint8 a=255); - void SetColor(int r, int g, int b, int a=255); - void SetColor(uint16 color16); - void SetColor(uint8 color8); - void SetColor(rgb_color color); - void SetColor(const RGBColor &col); - RGBColor MakeBlendColor(RGBColor color, float position); - RGBColor & operator=(const RGBColor &col); - RGBColor & operator=(rgb_color col); - bool operator==(const rgb_color &col); - bool operator==(const RGBColor &col); -protected: - rgb_color color32; - uint16 color16; - uint8 color8; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/ScreenDriver.cpp b/src/servers/app/proto7/ScreenDriver.cpp deleted file mode 100644 index ae7eeec347..0000000000 --- a/src/servers/app/proto7/ScreenDriver.cpp +++ /dev/null @@ -1,2385 +0,0 @@ -/* - ScreenDriver.cpp - Replacement class for the ViewDriver which utilizes a BWindowScreen for ease - of testing without requiring a second video card for SecondDriver and also - without the limitations (mostly speed) of ViewDriver. - - This module also emulates the input server via the keyboard. - Cursor keys move the mouse and the left modifier keys Option and Ctrl, which - operate the first and second mouse buttons, respectively. - The right window key on American keymaps doesn't map to anything, so it is - not used. Consequently, when a right modifier key is pressed, it works normally. - - The concept is pretty close to the retooled ViewDriver, where each module - call locks a couple BLockers and draws to the buffer. - - Components: - ScreenDriver: actual driver module - FrameBuffer: BWindowScreen derivative which provides the module access - to the video card - Internal functions for doing graphics on the buffer -*/ -#include "Angle.h" -#include "ScreenDriver.h" -#include "ServerProtocol.h" -#include "ServerBitmap.h" -#include "SystemPalette.h" -#include "ColorUtils.h" -#include "PortLink.h" -#include "FontFamily.h" -#include "RGBColor.h" -#include "DebugTools.h" -#include "LayerData.h" -#include "LineCalc.h" -#include -#include -#include -#include -#include - -//#define DEBUG_DRIVER -#define DEBUG_SERVER_EMU - -//#define DISABLE_SERVER_EMU - -// Define this if you want to use the spacebar to launch the server prototype's -// test application -#define LAUNCH_TESTAPP - -#ifdef LAUNCH_TESTAPP -#include -#include -#endif - -void HLine_32Bit(graphics_card_info i, uint16 x, uint16 y, uint16 length, rgb_color col); -void HLine_16Bit(graphics_card_info i, uint16 x, uint16 y, uint16 length, uint16 col); -void HLine_16Bit(graphics_card_info i, uint16 x, uint16 y, uint16 length, uint8 col); - -FrameBuffer::FrameBuffer(const char *title, uint32 space, status_t *st,bool debug) - : BWindowScreen(title,space,st,debug) -{ - is_connected=false; - port_id serverport=find_port(SERVER_INPUT_PORT); - serverlink=new PortLink(serverport); - mousepos.Set(0,0); - buttons=0; -#ifdef DEBUG_SERVER_EMU -printf("ScreenDriver:: app_server input port: %ld\n",serverlink->GetPort()); -#endif -} - -FrameBuffer::~FrameBuffer(void) -{ - delete serverlink; -} - -void FrameBuffer::ScreenConnected(bool connected) -{ - is_connected=connected; - if(connected) - { - // Cache the state just in case - graphics_card_info *info=CardInfo(); - gcinfo=*info; - } -} - -void FrameBuffer::MessageReceived(BMessage *msg) -{ - switch(msg->what) - { - case B_KEY_DOWN: - { - int32 key,modifiers; - msg->FindInt32("key",&key); - msg->FindInt32("modifiers",&modifiers); - - 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; - - switch(key) - { - case 0x47: // Enter key - { - port_id serverport=find_port(SERVER_PORT_NAME); - write_port(serverport,B_QUIT_REQUESTED,NULL,0); - break; - } -#ifdef LAUNCH_TESTAPP - // use spacebar to launch test app - case 0x5e: - { - printf("Launching test app\n"); - status_t value; -// BEntry entry("/boot/home/Desktop/openbeos/sources/proto6/OBApplication/OBApplication"); - BEntry entry("/boot/home/Desktop/openbeos/sources/proto7/OBApplication/OBApplication"); - entry_ref ref; - entry.GetRef(&ref); - value=be_roster->Launch(&ref); - - BString str=TranslateStatusToString(value); - printf("Launch return code: %s",str.String()); - printf("\n"); - break; - } -#endif - -#ifndef DISABLE_SERVER_EMU - 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; - } - } - case B_MODIFIERS_CHANGED: - { - int32 modifiers; - if(msg->FindInt32("modifiers",&modifiers)==B_OK) - { -#ifndef DISABLE_SERVER_EMU - - 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); - } -} - -bool FrameBuffer::QuitRequested(void) -{ - port_id serverport=find_port(SERVER_PORT_NAME); - - if(serverport!=B_NAME_NOT_FOUND) - write_port(serverport,B_QUIT_REQUESTED,NULL,0); - - return true; -} - -ScreenDriver::ScreenDriver(void) : DisplayDriver() -{ - status_t st; - fbuffer=new FrameBuffer("OBAppServer",B_8_BIT_640x480,&st,true); - - drawmode = DRAW_COPY; - - cursor=NULL; - under_cursor=NULL; - cursorframe.Set(0,0,0,0); -} - -ScreenDriver::~ScreenDriver(void) -{ - if(cursor) - delete cursor; - if(under_cursor) - delete under_cursor; -} - -bool ScreenDriver::Initialize(void) -{ - fbuffer->Show(); - - // wait 1 sec for the window to show... - snooze(500000); - - // we start out without a cursor shown because otherwise we get glitches in the - // upper left corner. init_desktop *always* sets a cursor, so this shouldn't be a problem - return true; -} - -void ScreenDriver::Shutdown(void) -{ - fbuffer->Lock(); - fbuffer->Quit(); -} - -void ScreenDriver::DrawBitmap(ServerBitmap *bitmap, BRect source, BRect dest) -{ - Lock(); -#ifdef DEBUG_DRIVER -printf("ScreenDriver::DrawBitmap(*, (%f,%f,%f,%f),(%f,%f,%f,%f) )\n", - source.left,source.top,source.right,source.bottom, - dest.left,dest.top,dest.right,dest.bottom); -#endif - if(fbuffer->IsConnected()) - { - // Scale bitmap here if source!=dest - - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 32: - case 24: - { - printf("DrawBitmap: 32/24-bit unimplemented\n"); - break; - } - case 16: - case 15: - { - printf("DrawBitmap: 16/15-bit unimplemented\n"); - break; - } - case 8: - { - printf("DrawBitmap: 8-bit unimplemented\n"); - break; - } - default: - { -#ifdef DEBUG_DRIVER -printf("Clear: unknown bit depth %u\n",fbuffer->gcinfo.bits_per_pixel); -#endif - break; - } - } - } - - Unlock(); -} - -// Ellipse code shamelessly stolen from the graphics library gd v2.0.1 and bolted on -// to support our API -void ScreenDriver::FillEllipse(BRect r, LayerData *ldata, int8 *pat) -{ - long d, b_sq, b_sq_4, b_sq_6; - long a_sq, a_sq_4, a_sq_6; - int x, y, switchem; - long lsqrt (long); - int pix, half, pstart; - int32 thick = (int32)ldata->pensize; - - half = thick / 2; - int32 w=int32(r.Width()/2), - h=int32(r.Height()/2); - int32 cx=(int32)r.left+w; - int32 cy=(int32)r.top+h; - - d = 2 * (long) h *h + (long) w *w - 2 * (long) w *w * h; - b_sq = (long) h *h; - b_sq_4 = 4 * (long) h *h; - b_sq_6 = 6 * (long) h *h; - a_sq = (long) w *w; - a_sq_4 = 4 * (long) w *w; - a_sq_6 = 6 * (long) w *w; - - x = 0; - y = -h; -// switchem = a_sq / lsqrt (a_sq + b_sq); - switchem = a_sq / (int32)sqrt(a_sq + b_sq); - - while (x <= switchem) - { - pstart = y - half; - for (pix = pstart; pix < pstart + thick; pix++) - { - Line( BPoint(cx - x, cy + pix), BPoint(cx + x, cy + pix), ldata, solidhigh); - Line( BPoint(cx - x, cy - pix), BPoint(cx + x, cy - pix), ldata, solidhigh); - } - if (d < 0) - d += b_sq_4 * x++ + b_sq_6; - else - d += b_sq_4 * x++ + b_sq_6 + a_sq_4 * (++y); - } - - /* Middlesplat! - ** Go a little further if the thickness is not nominal... - */ - if (thick > 1) - { - int xp = x; - int yp = y; - int dp = d; - int thick2 = thick + 2; - int half2 = half + 1; - - while (xp <= switchem + half) - { - pstart = yp - half2; - for (pix = pstart; pix < pstart + thick2; pix++) - { - Line( BPoint(cx - xp, cy + pix), BPoint(cx + xp, cy + pix), ldata, solidhigh); - Line( BPoint(cx - xp, cy - pix), BPoint(cx + xp, cy - pix), ldata, solidhigh); - } - if (dp < 0) - dp += b_sq_4 * xp++ + b_sq_6; - else - dp += b_sq_4 * xp++ + b_sq_6 + a_sq_4 * (++yp); - } - } - - d += -2 * (long) b_sq + 2 * (long) a_sq - 2 * (long) b_sq *(x - 1) + 2 * (long) a_sq *(y - 1); - - while (y <= 0) - { - pstart = x - half; - for (pix = pstart; pix < pstart + thick; pix++) - { - Line( BPoint(cx - pix, cy + y), BPoint(cx + pix, cy + y), ldata, solidhigh); - Line( BPoint(cx - pix, cy - y), BPoint(cx + pix, cy - y), ldata, solidhigh); - } - - if (d < 0) - d += a_sq_4 * y++ + a_sq_6 + b_sq_4 * (++x); - else - d += a_sq_4 * y++ + a_sq_6; - } -} - -void ScreenDriver::FillRect(BRect r, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::FillRect( (%f,%f,%f,%f)\n",r.left,r.top,r.right,r.bottom); -#endif - Lock(); - if(fbuffer->IsConnected()) - { - // int32 width=rect.IntegerWidth(); - for(int32 i=(int32)r.top;i<=r.bottom;i++) - // HLine(fbuffer->gcinfo,(int32)rect.left,i,width,col); - Line(BPoint(r.left,i),BPoint(r.right,i),d,pat); - } - Unlock(); -} - -void ScreenDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::FillRoundRect( (%f,%f,%f,%f), %llx) ---->Unimplemented<----\n",r.left,r.top, - r.right,r.bottom,*((uint64*)pat)); -#endif - FillRect(r,d,pat); -} - -void ScreenDriver::FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::FillTriangle(%llx): --->Currently Unimplemented<---\n",*((uint64*)pat)); -printf("\tFirst: (%f,%f)\n\tSecond: (%f,%f)\n\tThird: (%f,%f)\n",pts[0].x,pts[0].y, - pts[1].x,pts[1].y,pts[2].x,pts[2].y); -r.PrintToStream(); -#endif - if(!pts || !d || !pat) - return; - - Lock(); - if(fbuffer->IsConnected()) - { - BPoint first, second, third; - - // Sort points according to their y values - if(pts[0].y < pts[1].y) - { - first=pts[0]; - second=pts[1]; - } - else - { - first=pts[1]; - second=pts[0]; - } - - if(second.ygcinfo.bits_per_pixel) - { - case 32: - case 24: - SetThickPixel32(x,y,thick,col.GetColor32()); - break; - case 16: - case 15: - SetThickPixel16(x,y,thick,col.GetColor16()); - break; - case 8: - SetThickPixel8(x,y,thick,col.GetColor8()); - break; - default: - printf("Unknown pixel depth %d in SetThickPixel\n",fbuffer->gcinfo.bits_per_pixel); - break; - } -} - -void ScreenDriver::SetThickPixel32(int x, int y, int thick, rgb_color col) -{ - // Code courtesy of YNOP's SecondDriver - union - { - uint8 bytes[4]; - uint32 word; - }c1; - - c1.bytes[0]=col.blue; - c1.bytes[1]=col.green; - c1.bytes[2]=col.red; - c1.bytes[3]=col.alpha; - - /* - uint32 *bits=(uint32*)fbuffer->gcinfo.frame_buffer; - *(bits + x + (y*fbuffer->gcinfo.width))=c1.word; - */ - uint32 *bits=(uint32*)fbuffer->gcinfo.frame_buffer+(x-thick/2)+(y-thick/2)*fbuffer->gcinfo.width; - int i,j; - for (i=0; igcinfo.width; - } -} - -void ScreenDriver::SetThickPixel16(int x, int y, int thick, uint16 col) -{ - -#ifdef DEBUG_DRIVER -printf("SetPixel16 unimplemented\n"); -#endif - -} - -void ScreenDriver::SetThickPixel8(int x, int y, int thick, uint8 col) -{ - // When the DisplayDriver API changes, we'll use the uint8 highcolor. Until then, - // we'll use *pattern - /* - uint8 *bits=(uint8*)fbuffer->gcinfo.frame_buffer; - *(bits + x + (y*fbuffer->gcinfo.bytes_per_row))=col; - */ - - uint8 *bits=(uint8*)fbuffer->gcinfo.frame_buffer+(x-thick/2)+(y-thick/2)*fbuffer->gcinfo.bytes_per_row; - int i,j; - for (i=0; igcinfo.bytes_per_row; - } -} - -void ScreenDriver::SetPixel(int x, int y, RGBColor col) -{ - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 32: - case 24: - SetPixel32(x,y,col.GetColor32()); - break; - case 16: - case 15: - SetPixel16(x,y,col.GetColor16()); - break; - case 8: - SetPixel8(x,y,col.GetColor8()); - break; - default: - printf("Unknown pixel depth %d in SetPixel\n",fbuffer->gcinfo.bits_per_pixel); - break; - } -} - -void ScreenDriver::SetPixel32(int x, int y, rgb_color col) -{ - // Code courtesy of YNOP's SecondDriver - union - { - uint8 bytes[4]; - uint32 word; - }c1; - - c1.bytes[0]=col.blue; - c1.bytes[1]=col.green; - c1.bytes[2]=col.red; - c1.bytes[3]=col.alpha; - - uint32 *bits=(uint32*)fbuffer->gcinfo.frame_buffer; - *(bits + x + (y*fbuffer->gcinfo.width))=c1.word; -} - -void ScreenDriver::SetPixel16(int x, int y, uint16 col) -{ - -#ifdef DEBUG_DRIVER -printf("SetPixel16 unimplemented\n"); -#endif - -} - -void ScreenDriver::SetPixel8(int x, int y, uint8 col) -{ - // When the DisplayDriver API changes, we'll use the uint8 highcolor. Until then, - // we'll use *pattern - uint8 *bits=(uint8*)fbuffer->gcinfo.frame_buffer; - *(bits + x + (y*fbuffer->gcinfo.bytes_per_row))=col; - -} - -void ScreenDriver::SetMode(int32 space) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::SetScreen(%lu}\n",space); -#endif - Lock(); - if(fbuffer->IsConnected()) - { - fbuffer->SetSpace(space); - - // We have changed the frame buffer info, so update the cached info - graphics_card_info *info=fbuffer->CardInfo(); - fbuffer->gcinfo=*info; - - // clear the frame buffer. Otherwise, we'll have garbage in it - LayerData d; - d.highcolor.SetColor(80,85,152); - for(int32 i=0; iheight; i++) - { - Line(BPoint(0,i),BPoint(info->width-1,i),&d,solidhigh); - } - } - Unlock(); -} - - -// Currently does not support pattern -void ScreenDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat) -{ - float xc = (r.left+r.right)/2; - float yc = (r.top+r.bottom)/2; - float rx = r.Width()/2; - float ry = r.Height()/2; - int Rx2 = ROUND(rx*rx); - int Ry2 = ROUND(ry*ry); - int twoRx2 = 2*Rx2; - int twoRy2 = 2*Ry2; - int p; - int x=0; - int y = (int)ry; - int px = 0; - int py = twoRx2 * y; - int startx, endx; - int startQuad, endQuad; - bool useQuad1, useQuad2, useQuad3, useQuad4; - bool shortspan = false; - int thick = (int)d->pensize; - - // Watch out for bozos giving us whacko spans - if ( (span >= 360) || (span <= -360) ) - { - StrokeEllipse(r,d,pat); - return; - } - - if ( span > 0 ) - { - startQuad = (int)(angle/90)%4+1; - endQuad = (int)((angle+span)/90)%4+1; - startx = ROUND(.5*r.Width()*fabs(cos(angle*M_PI/180))); - endx = ROUND(.5*r.Width()*fabs(cos((angle+span)*M_PI/180))); - } - else - { - endQuad = (int)(angle/90)%4+1; - startQuad = (int)((angle+span)/90)%4+1; - endx = ROUND(.5*r.Width()*fabs(cos(angle*M_PI/180))); - startx = ROUND(.5*r.Width()*fabs(cos((angle+span)*M_PI/180))); - } - - if ( startQuad != endQuad ) - { - useQuad1 = (endQuad > 1) && (startQuad > endQuad); - useQuad2 = ((startQuad == 1) && (endQuad > 2)) || ((startQuad > endQuad) && (endQuad > 2)); - useQuad3 = ((startQuad < 3) && (endQuad == 4)) || ((startQuad < 3) && (endQuad < startQuad)); - useQuad4 = (startQuad < 4) && (startQuad > endQuad); - } - else - { - if ( (span < 90) && (span > -90) ) - { - useQuad1 = false; - useQuad2 = false; - useQuad3 = false; - useQuad4 = false; - shortspan = true; - } - else - { - useQuad1 = (startQuad != 1); - useQuad2 = (startQuad != 2); - useQuad3 = (startQuad != 3); - useQuad4 = (startQuad != 4); - } - } - - if ( useQuad1 || - (!shortspan && (((startQuad == 1) && (x <= startx)) || ((endQuad == 1) && (x >= endx)))) || - (shortspan && (startQuad == 1) && (x <= startx) && (x >= endx)) ) - SetThickPixel(xc+x,yc-y,thick,d->highcolor); - if ( useQuad2 || - (!shortspan && (((startQuad == 2) && (x >= startx)) || ((endQuad == 2) && (x <= endx)))) || - (shortspan && (startQuad == 2) && (x >= startx) && (x <= endx)) ) - SetThickPixel(xc-x,yc-y,thick,d->highcolor); - if ( useQuad3 || - (!shortspan && (((startQuad == 3) && (x <= startx)) || ((endQuad == 3) && (x >= endx)))) || - (shortspan && (startQuad == 3) && (x <= startx) && (x >= endx)) ) - SetThickPixel(xc-x,yc+y,thick,d->highcolor); - if ( useQuad4 || - (!shortspan && (((startQuad == 4) && (x >= startx)) || ((endQuad == 4) && (x <= endx)))) || - (shortspan && (startQuad == 4) && (x >= startx) && (x <= endx)) ) - SetThickPixel(xc+x,yc+y,thick,d->highcolor); - - p = ROUND (Ry2 - (Rx2 * ry) + (.25 * Rx2)); - while (px < py) - { - x++; - px += twoRy2; - if ( p < 0 ) - p += Ry2 + px; - else - { - y--; - py -= twoRx2; - p += Ry2 + px - py; - } - - if ( useQuad1 || - (!shortspan && (((startQuad == 1) && (x <= startx)) || ((endQuad == 1) && (x >= endx)))) || - (shortspan && (startQuad == 1) && (x <= startx) && (x >= endx)) ) - SetThickPixel(xc+x,yc-y,thick,d->highcolor); - if ( useQuad2 || - (!shortspan && (((startQuad == 2) && (x >= startx)) || ((endQuad == 2) && (x <= endx)))) || - (shortspan && (startQuad == 2) && (x >= startx) && (x <= endx)) ) - SetThickPixel(xc-x,yc-y,thick,d->highcolor); - if ( useQuad3 || - (!shortspan && (((startQuad == 3) && (x <= startx)) || ((endQuad == 3) && (x >= endx)))) || - (shortspan && (startQuad == 3) && (x <= startx) && (x >= endx)) ) - SetThickPixel(xc-x,yc+y,thick,d->highcolor); - if ( useQuad4 || - (!shortspan && (((startQuad == 4) && (x >= startx)) || ((endQuad == 4) && (x <= endx)))) || - (shortspan && (startQuad == 4) && (x >= startx) && (x <= endx)) ) - SetThickPixel(xc+x,yc+y,thick,d->highcolor); - } - - p = ROUND(Ry2*(x+.5)*(x+.5) + Rx2*(y-1)*(y-1) - Rx2*Ry2); - while (y>0) - { - y--; - py -= twoRx2; - if (p>0) - p += Rx2 - py; - else - { - x++; - px += twoRy2; - p += Rx2 - py +px; - } - - if ( useQuad1 || - (!shortspan && (((startQuad == 1) && (x <= startx)) || ((endQuad == 1) && (x >= endx)))) || - (shortspan && (startQuad == 1) && (x <= startx) && (x >= endx)) ) - SetThickPixel(xc+x,yc-y,thick,d->highcolor); - if ( useQuad2 || - (!shortspan && (((startQuad == 2) && (x >= startx)) || ((endQuad == 2) && (x <= endx)))) || - (shortspan && (startQuad == 2) && (x >= startx) && (x <= endx)) ) - SetThickPixel(xc-x,yc-y,thick,d->highcolor); - if ( useQuad3 || - (!shortspan && (((startQuad == 3) && (x <= startx)) || ((endQuad == 3) && (x >= endx)))) || - (shortspan && (startQuad == 3) && (x <= startx) && (x >= endx)) ) - SetThickPixel(xc-x,yc+y,thick,d->highcolor); - if ( useQuad4 || - (!shortspan && (((startQuad == 4) && (x >= startx)) || ((endQuad == 4) && (x <= endx)))) || - (shortspan && (startQuad == 4) && (x >= startx) && (x <= endx)) ) - SetThickPixel(xc+x,yc+y,thick,d->highcolor); - } -} - -// Currently does not support pattern -void ScreenDriver::StrokeBezier(BPoint *pts, LayerData *d, int8 *pat) -{ - double Ax, Bx, Cx, Dx; - double Ay, By, Cy, Dy; - int x, y; - int lastx=-1, lasty=-1; - double t; - double dt = .001; - double dt2, dt3; - double X, Y, dx, ddx, dddx, dy, ddy, dddy; - - Ax = -pts[0].x + 3*pts[1].x - 3*pts[2].x + pts[3].x; - Bx = 3*pts[0].x - 6*pts[1].x + 3*pts[2].x; - Cx = -3*pts[0].x + 3*pts[1].x; - Dx = pts[0].x; - - Ay = -pts[0].y + 3*pts[1].y - 3*pts[2].y + pts[3].y; - By = 3*pts[0].y - 6*pts[1].y + 3*pts[2].y; - Cy = -3*pts[0].y + 3*pts[1].y; - Dy = pts[0].y; - - dt2 = dt * dt; - dt3 = dt2 * dt; - X = Dx; - dx = Ax*dt3 + Bx*dt2 + Cx*dt; - ddx = 6*Ax*dt3 + 2*Bx*dt2; - dddx = 6*Ax*dt3; - Y = Dy; - dy = Ay*dt3 + By*dt2 + Cy*dt; - ddy = 6*Ay*dt3 + 2*By*dt2; - dddy = 6*Ay*dt3; - - lastx = -1; - lasty = -1; - - for (t=0; t<=1; t+=dt) - { - x = ROUND(X); - y = ROUND(Y); - if ( (x!=lastx) || (y!=lasty) ) - SetThickPixel(x,y,d->pensize,d->highcolor); - lastx = x; - lasty = y; - - X += dx; - dx += ddx; - ddx += dddx; - Y += dy; - dy += ddy; - ddy += dddy; - } -} - -// Ellipse code shamelessly stolen from the graphics library gd v2.0.1 and bolted on -// to support our API -void ScreenDriver::StrokeEllipse(BRect r, LayerData *ldata, int8 *pat) -{ - long d, b_sq, b_sq_4, b_sq_6; - long a_sq, a_sq_4, a_sq_6; - int x, y, switchem; - long lsqrt (long); - int pix, half, pstart; - int32 thick = (int32)ldata->pensize; - - half = thick / 2; - int32 w=int32(r.Width()/2), - h=int32(r.Height()/2); - int32 cx=(int32)r.left+w; - int32 cy=(int32)r.top+h; - - d = 2 * (long) h *h + (long) w *w - 2 * (long) w *w * h; - b_sq = (long) h *h; - b_sq_4 = 4 * (long) h *h; - b_sq_6 = 6 * (long) h *h; - a_sq = (long) w *w; - a_sq_4 = 4 * (long) w *w; - a_sq_6 = 6 * (long) w *w; - - x = 0; - y = -h; -// switchem = a_sq / lsqrt (a_sq + b_sq); - switchem = a_sq / (int32)sqrt(a_sq + b_sq); - - while (x <= switchem) - { - pstart = y - half; - for (pix = pstart; pix < pstart + thick; pix++) - { - SetPixel(cx + x, cy + pix, ldata->highcolor); - SetPixel(cx - x, cy + pix, ldata->highcolor); - SetPixel(cx + x, cy - pix, ldata->highcolor); - SetPixel(cx - x, cy - pix, ldata->highcolor); - } - if (d < 0) - d += b_sq_4 * x++ + b_sq_6; - else - d += b_sq_4 * x++ + b_sq_6 + a_sq_4 * (++y); - } - - /* Middlesplat! - ** Go a little further if the thickness is not nominal... - */ - if (thick > 1) - { - int xp = x; - int yp = y; - int dp = d; - int thick2 = thick + 2; - int half2 = half + 1; - - while (xp <= switchem + half) - { - pstart = yp - half2; - for (pix = pstart; pix < pstart + thick2; pix++) - { - SetPixel(cx + xp, cy + pix, ldata->highcolor); - SetPixel(cx - xp, cy + pix, ldata->highcolor); - SetPixel(cx + xp, cy - pix, ldata->highcolor); - SetPixel(cx - xp, cy - pix, ldata->highcolor); - } - if (dp < 0) - dp += b_sq_4 * xp++ + b_sq_6; - else - dp += b_sq_4 * xp++ + b_sq_6 + a_sq_4 * (++yp); - } - } - - d += -2 * (long) b_sq + 2 * (long) a_sq - 2 * (long) b_sq *(x - 1) + 2 * (long) a_sq *(y - 1); - - while (y <= 0) - { - pstart = x - half; - for (pix = pstart; pix < pstart + thick; pix++) - { - SetPixel (cx + pix, cy + y, ldata->highcolor); - SetPixel (cx - pix, cy + y, ldata->highcolor); - SetPixel (cx + pix, cy - y, ldata->highcolor); - SetPixel (cx - pix, cy - y, ldata->highcolor); - } - - if (d < 0) - d += a_sq_4 * y++ + a_sq_6 + b_sq_4 * (++x); - else - d += a_sq_4 * y++ + a_sq_6; - } - -} - -void ScreenDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeLine( (%f,%f), %llx}\n",start.x,start.y,*((uint64*)pat)); -#endif - Lock(); - if(fbuffer->IsConnected()) - { - // Courtesy YNOP's SecondDriver with minor changes by DW - int oct=0; - int xoff=(int32)end.x; - int yoff=(int32)end.y; - int32 x2=(int32)start.x-xoff; - int32 y2=(int32)start.y-yoff; - int32 x1=0; - int32 y1=0; - if(y2<0){ y2=-y2; oct+=4; }//bit2=1 - if(x2<0){ x2=-x2; oct+=2;}//bit1=1 - if(x2highcolor);break; - case 1:SetPixel(( y)+xoff,( x)+yoff,d->highcolor);break; - case 3:SetPixel((-y)+xoff,( x)+yoff,d->highcolor);break; - case 2:SetPixel((-x)+xoff,( y)+yoff,d->highcolor);break; - case 6:SetPixel((-x)+xoff,(-y)+yoff,d->highcolor);break; - case 7:SetPixel((-y)+xoff,(-x)+yoff,d->highcolor);break; - case 5:SetPixel(( y)+xoff,(-x)+yoff,d->highcolor);break; - case 4:SetPixel(( x)+xoff,(-y)+yoff,d->highcolor);break; - } - x++; - sum-=Dy; - if(sum < 0) - { - y++; - sum += Dx; - } - } - } - Unlock(); -} - -void ScreenDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokePolygon( is_closed=%s)\n",(is_closed==true)?"true":"false"); -for(int debug=0;debugIsConnected()) - { - for(int32 i=0; i<(numpts-1); i++) - Line(ptlist[i],ptlist[i+1],d,pat); - - if(is_closed) - Line(ptlist[numpts-1],ptlist[0],d,pat); - } - Unlock(); -} - -void ScreenDriver::StrokeRect(BRect r, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeRect( (%f,%f,%f,%f), %llx)\n",r.left,r.top, - r.right,r.bottom,*((uint64*)pat)); -#endif - Lock(); - if(fbuffer->IsConnected()) - { - Line(r.LeftTop(),r.RightTop(),d,pat); - Line(r.RightTop(),r.RightBottom(),d,pat); - Line(r.RightBottom(),r.LeftBottom(),d,pat); - Line(r.LeftTop(),r.LeftBottom(),d,pat); - } - Unlock(); -} - -void ScreenDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeRoundRect( (%f,%f,%f,%f), %llx) ---->Unimplemented<----\n",r.left,r.top, - r.right,r.bottom,*((uint64*)pat)); -#endif - StrokeRect(r,d,pat); -} - -void ScreenDriver::StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::StrokeTriangle(%llx): --->Currently Unimplemented<---\n",*((uint64*)pat)); -printf("\tFirst: (%f,%f)\n\tSecond: (%f,%f)\n\tThird: (%f,%f)\n",pts[0].x,pts[0].y, - pts[1].x,pts[1].y,pts[2].x,pts[2].y); -r.PrintToStream(); -#endif - Lock(); - if(fbuffer->IsConnected()) - { - Line(pts[0],pts[1],d,pat); - Line(pts[1],pts[2],d,pat); - Line(pts[2],pts[0],d,pat); - } - Unlock(); -} - -void ScreenDriver::SetPixelPattern(int x, int y, uint8 *pattern, uint8 patternindex) -{ - // This function is designed to add pattern support to this thing. Should be - // inlined later to add speed lost in the multiple function calls. -#ifdef DEBUG_DRIVER -printf("ScreenDriver::SetPixelPattern(%u,%u,%llx,%u)\n",x,y,*((int64*)pattern),patternindex); -#endif - if(patternindex>32) - return; - - if(fbuffer->IsConnected()) - { - uint64 *p64=(uint64*)pattern; - - // check for transparency in mask. If transparent, we can quit here - - bool transparent_bit= - ( *p64 & ~((uint64)2 << (32-patternindex)))?true:false; -printf("SetPixelPattern: pattern=0x%llx\n",*p64); -printf("SetPixelPattern: bit=0x%llx\n",((uint64)2 << (32-patternindex))); -printf("SetPixelPattern: bit mask=0x%llx\n",~((uint64)2 << (32-patternindex))); -printf("SetPixelPattern: bit value=%s\n",transparent_bit?"true":"false"); - -// bool highcolor_bit= -// ( *p64 & ~((uint64)2 << (64-patternindex)))?true:false; - - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 32: - case 24: - { - - break; - } - case 16: - case 15: - { - break; - } - case 8: - { - break; - } - default: - { -#ifdef DEBUG_DRIVER -printf("SetPixelPattern: unknown bit depth %u\n",fbuffer->gcinfo.bits_per_pixel); -#endif - break; - } - } - } - else - { -#ifdef DEBUG_DRIVER -printf("SetPixelPattern: driver is disconnected\n"); -#endif - } -} - -void ScreenDriver::Line(BPoint start, BPoint end, LayerData *d, int8 *pat) -{ - // Internal function which is called from within other functions - - // Courtesy YNOP's SecondDriver with minor changes by DW - int oct=0; - int xoff=(int32)end.x; - int yoff=(int32)end.y; - int32 x2=(int32)start.x-xoff; - int32 y2=(int32)start.y-yoff; - int32 x1=0; - int32 y1=0; - if(y2<0){ y2=-y2; oct+=4; }//bit2=1 - if(x2<0){ x2=-x2; oct+=2;}//bit1=1 - if(x2highcolor);break; - case 1:SetPixel(( y)+xoff,( x)+yoff,d->highcolor);break; - case 3:SetPixel((-y)+xoff,( x)+yoff,d->highcolor);break; - case 2:SetPixel((-x)+xoff,( y)+yoff,d->highcolor);break; - case 6:SetPixel((-x)+xoff,(-y)+yoff,d->highcolor);break; - case 7:SetPixel((-y)+xoff,(-x)+yoff,d->highcolor);break; - case 5:SetPixel(( y)+xoff,(-x)+yoff,d->highcolor);break; - case 4:SetPixel(( x)+xoff,(-y)+yoff,d->highcolor);break; - } - x++; - sum-=Dy; - if(sum < 0) - { - y++; - sum += Dx; - } - } -} - -void ScreenDriver::HideCursor(void) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::HideCursor\n"); -#endif - Lock(); - if(fbuffer->IsConnected()) - { - SetCursorHidden(true); - if(CursorStateChanged()) - BlitBitmap(under_cursor,under_cursor->Bounds(),cursorframe, B_OP_COPY); - - } - Unlock(); -} - -void ScreenDriver::MoveCursorTo(float x, float y) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::MoveCursorTo(%f,%f)\n",x,y); -#endif - Lock(); - if(!IsCursorHidden()) - BlitBitmap(under_cursor,under_cursor->Bounds(),cursorframe, B_OP_COPY); - - cursorframe.OffsetTo(x,y); - ExtractToBitmap(under_cursor,under_cursor->Bounds(),cursorframe); - - if(!IsCursorHidden()) - BlitBitmap(cursor,cursor->Bounds(),cursorframe, B_OP_OVER); - - Unlock(); -} - -void ScreenDriver::ShowCursor(void) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::ShowCursor\n"); -#endif - Lock(); - if(fbuffer->IsConnected()) - { - SetCursorHidden(false); - if(CursorStateChanged()) - BlitBitmap(cursor,cursor->Bounds(),cursorframe, B_OP_OVER); - } - Unlock(); -} - -void ScreenDriver::ObscureCursor(void) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::ObscureCursor\n"); -#endif - Lock(); - SetCursorObscured(true); - if(!IsCursorHidden() && fbuffer->IsConnected()) - BlitBitmap(under_cursor,under_cursor->Bounds(),cursorframe, B_OP_COPY); - Unlock(); -} - -void ScreenDriver::SetCursor(ServerBitmap *csr, const BPoint &spot) -{ -#ifdef DEBUG_DRIVER -printf("ScreenDriver::SetCursor\n"); -#endif - if(!csr) - return; - - Lock(); - - // erase old if visible - if(!IsCursorHidden() && under_cursor) - BlitBitmap(under_cursor,under_cursor->Bounds(),cursorframe, B_OP_COPY); - - if(cursor) - delete cursor; - if(under_cursor) - delete under_cursor; - - cursor=new ServerBitmap(csr); - under_cursor=new ServerBitmap(csr); - - if(cursor->Bounds().Contains(spot)) - SetHotSpot(spot); - else - SetHotSpot(BPoint(0,0)); - - cursorframe.right=cursorframe.left+csr->Bounds().Width(); - cursorframe.bottom=cursorframe.top+csr->Bounds().Height(); - - ExtractToBitmap(under_cursor,under_cursor->Bounds(),cursorframe); - - if(!IsCursorHidden()) - BlitBitmap(cursor,cursor->Bounds(),cursorframe, B_OP_OVER); - - Unlock(); -} - -void ScreenDriver::HLine(int32 x1, int32 x2, int32 y, RGBColor color) -{ - // Internal function called from others in the driver - - // TODO: Implement and substitute Line() calls with HLine calls as appropriate - // elsewhere in the driver - - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 32: - case 24: - break; - case 16: - case 15: - break; - default: - break; - } -} - -void HLine_32Bit(graphics_card_info i, uint16 x, uint16 y, uint16 length, rgb_color col) -{ -#ifdef DEBUG_DRIVER -printf("HLine() Unfinished\n"); -#endif - uint32 c=0,*pcolor,bytes; - - // apparently width=bytes per row - uint32 bpr=i.width; - - // ARGB order - c|=col.alpha * 0x01000000; - c|=col.red * 0x010000; - c|=col.green * 0x0100; - c|=col.blue; - -#ifdef DEBUG_DRIVER -printf("HLine color value: 0x%lx\n",c); -#endif - bytes=(uint32(x+length)>bpr)?length-((x+length)-bpr):length; - - pcolor=(uint32*)i.frame_buffer; - pcolor+=(y*bpr)+(x*4); - for(int32 i=0;ibpr)?length-((x+length)-bpr):length; - - memset(pcolor,col,bytes); -} - -// This function is intended to eventually take care of most of the heavy lifting for -// DrawBitmap in 32-bit mode, with others coming later. Right now, it is *just* used for -// the -void ScreenDriver::BlitBitmap(ServerBitmap *sourcebmp,BRect sourcerect, BRect destrect, drawing_mode mode=B_OP_COPY) -{ - // Another internal function called from other functions. - - if(!sourcebmp) - { -#ifdef DEBUG_DRIVER -printf("ScreenDriver::BlitBitmap(): NULL source bitmap\n"); -#endif - return; - } - - if(sourcebmp->bpp != fbuffer->gcinfo.bits_per_pixel) - { -#ifdef DEBUG_DRIVER -printf("ScreenDriver::BlitBitmap(): Incompatible bitmap pixel depth\n"); -#endif - return; - } - - uint8 colorspace_size=sourcebmp->BitsPerPixel()/8; - // First, clip source rect to destination - if(sourcerect.Width() > destrect.Width()) - sourcerect.right=sourcerect.left+destrect.Width(); - - - if(sourcerect.Height() > destrect.Height()) - sourcerect.bottom=sourcerect.top+destrect.Height(); - - - // Second, check rectangle bounds against their own bitmaps - BRect work_rect; - - work_rect.Set( sourcebmp->Bounds().left, - sourcebmp->Bounds().top, - sourcebmp->Bounds().right, - sourcebmp->Bounds().bottom ); - if( !(work_rect.Contains(sourcerect)) ) - { // something in selection must be clipped - if(sourcerect.left < 0) - sourcerect.left = 0; - if(sourcerect.right > work_rect.right) - sourcerect.right = work_rect.right; - if(sourcerect.top < 0) - sourcerect.top = 0; - if(sourcerect.bottom > work_rect.bottom) - sourcerect.bottom = work_rect.bottom; - } - - work_rect.Set( 0,0,fbuffer->gcinfo.width-1,fbuffer->gcinfo.height-1); - - if( !(work_rect.Contains(destrect)) ) - { // something in selection must be clipped - if(destrect.left < 0) - destrect.left = 0; - if(destrect.right > work_rect.right) - destrect.right = work_rect.right; - if(destrect.top < 0) - destrect.top = 0; - if(destrect.bottom > work_rect.bottom) - destrect.bottom = work_rect.bottom; - } - - // Set pointers to the actual data - uint8 *src_bits = (uint8*) sourcebmp->Bits(); - uint8 *dest_bits = (uint8*) fbuffer->gcinfo.frame_buffer; - - // Get row widths for offset looping - uint32 src_width = uint32 (sourcebmp->BytesPerRow()); - uint32 dest_width = uint32 (fbuffer->gcinfo.bytes_per_row); - - // Offset bitmap pointers to proper spot in each bitmap - src_bits += uint32 ( (sourcerect.top * src_width) + (sourcerect.left * colorspace_size) ); - dest_bits += uint32 ( (destrect.top * dest_width) + (destrect.left * colorspace_size) ); - - uint32 line_length = uint32 ((destrect.right - destrect.left+1)*colorspace_size); - uint32 lines = uint32 (destrect.bottom-destrect.top+1); - - switch(mode) - { - case B_OP_OVER: - { - uint32 srow_pixels=src_width>>2; - uint8 *srow_index, *drow_index; - - - // This could later be optimized to use uint32's for faster copying - for (uint32 pos_y=0; pos_y!=lines; pos_y++) - { - - srow_index=src_bits; - drow_index=dest_bits; - - for(uint32 pos_x=0; pos_x!=srow_pixels;pos_x++) - { - // 32-bit RGBA32 mode byte order is BGRA - if(srow_index[3]>127) - { - *drow_index=*srow_index; drow_index++; srow_index++; - *drow_index=*srow_index; drow_index++; srow_index++; - *drow_index=*srow_index; drow_index++; srow_index++; - // we don't copy the alpha channel - drow_index++; srow_index++; - } - else - { - srow_index+=4; - drow_index+=4; - } - } - - // Increment offsets - src_bits += src_width; - dest_bits += dest_width; - } - break; - } - default: // B_OP_COPY - { - for (uint32 pos_y = 0; pos_y != lines; pos_y++) - { - memcpy(dest_bits,src_bits,line_length); - - // Increment offsets - src_bits += src_width; - dest_bits += dest_width; - } - break; - } - } -} - -void ScreenDriver::ExtractToBitmap(ServerBitmap *destbmp,BRect destrect, BRect sourcerect) -{ - // Another internal function called from other functions. Extracts data from - // the framebuffer to a target ServerBitmap - - if(!destbmp) - { -#ifdef DEBUG_DRIVER -printf("ScreenDriver::ExtractToBitmap(): NULL destination bitmap\n"); -#endif - return; - } - - if(destbmp->bpp != fbuffer->gcinfo.bits_per_pixel) - { -#ifdef DEBUG_DRIVER -printf("ScreenDriver::ExtractToBitmap(): Incompatible bitmap pixel depth\n"); -#endif - return; - } - - uint8 colorspace_size=destbmp->BitsPerPixel()/8; - // First, clip source rect to destination - if(sourcerect.Width() > destrect.Width()) - sourcerect.right=sourcerect.left+destrect.Width(); - - - if(sourcerect.Height() > destrect.Height()) - sourcerect.bottom=sourcerect.top+destrect.Height(); - - - // Second, check rectangle bounds against their own bitmaps - BRect work_rect; - - work_rect.Set( destbmp->Bounds().left, - destbmp->Bounds().top, - destbmp->Bounds().right, - destbmp->Bounds().bottom ); - if( !(work_rect.Contains(destrect)) ) - { // something in selection must be clipped - if(destrect.left < 0) - destrect.left = 0; - if(destrect.right > work_rect.right) - destrect.right = work_rect.right; - if(destrect.top < 0) - destrect.top = 0; - if(destrect.bottom > work_rect.bottom) - destrect.bottom = work_rect.bottom; - } - - work_rect.Set( 0,0,fbuffer->gcinfo.width-1,fbuffer->gcinfo.height-1); - - if( !(work_rect.Contains(sourcerect)) ) - { // something in selection must be clipped - if(sourcerect.left < 0) - sourcerect.left = 0; - if(sourcerect.right > work_rect.right) - sourcerect.right = work_rect.right; - if(sourcerect.top < 0) - sourcerect.top = 0; - if(sourcerect.bottom > work_rect.bottom) - sourcerect.bottom = work_rect.bottom; - } - - // Set pointers to the actual data - uint8 *dest_bits = (uint8*) destbmp->Bits(); - uint8 *src_bits = (uint8*) fbuffer->gcinfo.frame_buffer; - - // Get row widths for offset looping - uint32 dest_width = uint32 (destbmp->BytesPerRow()); - uint32 src_width = uint32 (fbuffer->gcinfo.bytes_per_row); - - // Offset bitmap pointers to proper spot in each bitmap - src_bits += uint32 ( (sourcerect.top * src_width) + (sourcerect.left * colorspace_size) ); - dest_bits += uint32 ( (destrect.top * dest_width) + (destrect.left * colorspace_size) ); - - uint32 line_length = uint32 ((destrect.right - destrect.left+1)*colorspace_size); - uint32 lines = uint32 (destrect.bottom-destrect.top+1); - - for (uint32 pos_y = 0; pos_y != lines; pos_y++) - { - memcpy(dest_bits,src_bits,line_length); - - // Increment offsets - src_bits += src_width; - dest_bits += dest_width; - } -} - -void ScreenDriver::InvertRect(BRect r) -{ - Lock(); - if(fbuffer->IsConnected()) - { - if(r.top<0 || r.left<0 || - r.right>fbuffer->gcinfo.width-1 || r.bottom>fbuffer->gcinfo.height-1) - { - Unlock(); - return; - } - - switch(fbuffer->gcinfo.bits_per_pixel) - { - case 32: - case 24: - { - uint16 width=r.IntegerWidth(), height=r.IntegerHeight(); - uint32 *start=(uint32*)fbuffer->gcinfo.frame_buffer, *index; - start+=int32(r.top)*fbuffer->gcinfo.width; - start+=int32(r.left); - - for(int32 i=0;igcinfo.width); - for(int32 j=0; jfont) - return 0.0; - Lock(); - - ServerFont *font=d->font; - FontStyle *style=font->Style(); - - if(!style) - { - Unlock(); - return 0.0; - } - - FT_Face face; - FT_GlyphSlot slot; - FT_UInt glyph_index, previous=0; - FT_Vector pen,delta; - int16 error=0; - int32 strlength,i; - float returnval; - - error=FT_New_Face(ftlib, style->GetPath(), 0, &face); - if(error) - { - printf("Couldn't create face object\n"); - Unlock(); - return 0.0; - } - - slot=face->glyph; - - bool use_kerning=FT_HAS_KERNING(face) && font->Spacing()==B_STRING_SPACING; - - error=FT_Set_Char_Size(face, 0,int32(font->Size())*64,72,72); - if(error) - { - printf("Couldn't set character size - error 0x%x\n",error); - Unlock(); - return 0.0; - } - - // set the pen position in 26.6 cartesian space coordinates - pen.x=0; - - slot=face->glyph; - - strlength=strlen(string); - if(lengthadvance.x; - previous=glyph_index; - } - - FT_Done_Face(face); - - returnval=pen.x>>6; - Unlock(); - return returnval; -} - -float ScreenDriver::StringHeight(const char *string, int32 length, LayerData *d) -{ - if(!string || !d || !d->font) - return 0.0; - Lock(); - - ServerFont *font=d->font; - FontStyle *style=font->Style(); - - if(!style) - { - Unlock(); - return 0.0; - } - - FT_Face face; - FT_GlyphSlot slot; - int16 error=0; - int32 strlength,i; - float returnval=0.0,ascent=0.0,descent=0.0; - - error=FT_New_Face(ftlib, style->GetPath(), 0, &face); - if(error) - { - printf("Couldn't create face object\n"); - Unlock(); - return 0.0; - } - - slot=face->glyph; - - error=FT_Set_Char_Size(face, 0,int32(font->Size())*64,72,72); - if(error) - { - printf("Couldn't set character size - error 0x%x\n",error); - Unlock(); - return 0.0; - } - - slot=face->glyph; - - strlength=strlen(string); - if(lengthmetrics.horiBearingYmetrics.height) - descent=MAX((slot->metrics.height-slot->metrics.horiBearingY)>>6,descent); - else - ascent=MAX(slot->bitmap.rows,ascent); - } - Unlock(); - - FT_Done_Face(face); - - returnval=ascent+descent; - Unlock(); - return returnval; -} - -void ScreenDriver::DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *edelta=NULL) -{ - if(!string || !d || !d->font) - return; - - Lock(); - - pt.y--; // because of Be's backward compatibility hack - - ServerFont *font=d->font; - FontStyle *style=font->Style(); - - if(!style) - { - Unlock(); - return; - } - - FT_Face face; - FT_GlyphSlot slot; - FT_Matrix rmatrix,smatrix; - FT_UInt glyph_index, previous=0; - FT_Vector pen,delta,space,nonspace; - int16 error=0; - int32 strlength,i; - Angle rotation(font->Rotation()), shear(font->Shear()); - - bool antialias=( (font->Size()<18 && font->Flags()& B_DISABLE_ANTIALIASING==0) - || font->Flags()& B_FORCE_ANTIALIASING)?true:false; - - // Originally, I thought to do this shear checking here, but it really should be - // done in BFont::SetShear() - float shearangle=shear.Value(); - if(shearangle>135) - shearangle=135; - if(shearangle<45) - shearangle=45; - - if(shearangle>90) - shear=90+((180-shearangle)*2); - else - shear=90-(90-shearangle)*2; - - error=FT_New_Face(ftlib, style->GetPath(), 0, &face); - if(error) - { - printf("Couldn't create face object\n"); - Unlock(); - return; - } - - slot=face->glyph; - - bool use_kerning=FT_HAS_KERNING(face) && font->Spacing()==B_STRING_SPACING; - - error=FT_Set_Char_Size(face, 0,int32(font->Size())*64,72,72); - if(error) - { - printf("Couldn't set character size - error 0x%x\n",error); - Unlock(); - return; - } - - // if we do any transformation, we do a call to FT_Set_Transform() here - - // First, rotate - rmatrix.xx = (FT_Fixed)( rotation.Cosine()*0x10000); - rmatrix.xy = (FT_Fixed)( rotation.Sine()*0x10000); - rmatrix.yx = (FT_Fixed)(-rotation.Sine()*0x10000); - rmatrix.yy = (FT_Fixed)( rotation.Cosine()*0x10000); - - // Next, shear - smatrix.xx = (FT_Fixed)(0x10000); - smatrix.xy = (FT_Fixed)(-shear.Cosine()*0x10000); - smatrix.yx = (FT_Fixed)(0); - smatrix.yy = (FT_Fixed)(0x10000); - - //FT_Matrix_Multiply(&rmatrix,&smatrix); - FT_Matrix_Multiply(&smatrix,&rmatrix); - - // Set up the increment value for escapement padding - space.x=int32(d->edelta.space * rotation.Cosine()*64); - space.y=int32(d->edelta.space * rotation.Sine()*64); - nonspace.x=int32(d->edelta.nonspace * rotation.Cosine()*64); - nonspace.y=int32(d->edelta.nonspace * rotation.Sine()*64); - - // set the pen position in 26.6 cartesian space coordinates - pen.x=(int32)pt.x * 64; - pen.y=(int32)pt.y * 64; - - slot=face->glyph; - - - strlength=strlen(string); - if(lengthbitmap, - BPoint(slot->bitmap_left,pt.y-(slot->bitmap_top-pt.y)), d); - else - BlitMono2RGB32(&slot->bitmap, - BPoint(slot->bitmap_left,pt.y-(slot->bitmap_top-pt.y)), d); - } - else - printf("Couldn't load character %c\n", string[i]); - - // increment pen position - pen.x+=slot->advance.x; - pen.y+=slot->advance.y; - previous=glyph_index; - } - FT_Done_Face(face); - Unlock(); -} - -void ScreenDriver::BlitMono2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d) -{ - rgb_color color=d->highcolor.GetColor32(); - - // pointers to the top left corner of the area to be copied in each bitmap - uint8 *srcbuffer, *destbuffer; - - // index pointers which are incremented during the course of the blit - uint8 *srcindex, *destindex, *rowptr, value; - - // increment values for the index pointers - int32 srcinc=src->pitch, destinc=fbuffer->gcinfo.bytes_per_row; - - int16 i,j,k, srcwidth=src->pitch, srcheight=src->rows; - int32 x=(int32)pt.x,y=(int32)pt.y; - - // starting point in source bitmap - srcbuffer=(uint8*)src->buffer; - - if(y<0) - { - if(yfbuffer->gcinfo.height) - { - if(y>pt.y) - y--; - srcheight-=(y+srcheight-1)-fbuffer->gcinfo.height; - } - - if(x+srcwidth>fbuffer->gcinfo.width) - { - if(x>pt.x) - x--; - srcwidth-=(x+srcwidth-1)-fbuffer->gcinfo.width; - } - - if(x<0) - { - if(x>3; - srcwidth-=0-x; - destbuffer+=(0-x)*4; - } - - // starting point in destination bitmap - destbuffer=(uint8*)fbuffer->gcinfo.frame_buffer+int32( (pt.y*fbuffer->gcinfo.bytes_per_row)+(pt.x*4) ); - - srcindex=srcbuffer; - destindex=destbuffer; - - for(i=0; ihighcolor.GetColor32(), lowcolor=d->lowcolor.GetColor32(); float rstep,gstep,bstep,astep; - - rstep=float(highcolor.red-lowcolor.red)/255.0; - gstep=float(highcolor.green-lowcolor.green)/255.0; - bstep=float(highcolor.blue-lowcolor.blue)/255.0; - astep=float(highcolor.alpha-lowcolor.alpha)/255.0; - - // increment values for the index pointers - int32 x=(int32)pt.x, - y=(int32)pt.y, - srcinc=src->pitch, -// destinc=dest->BytesPerRow(), - destinc=fbuffer->gcinfo.bytes_per_row, - srcwidth=src->width, - srcheight=src->rows, - incval=0; - - int16 i,j; - - // starting point in source bitmap - srcbuffer=(uint8*)src->buffer; - - // starting point in destination bitmap -// destbuffer=(uint8*)dest->Bits()+(y*dest->BytesPerRow()+(x*4)); - destbuffer=(uint8*)fbuffer->gcinfo.frame_buffer+(y*fbuffer->gcinfo.bytes_per_row+(x*4)); - - - if(y<0) - { - if(yfbuffer->gcinfo.height) - { - if(y>pt.y) - y--; - srcheight-=(y+srcheight-1)-fbuffer->gcinfo.height; - } - - if(x+srcwidth>fbuffer->gcinfo.width) - { - if(x>pt.x) - x--; - srcwidth-=(x+srcwidth-1)-fbuffer->gcinfo.width; - } - - if(x<0) - { - if(xdraw_mode==B_OP_COPY) - { - rowptr[0]=uint8(highcolor.blue-(value*bstep)); - rowptr[1]=uint8(highcolor.green-(value*gstep)); - rowptr[2]=uint8(highcolor.red-(value*rstep)); - rowptr[3]=255; - } - else - if(d->draw_mode==B_OP_OVER) - { - if(highcolor.alpha>127) - { - rowptr[0]=uint8(highcolor.blue-(value*(float(highcolor.blue-rowptr[0])/255.0))); - rowptr[1]=uint8(highcolor.green-(value*(float(highcolor.green-rowptr[1])/255.0))); - rowptr[2]=uint8(highcolor.red-(value*(float(highcolor.red-rowptr[2])/255.0))); - rowptr[3]=255; - } - } - } - rowptr+=4; - - } - - srcindex+=srcinc; - destindex+=destinc; - } -} - -rgb_color ScreenDriver::GetBlitColor(rgb_color src, rgb_color dest, LayerData *d, bool use_high=true) -{ - rgb_color returncolor={0,0,0,0}; - int16 value; - if(!d) - return returncolor; - - switch(d->draw_mode) - { - case B_OP_COPY: - { - return src; - } - case B_OP_ADD: - { - value=src.red+dest.red; - returncolor.red=(value>255)?255:value; - - value=src.green+dest.green; - returncolor.green=(value>255)?255:value; - - value=src.blue+dest.blue; - returncolor.blue=(value>255)?255:value; - return returncolor; - } - case B_OP_SUBTRACT: - { - value=src.red-dest.red; - returncolor.red=(value<0)?0:value; - - value=src.green-dest.green; - returncolor.green=(value<0)?0:value; - - value=src.blue-dest.blue; - returncolor.blue=(value<0)?0:value; - return returncolor; - } - case B_OP_BLEND: - { - value=int16(src.red+dest.red)>>1; - returncolor.red=value; - - value=int16(src.green+dest.green)>>1; - returncolor.green=value; - - value=int16(src.blue+dest.blue)>>1; - returncolor.blue=value; - return returncolor; - } - case B_OP_MIN: - { - - return ( uint16(src.red+src.blue+src.green) > - uint16(dest.red+dest.blue+dest.green) )?dest:src; - } - case B_OP_MAX: - { - return ( uint16(src.red+src.blue+src.green) < - uint16(dest.red+dest.blue+dest.green) )?dest:src; - } - case B_OP_OVER: - { - return (use_high && src.alpha>127)?src:dest; - } - case B_OP_INVERT: - { - returncolor.red=dest.red ^ 255; - returncolor.green=dest.green ^ 255; - returncolor.blue=dest.blue ^ 255; - return (use_high && src.alpha>127)?returncolor:dest; - } - // This is a pain in the arse to implement, so I'm saving it for the real - // server - case B_OP_ALPHA: - { - return src; - } - case B_OP_ERASE: - { - // This one's tricky. - return (use_high && src.alpha>127)?d->lowcolor.GetColor32():dest; - } - case B_OP_SELECT: - { - // This one's tricky, too. We are passed a color in src. If it's the layer's - // high color or low color, we check for a swap. - if(d->highcolor==src) - return (use_high && d->highcolor==dest)?d->lowcolor.GetColor32():dest; - - if(d->lowcolor==src) - return (use_high && d->lowcolor==dest)?d->highcolor.GetColor32():dest; - - return dest; - } - default: - { - break; - } - } - Unlock(); - return returncolor; -} diff --git a/src/servers/app/proto7/ScreenDriver.h b/src/servers/app/proto7/ScreenDriver.h deleted file mode 100644 index 58035264d9..0000000000 --- a/src/servers/app/proto7/ScreenDriver.h +++ /dev/null @@ -1,111 +0,0 @@ -#ifndef _SCREENDRIVER_H_ -#define _SCREENDRIVER_H_ - -#include -#include -#include -#include -#include -#include -#include -#include // for clipping_rect definition -#include -#include "DisplayDriver.h" -#include -#include FT_FREETYPE_H -#include FT_GLYPH_H - -class VDWindow; -class ServerCursor; -class ServerBitmap; -class RGBColor; -class PortLink; - - -class FrameBuffer : public BWindowScreen -{ -public: - FrameBuffer(const char *title, uint32 space, status_t *st,bool debug); - ~FrameBuffer(void); - void ScreenConnected(bool connected); - void MessageReceived(BMessage *msg); - bool IsConnected(void) const { return is_connected; } - bool QuitRequested(void); - - graphics_card_info gcinfo; -protected: - bool is_connected; - PortLink *serverlink; - BPoint mousepos; - uint32 buttons; -}; - -class ScreenDriver : public DisplayDriver -{ -public: - ScreenDriver(void); - ~ScreenDriver(void); - - bool Initialize(void); - void Shutdown(void); - - // Settings functions -// virtual void CopyBits(BRect src, BRect dest); - virtual void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest); -// virtual void DrawPicture(SPicture *pic, BPoint pt); - virtual void DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL); - -// virtual void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat); -// virtual void FillBezier(BPoint *pts, LayerData *d, int8 *pat); - virtual void FillEllipse(BRect r, LayerData *d, int8 *pat); -// virtual void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat); - virtual void FillRect(BRect r, LayerData *d, int8 *pat); - virtual void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// virtual void FillShape(SShape *sh, LayerData *d, int8 *pat); - virtual void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); - - virtual void HideCursor(void); - virtual void MoveCursorTo(float x, float y); - virtual void InvertRect(BRect r); - virtual void ShowCursor(void); - virtual void ObscureCursor(void); - virtual void SetCursor(ServerBitmap *cursor, const BPoint &spot); - - virtual void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat); - virtual void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat); - virtual void StrokeEllipse(BRect r, LayerData *d, int8 *pat); - virtual void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat); - virtual void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true); - virtual void StrokeRect(BRect r, LayerData *d, int8 *pat); - virtual void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// virtual void StrokeShape(SShape *sh, LayerData *d, int8 *pat); - virtual void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); -// virtual void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d); - virtual void SetMode(int32 mode); - float StringWidth(const char *string, int32 length, LayerData *d); - float StringHeight(const char *string, int32 length, LayerData *d); -// virtual bool DumpToFile(const char *path); -protected: - void BlitMono2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d); - void BlitGray2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d); - void BlitBitmap(ServerBitmap *sourcebmp, BRect sourcerect, BRect destrect, drawing_mode mode=B_OP_COPY); - void ExtractToBitmap(ServerBitmap *destbmp, BRect destrect, BRect sourcerect); - void SetPixelPattern(int x, int y, uint8 *pattern, uint8 patternindex); - void Line(BPoint start, BPoint end, LayerData *d, int8 *pat); - void HLine(int32 x1, int32 x2, int32 y, RGBColor color); - rgb_color GetBlitColor(rgb_color src, rgb_color dest, LayerData *d, bool use_high=true); - void SetPixel(int x, int y, RGBColor col); - void SetPixel32(int x, int y, rgb_color col); - void SetPixel16(int x, int y, uint16 col); - void SetPixel8(int x, int y, uint8 col); - void SetThickPixel(int x, int y, int thick, RGBColor col); - void SetThickPixel32(int x, int y, int thick, rgb_color col); - void SetThickPixel16(int x, int y, int thick, uint16 col); - void SetThickPixel8(int x, int y, int thick, uint8 col); - FrameBuffer *fbuffer; - ServerBitmap *cursor, *under_cursor; - int32 drawmode; - BRect cursorframe; -}; - -#endif diff --git a/src/servers/app/proto7/ServerApp.cpp b/src/servers/app/proto7/ServerApp.cpp deleted file mode 100644 index 2b29080f1f..0000000000 --- a/src/servers/app/proto7/ServerApp.cpp +++ /dev/null @@ -1,745 +0,0 @@ -/* - ServerApp.cpp - Class which works with a BApplication. Handles all messages coming - from and going to its application. -*/ -//#define DEBUG_SERVERAPP_MSGS -//#define DEBUG_SERVERAPP_CURSORS -//#define DEBUG_SERVERAPP_MISC - -#include -#include -#include -#include -#include "Desktop.h" -#include "DisplayDriver.h" -//#include "Layer.h" -#include "FontServer.h" -#include "ServerApp.h" -#include "ServerWindow.h" -#include "ServerBitmap.h" -#include "ServerProtocol.h" -#include "PortLink.h" -#include -#include -#include -#include "DebugTools.h" -#include "LayerData.h" - - -ServerApp::ServerApp(port_id msgport, char *signature) -{ - // need to copy the signature because the message buffer - // owns the copy which we are passed as a parameter. - app_sig=(signature)?signature:"Application"; - - // sender is the monitored app's event port - sender=msgport; - applink=new PortLink(sender); - - port_info pinfo; - get_port_info(sender,&pinfo); - target_id=pinfo.team; - - // receiver is the port to which the app sends messages for the server - receiver=create_port(30,app_sig.String()); - -#ifdef DEBUG_SERVERAPP_MISC -printf("ServerApp port for app %s is at %ld\n",app_sig.String(),receiver); -#endif - - if(receiver==B_NO_MORE_PORTS) - { - // uh-oh. We have a serious problem. Tell the app to quit - applink->SetOpCode(B_QUIT_REQUESTED); - applink->Flush(); - } - - // No longer necessary. This message is sent from the app_server thread - // now because of changes in the application structure from previous - // prototypes. -/* else - { - // Everything checks out, so tell the application - // where to send future messages - applink->SetOpCode(SET_SERVER_PORT); - applink->Attach(&receiver,sizeof(port_id)); - applink->Flush(); - } -*/ - applink->SetPort(sender); - winlist=new BList(0); - bmplist=new BList(0); - driver=get_gfxdriver(); - isactive=false; - cursor=NULL; - - // This exists for testing the graphics access module and will disappear - // when layers are implemented - high.red=255; - high.green=255; - high.blue=255; - high.alpha=255; - low.red=0; - low.green=0; - low.blue=0; - low.alpha=255; -} - -ServerApp::~ServerApp(void) -{ -#ifdef DEBUG_SERVERAPP_MISC -printf("%s: ~ServerApp\n",app_sig.String()); -#endif - int32 i; - ServerWindow *tempwin; - for(i=0;iCountItems();i++) - { - tempwin=(ServerWindow*)winlist->ItemAt(i); - if(tempwin) - delete tempwin; - } - winlist->MakeEmpty(); - delete winlist; - - ServerBitmap *tempbmp; - for(i=0;iCountItems();i++) - { - tempbmp=(ServerBitmap*)bmplist->ItemAt(i); - if(tempbmp) - delete tempbmp; - } - bmplist->MakeEmpty(); - delete bmplist; - - delete applink; - applink=NULL; - if(cursor) - delete cursor; - - // Kill the monitor thread if it exists - thread_info info; - if(get_thread_info(monitor_thread,&info)==B_OK) - kill_thread(monitor_thread); -} - -bool ServerApp::Run(void) -{ -#ifdef DEBUG_SERVERAPP_MISC -printf("%s: Run()\n",app_sig.String()); -#endif - // Unlike a BApplication, a ServerApp is *supposed* to return immediately - // when its Run function is called. - monitor_thread=spawn_thread(MonitorApp,app_sig.String(),B_NORMAL_PRIORITY,this); - if(monitor_thread==B_NO_MORE_THREADS || monitor_thread==B_NO_MEMORY) - return false; - resume_thread(monitor_thread); - return true; -} - -bool ServerApp::PingTarget(void) -{ - // This function is called by the app_server thread to ensure that - // the target app still exists. We do this not by sending a message - // but by calling get_port_info. We don't want to send ping messages - // just because the app might simply be hung. If this is the case, it - // should be up to the user to kill it. If the app has been killed, its - // ports will be invalid. Thus, if get_port_info returns an error, we - // tell the app_server to delete the respective ServerApp. - - team_info tinfo; - if(get_team_info(target_id,&tinfo)==B_BAD_TEAM_ID) - { - port_id serverport=find_port(SERVER_PORT_NAME); - if(serverport==B_NAME_NOT_FOUND) - { - printf("PANIC: ServerApp %s could not find the app_server port in PingTarget()!\n",app_sig.String()); - return false; - } - applink->SetPort(serverport); - applink->SetOpCode(DELETE_APP); - applink->Attach(&monitor_thread,sizeof(thread_id)); - applink->Flush(); -#ifdef DEBUG_SERVERAPP_MISC -printf("%s: target application is dead. ServerApp is quitting\n",app_sig.String()); -#endif - return false; - } - return true; -} - -int32 ServerApp::MonitorApp(void *data) -{ - ServerApp *app=(ServerApp *)data; - app->Loop(); - exit_thread(0); - return 0; -} - -void ServerApp::Loop(void) -{ -#ifdef DEBUG_SERVERAPP_MISC -printf("%s: Loop()\n",app_sig.String()); -#endif - // Message-dispatching loop for the ServerApp - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(receiver); - - if(buffersize>0) - { - // buffers are PortLink messages. Allocate necessary buffer and - // we'll cast it as a BMessage. - msgbuffer=new int8[buffersize]; - bytesread=read_port(receiver,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(receiver,&msgcode,NULL,0); - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { -// -------------- Messages received from the Application ------------------ - case B_QUIT_REQUESTED: - { - // 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) - { - printf("PANIC: ServerApp %s could not find the app_server port!\n",app_sig.String()); - break; - } - applink->SetPort(serverport); - applink->SetOpCode(DELETE_APP); - applink->Attach(&monitor_thread,sizeof(thread_id)); - applink->Flush(); - break; - } - -// -------------- 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. Eventually, this will be replaced by a - // BMessage - write_port(sender, msgcode, msgbuffer, buffersize); - break; - } - case QUIT_APP: - { - // This message is received from the app_server thread - // because the server was asked to quit. Thus, we - // ask all apps to quit. This is NOT the same as system - // shutdown and will happen only in testing - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp asking %s to quit\n",app_sig.String()); -#endif - applink->SetOpCode(B_QUIT_REQUESTED); - applink->Flush(); - break; - } - default: - { - DispatchMessage(msgcode, msgbuffer); - break; - } - } - - } - - if(buffersize>0) - delete msgbuffer; - - if(msgcode==B_QUIT_REQUESTED) - break; - } -} - -void ServerApp::DispatchMessage(int32 code, int8 *buffer) -{ -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp "); -PrintMessageCode(code); -#endif - -int8 *index=buffer; -LayerData ld; - switch(code) - { - case UPDATED_CLIENT_FONTLIST: - { - // received when the client-side global font list has been - // refreshed - fontserver->Lock(); - fontserver->FontsUpdated(); - fontserver->Unlock(); - break; - } - case CREATE_WINDOW: - { - // Create the ServerWindow to node monitor a new OBWindow - - // Attached data: - // 1) port_id reply port - // 2) BRect window frame - // 3) uint32 window flags - // 4) port_id window's message port - // 5) uint32 workspace index - // 6) const char * title - - // Find the necessary data - port_id reply_port=*((port_id*)index); index+=sizeof(port_id); - BRect rect=*((BRect*)index); index+=sizeof(BRect); - - uint32 winlook=*((uint32*)index); index+=sizeof(uint32); - uint32 winfeel=*((uint32*)index); index+=sizeof(uint32); - uint32 winflags=*((uint32*)index); index+=sizeof(uint32); - - port_id win_port=*((port_id*)index); index+=sizeof(port_id); - uint32 workspace=*((uint32*)index); index+=sizeof(uint32); - - // Create the ServerWindow object for this window - ServerWindow *newwin=new ServerWindow(rect,(const char *)index, - winlook, winfeel, winflags,this,win_port,workspace); - winlist->AddItem(newwin); - - // 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->Attach((int32)newwin->receiver); - replylink->Flush(); - - delete replylink; - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: Create Window()\n"); -printf("Frame: "); rect.PrintToStream(); -printf("Title: %s\n",(const char*)index); -printf("SenderPort: %ld\n",win_port); -printf("Look: 0x%lx\n",winlook); -printf("Feel: 0x%lx\n",winfeel); -printf("Flags: 0x%lx\n",winflags); -printf("Workspace: 0x%lx\n",workspace); -#endif - - break; - - } - case DELETE_WINDOW: - { - // Received from a ServerWindow when its window quits - - // Attached data: - // 1) thread_id ServerWindow ID - thread_id winid; - ServerWindow *w; - for(int32 i=0;iCountItems();i++) - { - w=(ServerWindow*)winlist->ItemAt(i); - if(w->thread==winid) - { - winlist->RemoveItem(w); - delete w; - break; - } - } -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: Delete Window()\n"); -printf("Thread ID: %ld",winid); -#endif - break; - } - case GFX_SET_SCREEN_MODE: - { - // Attached data - // 1) int32 workspace # - // 2) uint32 screen mode - // 3) bool make default - int32 workspace=*((int32*)index); index+=sizeof(int32); - uint32 mode=*((uint32*)index); index+=sizeof(uint32); - - SetScreenSpace(workspace,mode,*((bool*)index)); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: SetScreenMode(%ld,%lu,%s)\n",workspace, - mode,(*((bool*)index)==true)?"true":"false"); -#endif - break; - } - case GFX_ACTIVATE_WORKSPACE: - { - // Attached data - // 1) int32 workspace index - ActivateWorkspace(*((int32*)index)); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp: ActivateWorkspace(%ld)\n",*((int32*)index)); -#endif - break; - } - case SHOW_CURSOR: - { - driver->ShowCursor(); - break; - } - case HIDE_CURSOR: - { - driver->HideCursor(); - break; - } - case OBSCURE_CURSOR: - { - driver->ObscureCursor(); - break; - } - case SET_CURSOR_DATA: - { - // Attached data: 68 bytes of cursor data - - // Get the data, update the app's cursor, and update the - // app's cursor if active. - int8 cdata[68]; - memcpy(cdata, buffer, 68); - if(cursor) - delete cursor; - cursor=new ServerBitmap(cdata); - driver->SetCursor(cursor,BPoint(cdata[2],cdata[3])); -#ifdef DEBUG_SERVERAPP_CURSORS -printf("ServerApp: SetCursor(%d,%d,%d,%d)\n",r,g,b,a); -#endif - break; - } - case SET_CURSOR_BCURSOR: - // Not yet implemented - break; - - case SET_CURSOR_BBITMAP: - // Not yet implemented - break; - - case GET_FAMILY_ID: - { - // Attached data: - // - break; - } -/* case GFX_DRAW_STRING: - { - // Attached data: - // 1) uint16 string length - // 2) char * string - // 3) BPoint point - - uint16 length=*((uint16*)index); index+=sizeof(uint16); -// char *string=new char[length]; -// strcpy(string, (const char *)index); index+=length; - BString string=(char *)index; index+=length; - BPoint point=*((BPoint*)index); - -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp DrawString(%s, %d, BPoint(%f,%f))\n",string.String(),length,point.x,point.y); -#endif - driver->DrawString((char*)string.String(), length, point); -// delete string; - break; - } -*/ - case GFX_STROKE_ARC: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) float starting angle - // 6) float span (arc length in degrees) - // 7) uint8[8] pattern - float cx,cy,rx,ry,angle,span; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); - BRect r(cx-rx,cy-ry,cx+rx,cy+ry); - - angle=*((float*)index); index+=sizeof(float); - span=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeArc: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("Angle, Span: %f,%f\n",angle, span); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeArc(r,angle,span,&ld,index); - break; - } - case GFX_STROKE_BEZIER: - { - // Attached data: - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BPoint #4 - // 5) uint8[8] pattern - -#ifdef DEBUG_SERVERAPP_MSGS -BPoint *pt=(BPoint*)index; -printf("ServerApp StrokeBezier:\n"); -printf("Point 1: "); pt[0].PrintToStream(); -printf("Point 2: "); pt[1].PrintToStream(); -printf("Point 3: "); pt[2].PrintToStream(); -printf("Point 4: "); pt[3].PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeBezier((BPoint*)index,&ld,(int8*)(index+(sizeof(BPoint)*4))); - break; - } - case GFX_STROKE_ELLIPSE: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) uint8[8] pattern - float cx,cy,rx,ry; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); - BRect r(cx-rx,cy-ry,cx+rx,cy+ry); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeEllipse: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeEllipse(r,&ld,(int8*)index); - break; - } - case GFX_STROKE_POLYGON: - break; - case GFX_STROKE_RECT: - { - // Attached data: - // 1) BRect rect - // 2) uint8[8] pattern - BRect rect; - rect=*((BRect*)index); index+=sizeof(BRect); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeRect: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeRect(rect,&ld,(int8*)index); - break; - } - case GFX_STROKE_ROUNDRECT: - { - // Attached data: - // 1) BRect rect - // 2) float x_radius - // 3) float y_radius - // 4) uint8[8] pattern - BRect rect; - float x,y; - - rect=*((BRect*)index); index+=sizeof(BRect); - x=*((float*)index); index+=sizeof(float); - y=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeRoundRect: "); rect.PrintToStream(); -printf("Radii: %f,%f\n",x,y); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeRoundRect(rect, x,y,&ld,(int8*)index); - break; - } - case GFX_STROKE_SHAPE: - break; - case GFX_STROKE_TRIANGLE: - { - // Attached data - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BRect invalid rect - // 5) uint8[8] pattern - BRect rect; - rect=*((BRect*)index+(sizeof(BPoint)*3)); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp StrokeTriangle: "); -printf("Point 1: "); ((BPoint*)index)[0].PrintToStream(); -printf("Point 2: "); ((BPoint*)index)[1].PrintToStream(); -printf("Point 3: "); ((BPoint*)index)[2].PrintToStream(); -printf("Rectangle: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->StrokeTriangle((BPoint*)index,rect,&ld,(int8*)(index+(sizeof(BPoint)*3))); - break; - } - case GFX_FILL_ARC: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) float starting angle - // 6) float span (arc length in degrees) - // 7) uint8[8] pattern - float cx,cy,rx,ry,angle,span; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); - BRect r(cx-rx,cy-ry,cx+rx,cy+ry); - angle=*((float*)index); index+=sizeof(float); - span=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillArc: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("Angle, Span: %f,%f\n",angle, span); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillArc(r,angle,span,&ld,(int8*)index); - break; - } - case GFX_FILL_BEZIER: - { - // Attached data: - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BPoint #4 - // 5) uint8[8] pattern - -#ifdef DEBUG_SERVERAPP_MSGS -BPoint *pt=(BPoint*)index; -printf("ServerApp FillBezier:\n"); -printf("Point 1: "); pt[0].PrintToStream(); -printf("Point 2: "); pt[1].PrintToStream(); -printf("Point 3: "); pt[2].PrintToStream(); -printf("Point 4: "); pt[3].PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillBezier((BPoint*)index,&ld,(int8*)(index+(sizeof(BPoint)*4))); - break; - } - case GFX_FILL_ELLIPSE: - { - // Attached data: - // 1) float center x - // 2) float center y - // 3) float x radius - // 4) float y radius - // 5) uint8[8] pattern - float cx,cy,rx,ry; - - cx=*((float*)index); index+=sizeof(float); - cy=*((float*)index); index+=sizeof(float); - rx=*((float*)index); index+=sizeof(float); - ry=*((float*)index); index+=sizeof(float); - BRect r(cx-rx,cy-ry,cx+rx,cy+ry); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillEllipse: "); -printf("Center: %f,%f\n",cx,cy); -printf("Radii: %f,%f\n",rx,ry); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillEllipse(r,&ld,(int8*)index); - break; - } - case GFX_FILL_POLYGON: - break; - case GFX_FILL_RECT: - { - // Attached data: - // 1) BRect rect - // 2) uint8[8] pattern - BRect rect; - rect=*((BRect*)index); index+=sizeof(BRect); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillRect: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillRect(rect,&ld,(int8*)index); - break; - } - case GFX_FILL_REGION: - break; - case GFX_FILL_ROUNDRECT: - { - // Attached data: - // 1) BRect rect - // 2) float x_radius - // 3) float y_radius - // 4) uint8[8] pattern - BRect rect; - float x,y; - - rect=*((BRect*)index); index+=sizeof(BRect); - x=*((float*)index); index+=sizeof(float); - y=*((float*)index); index+=sizeof(float); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillRoundRect: "); rect.PrintToStream(); -printf("Radii: %f,%f\n",x,y); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillRoundRect(rect,x,y,&ld,(int8*)index); - break; - } - case GFX_FILL_SHAPE: - break; - case GFX_FILL_TRIANGLE: - { - // Attached data - // 1) BPoint #1 - // 2) BPoint #2 - // 3) BPoint #3 - // 4) BRect invalid rect - // 5) uint8[8] pattern - BRect rect; - rect=*((BRect*)index+(sizeof(BPoint)*3)); -#ifdef DEBUG_SERVERAPP_MSGS -printf("ServerApp FillTriangle: "); -printf("Point 1: "); ((BPoint*)index)[0].PrintToStream(); -printf("Point 2: "); ((BPoint*)index)[1].PrintToStream(); -printf("Point 3: "); ((BPoint*)index)[2].PrintToStream(); -printf("Rectangle: "); rect.PrintToStream(); -printf("pattern: {%d,%d,%d,%d,%d,%d,%d,%d}\n",index[0],index[1],index[2],index[3],index[4],index[5],index[6],index[7]); -#endif - driver->FillTriangle((BPoint*)index,rect,&ld,(int8*)(index+(sizeof(BPoint)*3))); - break; - } - default: - { -#ifdef DEBUG_SERVERAPP_MSGS -cout << "DispatchMessage::Unrecognized code: "; -TranslateMessageCodeToStream(code); -cout << endl << flush; -#endif - break; - } - } -} - -// Prevent any preprocessor problems in case I screw something up -#ifdef DEBUG_SERVERAPP_MSGS -#undef DEBUG_SERVERAPP_MSGS -#endif - -#ifdef DEBUG_SERVERAPP_CURSORS -#undef DEBUG_SERVERAPP_CURSORS -#endif diff --git a/src/servers/app/proto7/ServerApp.h b/src/servers/app/proto7/ServerApp.h deleted file mode 100644 index 39a184115c..0000000000 --- a/src/servers/app/proto7/ServerApp.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _SRVAPP_H_ -#define _SRVAPP_H_ - -#include -#include -class BMessage; -class PortLink; -class BList; -class DisplayDriver; - -class ServerApp -{ -public: - ServerApp(port_id msgport, char *signature); - ~ServerApp(void); - - bool Run(void); - static int32 MonitorApp(void *data); - void Loop(void); - bool IsActive(void) const { return isactive; } - void Activate(bool value) { isactive=value; } - bool PingTarget(void); - -// char *app_sig; - port_id sender,receiver; - BString app_sig; - thread_id monitor_thread; - PortLink *applink; - BList *winlist, *bmplist; - ServerBitmap *cursor; - DisplayDriver *driver; - rgb_color high, low; // just for testing until layers are implemented - -protected: - void DispatchMessage(int32 code, int8 *buffer); - - bool isactive; - team_id target_id; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/ServerBitmap.cpp b/src/servers/app/proto7/ServerBitmap.cpp deleted file mode 100644 index c7363945fc..0000000000 --- a/src/servers/app/proto7/ServerBitmap.cpp +++ /dev/null @@ -1,378 +0,0 @@ -/* - ServerBitmap.cpp - Bitmap class which is intended to provide an easy way to package all the - data associated with a picture. It's very low-level, so there's still - plenty to do when coding with 'em. Also, they can be used to access draw on the - frame buffer in a relatively easy way, although it is currently unclear - whether this functionality will even be necessary. -*/ - -// These three includes for ServerBitmap(const char *path_to_image_file) only -#include -#include -#include - -#include "ServerBitmap.h" -#include "Desktop.h" -#include "DisplayDriver.h" - -//#define DEBUG_BITMAP - -#ifdef DEBUG_BITMAP -#include -#endif - -long pow2(int power) -{ - if(power==0) - return 1; - return long(2 << (power-1)); -} - -ServerBitmap::ServerBitmap(BRect rect,color_space space,int32 BytesPerLine=0) -{ - is_initialized=true; - width=rect.IntegerWidth()+1; - height=rect.IntegerHeight()+1; - cspace=space; - areaid=B_ERROR; - - HandleSpace(space, BytesPerLine); - buffer=new uint8[bytesperline*height]; -} - -ServerBitmap::ServerBitmap(int32 w,int32 h,color_space space,int32 BytesPerLine=0) -{ - is_initialized=true; - width=w; - height=h; - cspace=space; - areaid=B_ERROR; - - HandleSpace(space, BytesPerLine); - buffer=new uint8[bytesperline*height]; -} - -// This loads a bitmap from disk, given a path -ServerBitmap::ServerBitmap(const char *path) -{ - is_initialized=true; - if(!path) - { - width=0; - height=0; - cspace=B_NO_COLOR_SPACE; - bytesperline=0; - is_initialized=false; - buffer=NULL; - return; - } - - BBitmap *bmp=BTranslationUtils::GetBitmap(path); - - if(bmp==NULL) - { - width=0; - height=0; - cspace=B_NO_COLOR_SPACE; - bytesperline=0; - is_initialized=false; - buffer=NULL; - } - else - { - width=bmp->Bounds().IntegerWidth(); - height=bmp->Bounds().IntegerHeight(); - cspace=bmp->ColorSpace(); - bytesperline=bmp->BytesPerRow(); - buffer=new uint8[bmp->BitsLength()]; - memcpy(buffer,(void *)bmp->Bits(),bmp->BitsLength()); - HandleSpace(cspace,bytesperline); - } -} - -// Load a bitmap from a resource file -ServerBitmap::ServerBitmap(uint32 type,int32 id) -{ - is_initialized=true; - BBitmap *bmp=BTranslationUtils::GetBitmap(type,id); - - if(bmp==NULL) - { - width=0; - height=0; - cspace=B_NO_COLOR_SPACE; - bytesperline=0; - is_initialized=false; - buffer=NULL; - } - else - { - width=bmp->Bounds().IntegerWidth(); - height=bmp->Bounds().IntegerHeight(); - cspace=bmp->ColorSpace(); - bytesperline=bmp->BytesPerRow(); - buffer=new uint8[bmp->BitsLength()]; - memcpy(buffer,(void *)bmp->Bits(),bmp->BitsLength()); - HandleSpace(cspace,bytesperline); - } -} - -ServerBitmap::ServerBitmap(uint32 type, const char *name) -{ - is_initialized=true; - BBitmap *bmp=BTranslationUtils::GetBitmap(type,name); - - if(bmp==NULL) - { - width=0; - height=0; - cspace=B_NO_COLOR_SPACE; - bytesperline=0; - is_initialized=false; - buffer=NULL; - } - else - { - width=bmp->Bounds().IntegerWidth(); - height=bmp->Bounds().IntegerHeight(); - cspace=bmp->ColorSpace(); - bytesperline=bmp->BytesPerRow(); - buffer=new uint8[bmp->BitsLength()]; - memcpy(buffer,(void *)bmp->Bits(),bmp->BitsLength()); - HandleSpace(cspace,bytesperline); - } -} - -ServerBitmap::ServerBitmap(ServerBitmap *bitmap) -{ - is_initialized=true; - width=bitmap->width; - height=bitmap->height; - bytesperline = bitmap->bytesperline; - cspace=bitmap->cspace; - areaid=B_ERROR; - - HandleSpace(bitmap->cspace, bitmap->bytesperline); - buffer=new uint8[bytesperline*height]; - memcpy(buffer, bitmap->buffer, bytesperline * height); -} - -ServerBitmap::ServerBitmap(int8 *data) -{ - // 68-byte array used in R5 for holding cursors. - // This API has serious problems and should be deprecated(but supported) in R2 - - // Now that we have all the setup, we're going to map (for now) the cursor - // to RGBA32. Eventually, there will be support for 16 and 8-bit depths - is_initialized=true; - if(data) - { - uint32 black=0xFF000000, - white=0xFFFFFFFF, - *bmppos; - uint16 *cursorpos, *maskpos,cursorflip, maskflip, - cursorval, maskval; - uint8 i,j; - - cursorpos=(uint16*)(data+4); - maskpos=(uint16*)(data+36); - - buffer=new uint8[1024]; // 16x16x4 - RGBA32 space - width=16; - height=16; - bytesperline=64; - cspace=B_RGBA32; - HandleSpace(cspace,bytesperline); - - // for each row in the cursor data - for(j=0;j<16;j++) - { - bmppos=(uint32*)(buffer+ (j*64) ); - - // On intel, our bytes end up swapped, so we must swap them back - cursorflip=(cursorpos[j] & 0xFF) << 8; - cursorflip |= (cursorpos[j] & 0xFF00) >> 8; - maskflip=(maskpos[j] & 0xFF) << 8; - maskflip |= (maskpos[j] & 0xFF00) >> 8; - - // for each column in each row of cursor data - for(i=0;i<16;i++) - { - // Get the values and dump them to the bitmap - cursorval=cursorflip & pow2(15-i); - maskval=maskflip & pow2(15-i); - bmppos[i]=((cursorval!=0)?black:white) & ((maskval>0)?0xFFFFFFFF:0x00FFFFFF); - } - } - } - else - { - buffer=NULL; - width=0; - height=0; - bytesperline=0; - cspace=B_NO_COLOR_SPACE; - } - -#ifdef DEBUG_SERVER_CURSOR - PrintToStream(); -#endif -} - -ServerBitmap::~ServerBitmap(void) -{ - if(buffer) - delete[] buffer; -} - -void ServerBitmap::UpdateSettings(void) -{ - // This is only used when the object is pointing to the frame buffer - bpp=driver->GetDepth(); - width=driver->GetWidth(); - height=driver->GetHeight(); -} - -uint8 *ServerBitmap::Bits(void) -{ - return buffer; -} - -uint32 ServerBitmap::BitsLength(void) -{ - return (uint32)(bytesperline*height); -} - -void ServerBitmap::HandleSpace(color_space space, int32 BytesPerLine) -{ - // Function written to handle color space setup which is required - // by the two "normal" constructors - - // Big convoluted mess just to handle every color space and dword align - // the buffer - switch(space) - { - // Buffer is dword-aligned, so nothing need be done - // aside from allocate the memory - case B_RGB32: - case B_RGBA32: - case B_RGB32_BIG: - case B_RGBA32_BIG: - case B_UVL32: - case B_UVLA32: - case B_LAB32: - case B_LABA32: - case B_HSI32: - case B_HSIA32: - case B_HSV32: - case B_HSVA32: - case B_HLS32: - case B_HLSA32: - case B_CMY32: - case B_CMYA32: - case B_CMYK32: - - // 24-bit = 32-bit with extra 8 bits ignored - case B_RGB24_BIG: - case B_RGB24: - case B_LAB24: - case B_UVL24: - case B_HSI24: - case B_HSV24: - case B_HLS24: - case B_CMY24: - { - if(BytesPerLine<(width*4)) - bytesperline=width*4; - else - bytesperline=BytesPerLine; - bpp=32; - break; - } - // Calculate size and dword-align - - // 1-bit - case B_GRAY1: - { - int32 numbytes=width>>3; - if((width % 8) != 0) - numbytes++; - if(BytesPerLine -#include -#include - -class DisplayDriver; - -class ServerBitmap -{ -public: - ServerBitmap(BRect rect,color_space space,int32 BytesPerLine=0); - ServerBitmap(int32 w,int32 h,color_space space,int32 BytesPerLine=0); - ServerBitmap(const char *path); - ServerBitmap(ServerBitmap *bitmap); - ServerBitmap(uint32 type, int32 id); - ServerBitmap(int8 *data); - ServerBitmap(uint32 type, const char *name); - ~ServerBitmap(void); - void UpdateSettings(void); - void SetBuffer(void *ptr) { buffer=(uint8*)ptr; } - void FreeBuffer(void) { if(buffer!=NULL) { delete buffer; buffer=NULL; } } - uint8 *Bits(void); - void SetArea(area_id ID); - area_id Area(void); - uint32 BitsLength(void); - BRect Bounds() { return BRect(0,0,width-1,height-1); }; - int32 BytesPerRow(void) { return bytesperline; }; - uint8 BitsPerPixel(void) { return bpp; } - color_space ColorSpace(void) { return cspace; } - const bool &InitCheck(void) { return is_initialized; } - - int32 width,height; - int32 bytesperline; - color_space cspace; - int bpp; - -protected: - bool is_initialized; - void HandleSpace(color_space space, int32 BytesPerLine); - DisplayDriver *driver; - area_id areaid; - uint8 *buffer; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/ServerFont.cpp b/src/servers/app/proto7/ServerFont.cpp deleted file mode 100644 index 25b11eb040..0000000000 --- a/src/servers/app/proto7/ServerFont.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - This class is the shadow class to BFont. The only problem is that - FreeType is going to need to be, um, "customized" to do everything - we need it to do, such as the file format, other encodings, etc. -*/ - -#include "FontFamily.h" -#include "ServerFont.h" - - -ServerFont::ServerFont(FontStyle *style, float size=12.0, float rotation=0.0, float shear=90.0, - uint16 flags=0, uint8 spacing=B_CHAR_SPACING) -{ - fstyle=style; - fsize=size; - frotation=rotation; - fshear=shear; - fflags=flags; - fspacing=spacing; - fdirection=B_FONT_LEFT_TO_RIGHT; - fface=B_REGULAR_FACE; - ftruncate=B_TRUNCATE_END; - fencoding=B_UNICODE_UTF8; - fbounds.Set(0,0,0,0); - if(fstyle) - fstyle->AddDependent(); -} - -ServerFont::ServerFont(const ServerFont &font) -{ - fstyle=font.fstyle; - fsize=font.fsize; - frotation=font.frotation; - fshear=font.fshear; - fflags=font.fflags; - fspacing=font.fspacing; - fdirection=font.fdirection; - fface=font.fface; - ftruncate=font.ftruncate; - fencoding=font.fencoding; - fbounds.Set(0,0,0,0); - if(fstyle) - fstyle->AddDependent(); -} - -ServerFont::~ServerFont(void) -{ - if(fstyle) - fstyle->RemoveDependent(); -} - -/* TODO: implement these functions -BRect BoundingBox(void) -{ -} - -escapement_delta Escapements(char c) -{ -} -*/ - -const BRect &ServerFont::BoundingBox(void) -{ - return fbounds; -} - -BRect ServerFont::StringBounds(const char *string) -{ - return BRect(0,0,0,0); -} - -void ServerFont::Height(font_height *fh) -{ - fh->ascent=fheight.ascent; - fh->descent=fheight.descent; - fh->leading=fheight.leading; -} - diff --git a/src/servers/app/proto7/ServerFont.h b/src/servers/app/proto7/ServerFont.h deleted file mode 100644 index 8735174f07..0000000000 --- a/src/servers/app/proto7/ServerFont.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef SERVERFONT_H_ -#define SERVERFONT_H_ - -#include -#include - -class FontStyle; - -class ServerFont -{ -public: - ServerFont(FontStyle *fstyle, float fsize=12.0, float frotation=0.0, float fshear=90.0, - uint16 flags=0, uint8 spacing=B_CHAR_SPACING); - ServerFont(const ServerFont &font); - ~ServerFont(void); - font_direction Direction(void) { return fdirection; } - uint8 Encoding(void) { return fencoding; } - edge_info Edges(void) { return fedges; } - uint32 Flags(void) { return fflags; } - uint8 Spacing(void) { return fspacing; } - float Shear(void) { return fshear; } - float Rotation(void) { return frotation; } - float Size(void) { return fsize; } - uint16 Face(void) { return fface; } - uint32 CountGlyphs(void); - FontStyle *Style(void) { return fstyle; } - - void SetDirection(const font_direction &dir) { fdirection=dir; } - void SetEdges(const edge_info &info) { fedges=info; } - void SetEncoding(uint8 encoding) { fencoding=encoding; } - void SetFlags(const uint32 &value) { fflags=value; } - void SetSpacing(const uint8 &value) { fspacing=value; } - void SetShear(const float &value) { fshear=value; } - void SetSize(const float &value) { fsize=value; } - void SetRotation(const float &value) { frotation=value; } - void SetFace(const uint16 &value) { fface=value; } - - const BRect &BoundingBox(void); - BRect StringBounds(const char *string); -// escapement_delta Escapements(char c); - void Height(font_height *fh); -protected: - friend FontStyle; - FontStyle *fstyle; - font_height fheight; - edge_info fedges; - float fsize, frotation, fshear; - BRect fbounds; - uint32 fflags; - uint8 fspacing; - uint16 fface; - font_direction fdirection; - uint8 ftruncate; - uint8 fencoding; -}; - -#endif diff --git a/src/servers/app/proto7/ServerProtocol.h b/src/servers/app/proto7/ServerProtocol.h deleted file mode 100644 index 7e639be15c..0000000000 --- a/src/servers/app/proto7/ServerProtocol.h +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef _APPSERVER_PROTOCOL_ -#define _APPSERVER_PROTOCOL_ - -#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' - -#define SERVER_PORT_NAME "OBappserver" -#define SERVER_INPUT_PORT "OBinputport" -#define SERVER_FONT_LIST "/boot/home/config/settings/app_server/fontlist" -#define SERVER_SETTINGS_DIR "/boot/home/config/settings/app_server/" -#define COLOR_SET_DIR "/boot/home/config/settings/color_sets/" -#define DECORATORS_DIR "/boot/home/config/add-ons/decorators/" -#define COLOR_SETTINGS_NAME "system_colors" - -// Used for quick replies from the app_server -#define SERVER_TRUE 'svtr' -#define SERVER_FALSE 'svfl' - -// 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' - - -// This will be modified. Currently a kludge for the input server until -// BScreens are implemented by the IK Taeam -#define GET_SCREEN_MODE 'gsmd' - -#define SET_UI_COLORS 'suic' -#define GET_UI_COLOR 'guic' -#define SET_DECORATOR 'sdec' -#define GET_DECORATOR 'gdec' - -#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 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' - -#define GFX_SET_HIGH_COLOR 'gshc' -#define GFX_SET_LOW_COLOR 'gslc' -#define GFX_SET_VIEW_COLOR 'gsvc' - -#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' - -#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' - -#define GFX_MOVEPENBY 'gmpb' -#define GFX_MOVEPENTO 'gmpt' -#define GFX_SETPENSIZE 'gsps' - -#define GFX_DRAW_STRING 'gdst' -#define GFX_SET_FONT 'gsft' -#define GFX_SET_FONT_SIZE 'gsfs' - -#define GFX_FLUSH 'gfsh' -#define GFX_SYNC 'gsyn' - -#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 BEGIN_RECT_TRACKING 'rtbg' -#define END_RECT_TRACKING 'rten' - -#define VIEW_GET_TOKEN 'vgtk' -#define VIEW_ADD 'vadd' -#define VIEW_REMOVE 'vrem' -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/ServerWindow.cpp b/src/servers/app/proto7/ServerWindow.cpp deleted file mode 100644 index 991adf9cd5..0000000000 --- a/src/servers/app/proto7/ServerWindow.cpp +++ /dev/null @@ -1,514 +0,0 @@ -/* - ServerWindow.cpp - Class which works with a BWindow. Handles all messages coming from and - going to its window plus all drawing calls. -*/ -#include -#include -#include -#include -#include -#include // for B_XXXXX_MOUSE_BUTTON defines -#include "AppServer.h" -#include "Layer.h" -#include "PortLink.h" -#include "ServerWindow.h" -#include "ServerApp.h" -#include "ServerProtocol.h" -#include "WindowBorder.h" -#include "DebugTools.h" -#include "Desktop.h" - -//#define DEBUG_SERVERWIN - -// Used for providing identifiers for views -int32 view_counter=0; - -// defined in WindowBorder.cpp locking not necessary - the only -// thread which accesses them is the Poller thread -extern bool is_moving_window,is_resizing_window,is_sliding_tab; - -// Used in window focus management -ServerWindow *active_serverwindow=NULL; - -ServerWindow::ServerWindow(BRect rect, const char *string, uint32 wlook, - uint32 wfeel, uint32 wflags, ServerApp *winapp, port_id winport, uint32 index) -{ - title=new BString; - if(string) - title->SetTo(string); - else - title->SetTo("Window"); -#ifdef DEBUG_SERVERWIN -printf("ServerWindow(%s)\n",title->String()); -#endif - - // This must happen before the WindowBorder object - it needs this object's frame - // to be valid - frame=rect; - - // set these early also - the decorator will also need them - winflags=wflags; - winlook=wlook; - winfeel=wfeel; - - - winborder=new WindowBorder(this, title->String()); - - // hard code this for now - window look also needs to be attached and sent to - // server by BWindow constructor - decorator=instantiate_decorator(frame,title->String(),winlook,winfeel,winflags,get_gfxdriver()); -#ifdef DEBUG_SERVERWIN -if(decorator==NULL) - printf("\tNULL decorator returned\n"); -#endif - winborder->SetDecorator(decorator); -#ifdef DEBUG_SERVERWIN -printf("\tdecorator set\n"); -#endif - - // sender is the monitored app's event port - sender=winport; - winlink=new PortLink(sender); - - if(winapp!=NULL) - applink=new PortLink(winapp->receiver); - else - applink=NULL; -#ifdef DEBUG_SERVERWIN -printf("\tPortLink established\n"); -#endif - - // 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 thread - thread=spawn_thread(MonitorWin,title->String(),B_NORMAL_PRIORITY,this); - if(thread!=B_NO_MORE_THREADS && thread!=B_NO_MEMORY) - resume_thread(thread); -#ifdef DEBUG_SERVERWIN -printf("\tMonitorThread spawned\n"); -#endif - - workspace=index; - - AddWindowToDesktop(this,index); -#ifdef DEBUG_SERVERWIN -printf("\tAdded to Desktop\n"); -#endif -} - -ServerWindow::~ServerWindow(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::~ServerWindow()\n",title->String()); -#endif - RemoveWindowFromDesktop(this); - if(applink) - { - delete applink; - applink=NULL; - - delete title; - delete winlink; - delete decorator; - delete winborder; - } - kill_thread(thread); -} - -void ServerWindow::RequestDraw(BRect rect) -{ - winlink->SetOpCode(LAYER_DRAW); - winlink->Attach(&rect,sizeof(BRect)); - winlink->Flush(); -} - -void ServerWindow::ReplaceDecorator(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::ReplaceDecorator()\n",title->String()); -#endif -} - -void ServerWindow::Quit(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::Quit()\n",title->String()); -#endif -} - -const char *ServerWindow::GetTitle(void) -{ - return title->String(); -} - -ServerApp *ServerWindow::GetApp(void) -{ - return app; -} - -void ServerWindow::Show(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::Show()\n",title->String()); -#endif - if(winborder) - { - winborder->ShowLayer(); - ActivateWindow(this); -// winborder->Draw(frame); - } -} - -void ServerWindow::Hide(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::Hide()\n",title->String()); -#endif - if(winborder) - winborder->HideLayer(); -} - -bool ServerWindow::IsHidden(void) -{ - return (hidecount==0)?true:false; -} - -void ServerWindow::SetFocus(bool value) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::SetFocus(%s)\n",title->String(),(value==true)?"true":"false"); -#endif - if(active!=value) - { - active=value; - decorator->SetFocus(value); - decorator->Draw(); - } -} - -bool ServerWindow::HasFocus(void) -{ - return active; -} - -void ServerWindow::WorkspaceActivated(int32 NewWorkspace, const BPoint Resolution, color_space CSpace) -{ -} - -void ServerWindow::WindowActivated(bool Active) -{ -} - -void ServerWindow::ScreenModeChanged(const BPoint Resolustion, color_space CSpace) -{ -} - -void ServerWindow::SetFrame(const BRect &rect) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::SetFrame()",title->String()); rect.PrintToStream(); -#endif - frame=rect; -} - -BRect ServerWindow::Frame(void) -{ - return frame; -} - -status_t ServerWindow::Lock(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::Lock()\n",title->String()); -#endif - return locker.Lock(); -} - -void ServerWindow::Unlock(void) -{ -#ifdef DEBUG_SERVERWIN -printf("%s::Unlock()\n",title->String()); -#endif - locker.Unlock(); -} - -bool ServerWindow::IsLocked(void) -{ - return locker.IsLocked(); -} - -void ServerWindow::Loop(void) -{ - // Message-dispatching loop for the ServerWindow - -#ifdef DEBUG_SERVERWIN -printf("%s::Loop()\n",title->String()); -#endif - int32 msgcode; - int8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - buffersize=port_buffer_size(receiver); - - if(buffersize>0) - { - msgbuffer=new int8[buffersize]; - bytesread=read_port(receiver,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(receiver,&msgcode,NULL,0); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case 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) (int32) id of the child view - // 3) (BRect) frame in parent's coordinates - // 4) (int32) resize flags - // 5) (int32) view flags - // 6) (uint16) view's hide level - - 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)thread); - applink->Flush(); - break; - } - case VIEW_GET_TOKEN: - { - // Request to get a view identifier - this is synchronous, so reply - // immediately - - // Attached data: - // 1) port_id reply port - port_id reply_port=*((port_id*)msgbuffer); - PortLink *link=new PortLink(reply_port); - link->Attach(view_counter++); - link->Flush(); - break; - } - default: - DispatchMessage(msgcode,msgbuffer); - break; - } - - } - - if(buffersize>0) - delete msgbuffer; - - 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; -} - -void ServerWindow::HandleMouseEvent(int32 code, int8 *buffer) -{ - ServerWindow *mousewin=NULL; - int8 *index=buffer; - - // Find the window which will receive our mouse event. - Layer *root=GetRootLayer(); - WindowBorder *winborder; - - // activeborder is used to remember windows when resizing/moving windows - // or sliding a tab - ASSERT(root!=NULL); - - // Dispatch the mouse event to the proper window - switch(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 - -// int64 time=*((int64*)index); - index+=sizeof(int64); - float x=*((float*)index); - index+=sizeof(float); - float y=*((float*)index); - index+=sizeof(float); - int32 modifiers=*((int32*)index); - index+=sizeof(uint32); - uint32 buttons=*((uint32*)index); - index+=sizeof(uint32); -// int32 clicks=*((int32*)index); - BPoint pt(x,y); - - // If we have clicked on a window, - winborder=(WindowBorder*)root->GetChildAt(pt); - if(winborder) - { - mousewin=winborder->Window(); - ASSERT(mousewin!=NULL); - winborder->MouseDown(pt,buttons,modifiers); -#ifdef DEBUG_SERVERWIN -printf("ServerWindow() %s: MouseDown(%.1f,%.1f)\n",mousewin->title->String(),x,y); -#endif - } - 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 - -// int64 time=*((int64*)index); - index+=sizeof(int64); - float x=*((float*)index); - index+=sizeof(float); - float y=*((float*)index); - index+=sizeof(float); -// int32 modifiers=*((int32*)index); - BPoint pt(x,y); - - is_moving_window=false; - winborder=(WindowBorder*)root->GetChildAt(pt); - if(winborder) - { - mousewin=winborder->Window(); - ASSERT(mousewin!=NULL); - - // Eventually, we will build in MouseUp messages with buttons specified - // For now, we just "assume" no mouse specification with a 0. - winborder->MouseUp(pt,0,0); - - // Do cool mouse stuff here - -#ifdef DEBUG_SERVERWIN -printf("ServerWindow() %s: MouseUp(%.1f,%.1f)\n",mousewin->title->String(),x,y); -#endif - } - 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 -// int64 time=*((int64*)index); - index+=sizeof(int64); - float x=*((float*)index); - index+=sizeof(float); - float y=*((float*)index); - index+=sizeof(float); - uint32 buttons=*((uint32*)index); - BPoint pt(x,y); - - if(is_moving_window || is_resizing_window || is_sliding_tab) - { - mousewin=active_serverwindow; - ASSERT(mousewin!=NULL); - - mousewin->winborder->MouseMoved(pt,buttons,0); - } - else - { - winborder=(WindowBorder*)root->GetChildAt(pt); - if(winborder) - { - mousewin=winborder->Window(); - ASSERT(mousewin!=NULL); - - winborder->MouseMoved(pt,buttons,0); - } - } - break; - } - default: - { -#ifdef DEBUG_SERVERWIN -printf("HandleMouseEvent() received an unrecognized mouse event"); -PrintMessageCode(code); -#endif - break; - } - } -} - -void ActivateWindow(ServerWindow *win) -{ - if(active_serverwindow==win) - return; - if(active_serverwindow) - active_serverwindow->SetFocus(false); - active_serverwindow=win; - if(win) - win->SetFocus(true); -} diff --git a/src/servers/app/proto7/ServerWindow.h b/src/servers/app/proto7/ServerWindow.h deleted file mode 100644 index 9266979aea..0000000000 --- a/src/servers/app/proto7/ServerWindow.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef _SERVERWIN_H_ -#define _SERVERWIN_H_ - -#include -#include -#include -#include -#include -#include - -class BString; -class BMessenger; -class BPoint; -class ServerApp; -class Decorator; -class PortLink; -class WindowBorder; - -class ServerWindow -{ -public: - ServerWindow(BRect rect, const char *string, uint32 wlook, uint32 wfeel, - uint32 wflags, ServerApp *winapp, port_id winport, uint32 index); - ~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 SetFocus(bool value); - bool HasFocus(void); - void RequestDraw(BRect rect); - - void WorkspaceActivated(int32 NewDesktop, const BPoint Resolution, color_space CSpace); - void WindowActivated(bool Active); - void ScreenModeChanged(const BPoint Resolution, color_space CSpace); - - void SetFrame(const BRect &rect); - BRect Frame(void); - - status_t Lock(void); - void Unlock(void); - bool IsLocked(void); - - void DispatchMessage(int32 code, int8 *msgbuffer); - static int32 MonitorWin(void *data); - static void HandleMouseEvent(int32 code, int8 *buffer); - void Loop(void); - - BString *title; - int32 winlook, winfeel, winflags; - int32 workspace; - bool active; - - ServerApp *app; - - Decorator *decorator; - WindowBorder *winborder; - bigtime_t lasthit; // Time of last mouse click - - thread_id thread; - port_id receiver; // Messages from window - port_id sender; // Messages to window - PortLink *winlink,*applink; - BLocker locker; - BRect frame; - uint8 hidecount; -}; - -void ActivateWindow(ServerWindow *win); - - -#endif diff --git a/src/servers/app/proto7/SharedObject.h b/src/servers/app/proto7/SharedObject.h deleted file mode 100644 index db9ebf33aa..0000000000 --- a/src/servers/app/proto7/SharedObject.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef SHAREDOBJ_H_ -#define SHAREDOBJ_H_ - -/* - This class is used as a base class for other objects which must be shared. - By using this, objects which depend on its existence can be somewhat sure - that the shared object will not be deleted until nothing depends on it. -*/ -#include - -class SharedObject -{ -public: - SharedObject(void) { dependents=0; } - virtual ~SharedObject(void){} - virtual void AddDependent(void) { dependents++; } - virtual void RemoveDependent(void) { dependents--; } - virtual bool HasDependents(void) { return (dependents>0)?true:false; } -private: - uint32 dependents; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/SystemPalette.cpp b/src/servers/app/proto7/SystemPalette.cpp deleted file mode 100644 index 5d81cd4155..0000000000 --- a/src/servers/app/proto7/SystemPalette.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/* - SystemPalette.cpp - One global function to generate the palette which is the default BeOS - System palette and the variable to go with it -*/ - -#include "SystemPalette.h" - -rgb_color system_palette[256]; - -void GenerateSystemPalette(rgb_color *palette) -{ - int i,j,index=0; - int indexvals1[]={ 255,229,204,179,154,129,105,80,55,30 }, - indexvals2[]={ 255,203,152,102,51,0 }; - // ff, cb, 98, 66, 33 - rgb_color *currentcol; - - // Grays 0,0,0 -> 248,248,248 by 8's - for(i=0; i<=248; i+=8,index++) - { - currentcol=&(palette[index]); - currentcol->red=i; - currentcol->green=i; - currentcol->blue=i; - currentcol->alpha=255; - } - - // Blues, following indexvals1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=0; - currentcol->blue=indexvals1[i]; - currentcol->alpha=255; - } - - // Reds, following indexvals1 - 1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals1[i] - 1; - currentcol->green=0; - currentcol->blue=0; - currentcol->alpha=255; - } - - // Greens, following indexvals1 - 1 - for(i=0; i<10; i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=indexvals1[i] - 1; - currentcol->blue=0; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=152; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=255; - currentcol->blue=255; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=0;i<4;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=152; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=0; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=255; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=203; - index++; - - // Mostly array runs from here on out - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=203; - currentcol->green=203; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=152; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=102; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=51; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=102; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=152; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=102; - index++; - - // knocks out 4 assignment loops at once :) - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=152; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - currentcol+=sizeof(rgb_color); - currentcol->red=230; - currentcol->green=134; - currentcol->blue=0; - index++; - - for(i=1;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=102; - currentcol->blue=0; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=102; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=175; - currentcol->blue=19; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=255; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=203; - index++; - - for(j=1;j<5;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - for(i=3;i>=0;i--,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - for(i=2;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=0; - currentcol->green=51; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - for(i=0;i<5;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=203; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=227; - currentcol->blue=70; - index++; - - for(j=2;j<6;j++) - { - for(i=0;i<6;i++,index++) - { - currentcol=&(palette[index]); - currentcol->red=indexvals2[j]; - currentcol->green=0; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - } - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=51; - index++; - - currentcol+=sizeof(rgb_color); - currentcol->red=255; - currentcol->green=203; - currentcol->blue=0; - index++; - - for(i=5;i<=0;i--,index++) - { - currentcol=&(palette[index]); - currentcol->red=255; - currentcol->green=255; - currentcol->blue=indexvals2[i]; - currentcol->alpha=255; - } - -} diff --git a/src/servers/app/proto7/SystemPalette.h b/src/servers/app/proto7/SystemPalette.h deleted file mode 100644 index 1bc1d7188a..0000000000 --- a/src/servers/app/proto7/SystemPalette.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _SYSTEM_PALETTE_H_ -#define _SYSTEM_PALETTE_H_ - -#include - -void GenerateSystemPalette(rgb_color *palette); -extern rgb_color system_palette[]; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/ViewDriver.cpp b/src/servers/app/proto7/ViewDriver.cpp deleted file mode 100644 index 1b72f40cfc..0000000000 --- a/src/servers/app/proto7/ViewDriver.cpp +++ /dev/null @@ -1,1576 +0,0 @@ -/* - ViewDriver: - First, slowest, and easiest driver class in the app_server which is designed - to utilize the BeOS graphics functions to cut out a lot of junk in getting the - drawing infrastructure in this server. - - The concept is to have VDView::Draw() draw a bitmap, which is a "frame buffer" - of sorts, utilize a second view to write to it. This cuts out - the most problems with having a crapload of code to get just right without - having to write a bunch of unit tests - - Components: 3 classes, VDView, VDWindow, and ViewDriver - - ViewDriver - a wrapper class which mostly posts messages to the VDWindow - VDWindow - does most of the work. - VDView - doesn't do all that much except display the rendered bitmap -*/ - -//#define DEBUG_DRIVER_MODULE -//#define DEBUG_SERVER_EMU - -//#define DISABLE_SERVER_EMU - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "Angle.h" -#include "PortLink.h" -#include "ServerProtocol.h" -#include "ServerBitmap.h" -#include "ViewDriver.h" -#include "ServerFont.h" -#include "FontFamily.h" -//#include "DebugTools.h" -#include "LayerData.h" - -enum -{ -VDWIN_CLEAR=100, - -VDWIN_SHOWCURSOR, -VDWIN_HIDECURSOR, -VDWIN_OBSCURECURSOR, -VDWIN_MOVECURSOR, -VDWIN_SETCURSOR, -}; - -ViewDriver *viewdriver_global; - -#ifdef DEBUG_DRIVER_MODULE - -void DumpLayerData(LayerData *ld) -{ - if(ld) - { - printf("Layer Data: \n"); - printf("\tPen Size: %f\n" - "\tPen Location: (%f,%f)\n" - "\tDraw Mode: %d\n" - "\tScale: %f\n", - ld->pensize, - ld->penlocation.x, ld->penlocation.y, - ld->draw_mode, - ld->scale); - ld->highcolor.PrintToStream(); - ld->lowcolor.PrintToStream(); - } - else - { - printf("Layer Data: NULL\n"); - } -} - -#endif - -VDView::VDView(BRect bounds) - : BView(bounds,"viewdriver_view",B_FOLLOW_ALL, B_WILL_DRAW) -{ - SetViewColor(B_TRANSPARENT_32_BIT); - viewbmp=new BBitmap(bounds,B_RGB32,true); - - // This link for sending mouse messages to the OBAppServer. - // This is only to take the place of the Input Server. I suppose I could write - // an addon filter to be more like the Input Server, but then I wouldn't be working - // on this thing! :P - serverlink=new PortLink(find_port(SERVER_INPUT_PORT)); - -#ifdef DEBUG_DRIVER_MODULE - printf("VDView: app_server input port: %ld\n",serverlink->GetPort()); -#endif - - // Create a cursor which isn't just a box - cursor=new BBitmap(BRect(0,0,20,20),B_RGBA32,true); - BView *v=new BView(cursor->Bounds(),"v", B_FOLLOW_NONE, B_WILL_DRAW); - hide_cursor=0; - - cursor->Lock(); - cursor->AddChild(v); - - v->SetHighColor(255,255,255,0); - v->FillRect(cursor->Bounds()); - v->SetHighColor(255,0,0,255); - v->FillTriangle(cursor->Bounds().LeftTop(),cursor->Bounds().RightTop(),cursor->Bounds().LeftBottom()); - - cursor->RemoveChild(v); - cursor->Unlock(); - - cursorframe=cursor->Bounds(); - oldcursorframe=cursor->Bounds(); -} - -VDView::~VDView(void) -{ - delete serverlink; - delete viewbmp; - delete cursor; -} - -void VDView::AttachedToWindow(void) -{ -} - -void VDView::Draw(BRect rect) -{ - if(viewbmp) - { - DrawBitmapAsync(viewbmp,oldcursorframe,oldcursorframe); - DrawBitmapAsync(viewbmp,rect,rect); - - if(hide_cursor==0 && obscure_cursor==false) - { - SetDrawingMode(B_OP_ALPHA); - DrawBitmapAsync(cursor,cursor->Bounds(),cursorframe); - SetDrawingMode(B_OP_COPY); - } - Sync(); - } -} - -// These functions emulate the Input Server by sending the *exact* same kind of messages -// to the server's port. Being we're using a regular window, it would make little sense -// to do anything else. - -void VDView::MouseDown(BPoint pt) -{ -#ifdef DEBUG_SERVER_EMU -printf("ViewDriver::MouseDown\n"); -#endif - // 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 -#ifndef DISABLE_SERVER_EMU - BPoint p; - - uint32 buttons, - mod=modifiers(), - clicks=1; // can't get the # of clicks without a *lot* of extra work :( - - int64 time=(int64)real_time_clock(); - - GetMouse(&p,&buttons); - - serverlink->SetOpCode(B_MOUSE_DOWN); - serverlink->Attach(&time, sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - serverlink->Attach(&mod, sizeof(uint32)); - serverlink->Attach(&buttons, sizeof(uint32)); - serverlink->Attach(&clicks, sizeof(uint32)); - serverlink->Flush(); -#endif -} - -void VDView::MouseMoved(BPoint pt, uint32 transit, const BMessage *msg) -{ - // Attach 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 -#ifndef DISABLE_SERVER_EMU - BPoint p; - uint32 buttons; - int64 time=(int64)real_time_clock(); - - serverlink->SetOpCode(B_MOUSE_MOVED); - serverlink->Attach(&time,sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - GetMouse(&p,&buttons); - serverlink->Attach(&buttons,sizeof(int32)); - serverlink->Flush(); -#endif -} - -void VDView::MouseUp(BPoint pt) -{ -#ifdef DEBUG_SERVER_EMU -printf("ViewDriver::MouseUp\n"); -#endif - // 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 -#ifndef DISABLE_SERVER_EMU - BPoint p; - - uint32 buttons, - mod=modifiers(); - - int64 time=(int64)real_time_clock(); - - GetMouse(&p,&buttons); - - serverlink->SetOpCode(B_MOUSE_UP); - serverlink->Attach(&time, sizeof(int64)); - serverlink->Attach(&pt.x,sizeof(float)); - serverlink->Attach(&pt.y,sizeof(float)); - serverlink->Attach(&mod, sizeof(uint32)); - serverlink->Flush(); -#endif -} - -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- - -VDWindow::VDWindow(void) - : BWindow(BRect(100,60,740,540),"OBOS App Server, P7",B_TITLED_WINDOW, - B_NOT_ZOOMABLE | B_NOT_RESIZABLE) -{ - view=new VDView(Bounds()); - AddChild(view); -} - -VDWindow::~VDWindow(void) -{ -} - -void VDWindow::MessageReceived(BMessage *msg) -{ - switch(msg->what) - { - case VDWIN_SHOWCURSOR: - { - if(view->hide_cursor>0) - { - view->hide_cursor--; -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: ShowCursor() - still hidden\n"); -#endif - } - if(view->hide_cursor==0) - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: ShowCursor() - cursor shown\n"); -#endif - view->Invalidate(view->cursorframe); - } - break; - } - case VDWIN_HIDECURSOR: - { - view->hide_cursor++; - if(view->hide_cursor==1) - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: HideCursor() - cursor was hidden\n"); -#endif - view->Invalidate(view->cursorframe); - } - else - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: HideCursor()\n"); -#endif - } - break; - } - case VDWIN_OBSCURECURSOR: - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: ObscureCursor()\n"); -#endif - view->obscure_cursor=true; - view->Invalidate(view->cursorframe); - break; - } - case VDWIN_MOVECURSOR: - { - float x,y; - msg->FindFloat("x",&x); - msg->FindFloat("y",&y); - - // this was changed because an extra message was - // sent even though the mouse was never moved - if(view->cursorframe.left!=x || view->cursorframe.top!=y) - { - if(view->obscure_cursor) - view->obscure_cursor=false; - - view->oldcursorframe=view->cursorframe; - view->cursorframe.OffsetTo(x,y); - } - - if(view->hide_cursor==0) - view->Invalidate(view->oldcursorframe); - break; - } - case VDWIN_SETCURSOR: - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: SetCursor()\n"); -#endif - ServerBitmap *cdata; - msg->FindPointer("SCursor",(void**)&cdata); - - if(cdata!=NULL) - { - BBitmap *bmp=new BBitmap(cdata->Bounds(), B_RGBA32); - - // Copy the server bitmap in the cursor to a BBitmap - uint8 *sbmppos=(uint8*)cdata->Bits(), - *bbmppos=(uint8*)bmp->Bits(); - - int32 bytes=cdata->BytesPerRow(), - bbytes=bmp->BytesPerRow(); - - for(int i=0;iBounds().IntegerHeight();i++) - memcpy(bbmppos+(i*bbytes), sbmppos+(i*bytes), bytes); - - // Replace the bitmap - delete view->cursor; - view->cursor=bmp; - view->Invalidate(view->cursorframe); - break; - } - break; - } - default: - BWindow::MessageReceived(msg); - break; - } -} - -bool VDWindow::QuitRequested(void) -{ - port_id serverport=find_port(SERVER_PORT_NAME); - - if(serverport!=B_NAME_NOT_FOUND) - write_port(serverport,B_QUIT_REQUESTED,NULL,0); - - return true; -} - -void VDWindow::WindowActivated(bool active) -{ - // This is just to hide the regular system cursor so we can see our own - if(active) - be_app->HideCursor(); - else - be_app->ShowCursor(); -} - -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- -//----------------------------------------------------------------------- - -ViewDriver::ViewDriver(void) -{ - viewdriver_global=this; - screenwin=new VDWindow(); - framebuffer=screenwin->view->viewbmp; - serverlink=screenwin->view->serverlink; - hide_cursor=0; -} - -ViewDriver::~ViewDriver(void) -{ - if(is_initialized) - { - screenwin->Lock(); - screenwin->Quit(); - screenwin=NULL; - } -} - -bool ViewDriver::Initialize(void) -{ - Lock(); - drawview=new BView(framebuffer->Bounds(),"drawview",B_FOLLOW_ALL, B_WILL_DRAW); - framebuffer->AddChild(drawview); - - hide_cursor=0; - obscure_cursor=false; - - is_initialized=true; - - // We can afford to call the above functions without locking - // because the window is locked until Show() is first called - screenwin->Show(); - Unlock(); - return true; -} - -void ViewDriver::Shutdown(void) -{ - Lock(); - is_initialized=false; - Unlock(); -} - -void ViewDriver::SetMode(int32 space) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: SetMode(%ld)\n",space); -#endif - screenwin->Lock(); - int16 w=640,h=480; - color_space s; - - switch(space) - { - case B_32_BIT_800x600: - case B_16_BIT_800x600: - case B_8_BIT_800x600: - { - w=800; h=600; - break; - } - case B_32_BIT_1024x768: - case B_16_BIT_1024x768: - case B_8_BIT_1024x768: - { - w=1024; h=768; - break; - } - default: - break; - } - screenwin->ResizeTo(w-1,h-1); - - switch(space) - { - case B_32_BIT_640x480: - case B_32_BIT_800x600: - case B_32_BIT_1024x768: - s=B_RGBA32; - break; - case B_16_BIT_640x480: - case B_16_BIT_800x600: - case B_16_BIT_1024x768: - s=B_RGBA15; - break; - case B_8_BIT_640x480: - case B_8_BIT_800x600: - case B_8_BIT_1024x768: - s=B_CMAP8; - break; - default: - break; - } - - - delete framebuffer; - - screenwin->view->viewbmp=new BBitmap(BRect(0,0,w-1,h-1),s,true); - framebuffer=screenwin->view->viewbmp; - drawview=new BView(framebuffer->Bounds(),"drawview",B_FOLLOW_ALL, B_WILL_DRAW); - framebuffer->AddChild(drawview); - - framebuffer->Lock(); - drawview->SetHighColor(80,85,152); - drawview->FillRect(drawview->Bounds()); - drawview->Sync(); - framebuffer->Unlock(); - screenwin->view->Invalidate(); - screenwin->Unlock(); -} - -void ViewDriver::CopyBits(BRect src, BRect dest) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: CopyBits()\n"); src.PrintToStream(); dest.PrintToStream(); -#endif - screenwin->Lock(); - framebuffer->Lock(); - drawview->CopyBits(src,dest); - drawview->Sync(); - screenwin->view->Invalidate(src); - screenwin->view->Invalidate(dest); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::DrawBitmap(ServerBitmap *bitmap, BRect src, BRect dest) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: DrawBitmap unimplemented()\n"); -#endif -} - -void ViewDriver::DrawChar(char c, BPoint pt, LayerData *d) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: DrawChar(%c, BPoint(%f,%f))\n",c,pt.x,pt.y); -#endif - char str[2]; - str[0]=c; - str[1]='\0'; - DrawString(str, 1, pt, d); -} -/* -void ViewDriver::DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: DrawString(\"%s\",%ld,BPoint(%f,%f))\n",string,length,pt.x,pt.y); -#endif - if(!d) - return; - BRect r; - - screenwin->Lock(); - framebuffer->Lock(); - - SetLayerData(d,true); // set all layer data and additionally set the font-related data - - drawview->DrawString(string,length,pt,delta); - drawview->Sync(); - - // calculate the invalid rectangle - font_height fh; - BFont font; - drawview->GetFont(&font); - drawview->GetFontHeight(&fh); - r.left=pt.x; - r.right=pt.x+font.StringWidth(string); - r.top=pt.y-fh.ascent; - r.bottom=pt.y+fh.descent; - screenwin->view->Invalidate(r); - - framebuffer->Unlock(); - screenwin->Unlock(); - -} -*/ -/* -bool ViewDriver::DumpToFile(const char *path) -{ - return false; -} -*/ -void ViewDriver::FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: FillArc()\n"); -#endif - if(!pat || !d) - return; - screenwin->Lock(); - framebuffer->Lock(); - SetLayerData(d); - drawview->FillArc(r,angle,span,*((pattern*)pat)); - drawview->Sync(); - screenwin->view->Invalidate(r); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillBezier(BPoint *pts, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: FillBezier()\n"); -#endif - if(!pat || !pts) - return; - screenwin->Lock(); - framebuffer->Lock(); - SetLayerData(d); - drawview->FillBezier(pts,*((pattern*)pat)); - drawview->Sync(); - - // Invalidate the whole view until I get around to adding in the invalid rect calc code - screenwin->view->Invalidate(); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillEllipse(BRect r, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: FillEllipse()\n"); -#endif - if(!pat || !d) - return; - screenwin->Lock(); - framebuffer->Lock(); - SetLayerData(d); - drawview->FillEllipse(r,*((pattern*)pat)); - drawview->Sync(); - screenwin->view->Invalidate(r); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: FillPolygon unimplemented\n"); -#endif - if(!pat || !ptlist) - return; -} - -void ViewDriver::FillRect(BRect r, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: FillRect()\n"); -#endif - if(!pat || !d) - return; - screenwin->Lock(); - framebuffer->Lock(); - SetLayerData(d); - drawview->FillRect(r,*((pattern*)pat)); - drawview->Sync(); - screenwin->view->Invalidate(r); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: FillRoundRect()\n"); -#endif - if(!pat || !d) - return; - screenwin->Lock(); - framebuffer->Lock(); - SetLayerData(d); - drawview->FillRoundRect(r,xrad,yrad,*((pattern*)pat)); - drawview->Sync(); - screenwin->view->Invalidate(r); - framebuffer->Unlock(); - screenwin->Unlock(); - -} - -void ViewDriver::FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: FillTriangle()\n"); -#endif - if(!pat || !pts) - return; - screenwin->Lock(); - framebuffer->Lock(); - BPoint first=pts[0],second=pts[1],third=pts[2]; - SetLayerData(d); - drawview->FillTriangle(first,second,third,r,*((pattern*)pat)); - drawview->Sync(); - screenwin->view->Invalidate(r); - framebuffer->Unlock(); - screenwin->Unlock(); - -} - -void ViewDriver::HideCursor(void) -{ - screenwin->Lock(); - Lock(); - - hide_cursor++; - screenwin->PostMessage(VDWIN_HIDECURSOR); - - Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::InvertRect(BRect r) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: InvertRect()\n"); -#endif - screenwin->Lock(); - framebuffer->Lock(); - drawview->InvertRect(r); - drawview->Sync(); - screenwin->view->Invalidate(r); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -bool ViewDriver::IsCursorHidden(void) -{ - screenwin->Lock(); - bool value=(hide_cursor>0)?true:false; - screenwin->Unlock(); - return value; -} - -void ViewDriver::ObscureCursor(void) -{ - screenwin->Lock(); - screenwin->PostMessage(VDWIN_OBSCURECURSOR); - screenwin->Unlock(); -} - -void ViewDriver::MoveCursorTo(float x, float y) -{ - screenwin->Lock(); - BMessage *msg=new BMessage(VDWIN_MOVECURSOR); - msg->AddFloat("x",x); - msg->AddFloat("y",y); - screenwin->PostMessage(msg); - screenwin->Unlock(); -} - -void ViewDriver::SetCursor(ServerBitmap *cursor, const BPoint &spot) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: SetCursor(%p)\n",cursor); -#endif - if(cursor!=NULL) - { - screenwin->Lock(); - BBitmap *bmp=new BBitmap(cursor->Bounds(),B_RGBA32); - - // Copy the server bitmap in the cursor to a BBitmap - uint8 *sbmppos=(uint8*)cursor->Bits(), - *bbmppos=(uint8*)bmp->Bits(); - - int32 bytes=cursor->BytesPerRow(), - bbytes=bmp->BytesPerRow(); - - for(int i=0;i<=cursor->Bounds().IntegerHeight();i++) - memcpy(bbmppos+(i*bbytes), sbmppos+(i*bytes), bytes); - - if(cursor->Bounds().Contains(spot)) - SetHotSpot(spot); - else - SetHotSpot(BPoint(0,0)); - - // Replace the bitmap - delete screenwin->view->cursor; - screenwin->view->cursor=bmp; - screenwin->view->Invalidate(screenwin->view->cursorframe); - screenwin->Unlock(); - } -} - -void ViewDriver::ShowCursor(void) -{ - screenwin->Lock(); - if(hide_cursor>0) - { - hide_cursor--; - screenwin->PostMessage(VDWIN_SHOWCURSOR); - } - screenwin->Unlock(); - -} - -void ViewDriver::StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeArc()\n"); -#endif - if(!pat || !d) - return; - screenwin->Lock(); - framebuffer->Lock(); - SetLayerData(d); - drawview->StrokeArc(r,angle,span,*((pattern*)pat)); - drawview->Sync(); - screenwin->view->Invalidate(r); - framebuffer->Unlock(); - screenwin->Unlock(); - -} - -void ViewDriver::StrokeBezier(BPoint *pts, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeBezier()\n"); -#endif - if(!pat || !pts) - return; - screenwin->Lock(); - framebuffer->Lock(); - SetLayerData(d); - drawview->StrokeBezier(pts,*((pattern*)pat)); - drawview->Sync(); - - // Invalidate the whole view until I get around to adding in the invalid rect calc code - screenwin->view->Invalidate(); - framebuffer->Unlock(); - screenwin->Unlock(); - -} - -void ViewDriver::StrokeEllipse(BRect r, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeEllipse()\n"); -#endif - if(!pat || !d) - return; - screenwin->Lock(); - framebuffer->Lock(); - SetLayerData(d); - drawview->StrokeEllipse(r,*((pattern*)pat)); - drawview->Sync(); - screenwin->view->Invalidate(r); - framebuffer->Unlock(); - screenwin->Unlock(); - -} - -void ViewDriver::StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeLine()\n"); -#endif - if(!pat || !d) - return; - screenwin->Lock(); - framebuffer->Lock(); - SetLayerData(d); - drawview->StrokeLine(start,end,*((pattern*)pat)); - drawview->Sync(); - screenwin->view->Invalidate(BRect(start,end)); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeLineArray unimplemented\n"); -#endif -} - -void ViewDriver::StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokePolygon()\n"); -#endif - if(!pat || !ptlist) - return; - screenwin->Lock(); - framebuffer->Lock(); - - BRegion invalid; - - SetLayerData(d); - drawview->BeginLineArray(numpts+2); - for(int i=1;iAddLine(ptlist[i-1],ptlist[i],d->highcolor.GetColor32()); - invalid.Include(BRect(ptlist[i-1],ptlist[i])); - } - - if(is_closed) - { - drawview->AddLine(ptlist[numpts-1],ptlist[0],d->highcolor.GetColor32()); - invalid.Include(BRect(ptlist[numpts-1],ptlist[0])); - } - drawview->EndLineArray(); - - drawview->Sync(); - screenwin->view->Invalidate(invalid.Frame()); - framebuffer->Unlock(); - screenwin->Unlock(); - -} - -void ViewDriver::StrokeRect(BRect r, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeRect()\n"); -#endif - if(!pat || !d) - return; - screenwin->Lock(); - framebuffer->Lock(); - SetLayerData(d); - drawview->StrokeRect(r,*((pattern*)pat)); - drawview->Sync(); - screenwin->view->Invalidate(r); - framebuffer->Unlock(); - screenwin->Unlock(); -} - -void ViewDriver::StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeRoundRect()\n"); -#endif - if(!pat || !d) - return; - screenwin->Lock(); - framebuffer->Lock(); - SetLayerData(d); - drawview->StrokeRoundRect(r,xrad,yrad,*((pattern*)pat)); - drawview->Sync(); - screenwin->view->Invalidate(r); - framebuffer->Unlock(); - screenwin->Unlock(); - -} - -void ViewDriver::StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat) -{ -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver:: StrokeTriangle()\n"); -#endif - if(!pat || !pts || !d) - return; - screenwin->Lock(); - framebuffer->Lock(); - BPoint first=pts[0],second=pts[1],third=pts[2]; - SetLayerData(d); - drawview->StrokeTriangle(first,second,third,r,*((pattern*)pat)); - drawview->Sync(); - screenwin->view->Invalidate(r); - framebuffer->Unlock(); - screenwin->Unlock(); - -} - -void ViewDriver::SetLayerData(LayerData *d, bool set_font_data=false) -{ - if(!d) - return; - - drawview->SetPenSize(d->pensize); - drawview->SetDrawingMode(d->draw_mode); - drawview->SetHighColor(d->highcolor.GetColor32()); - drawview->SetLowColor(d->lowcolor.GetColor32()); - drawview->SetScale(d->scale); - drawview->MovePenTo(d->penlocation); - if(set_font_data) - { - BFont font; - ServerFont *sf=d->font; - - if(!sf) - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver::SetLayerData was passed a NULL ServerFont\n"); -#endif - return; - } - FontStyle *style=d->font->Style(); - - if(!style) - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver::SetLayerData font had a NULL style\n"); -#endif - return; - } - - FontFamily *family=(FontFamily *)style->Family(); - if(!family) - { -#ifdef DEBUG_DRIVER_MODULE -printf("ViewDriver::SetLayerData font had a NULL family\n"); -#endif - } - font.SetFamilyAndStyle((font_family)family->GetName(),style->Style()); - font.SetFlags(sf->Flags()); - font.SetEncoding(sf->Encoding()); - font.SetSize(sf->Size()); - font.SetRotation(sf->Rotation()); - font.SetShear(sf->Shear()); - font.SetSpacing(sf->Spacing()); - drawview->SetFont(&font); - } -} - -float ViewDriver::StringWidth(const char *string, int32 length, LayerData *d) -{ - if(!string || !d || !d->font) - return 0.0; - screenwin->Lock(); - - ServerFont *font=d->font; - FontStyle *style=font->Style(); - - if(!style) - return 0.0; - - FT_Face face; - FT_GlyphSlot slot; - FT_UInt glyph_index, previous=0; - FT_Vector pen,delta; - int16 error=0; - int32 strlength,i; - float returnval; - - error=FT_New_Face(ftlib, style->GetPath(), 0, &face); - if(error) - { - printf("Couldn't create face object\n"); - return 0.0; - } - - slot=face->glyph; - - bool use_kerning=FT_HAS_KERNING(face) && font->Spacing()==B_STRING_SPACING; - - error=FT_Set_Char_Size(face, 0,int32(font->Size())*64,72,72); - if(error) - { - printf("Couldn't set character size - error 0x%x\n",error); - return 0.0; - } - - // set the pen position in 26.6 cartesian space coordinates - pen.x=0; - - slot=face->glyph; - - strlength=strlen(string); - if(lengthadvance.x; - previous=glyph_index; - } - screenwin->Unlock(); - - FT_Done_Face(face); - - returnval=pen.x>>6; - return returnval; -} - -float ViewDriver::StringHeight(const char *string, int32 length, LayerData *d) -{ - if(!string || !d || !d->font) - return 0.0; - screenwin->Lock(); - - ServerFont *font=d->font; - FontStyle *style=font->Style(); - - if(!style) - return 0.0; - - FT_Face face; - FT_GlyphSlot slot; - int16 error=0; - int32 strlength,i; - float returnval=0.0,ascent=0.0,descent=0.0; - - error=FT_New_Face(ftlib, style->GetPath(), 0, &face); - if(error) - { - printf("Couldn't create face object\n"); - return 0.0; - } - - slot=face->glyph; - - error=FT_Set_Char_Size(face, 0,int32(font->Size())*64,72,72); - if(error) - { - printf("Couldn't set character size - error 0x%x\n",error); - return 0.0; - } - - slot=face->glyph; - - strlength=strlen(string); - if(lengthmetrics.horiBearingYmetrics.height) - descent=MAX((slot->metrics.height-slot->metrics.horiBearingY)>>6,descent); - else - ascent=MAX(slot->bitmap.rows,ascent); - } - screenwin->Unlock(); - - FT_Done_Face(face); - - returnval=ascent+descent; - return returnval; -} - -void ViewDriver::DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *edelta=NULL) -{ - if(!string || !d || !d->font) - return; - screenwin->Lock(); - - pt.y--; // because of Be's backward compatibility hack - - ServerFont *font=d->font; - FontStyle *style=font->Style(); - - if(!style) - return; - - FT_Face face; - FT_GlyphSlot slot; - FT_Matrix rmatrix,smatrix; - FT_UInt glyph_index, previous=0; - FT_Vector pen,delta,space,nonspace; - int16 error=0; - int32 strlength,i; - Angle rotation(font->Rotation()), shear(font->Shear()); - - bool antialias=( (font->Size()<18 && font->Flags()& B_DISABLE_ANTIALIASING==0) - || font->Flags()& B_FORCE_ANTIALIASING)?true:false; - - // Originally, I thought to do this shear checking here, but it really should be - // done in BFont::SetShear() - float shearangle=shear.Value(); - if(shearangle>135) - shearangle=135; - if(shearangle<45) - shearangle=45; - - if(shearangle>90) - shear=90+((180-shearangle)*2); - else - shear=90-(90-shearangle)*2; - - error=FT_New_Face(ftlib, style->GetPath(), 0, &face); - if(error) - { - printf("Couldn't create face object\n"); - return; - } - - slot=face->glyph; - - bool use_kerning=FT_HAS_KERNING(face) && font->Spacing()==B_STRING_SPACING; - - error=FT_Set_Char_Size(face, 0,int32(font->Size())*64,72,72); - if(error) - { - printf("Couldn't set character size - error 0x%x\n",error); - return; - } - - // if we do any transformation, we do a call to FT_Set_Transform() here - - // First, rotate - rmatrix.xx = (FT_Fixed)( rotation.Cosine()*0x10000); - rmatrix.xy = (FT_Fixed)(-rotation.Sine()*0x10000); - rmatrix.yx = (FT_Fixed)( rotation.Sine()*0x10000); - rmatrix.yy = (FT_Fixed)( rotation.Cosine()*0x10000); - - // Next, shear - smatrix.xx = (FT_Fixed)(0x10000); - smatrix.xy = (FT_Fixed)(-shear.Cosine()*0x10000); - smatrix.yx = (FT_Fixed)(0); - smatrix.yy = (FT_Fixed)(0x10000); - - FT_Matrix_Multiply(&rmatrix,&smatrix); - - // Set up the increment value for escapement padding - space.x=int32(d->edelta.space * rotation.Cosine()*64); - space.y=int32(d->edelta.space * rotation.Sine()*64); - nonspace.x=int32(d->edelta.nonspace * rotation.Cosine()*64); - nonspace.y=int32(d->edelta.nonspace * rotation.Sine()*64); - - // set the pen position in 26.6 cartesian space coordinates - pen.x=(int32)pt.x * 64; - pen.y=(int32)pt.y * 64; - - slot=face->glyph; - - - strlength=strlen(string); - if(lengthbitmap, - BPoint(slot->bitmap_left,pt.y-(slot->bitmap_top-pt.y)), d); - else - BlitMono2RGB32(&slot->bitmap, - BPoint(slot->bitmap_left,pt.y-(slot->bitmap_top-pt.y)), d); - } - else - printf("Couldn't load character %c\n", string[i]); - - // increment pen position - pen.x+=slot->advance.x; - pen.y+=slot->advance.y; - previous=glyph_index; - } - - // TODO: implement properly - // calculate the invalid rectangle - BRect r; - r.left=MIN(pt.x,pen.x>>6); - r.right=MAX(pt.x,pen.x>>6); - r.top=pt.y-face->height; - r.bottom=pt.y+face->height; - - screenwin->view->Invalidate(r); - screenwin->Unlock(); - - FT_Done_Face(face); -} - -void ViewDriver::BlitMono2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d) -{ - rgb_color color=d->highcolor.GetColor32(); - - // pointers to the top left corner of the area to be copied in each bitmap - uint8 *srcbuffer, *destbuffer; - - // index pointers which are incremented during the course of the blit - uint8 *srcindex, *destindex, *rowptr, value; - - // increment values for the index pointers - int32 srcinc=src->pitch, destinc=framebuffer->BytesPerRow(); - - int16 i,j,k, srcwidth=src->pitch, srcheight=src->rows; - int32 x=(int32)pt.x,y=(int32)pt.y; - - // starting point in source bitmap - srcbuffer=(uint8*)src->buffer; - - if(y<0) - { - if(yframebuffer->Bounds().IntegerHeight()) - { - if(y>pt.y) - y--; - srcheight-=(y+srcheight-1)-framebuffer->Bounds().IntegerHeight(); - } - - if(x+srcwidth>framebuffer->Bounds().IntegerWidth()) - { - if(x>pt.x) - x--; - srcwidth-=(x+srcwidth-1)-framebuffer->Bounds().IntegerWidth(); - } - - if(x<0) - { - if(x>3; - srcwidth-=0-x; - destbuffer+=(0-x)*4; - } - - // starting point in destination bitmap - destbuffer=(uint8*)framebuffer->Bits()+int32( (pt.y*framebuffer->BytesPerRow())+(pt.x*4) ); - - srcindex=srcbuffer; - destindex=destbuffer; - - for(i=0; ihighcolor.GetColor32(), lowcolor=d->lowcolor.GetColor32(); float rstep,gstep,bstep,astep; - - rstep=float(highcolor.red-lowcolor.red)/255.0; - gstep=float(highcolor.green-lowcolor.green)/255.0; - bstep=float(highcolor.blue-lowcolor.blue)/255.0; - astep=float(highcolor.alpha-lowcolor.alpha)/255.0; - - // increment values for the index pointers - int32 x=(int32)pt.x, - y=(int32)pt.y, - srcinc=src->pitch, -// destinc=dest->BytesPerRow(), - destinc=framebuffer->BytesPerRow(), - srcwidth=src->width, - srcheight=src->rows, - incval=0; - - int16 i,j; - - // starting point in source bitmap - srcbuffer=(uint8*)src->buffer; - - // starting point in destination bitmap -// destbuffer=(uint8*)dest->Bits()+(y*dest->BytesPerRow()+(x*4)); - destbuffer=(uint8*)framebuffer->Bits()+(y*framebuffer->BytesPerRow()+(x*4)); - - - if(y<0) - { - if(yframebuffer->Bounds().IntegerHeight()) - { - if(y>pt.y) - y--; - srcheight-=(y+srcheight-1)-framebuffer->Bounds().IntegerHeight(); - } - - if(x+srcwidth>framebuffer->Bounds().IntegerWidth()) - { - if(x>pt.x) - x--; - srcwidth-=(x+srcwidth-1)-framebuffer->Bounds().IntegerWidth(); - } - - if(x<0) - { - if(xdraw_mode==B_OP_COPY) - { - rowptr[0]=uint8(highcolor.blue-(value*bstep)); - rowptr[1]=uint8(highcolor.green-(value*gstep)); - rowptr[2]=uint8(highcolor.red-(value*rstep)); - rowptr[3]=255; - } - else - if(d->draw_mode==B_OP_OVER) - { - if(highcolor.alpha>127) - { - rowptr[0]=uint8(highcolor.blue-(value*(float(highcolor.blue-rowptr[0])/255.0))); - rowptr[1]=uint8(highcolor.green-(value*(float(highcolor.green-rowptr[1])/255.0))); - rowptr[2]=uint8(highcolor.red-(value*(float(highcolor.red-rowptr[2])/255.0))); - rowptr[3]=255; - } - } - } - rowptr+=4; - - } - - srcindex+=srcinc; - destindex+=destinc; - } -} - -rgb_color ViewDriver::GetBlitColor(rgb_color src, rgb_color dest, LayerData *d, bool use_high=true) -{ - rgb_color returncolor={0,0,0,0}; - int16 value; - if(!d) - return returncolor; - - switch(d->draw_mode) - { - case B_OP_COPY: - { - return src; - } - case B_OP_ADD: - { - value=src.red+dest.red; - returncolor.red=(value>255)?255:value; - - value=src.green+dest.green; - returncolor.green=(value>255)?255:value; - - value=src.blue+dest.blue; - returncolor.blue=(value>255)?255:value; - return returncolor; - } - case B_OP_SUBTRACT: - { - value=src.red-dest.red; - returncolor.red=(value<0)?0:value; - - value=src.green-dest.green; - returncolor.green=(value<0)?0:value; - - value=src.blue-dest.blue; - returncolor.blue=(value<0)?0:value; - return returncolor; - } - case B_OP_BLEND: - { - value=int16(src.red+dest.red)>>1; - returncolor.red=value; - - value=int16(src.green+dest.green)>>1; - returncolor.green=value; - - value=int16(src.blue+dest.blue)>>1; - returncolor.blue=value; - return returncolor; - } - case B_OP_MIN: - { - - return ( uint16(src.red+src.blue+src.green) > - uint16(dest.red+dest.blue+dest.green) )?dest:src; - } - case B_OP_MAX: - { - return ( uint16(src.red+src.blue+src.green) < - uint16(dest.red+dest.blue+dest.green) )?dest:src; - } - case B_OP_OVER: - { - return (use_high && src.alpha>127)?src:dest; - } - case B_OP_INVERT: - { - returncolor.red=dest.red ^ 255; - returncolor.green=dest.green ^ 255; - returncolor.blue=dest.blue ^ 255; - return (use_high && src.alpha>127)?returncolor:dest; - } - // This is a pain in the arse to implement, so I'm saving it for the real - // server - case B_OP_ALPHA: - { - return src; - } - case B_OP_ERASE: - { - // This one's tricky. - return (use_high && src.alpha>127)?d->lowcolor.GetColor32():dest; - } - case B_OP_SELECT: - { - // This one's tricky, too. We are passed a color in src. If it's the layer's - // high color or low color, we check for a swap. - if(d->highcolor==src) - return (use_high && d->highcolor==dest)?d->lowcolor.GetColor32():dest; - - if(d->lowcolor==src) - return (use_high && d->lowcolor==dest)?d->highcolor.GetColor32():dest; - - return dest; - } - default: - { - break; - } - } - return returncolor; -} diff --git a/src/servers/app/proto7/ViewDriver.h b/src/servers/app/proto7/ViewDriver.h deleted file mode 100644 index 4d5b7186ed..0000000000 --- a/src/servers/app/proto7/ViewDriver.h +++ /dev/null @@ -1,126 +0,0 @@ -#ifndef _VIEWDRIVER_H_ -#define _VIEWDRIVER_H_ - -#include -#include -#include -#include -#include // for pattern struct -#include -#include -#include -#include -#include "DisplayDriver.h" -#include -#include FT_FREETYPE_H - -class BBitmap; -class PortLink; -class VDWindow; -class LayerData; - -class VDView : public BView -{ -public: - VDView(BRect bounds); - ~VDView(void); - void AttachedToWindow(void); - void Draw(BRect rect); - void MouseDown(BPoint pt); - void MouseMoved(BPoint pt, uint32 transit, const BMessage *msg); - void MouseUp(BPoint pt); - - BBitmap *viewbmp; - PortLink *serverlink; - - int hide_cursor; - BBitmap *cursor; - - BRect cursorframe, oldcursorframe; - bool obscure_cursor; -}; - -class VDWindow : public BWindow -{ -public: - VDWindow(void); - ~VDWindow(void); - void MessageReceived(BMessage *msg); - bool QuitRequested(void); - void WindowActivated(bool active); - - VDView *view; -}; - -class ViewDriver : public DisplayDriver -{ -public: - ViewDriver(void); - ~ViewDriver(void); - - bool Initialize(void); // Sets the driver - void Shutdown(void); // You never know when you'll need this - - // Drawing functions - void CopyBits(BRect src, BRect dest); - void DrawBitmap(ServerBitmap *bmp, BRect src, BRect dest); - void DrawChar(char c, BPoint pt, LayerData *d); -// virtual void DrawPicture(SPicture *pic, BPoint pt); - void DrawString(const char *string, int32 length, BPoint pt, LayerData *d, escapement_delta *delta=NULL); - - void FillArc(BRect r, float angle, float span, LayerData *d, int8 *pat); - void FillBezier(BPoint *pts, LayerData *d, int8 *pat); - void FillEllipse(BRect r, LayerData *d, int8 *pat); - void FillPolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat); - void FillRect(BRect r, LayerData *d, int8 *pat); - void FillRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// void FillShape(SShape *sh, LayerData *d, int8 *pat); - void FillTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); - - void HideCursor(void); - void InvertRect(BRect r); - bool IsCursorHidden(void); - void MoveCursorTo(float x, float y); -// void MovePenTo(BPoint pt); - void ObscureCursor(void); -// BPoint PenPosition(void); -// float PenSize(void); - void SetCursor(ServerBitmap *cursor, const BPoint &spot); -// drawing_mode GetDrawingMode(void); -// void SetDrawingMode(drawing_mode mode); - void ShowCursor(void); - - void StrokeArc(BRect r, float angle, float span, LayerData *d, int8 *pat); - void StrokeBezier(BPoint *pts, LayerData *d, int8 *pat); - void StrokeEllipse(BRect r, LayerData *d, int8 *pat); - void StrokeLine(BPoint start, BPoint end, LayerData *d, int8 *pat); - void StrokeLineArray(BPoint *pts, int32 numlines, RGBColor *colors, LayerData *d); - void StrokePolygon(BPoint *ptlist, int32 numpts, BRect rect, LayerData *d, int8 *pat, bool is_closed=true); - void StrokeRect(BRect r, LayerData *d, int8 *pat); - void StrokeRoundRect(BRect r, float xrad, float yrad, LayerData *d, int8 *pat); -// void StrokeShape(SShape *sh, LayerData *d, int8 *pat); - void StrokeTriangle(BPoint *pts, BRect r, LayerData *d, int8 *pat); - void SetMode(int32 mode); - float StringWidth(const char *string, int32 length, LayerData *d); - float StringHeight(const char *string, int32 length, LayerData *d); -// bool DumpToFile(const char *path); - VDWindow *screenwin; -protected: - void SetLayerData(LayerData *d, bool set_font_data=false); - void BlitMono2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d); - void BlitGray2RGB32(FT_Bitmap *src, BPoint pt, LayerData *d); - rgb_color GetBlitColor(rgb_color src, rgb_color dest, LayerData *d, bool use_high=true); - int hide_cursor; - bool obscure_cursor; - BBitmap *framebuffer; - BView *drawview; - BRegion laregion; - - PortLink *serverlink; -// drawing_mode drawmode; - - rgb_color highcolor,lowcolor; - bool is_initialized; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/WindowBorder.cpp b/src/servers/app/proto7/WindowBorder.cpp deleted file mode 100644 index c23d753f5e..0000000000 --- a/src/servers/app/proto7/WindowBorder.cpp +++ /dev/null @@ -1,405 +0,0 @@ -#include -#include -#include -#include -#include -#include "View.h" // for mouse button defines -#include "ServerWindow.h" -#include "Decorator.h" -#include "DisplayDriver.h" -#include "Desktop.h" -#include "WindowBorder.h" - -#define DEBUG_WINBORDER - -#ifdef DEBUG_WINBORDER -#include -#endif - -bool is_moving_window=false; -bool is_resizing_window=false; -bool is_sliding_tab=false; -extern ServerWindow *active_serverwindow; - -WindowBorder::WindowBorder(ServerWindow *win, const char *bordertitle) - : Layer((win==NULL)?BRect(0,0,1,1):win->frame, - (win==NULL)?NULL:win->title->String()) -{ -#ifdef DEBUG_WINBORDER -printf("WindowBorder(%p, %s)\n",win,bordertitle); -#endif - mbuttons=0; - swin=win; - if(swin) - frame=swin->frame; - - mousepos.Set(0,0); - update=false; - - title=new BString(bordertitle); - hresizewin=false; - vresizewin=false; -} - -WindowBorder::~WindowBorder(void) -{ -#ifdef DEBUG_WINBORDER -printf("~WindowBorder()\n"); -#endif - delete title; -} - -void WindowBorder::MouseDown(BPoint pt, int32 buttons, int32 modifiers) -{ - mbuttons=buttons; - kmodifiers=modifiers; - click_type click=decor->Clicked(pt, mbuttons, kmodifiers); - mousepos=pt; - - switch(click) - { - case CLICK_MOVETOBACK: - { - MoveToBack(); - break; - } - case CLICK_MOVETOFRONT: - { - MoveToFront(); - break; - } - case CLICK_CLOSE: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): SetClose\n"); -#endif - decor->SetClose(true); - decor->Draw(); - break; - } - case CLICK_ZOOM: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): SetZoom\n"); -#endif - decor->SetZoom(true); - decor->Draw(); - break; - } - case CLICK_MINIMIZE: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): SetMinimize\n"); -#endif - decor->SetMinimize(true); - decor->Draw(); - break; - } - case CLICK_DRAG: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): Click Tab\n"); -#endif - if(buttons==B_PRIMARY_MOUSE_BUTTON) - { - is_moving_window=true; - } - if(buttons==B_SECONDARY_MOUSE_BUTTON) - MoveToBack(); - break; - } - case CLICK_SLIDETAB: - { - is_sliding_tab=true; - break; - } - case CLICK_RESIZE: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): Click Resize\n"); -#endif - if(buttons==B_PRIMARY_MOUSE_BUTTON) - { - is_resizing_window=true; - } - break; - } - case CLICK_NONE: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): Click None\n"); -#endif - break; - } - default: - { -#ifdef DEBUG_WINBORDER -printf("WindowBorder()::MouseDown: Undefined click type\n"); -#endif - break; - } - } - if(click!=CLICK_NONE) - ActivateWindow(swin); -} - -void WindowBorder::MouseMoved(BPoint pt, int32 buttons, int32 modifiers) -{ - mbuttons=buttons; - kmodifiers=modifiers; - click_type click=decor->Clicked(pt, mbuttons, kmodifiers); - if(click!=CLICK_CLOSE && decor->GetClose()) - { - decor->SetClose(false); - decor->Draw(); - } - - if(click!=CLICK_ZOOM && decor->GetZoom()) - { - decor->SetZoom(false); - decor->Draw(); - } - - if(click!=CLICK_MINIMIZE && decor->GetMinimize()) - { - decor->SetMinimize(false); - decor->Draw(); - } - - if(is_sliding_tab) - { - float dx=pt.x-mousepos.x; - - if(dx!=0) - { - // SlideTab returns how much things were moved, and currently - // supports just the x direction, so get the value so - // we can invalidate the proper area. - layerlock->Lock(); - parent->Invalidate(decor->SlideTab(dx,0)); - parent->RequestDraw(); - decor->DrawTab(); - layerlock->Unlock(); - } - } - if(is_moving_window) - { - float dx=pt.x-mousepos.x, - dy=pt.y-mousepos.y; - if(dx!=0 || dy!=0) - { - BRect oldmoveframe=swin->frame; - clientframe.OffsetBy(pt); - - swin->Lock(); - swin->frame.OffsetBy(dx,dy); - swin->Unlock(); - - layerlock->Lock(); -// InvalidateLowerSiblings(oldmoveframe); - parent->Invalidate(oldmoveframe); - MoveBy(dx,dy); - parent->RequestDraw(); - decor->MoveBy(BPoint(dx, dy)); - decor->Draw(); - layerlock->Unlock(); - } - } - if(is_resizing_window) - { - float dx=pt.x-mousepos.x, - dy=pt.y-mousepos.y; - if(dx!=0 || dy!=0) - { - clientframe.right+=dx; - clientframe.bottom+=dy; - - swin->Lock(); - swin->frame.right+=dx; - swin->frame.bottom+=dy; - swin->Unlock(); - - layerlock->Lock(); - ResizeBy(dx,dy); - parent->RequestDraw(); - layerlock->Unlock(); - decor->ResizeBy(dx,dy); - decor->Draw(); - } - } - mousepos=pt; -} - -void WindowBorder::MouseUp(BPoint pt, int32 buttons, int32 modifiers) -{ -// mbuttons&= ~buttons; - mbuttons=buttons; - kmodifiers=modifiers; - is_moving_window=false; - is_resizing_window=false; - is_sliding_tab=false; - - click_type click=decor->Clicked(pt, mbuttons, kmodifiers); - - switch(click) - { - case CLICK_CLOSE: - { - decor->SetClose(false); - decor->Draw(); - - // call close window stuff here - - break; - } - case CLICK_ZOOM: - { - decor->SetZoom(false); - decor->Draw(); - - // call zoom stuff here - - break; - } - case CLICK_MINIMIZE: - { - decor->SetMinimize(false); - decor->Draw(); - - // call minimize stuff here - - } - default: - { - break; - } - } -} - -void WindowBorder::Draw(BRect update_rect) -{ -#ifdef DEBUG_WINBORDER -printf("WindowBorder()::Draw():"); update_rect.PrintToStream(); -#endif - - if(update && visible!=NULL) - is_updating=true; - - decor->Draw(update_rect); - - if(update && visible!=NULL) - is_updating=false; -} - -void WindowBorder::SetDecorator(Decorator *newdecor) -{ - // AtheOS kills the decorator here. However, the decor - // under OBOS doesn't belong to the border - it belongs to the - // ServerWindow, so the ServerWindow will handle all (de)allocation - // tasks. We just need to update the pointer. -#ifdef DEBUG_WINBORDER -printf("WindowBorder::SetDecorator(%p)\n",newdecor); -#endif - if(newdecor) - { - decor=newdecor; - decor->SetTitle(title->String()); - decor->ResizeBy(0,0); -// if(visible) -// delete visible; -// visible=decor->GetFootprint(); - } -} - -ServerWindow *WindowBorder::Window(void) const -{ - return swin; -} -void WindowBorder::RequestDraw(void) -{ -//printf("Layer %s::RequestDraw\n",name->String()); - if(invalid) - { -//printf("drew something\n"); -// for(int32 i=0; iCountRects();i++) -// decor->Draw(ConvertToTop(invalid->RectAt(i))); - decor->Draw(); - delete invalid; - invalid=NULL; - is_dirty=false; - } - -} - -void WindowBorder::InvalidateLowerSiblings(BRect r) -{ - // this is used to update the other windows when a window border - // is moved or resized. - Layer *lay; - BRect toprect=ConvertToTop(r); - - for(lay=uppersibling;lay!=NULL;lay=lay->uppersibling) - { - lay->Invalidate(toprect); - lay->RequestDraw(); - } - -} - -void WindowBorder::MoveToBack(void) -{ -#ifdef DEBUG_WINBORDER -printf("WindowBorder(): MoveToBack\n"); -#endif - // Move the window to the back (the top of the tree) - Layer *top=GetRootLayer(); - ASSERT(top!=NULL); - layerlock->Lock(); - top->RemoveChild(this); - top->AddChild(this); - level=1; - swin->SetFocus(false); - decor->SetFocus(false); - decor->Draw(); - - if(uppersibling) - ActivateWindow(uppersibling->serverwin); - layerlock->Unlock(); - parent->RebuildRegions(true); -} - -void WindowBorder::MoveToFront(void) -{ -#ifdef DEBUG_WINBORDER -printf("MoveToFront: \n"); -#endif - // Move the window to the front by making it the bottom - // child of the root layer - Layer *top=GetRootLayer(); - layerlock->Lock(); - - top->RemoveChild(this); - - // Make this the bottom child of the parent layer. Can't use - // AddChild(), so we'll manipulate the pointers directly. Remember, - // we need to change pointers for 4 layers - the parent, the - // uppersibling (if any), the lowersibling, and the layer in question - - // temporary placeholder while we exchange the data - Layer *templayer; - - // tweak parent - templayer=top->bottomchild; - top->bottomchild=this; - - // Tweak this layer - parent=top; - uppersibling=templayer; - if(uppersibling) - uppersibling->lowersibling=this; - lowersibling=NULL; - - layerlock->Unlock(); - is_moving_window=true; - parent->RebuildRegions(true); -} diff --git a/src/servers/app/proto7/WindowBorder.h b/src/servers/app/proto7/WindowBorder.h deleted file mode 100644 index ecdf4390fd..0000000000 --- a/src/servers/app/proto7/WindowBorder.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef _WINBORDER_H_ -#define _WINBORDER_H_ - -#include -#include -#include "Layer.h" - -class ServerWindow; -class Decorator; -class DisplayDriver; - -class WindowBorder : public Layer -{ -public: - WindowBorder(ServerWindow *win, const char *bordertitle); - ~WindowBorder(void); - void MouseDown(BPoint pt, int32 buttons, int32 modifiers); - void MouseMoved(BPoint pt, int32 buttons, int32 modifiers); - void MouseUp(BPoint pt, int32 buttons, int32 modifiers); - void Draw(BRect update); - void SystemColorsUpdated(void); - void SetDecorator(Decorator *newdecor); - ServerWindow *Window(void) const; - void RequestDraw(void); - void MoveToBack(void); - void MoveToFront(void); - void InvalidateLowerSiblings(BRect r); - - ServerWindow *swin; - BString *title; - Decorator *decor; - int32 flags; - BRect frame, clientframe; - int32 mbuttons,kmodifiers; - BPoint mousepos; - bool update; - bool hresizewin,vresizewin; -}; - -extern bool is_moving_window, is_resizing_window; -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/testobapp/ClientFontList.cpp b/src/servers/app/proto7/testobapp/ClientFontList.cpp deleted file mode 100644 index 9c30ad63e6..0000000000 --- a/src/servers/app/proto7/testobapp/ClientFontList.cpp +++ /dev/null @@ -1,368 +0,0 @@ -/* - ClientFontList.cpp: - Maintainer object for the list of font families and styles which is - kept on the client side. -*/ - -#include "ClientFontList.h" -#include -#include -#include -#include -#include -#include -#include "PortLink.h" -#include "ServerProtocol.h" - -#define DEBUG_CLIENT_FONT_LIST - -class FontListFamily -{ -public: - FontListFamily(void); - ~FontListFamily(void); - BString name; - BList *styles; - int32 flags; -}; - -FontListFamily::FontListFamily(void) -{ - styles=new BList(0); - flags=0; -} - -FontListFamily::~FontListFamily(void) -{ - BString *s; - s=(BString*)styles->RemoveItem(0L); - while(s) - { - delete s; - s=(BString*)styles->RemoveItem(0L); - } - delete styles; -} - -ClientFontList::ClientFontList(void) -{ -#ifdef DEBUG_CLIENT_FONT_LIST -printf("ClientFontList()\n"); -#endif - familylist=new BList(0); - fontlock=create_sem(1,"fontlist_sem"); -} - -ClientFontList::~ClientFontList(void) -{ -#ifdef DEBUG_CLIENT_FONT_LIST -printf("~ClientFontList()\n"); -#endif - acquire_sem(fontlock); - - font_family *fam; - while(familylist->ItemAt(0L)!=NULL) - { - fam=(font_family *)familylist->RemoveItem(0L); - delete fam; - } - familylist->MakeEmpty(); - delete familylist; - delete_sem(fontlock); -} - -bool ClientFontList::Update(bool check_only) -{ -#ifdef DEBUG_CLIENT_FONT_LIST -printf("ClientFontList::Update(%s) - %s\n", (check_only)?"true":"false",SERVER_FONT_LIST); -#endif - // Open the font list kept in font list - acquire_sem(fontlock); - - // We're going to ask the server whether the list has changed - port_id serverport; - serverport=find_port(SERVER_PORT_NAME); - - bool needs_update=true; - PortLink *serverlink=new PortLink(serverport); - - if(serverport!=B_NAME_NOT_FOUND) - { - status_t stat; - int32 code; - ssize_t buffersize; - - serverlink->SetOpCode(QUERY_FONTS_CHANGED); - serverlink->FlushWithReply(&code, &stat, &buffersize); - - // Attached Data: none - // Reply: SERVER_TRUE if fonts have changed, SERVER_FALSE if not - - needs_update=(code==SERVER_TRUE)?true:false; - } -#ifdef DEBUG_CLIENT_FONT_LIST - else - { - printf("ClientFontList::Update(): Couldn't find app_server port\n"); - } -#endif - - if(check_only) - { - delete serverlink; - release_sem(fontlock); - return needs_update; - } - - // Don't update the list if nothing has changed - if(needs_update) - { - BFile file(SERVER_FONT_LIST,B_READ_ONLY); - BMessage fontmsg, familymsg; - - if(file.InitCheck()==B_OK) - { - if(fontmsg.Unflatten(&file)==B_OK) - { -#ifdef DEBUG_CLIENT_FONT_LIST -printf("Font message contents:\n"); -fontmsg.PrintToStream(); -#endif - // Empty the font list - FontListFamily *flf=(FontListFamily*)familylist->RemoveItem(0L); - BString sty, extra; - int32 famindex, styindex; - bool tempbool; - - while(flf) - { -#ifdef DEBUG_CLIENT_FONT_LIST -printf("Removing %s from list\n",flf->name.String()); -#endif - delete flf; - flf=(FontListFamily*)familylist->RemoveItem(0L); - } -#ifdef DEBUG_CLIENT_FONT_LIST -printf("\n"); -#endif - - famindex=0; - - // Repopulate with new listings - while(fontmsg.FindMessage("family",famindex,&familymsg)==B_OK) - { - famindex++; - - flf=new FontListFamily(); - familylist->AddItem(flf); - familymsg.FindString("name",&(flf->name)); - -#ifdef DEBUG_CLIENT_FONT_LIST -printf("Adding %s to list\n",flf->name.String()); -#endif - styindex=0; - - // populate family with styles - while(familymsg.FindString("styles",styindex,&sty)==B_OK) - { -#ifdef DEBUG_CLIENT_FONT_LIST -printf("\tAdding %s\n",sty.String()); -#endif - styindex++; - flf->styles->AddItem(new BString(sty)); - } - - if(familymsg.FindBool("tuned",&tempbool)==B_OK) - { -#ifdef DEBUG_CLIENT_FONT_LIST -printf("Family %s has tuned fonts\n", flf->name.String()); -#endif - flf->flags|=B_HAS_TUNED_FONT; - } - - if(familymsg.FindBool("fixed",&tempbool)==B_OK) - { -#ifdef DEBUG_CLIENT_FONT_LIST -printf("Family %s is fixed-width\n", flf->name.String()); -#endif - flf->flags|=B_IS_FIXED; - } - familymsg.MakeEmpty(); - - } - - serverlink->SetOpCode(UPDATED_CLIENT_FONTLIST); - serverlink->Flush(); - - delete serverlink; - release_sem(fontlock); - return false; - - } // end if Unflatten==B_OK - } // end if InitCheck==B_OK - } // end if needs_update - - delete serverlink; - release_sem(fontlock); - return false; -} - -int32 ClientFontList::CountFamilies(void) -{ -#ifdef DEBUG_CLIENT_FONT_LIST -printf("ClientFontList::CountFamilies\n"); -#endif - acquire_sem(fontlock); - int32 count=familylist->CountItems(); - release_sem(fontlock); - return count; -} - -status_t ClientFontList::GetFamily(int32 index, font_family *name, uint32 *flags=NULL) -{ -#ifdef DEBUG_CLIENT_FONT_LIST -printf("ClientFontList::GetFamily(%ld)\n",index); -#endif - if(!name) - { -#ifdef DEBUG_CLIENT_FONT_LIST -printf("ClientFontList::GetFamily: NULL font_family parameter\n"); -#endif - return B_ERROR; - } - - acquire_sem(fontlock); - FontListFamily *flf=(FontListFamily*)familylist->ItemAt(index); - if(!flf) - { -#ifdef DEBUG_CLIENT_FONT_LIST -printf("ClientFontList::GetFamily: index not found\n"); -#endif - return B_ERROR; - } - strcpy(*name,flf->name.String()); - - - release_sem(fontlock); - - return B_OK; -} - -int32 ClientFontList::CountStyles(font_family f) -{ - acquire_sem(fontlock); - - FontListFamily *flf=NULL; - int32 i, count=familylist->CountItems(); - bool found=false; - - for(i=0; iItemAt(i); - if(!flf) - continue; - if(flf->name.ICompare(f)==0) - { - found=true; - break; - } - } - - count=(found)?flf->styles->CountItems():0; - - release_sem(fontlock); - return count; -} - -status_t ClientFontList::GetStyle(font_family family, int32 index, font_style *name,uint32 *flags=NULL, uint16 *face=NULL) -{ - if(!name || !(*name) || !family) - return B_ERROR; - - acquire_sem(fontlock); - - FontListFamily *flf=NULL; - BString *style; - int32 i, count=familylist->CountItems(); - bool found=false; - - for(i=0; iItemAt(i); - if(!flf) - continue; - if(flf->name.ICompare(family)==0) - { - found=true; - break; - } - } - - if(!found) - { - release_sem(fontlock); - return B_ERROR; - } - - style=(BString*)flf->styles->ItemAt(index); - if(!style) - { - release_sem(fontlock); - return B_ERROR; - } - - strcpy(*name,style->String()); - - if(flags) - *flags=flf->flags; - - if(face) - { - if(style->ICompare("Roman")==0 || - style->ICompare("Regular")==0 || - style->ICompare("Normal")==0 || - style->ICompare("Light")==0 || - style->ICompare("Medium")==0 || - style->ICompare("Plain")==0) - { - *face|=B_REGULAR_FACE; -#ifdef DEBUG_FONTSERVER -printf("GetStyle: %s Roman face\n", style->String()); -#endif - } - else - if(style->ICompare("Bold")==0) - { - *face|=B_BOLD_FACE; -#ifdef DEBUG_FONTSERVER -printf("GetStyle: %s Bold face\n"); -#endif - } - else - if(style->ICompare("Italic")==0) - { - *face|=B_ITALIC_FACE; -#ifdef DEBUG_FONTSERVER -printf("GetStyle: %s Italic face\n"); -#endif - } - else - if(style->ICompare("Bold Italic")==0) - { - *face|=B_ITALIC_FACE | B_BOLD_FACE; -#ifdef DEBUG_FONTSERVER -printf("GetStyle: %s Bold Italic face\n"); -#endif - } - else - { -#ifdef DEBUG_FONTSERVER -printf("GetStyle: %s Unknown face %s\n", style->String()); -#endif - } - } - - release_sem(fontlock); - return B_OK; -} - diff --git a/src/servers/app/proto7/testobapp/ClientFontList.h b/src/servers/app/proto7/testobapp/ClientFontList.h deleted file mode 100644 index 0cebce656b..0000000000 --- a/src/servers/app/proto7/testobapp/ClientFontList.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef CLIENT_FONT_LIST_H -#define CLIENT_FONT_LIST_H - -#include // for BFont-related definitions - -#include -#include -#include - -class ClientFontList -{ -public: - ClientFontList(void); - ~ClientFontList(void); - bool Update(bool check_only); - int32 CountFamilies(void); - status_t GetFamily(int32 index, font_family *name, uint32 *flags=NULL); - int32 CountStyles(font_family f); - status_t GetStyle(font_family family, int32 index, font_style *name,uint32 *flags=NULL, uint16 *face=NULL); -private: - BList *familylist; - sem_id fontlock; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/testobapp/DebugTools.cpp b/src/servers/app/proto7/testobapp/DebugTools.cpp deleted file mode 100644 index 0a0c6aed1d..0000000000 --- a/src/servers/app/proto7/testobapp/DebugTools.cpp +++ /dev/null @@ -1,219 +0,0 @@ -#include -#include -#include -#include "DebugTools.h" - -void PrintStatusToStream(status_t value) -{ - // Function which simply translates a returned status code into a string - // and dumps it to stdout - BString outstr; - switch(value) - { - case B_OK: - outstr="B_OK "; - break; - case B_NAME_NOT_FOUND: - outstr="B_NAME_NOT_FOUND "; - break; - case B_BAD_VALUE: - outstr="B_BAD_VALUE "; - break; - case B_ERROR: - outstr="B_ERROR "; - break; - case B_TIMED_OUT: - outstr="B_TIMED_OUT "; - break; - case B_NO_MORE_PORTS: - outstr="B_NO_MORE_PORTS "; - break; - case B_WOULD_BLOCK: - outstr="B_WOULD_BLOCK "; - break; - case B_BAD_PORT_ID: - outstr="B_BAD_PORT_ID "; - break; - case B_BAD_TEAM_ID: - outstr="B_BAD_TEAM_ID "; - break; - default: - outstr="undefined status value in debugtools::PrintStatusToStream() "; - break; - } - cout << "Status: " << outstr.String() << endl << flush; - -} - -void PrintColorSpaceToStream(color_space value) -{ - // Dump a color space to cout - BString outstr; - switch(value) - { - case B_RGB32: - outstr="B_RGB32 "; - break; - case B_RGBA32: - outstr="B_RGBA32 "; - break; - case B_RGB32_BIG: - outstr="B_RGB32_BIG "; - break; - case B_RGBA32_BIG: - outstr=" "; - break; - case B_UVL32: - outstr="B_UVL32 "; - break; - case B_UVLA32: - outstr="B_UVLA32 "; - break; - case B_LAB32: - outstr="B_LAB32 "; - break; - case B_LABA32: - outstr="B_LABA32 "; - break; - case B_HSI32: - outstr="B_HSI32 "; - break; - case B_HSIA32: - outstr="B_HSIA32 "; - break; - case B_HSV32: - outstr="B_HSV32 "; - break; - case B_HSVA32: - outstr="B_HSVA32 "; - break; - case B_HLS32: - outstr="B_HLS32 "; - break; - case B_HLSA32: - outstr="B_HLSA32 "; - break; - case B_CMY32: - outstr="B_CMY32"; - break; - case B_CMYA32: - outstr="B_CMYA32 "; - break; - case B_CMYK32: - outstr="B_CMYK32 "; - break; - case B_RGB24_BIG: - outstr="B_RGB24_BIG "; - break; - case B_RGB24: - outstr="B_RGB24 "; - break; - case B_LAB24: - outstr="B_LAB24 "; - break; - case B_UVL24: - outstr="B_UVL24 "; - break; - case B_HSI24: - outstr="B_HSI24 "; - break; - case B_HSV24: - outstr="B_HSV24 "; - break; - case B_HLS24: - outstr="B_HLS24 "; - break; - case B_CMY24: - outstr="B_CMY24 "; - break; - case B_GRAY1: - outstr="B_GRAY1 "; - break; - case B_CMAP8: - outstr="B_CMAP8 "; - break; - case B_GRAY8: - outstr="B_GRAY8 "; - break; - case B_YUV411: - outstr="B_YUV411 "; - break; - case B_YUV420: - outstr="B_YUV420 "; - break; - case B_YCbCr422: - outstr="B_YCbCr422 "; - break; - case B_YCbCr411: - outstr="B_YCbCr411 "; - break; - case B_YCbCr420: - outstr="B_YCbCr420 "; - break; - case B_YUV422: - outstr="B_YUV422 "; - break; - case B_YUV9: - outstr="B_YUV9 "; - break; - case B_YUV12: - outstr="B_YUV12 "; - break; - case B_RGB15: - outstr="B_RGB15 "; - break; - case B_RGBA15: - outstr="B_RGBA15 "; - break; - case B_RGB16: - outstr="B_RGB16 "; - break; - case B_RGB16_BIG: - outstr="B_RGB16_BIG "; - break; - case B_RGB15_BIG: - outstr="B_RGB15_BIG "; - break; - case B_RGBA15_BIG: - outstr="B_RGBA15_BIG "; - break; - case B_YCbCr444: - outstr="B_YCbCr444 "; - break; - case B_YUV444: - outstr="B_YUV444 "; - break; - case B_NO_COLOR_SPACE: - outstr="B_NO_COLOR_SPACE "; - break; - default: - outstr="Undefined color space "; - break; - } - cout << "Color Space: " << outstr.String() << flush; -} - -void TranslateMessageCodeToStream(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - - cout << "'" - << (char)((code & 0xFF000000) >> 24) - << (char)((code & 0x00FF0000) >> 16) - << (char)((code & 0x0000FF00) >> 8) - << (char)((code & 0x000000FF)) << "' "; -} - -void PrintMessageCode(int32 code) -{ - // Used to translate BMessage message codes back to a character - // format - - printf("Message code %c%c%c%c\n", - (char)((code & 0xFF000000) >> 24), - (char)((code & 0x00FF0000) >> 16), - (char)((code & 0x0000FF00) >> 8), - (char)((code & 0x000000FF)) ); -} - diff --git a/src/servers/app/proto7/testobapp/DebugTools.h b/src/servers/app/proto7/testobapp/DebugTools.h deleted file mode 100644 index 2f45b1ac6c..0000000000 --- a/src/servers/app/proto7/testobapp/DebugTools.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _DEBUGTOOLS_H_ -#define _DEBUGTOOLS_H_ - -#include -#include - -void PrintStatusToStream(status_t value); -void PrintColorSpaceToStream(color_space value); -void TranslateMessageCodeToStream(int32 code); -void PrintMessageCode(int32 code); - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/testobapp/Jamfile b/src/servers/app/proto7/testobapp/Jamfile deleted file mode 100644 index 4df0b13d80..0000000000 --- a/src/servers/app/proto7/testobapp/Jamfile +++ /dev/null @@ -1,13 +0,0 @@ -SubDir OBOS_TOP src servers app proto7 testobapp ; - -App proto7_test_app : - <$(SOURCE_GRIST)>ClientFontList.cpp - <$(SOURCE_GRIST)>DebugTools.cpp - <$(SOURCE_GRIST)>OBApplication.cpp - <$(SOURCE_GRIST)>OBFont.cpp - <$(SOURCE_GRIST)>OBTestApp.cpp - <$(SOURCE_GRIST)>OBView.cpp - <$(SOURCE_GRIST)>OBWindow.cpp - <$(SOURCE_GRIST)>PortLink.cpp -; -LinkSharedOSLibs proto7_test_app : be stdc++.r4 ; diff --git a/src/servers/app/proto7/testobapp/OBApplication.cpp b/src/servers/app/proto7/testobapp/OBApplication.cpp deleted file mode 100644 index 960646ef15..0000000000 --- a/src/servers/app/proto7/testobapp/OBApplication.cpp +++ /dev/null @@ -1,390 +0,0 @@ -/* - OBApplication.cpp: - Beginning framework for a *real* BApplication replacement for the prototypes - -*/ - -#include -#include // for the pattern struct and screen mode defs -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ServerProtocol.h" -#include "PortLink.h" -#include "OBApplication.h" -#include "OBWindow.h" -#include "DebugTools.h" -#include "OBFont.h" - -class OBFont; - -OBApplication *obe_app; - -OBFont *obe_plain_font=NULL; -OBFont *obe_bold_font=NULL; -OBFont *obe_fixed_font=NULL; - -#define DEBUG_OBAPP - -OBApplication::OBApplication(const char *sig) : BApplication(sig) -{ - if(sig) - signature=new BString(sig); - else - signature=new BString("application/x-vnd.obos-OBApplication"); - -#ifdef DEBUG_OBAPP -printf("OBApplication(%s)\n",signature->String()); -#endif - - // A BApplication is locked on start, but because this is not a "real" - // one, we do not actually lock it. - - initcheckval=B_OK; - - // Receives messages from server and others - messageport=create_port(50,"msgport"); - if(messageport==B_BAD_VALUE || messageport==B_NO_MORE_PORTS) - { - printf("OBApplication: Couldn't create message port\n"); - initcheckval=B_ERROR; - } - - // Find the port for the app_server - serverport=find_port("OBappserver"); - if(serverport==B_NAME_NOT_FOUND) - { - printf("OBApplication: Couldn't find server port\n"); - serverlink=NULL; - write_port(messageport,B_QUIT_REQUESTED,NULL,0); - initcheckval=B_ERROR; - } - else - { - serverlink=new PortLink(serverport); -#ifdef DEBUG_OBAPP -printf("OBApplication(%s): App Server Port %ld\n",signature->String(),serverport); -#endif - - // Notify server of app's existence - int32 replycode; - status_t replystat; - ssize_t replysize; - int8 *replybuffer; - - serverlink->SetOpCode(CREATE_APP); - serverlink->Attach(&messageport,sizeof(port_id)); -// serverlink.Attach(PID); - serverlink->Attach((char*)signature->String(),strlen(signature->String())); - - // Send and wait for ServerApp port. Necessary here (as opposed to start - // of message loop) in case any windows are created in application constructor - replybuffer=serverlink->FlushWithReply(&replycode,&replystat,&replysize); - serverport=*((port_id*)replybuffer); - serverlink->SetPort(serverport); - delete replybuffer; -#ifdef DEBUG_OBAPP -printf("OBApplication(%s): ServerApp Port %ld\n",signature->String(),serverport); -#endif - ReadyToRun(); - } - - obe_app=this; - windowlist=new BList(0); -} - -OBApplication::~OBApplication(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::~OBApplication()\n",signature->String()); -#endif - delete signature; - - if(serverlink) - delete serverlink; - -// OBWindow *win; -// for(int32 i=0; iCountItems(); i++) -// { -// win=(OBWindow*)windowlist->RemoveItem(i); -// if(win) -// win->Quit(); -// } - - delete windowlist; -} - -status_t OBApplication::InitCheck(void) const -{ - // Called to make sure everything in the constructor turned out ok. If it didn't, - // the application falls through and the process ends. - return initcheckval; -} - -void OBApplication::MainLoop(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::MainLoop()\n",signature->String()); -#endif - - int32 msgcode; - uint8 *msgbuffer=NULL; - ssize_t buffersize,bytesread; - - for(;;) - { - // Modified this slightly so that OBApplications will eventually time out - // if the server crashes. Saves on a lot of Ctrl-Alt-Del's. :) CPU time is - // saved by setting the timeout to 3 seconds - more than enough time. - if(find_thread("OBAppServer")==B_NAME_NOT_FOUND) - { - printf("%s lost connection with server. Quitting.\n",signature->String()); - break; - } - - buffersize=port_buffer_size_etc(messageport,B_TIMEOUT,300000); - if(buffersize==B_TIMED_OUT) - continue; - - if(buffersize>0) - { - // buffers are flattened messages. Allocate necessary buffer and - // we'll cast it as a BMessage. - msgbuffer=new uint8[buffersize]; - bytesread=read_port(messageport,&msgcode,msgbuffer,buffersize); - } - else - bytesread=read_port(messageport,&msgcode,NULL,0); - - if (bytesread != B_BAD_PORT_ID && bytesread != B_TIMED_OUT && bytesread != B_WOULD_BLOCK) - { - switch(msgcode) - { - case B_QUIT_REQUESTED: - { - // Attached data: - // None -// printf("%s: Quit requested\n",signature); - serverlink->SetOpCode(msgcode); - serverlink->Flush(); - break; - } - case ADDWINDOW: - { - // This message is received by a window's constructor so that it - // can be added to the window list - - // Attached Data: - // 1) OBWindow *window - - // I hope this is the right syntax... - windowlist->AddItem(msgbuffer); - -#ifdef DEBUG_OBAPP -printf("%s: Add Window @ %p\n",signature->String(),msgbuffer); -#endif - break; - } - case REMOVEWINDOW: - { - // This message is received by a window's constructor so that it - // can be added to the window list - - // Attached Data: - // 1) OBWindow *window - - // I hope this is the right syntax... - windowlist->RemoveItem(msgbuffer); -#ifdef DEBUG_OBAPP -printf("%s: Remove Window @ %p\n",signature->String(),msgbuffer); -#endif - break; - } - case B_MOUSE_MOVED: - case B_MOUSE_DOWN: - case B_MOUSE_UP: - DispatchMessage(msgcode, (int8*)msgbuffer); - break; - - // Later on, this will default to passing the message to - // DispatchMessage(BMessage*, BHandler*) - default: - printf("OBApplication received unexpected code %ld - ",msgcode); - PrintMessageCode(msgcode); - break; - } - - if(msgcode==B_QUIT_REQUESTED) - { - printf("Quitting %s\n",signature->String()); - break; - } - } - - if(buffersize>0) - delete msgbuffer; - } -} - -void OBApplication::DispatchMessage(BMessage *msg, BHandler *handler) -{ -#ifdef DEBUG_OBAPP -printf("%s::DispatchMessage(BMessage*,BHandler*)\n",signature->String()); -#endif - BApplication::DispatchMessage(msg,handler); -} - -void OBApplication::DispatchMessage(int32 code, int8 *buffer) -{ - // This function will be necessary to handle server messages. - switch(code) - { - case B_MOUSE_DOWN: - case B_MOUSE_UP: - case B_MOUSE_MOVED: - break; - default: - printf("OBApplication %s received unknown code %ld\n",signature->String(),code); - break; - } -} - -void OBApplication::MessageReceived(BMessage *msg) -{ -#ifdef DEBUG_OBAPP -printf("%s::MessageReceived()\n",signature->String()); -#endif -} - -void OBApplication::ShowCursor(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::ShowCursor()\n",signature->String()); -#endif - serverlink->SetOpCode(SHOW_CURSOR); - serverlink->Flush(); -} - -void OBApplication::HideCursor(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::HideCursor()\n",signature->String()); -#endif - serverlink->SetOpCode(HIDE_CURSOR); - serverlink->Flush(); -} - -void OBApplication::ObscureCursor(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::ObscureCursor()\n",signature->String()); -#endif - serverlink->SetOpCode(OBSCURE_CURSOR); - serverlink->Flush(); -} - -bool OBApplication::IsCursorHidden(void) const -{ - return false; -} - -void OBApplication::SetCursor(const void *cursor) -{ -#ifdef DEBUG_OBAPP -printf("%s::SetCursor()\n",signature->String()); -#endif - // attach & send the 68-byte chunk - serverlink->SetOpCode(SET_CURSOR_DATA); - serverlink->Attach((void*)cursor, 68); - serverlink->Flush(); -} - -thread_id OBApplication::Run(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::Run()\n",signature->String()); -#endif - if(initcheckval==B_OK) - MainLoop(); - - return 0; -} - -status_t OBApplication::Archive(BMessage *data, bool deep = true) const -{ - return B_ERROR; -} - -void OBApplication::Quit(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::Quit()\n",signature->String()); -#endif - OBWindow *win; - while(windowlist->CountItems()>0) - { - win=(OBWindow*)windowlist->RemoveItem(0L); - if(win) - win->Quit(); - } - - BApplication::Quit(); -} - -bool OBApplication::QuitRequested(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::QuitRequested()\n",signature->String()); -#endif - return true; -} - -void OBApplication::Pulse(void) -{ -} - -void OBApplication::ArgvReceived(int32 argc, char **argv) -{ -} - -void OBApplication::AppActivated(bool active) -{ -} - -void OBApplication::RefsReceived(BMessage *a_message) -{ -} - -void OBApplication::AboutRequested(void) -{ -} - -BHandler *OBApplication::ResolveSpecifier(BMessage *msg,int32 index,BMessage *specifier, - int32 form,const char *property) -{ - return NULL; -} - -status_t OBApplication::GetSupportedSuites(BMessage *data) -{ - return B_ERROR; -} - -status_t OBApplication::Perform(perform_code d, void *arg) -{ - return B_ERROR; -} - -void OBApplication::ReadyToRun(void) -{ -#ifdef DEBUG_OBAPP -printf("%s::ReadyToRun()\n",signature->String()); -#endif -} diff --git a/src/servers/app/proto7/testobapp/OBApplication.h b/src/servers/app/proto7/testobapp/OBApplication.h deleted file mode 100644 index 14478ddfba..0000000000 --- a/src/servers/app/proto7/testobapp/OBApplication.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef _OBOS_APPLICATION_H_ -#define _OBOS_APPLICATION_H_ - -#include -#include - -class PortLink; -class BList; -class OBWindow; - -class OBApplication : private BApplication -{ -public: - -OBApplication(const char *signature); -OBApplication(const char *signature, status_t *error); -virtual ~OBApplication(void); - -OBApplication(BMessage *data); -static BArchivable *Instantiate(BMessage *data); -virtual status_t Archive(BMessage *data, bool deep = true) const; - -status_t InitCheck() const; - -virtual thread_id Run(void); -virtual void Quit(void); -virtual bool QuitRequested(void); -virtual void Pulse(void); -virtual void ReadyToRun(void); -virtual void MessageReceived(BMessage *msg); -virtual void ArgvReceived(int32 argc, char **argv); -virtual void AppActivated(bool active); -virtual void RefsReceived(BMessage *a_message); -virtual void AboutRequested(void); - -virtual BHandler *ResolveSpecifier(BMessage *msg,int32 index, -BMessage *specifier,int32 form,const char *property); - -void ShowCursor(void); -void HideCursor(void); -void ObscureCursor(void); -bool IsCursorHidden(void) const; -void SetCursor(const void *cursor); -void SetCursor(const BCursor *cursor, bool sync=true); -int32 CountWindows(void) const; -BWindow *WindowAt(int32 index) const; -int32 CountLoopers(void) const; -BLooper *LooperAt(int32 index) const; -bool IsLaunching(void) const; -status_t GetAppInfo(app_info *info) const; -static BResources *AppResources(void); -virtual void DispatchMessage(BMessage *an_event,BHandler *handler); -void SetPulseRate(bigtime_t rate); -virtual status_t GetSupportedSuites(BMessage *data); -virtual status_t Perform(perform_code d, void *arg); - -protected: -friend OBWindow; - -void MainLoop(void); -void DispatchMessage(int32 code, int8 *buffer); - -port_id messageport, serverport; -BString *signature; -PortLink *serverlink; -BList *windowlist; -status_t initcheckval; -}; - -extern OBApplication *obe_app; -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/testobapp/OBFont.cpp b/src/servers/app/proto7/testobapp/OBFont.cpp deleted file mode 100644 index 2ddf23f994..0000000000 --- a/src/servers/app/proto7/testobapp/OBFont.cpp +++ /dev/null @@ -1,516 +0,0 @@ -#include -#include -#include -#include "ClientFontList.h" -#include "OBFont.h" - -class OBFont; - -extern ClientFontList *client_font_list; - -class OBFontPrivate -{ -public: - OBFontPrivate(void); - OBFontPrivate &operator=(const OBFontPrivate &fontdata); - - BRect fBox; - font_family fFamily; - font_style fStyle; - bool fFixed; - font_file_format fFormat; - font_direction fDirection; - int32 fPrivateFlags; -}; - -OBFontPrivate::OBFontPrivate(void) -{ - fBox=BRect(0,0,0,0); - strcpy(fFamily,"\0"); - strcpy(fStyle,"\0"); - fFixed=false; - fFormat=B_TRUETYPE_WINDOWS; - fDirection=B_FONT_LEFT_TO_RIGHT; - fPrivateFlags=0; -} - -OBFontPrivate & OBFontPrivate::operator=(const OBFontPrivate &fontdata) -{ - fBox=fontdata.fBox; - *fFamily=*(fontdata.fFamily); - *fStyle=*(fontdata.fStyle); - fFixed=fontdata.fFixed; - fFormat=fontdata.fFormat; - fDirection=fontdata.fDirection; - fPrivateFlags=fontdata.fPrivateFlags; - return *this; -} - -OBFont::OBFont(void) -{ - private_data=new OBFontPrivate(); - if(be_plain_font) - { - fFamilyID=obe_plain_font->fFamilyID; - fStyleID=obe_plain_font->fStyleID; - fSize=obe_plain_font->fSize; - fShear=obe_plain_font->fShear; - fRotation=obe_plain_font->fRotation; - fSpacing=obe_plain_font->fSpacing; - fEncoding=obe_plain_font->fEncoding; - fFace=obe_plain_font->fFace; - fHeight=obe_plain_font->fHeight; - private_data=obe_plain_font->private_data; - } - else - { - fFamilyID=0; - fStyleID=0; - fSize=0.0; - fShear=90.0; - fRotation=0.0; - fSpacing=B_CHAR_SPACING; - fEncoding=B_UNICODE_UTF8; - fFace=B_REGULAR_FACE; - fHeight.ascent=0.0; - fHeight.descent=0.0; - fHeight.leading=0.0; - private_data->fPrivateFlags=0; - } -} - -OBFont::OBFont(const OBFont &font) -{ - private_data=new OBFontPrivate(); - fFamilyID=font.fFamilyID; - fStyleID=font.fStyleID; - fSize=font.fSize; - fShear=font.fShear; - fRotation=font.fRotation; - fSpacing=font.fSpacing; - fEncoding=font.fEncoding; - fFace=font.fFace; - fHeight=font.fHeight; - private_data=font.private_data; -} - -OBFont::OBFont(const OBFont *font) -{ - private_data=new OBFontPrivate(); - if(font) - { - fFamilyID=font->fFamilyID; - fStyleID=font->fStyleID; - fSize=font->fSize; - fShear=font->fShear; - fRotation=font->fRotation; - fSpacing=font->fSpacing; - fEncoding=font->fEncoding; - fFace=font->fFace; - fHeight=font->fHeight; - private_data=font->private_data; - } - else - { - if(obe_plain_font) - { - fFamilyID=obe_plain_font->fFamilyID; - fStyleID=obe_plain_font->fStyleID; - fSize=obe_plain_font->fSize; - fShear=obe_plain_font->fShear; - fRotation=obe_plain_font->fRotation; - fSpacing=obe_plain_font->fSpacing; - fEncoding=obe_plain_font->fEncoding; - fFace=obe_plain_font->fFace; - fHeight=obe_plain_font->fHeight; - private_data=obe_plain_font->private_data; - } - else - { - fFamilyID=0; - fStyleID=0; - fSize=0.0; - fShear=90.0; - fRotation=0.0; - fSpacing=B_CHAR_SPACING; - fEncoding=B_UNICODE_UTF8; - fFace=B_REGULAR_FACE; - fHeight.ascent=0.0; - fHeight.descent=0.0; - fHeight.leading=0.0; - private_data->fPrivateFlags=0; - } - } - -} - -OBFont::~OBFont(void) -{ - delete private_data; -} - -status_t OBFont::SetFamilyAndStyle(const font_family family, const font_style style) -{ - // TODO: implement - // TODO: find out what codes are returned by this function. Be Book says this returns nothing - - // Query server for the appropriate family and style IDs and then return the - // appropriate value - return B_ERROR; -} - -void OBFont::SetFamilyAndStyle(uint32 code) -{ - fStyleID=code & 0xFFFF; - fFamilyID=(code & 0xFFFF0000) >> 16; -} - -status_t OBFont::SetFamilyAndFace(const font_family family, uint16 face) -{ - // TODO: find out what codes are returned by this function. Be Book says this returns nothing - fFace=face; - - // TODO: finish this function by adding the app_server Family query protocol code - if(family) - { - // Query server for family id for the specified family - } - - return B_OK; -} - -void OBFont::SetSize(float size) -{ - fSize=size; -} - -void OBFont::SetShear(float shear) -{ - fShear=shear; -} - -void OBFont::SetRotation(float rotation) -{ - fRotation=rotation; -} - -void OBFont::SetSpacing(uint8 spacing) -{ - fSpacing=spacing; -} - -void OBFont::SetEncoding(uint8 encoding) -{ - fEncoding=encoding; -} - -void OBFont::SetFace(uint16 face) -{ - fFace=face; -} - -void OBFont::SetFlags(uint32 flags) -{ - fFlags=flags; -} - -void OBFont::GetFamilyAndStyle(font_family *family, font_style *style) const -{ - if(!family | !style) - return; - - // TODO: implement - - // Query server for the names of this stuff given the family and style IDs kept internally - strcpy((char *)family,private_data->fFamily); - strcpy((char *)style,private_data->fStyle); -} - -uint32 OBFont::FamilyAndStyle(void) const -{ - uint32 token; - token=(fFamilyID << 16) | fStyleID; - return 0L; -} - -float OBFont::Size(void) const -{ - return fSize; -} - -float OBFont::Shear(void) const -{ - return fShear; -} - -float OBFont::Rotation(void) const -{ - return fRotation; -} - -uint8 OBFont::Spacing(void) const -{ - return fSpacing; -} - -uint8 OBFont::Encoding(void) const -{ - return fEncoding; -} - -uint16 OBFont::Face(void) const -{ - return fFace; -} - -uint32 OBFont::Flags(void) const -{ - return fFlags; -} - -font_direction OBFont::Direction(void) const -{ - return B_FONT_LEFT_TO_RIGHT; -} - -bool OBFont::IsFixed(void) const -{ - // TODO: query server for whether this bad boy is fixed-width - - return false; -} - -bool OBFont::IsFullAndHalfFixed(void) const -{ - return false; -} - -BRect OBFont::BoundingBox(void) const -{ - // TODO: query server for bounding box - return BRect(0,0,0,0); -} - -unicode_block OBFont::Blocks(void) const -{ - // TODO: Add Block support - return unicode_block(); -} - -font_file_format OBFont::FileFormat(void) const -{ - // TODO: this will not work until I extend FreeType to handle this kind of call - return B_TRUETYPE_WINDOWS; -} - -int32 OBFont::CountTuned(void) const -{ - // TODO: query server for appropriate data - return 0; -} - -void OBFont::GetTunedInfo(int32 index, tuned_font_info *info) const -{ - // TODO: implement -} - -void OBFont::TruncateString(BString *in_out,uint32 mode,float width) const -{ - // TODO: implement -} - -void OBFont::GetTruncatedStrings(const char *stringArray[], int32 numStrings, - uint32 mode, float width, BString resultArray[]) const -{ - // TODO: implement -} - -void OBFont::GetTruncatedStrings(const char *stringArray[], int32 numStrings, - uint32 mode, float width, char *resultArray[]) const -{ - // TODO: implement -} - -float OBFont::StringWidth(const char *string) const -{ - // TODO: implement - return 0.0; -} - -float OBFont::StringWidth(const char *string, int32 length) const -{ - // TODO: implement - return 0.0; -} - -void OBFont::GetStringWidths(const char *stringArray[], const int32 lengthArray[], - int32 numStrings, float widthArray[]) const -{ - // TODO: implement -} - -void OBFont::GetEscapements(const char charArray[], int32 numChars, float escapementArray[]) const -{ - // TODO: implement -} - -void OBFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta, - float escapementArray[]) const -{ - // TODO: implement -} - -void OBFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta, - BPoint escapementArray[]) const -{ - // TODO: implement -} - -void OBFont::GetEscapements(const char charArray[], int32 numChars, escapement_delta *delta, - BPoint escapementArray[], BPoint offsetArray[]) const -{ - // TODO: implement -} - -void OBFont::GetEdges(const char charArray[], int32 numBytes, edge_info edgeArray[]) const -{ - // TODO: implement -} - -void OBFont::GetHeight(font_height *height) const -{ - if(height) - { - *height=fHeight; - } -} - -void OBFont::GetBoundingBoxesAsGlyphs(const char charArray[], int32 numChars, font_metric_mode mode, - BRect boundingBoxArray[]) const -{ - // TODO: implement -} - -void OBFont::GetBoundingBoxesAsString(const char charArray[], int32 numChars, font_metric_mode mode, - escapement_delta *delta, BRect boundingBoxArray[]) const -{ - // TODO: implement -} - -void OBFont::GetBoundingBoxesForStrings(const char *stringArray[], int32 numStrings, - font_metric_mode mode, escapement_delta deltas[], BRect boundingBoxArray[]) const -{ - // TODO: implement -} - -void OBFont::GetGlyphShapes(const char charArray[], int32 numChars, BShape *glyphShapeArray[]) const -{ - // TODO: implement -} - -void OBFont::GetHasGlyphs(const char charArray[], int32 numChars, bool hasArray[]) const -{ - // TODO: implement -} - -OBFont &OBFont::operator=(const OBFont &font) -{ - fFamilyID=font.fFamilyID; - fStyleID=font.fStyleID; - fSize=font.fSize; - fShear=font.fShear; - fRotation=font.fRotation; - fSpacing=font.fSpacing; - fEncoding=font.fEncoding; - fFace=font.fFace; - fHeight=font.fHeight; - private_data->fPrivateFlags=font.private_data->fPrivateFlags; - return *this; -} - -bool OBFont::operator==(const OBFont &font) const -{ - if( fFamilyID!=font.fFamilyID || - fStyleID!=font.fStyleID || - fSize!=font.fSize || - fShear!=font.fShear || - fRotation!=font.fRotation || - fSpacing!=font.fSpacing || - fEncoding!=font.fEncoding || - fFace!=font.fFace || - fHeight.ascent!=font.fHeight.ascent || - fHeight.descent!=font.fHeight.descent || - fHeight.leading!=font.fHeight.leading || - private_data->fPrivateFlags!=font.private_data->fPrivateFlags ) - return false; - return true; -} - -bool OBFont::operator!=(const OBFont &font) const -{ - if( fFamilyID!=font.fFamilyID || - fStyleID!=font.fStyleID || - fSize!=font.fSize || - fShear!=font.fShear || - fRotation!=font.fRotation || - fSpacing!=font.fSpacing || - fEncoding!=font.fEncoding || - fFace!=font.fFace || - fHeight.ascent!=font.fHeight.ascent || - fHeight.descent!=font.fHeight.descent || - fHeight.leading!=font.fHeight.leading || - private_data->fPrivateFlags!=font.private_data->fPrivateFlags ) - return true; - return false; -} - -void OBFont::PrintToStream(void) const -{ - printf("FAMILY STYLE %f %f %f %f %f %f\n", fSize, fShear, fRotation, fHeight.ascent, - fHeight.descent, fHeight.leading); -} - -int32 ob_count_font_families(void) -{ - return client_font_list->CountFamilies(); -} - -status_t ob_get_font_family(int32 index, font_family *name, uint32 *flags=NULL) -{ - - return client_font_list->GetFamily(index,name,flags); -} - -int32 ob_count_font_styles(font_family name) -{ - return client_font_list->CountStyles(name); -} - -status_t ob_get_font_style(font_family family, int32 index, font_style *name, uint32 *flags=NULL) -{ - return client_font_list->GetStyle(family,index,name,flags); -} - -status_t ob_get_font_style(font_family family, int32 index, font_style *name, - uint16 *face, uint32 *flags=NULL) -{ - return client_font_list->GetStyle(family,index,name,flags,face); -} - -bool ob_update_font_families(bool check_only) -{ - return client_font_list->Update(check_only); -} - -status_t ob_get_font_cache_info(uint32 id, void *set) -{ - // lame duck undocumented function - return B_OK; -} - -status_t ob_set_font_cache_info(uint32 id, void *set) -{ - // lame duck undocumented function - return B_OK; -} - diff --git a/src/servers/app/proto7/testobapp/OBFont.h b/src/servers/app/proto7/testobapp/OBFont.h deleted file mode 100644 index eb1d20f9d0..0000000000 --- a/src/servers/app/proto7/testobapp/OBFont.h +++ /dev/null @@ -1,189 +0,0 @@ -#ifndef OBFONT_H_ -#define OBFONT_H_ - -#include -#include -#include - -#include // for various font structure definitions - -class BShape; -class BString; -class OBFontPrivate; - -class OBFont { -public: - OBFont(void); - OBFont(const OBFont &font); - OBFont(const OBFont *font); - ~OBFont(void); - - status_t SetFamilyAndStyle(const font_family family, - const font_style style); - void SetFamilyAndStyle(uint32 code); - status_t SetFamilyAndFace(const font_family family, uint16 face); - - void SetSize(float size); - void SetShear(float shear); - void SetRotation(float rotation); - void SetSpacing(uint8 spacing); - void SetEncoding(uint8 encoding); - void SetFace(uint16 face); - void SetFlags(uint32 flags); - - void GetFamilyAndStyle(font_family *family, - font_style *style) const; - uint32 FamilyAndStyle(void) const; - float Size(void) const; - float Shear(void) const; - float Rotation(void) const; - uint8 Spacing(void) const; - uint8 Encoding(void) const; - uint16 Face(void) const; - uint32 Flags(void) const; - - font_direction Direction(void) const; - bool IsFixed(void) const; - bool IsFullAndHalfFixed(void) const; - BRect BoundingBox(void) const; - unicode_block Blocks(void) const; - font_file_format FileFormat(void) const; - - int32 CountTuned(void) const; - void GetTunedInfo(int32 index, tuned_font_info *info) const; - - void TruncateString(BString* in_out, - uint32 mode, - float width) const; - void GetTruncatedStrings(const char *stringArray[], - int32 numStrings, - uint32 mode, - float width, - BString resultArray[]) const; - void GetTruncatedStrings(const char *stringArray[], - int32 numStrings, - uint32 mode, - float width, - char *resultArray[]) const; - - float StringWidth(const char *string) const; - float StringWidth(const char *string, int32 length) const; - void GetStringWidths(const char *stringArray[], - const int32 lengthArray[], - int32 numStrings, - float widthArray[]) const; - - void GetEscapements(const char charArray[], - int32 numChars, - float escapementArray[]) const; - void GetEscapements(const char charArray[], - int32 numChars, - escapement_delta *delta, - float escapementArray[]) const; - void GetEscapements(const char charArray[], - int32 numChars, - escapement_delta *delta, - BPoint escapementArray[]) const; - void GetEscapements(const char charArray[], - int32 numChars, - escapement_delta *delta, - BPoint escapementArray[], - BPoint offsetArray[]) const; - - void GetEdges(const char charArray[], - int32 numBytes, - edge_info edgeArray[]) const; - void GetHeight(font_height *height) const; - - void GetBoundingBoxesAsGlyphs(const char charArray[], - int32 numChars, - font_metric_mode mode, - BRect boundingBoxArray[]) const; - void GetBoundingBoxesAsString(const char charArray[], - int32 numChars, - font_metric_mode mode, - escapement_delta *delta, - BRect boundingBoxArray[]) const; - void GetBoundingBoxesForStrings(const char *stringArray[], - int32 numStrings, - font_metric_mode mode, - escapement_delta deltas[], - BRect boundingBoxArray[]) const; - - void GetGlyphShapes(const char charArray[], - int32 numChars, - BShape *glyphShapeArray[]) const; - - void GetHasGlyphs(const char charArray[], - int32 numChars, - bool hasArray[]) const; - - OBFont& operator=(const OBFont &font); - bool operator==(const OBFont &font) const; - bool operator!=(const OBFont &font) const; - - void PrintToStream(void) const; - -private: - uint16 fFamilyID; - uint16 fStyleID; - float fSize; - float fShear; - float fRotation; - uint8 fSpacing; - uint8 fEncoding; - uint16 fFace; - uint32 fFlags; - font_height fHeight; - OBFontPrivate *private_data; - uint32 _reserved[2]; - - void SetPacket(void *packet) const; - void GetTruncatedStrings64(const char *stringArray[], - int32 numStrings, - uint32 mode, - float width, - char *resultArray[]) const; - void GetTruncatedStrings64(const char *stringArray[], - int32 numStrings, - uint32 mode, - float width, - BString resultArray[]) const; - void _GetEscapements_(const char charArray[], - int32 numChars, - escapement_delta *delta, - uint8 mode, - float *escapements, - float *offsets = NULL) const; - void _GetBoundingBoxes_(const char charArray[], - int32 numChars, - font_metric_mode mode, - bool string_escapement, - escapement_delta *delta, - BRect boundingBoxArray[]) const; -}; - -/*----------------------------------------------------------------*/ -/*----- OBFont related declarations -------------------------------*/ - -//extern const OBFont *obe_plain_font; -//extern const OBFont *obe_bold_font; -//extern const OBFont *obe_fixed_font; -extern OBFont *obe_plain_font; -extern OBFont *obe_bold_font; -extern OBFont *obe_fixed_font; - -int32 ob_count_font_families(void); -status_t ob_get_font_family(int32 index, font_family *name, uint32 *flags=NULL); - -int32 ob_count_font_styles(font_family name); -status_t ob_get_font_style(font_family family, int32 index, font_style *name, - uint32 *flags=NULL); -status_t ob_get_font_style(font_family family, int32 index, font_style *name, - uint16 *face, uint32 *flags=NULL); -bool ob_update_font_families(bool check_only); - -status_t ob_get_font_cache_info(uint32 id, void *set); -status_t ob_set_font_cache_info(uint32 id, void *set); - -#endif diff --git a/src/servers/app/proto7/testobapp/OBTestApp.cpp b/src/servers/app/proto7/testobapp/OBTestApp.cpp deleted file mode 100644 index f080c86559..0000000000 --- a/src/servers/app/proto7/testobapp/OBTestApp.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "OBApplication.h" -#include "OBWindow.h" -#include "OBView.h" -#include "ClientFontList.h" - -ClientFontList *client_font_list; - -class OBTestApp : public OBApplication -{ -public: - OBTestApp(void); - ~OBTestApp(void); -}; - -OBWindow *win; - -OBTestApp::OBTestApp(void) : OBApplication("application/OBTestApp") -{ - win=new OBWindow(BRect(100,100,200,200), "OBWindow1",B_FLOATING_WINDOW_LOOK, - B_NORMAL_WINDOW_FEEL,0); - win->Show(); - -} - -OBTestApp::~OBTestApp(void) -{ -} - -int main(void) -{ - client_font_list=new ClientFontList(); - client_font_list->Update(false); - - OBTestApp *app=new OBTestApp(); - app->Run(); - delete app; - - delete client_font_list; -} diff --git a/src/servers/app/proto7/testobapp/OBView.cpp b/src/servers/app/proto7/testobapp/OBView.cpp deleted file mode 100644 index 8412aefb9a..0000000000 --- a/src/servers/app/proto7/testobapp/OBView.cpp +++ /dev/null @@ -1,880 +0,0 @@ -#include -#include -#include "PortLink.h" -#include "ServerProtocol.h" -#include "OBView.h" -#include "OBWindow.h" - -//#define DEBUG_VIEW - -#ifndef SET_RGB_COLOR - #define SET_RGB_COLOR(a,b,c,d,e) a.red=b; a.green=c; a.blue=d; a.alpha=e; -#endif - -OBView::OBView(BRect frame,const char *name,uint32 resizeMask,uint32 flags) - : BHandler(name) -{ - viewflags=flags; - resizeflags=resizeMask; - origin_h=0.0; - origin_v=0.0; - - owner=NULL; - parent=NULL; - uppersibling=NULL; - lowersibling=NULL; - topchild=NULL; - bottomchild=NULL; - hidelevel=0; - - // This will be changed when added to a BWindow as the top view - topview=false; - - SET_RGB_COLOR(highcol,0,0,0,255); - SET_RGB_COLOR(lowcol,255,255,255,255); - SET_RGB_COLOR(viewcol,255,255,255,255); - - // We need to align to the nearest pixel, rounded down - // There's probably a better way to do this, but it'll work for now... - vframe.left=(int32)frame.left; - vframe.top=(int32)frame.top; - vframe.right=(int32)frame.right; - vframe.bottom=(int32)frame.bottom; -} - -OBView::~OBView() -{ - // Be Book says it's an error to delete while attached to a window. - // We'll just prevent that problem... - if(owner) - { - // No, this isn't an error to utilize parent and not owner. We - // aren't actually attached to the window class itself. We're - // attached to a view which is a member of the window. - parent->RemoveChild(this); - } - - - OBView *v; - for(v=topchild; v!=NULL; v=v->lowersibling) - delete v; -} - -void OBView::AttachedToWindow() -{ - // Hook function -} - -void OBView::AllAttached() -{ - // Hook function -} - -void OBView::DetachedFromWindow() -{ - // Hook function -} - -void OBView::AllDetached() -{ - // Hook function -} - -void OBView::MessageReceived(BMessage *msg) -{ - // Adds scripting support to the BHandler version. This is - // only a skeleton implementation, so it has been skipped - BHandler::MessageReceived(msg); -} - -void OBView::AddChild(OBView *child, OBView *before = NULL) -{ - if(!child) - return; - if(child->parent || child->owner) - { - printf("%s::AddChild(): child already has a parent\n",Name()); - return; - } - if(child->parent==this) - { - printf("%s::AddChild(): child already belongs to view\n",Name()); - return; - } - - // Adds a layer to the top of the layer's children -#ifdef DEBUG_VIEW - printf("%s::AddChild(%s)\n", Name(), child->Name()); -#endif - - child->parent=this; - child->owner=owner; - - // View specified. Add new child above the specified view - if(before) - { - if(before->parent==this) - { - child->lowersibling=before; - child->uppersibling=before->uppersibling; - before->uppersibling->lowersibling=child; - before->uppersibling=child; - - // If we're attached to a window, notify all child views of - // their attachment - if(owner) - { - CallAttached(child); - child->AllAttached(); - } - - } - else - { - printf("%s::AddChild(): Can't add %s before %s - different parents\n", - Name(), child->Name(), before->Name()); - } - return; - } - - // If we haven't specified, child is added to bottom of list - if(bottomchild!=NULL) - { - child->uppersibling=bottomchild; - bottomchild->lowersibling=child; - } - bottomchild=child; - -} - -bool OBView::RemoveChild(OBView *child) -{ - if(!child) - return false; - - if(child->parent!=this) - { - printf("%s::RemoveChild(): %s not child of this view\n",Name(),child->Name()); - return false; - } - - // Adds a layer to the top of the layer's children -#ifdef DEBUG_VIEW - printf("%s::RemoveChild(%s)\n", Name(), child->Name()); -#endif - - if(owner) - { - CallDetached(child); - - // We only need to tell the server to prune the layer tree - // at the child's level - PortLink *link=new PortLink(owner->outport); - link->SetOpCode(LAYER_DELETE); - link->Attach(child->id); - link->Flush(); - delete link; - } - - // Note that we do the pointer reassignments last because the other - // function calls made in RemoveChild() depend on these pointers - if(topchild==child) - topchild=child->lowersibling; - if(bottomchild==child) - bottomchild=child->lowersibling; - - if(child->uppersibling!=NULL) - child->uppersibling->lowersibling=child->lowersibling; - if(child->lowersibling!=NULL) - child->lowersibling->uppersibling=child->uppersibling; - - child->parent=NULL; - child->owner=NULL; - child->lowersibling=NULL; - child->uppersibling=NULL; - return true; -} - -bool OBView::RemoveSelf() -{ - return false; -} - -int32 OBView::CountChildren() const -{ - OBView *v=topchild; - int32 children=0; - - while(v!=NULL) - { - v=v->lowersibling; - children++; - } - - return children; -} - -OBView *OBView::ChildAt(int32 index) const -{ - // We're using a tree, so traverse the tree - OBView *v=topchild; - - for(int32 i=0;ilowersibling; - } - - return v; -} - -OBView *OBView::NextSibling() const -{ - return lowersibling; -} - -OBView *OBView::PreviousSibling() const -{ - return uppersibling; -} - -OBWindow *OBView::Window() const -{ - return owner; -} - -void OBView::Draw(BRect updateRect) -{ -} - -void OBView::MouseDown(BPoint where) -{ - // Hook function -} - -void OBView::MouseUp(BPoint where) -{ - // Hook function -} - -void OBView::MouseMoved(BPoint where,uint32 code,const BMessage *a_message) -{ - // Hook function -} - -void OBView::WindowActivated(bool state) -{ - // Hook function -} - -void OBView::KeyDown(const char *bytes, int32 numBytes) -{ - // Hook function -} - -void OBView::KeyUp(const char *bytes, int32 numBytes) -{ - // Hook function -} - -void OBView::Pulse() -{ - // Hook function -} - -void OBView::FrameMoved(BPoint new_position) -{ - // Hook function -} - -void OBView::FrameResized(float new_width, float new_height) -{ - // Hook function -} - -void OBView::TargetedByScrollView(BScrollView *scroll_view) -{ - // Hook function -} - -void OBView::BeginRectTracking(BRect startRect,uint32 style = B_TRACK_WHOLE_RECT) -{ - if(!owner) - { - printf("BeginRectTracking(): view must be attached to a window\n"); - return; - } - owner->serverlink->SetOpCode(BEGIN_RECT_TRACKING); - owner->serverlink->Attach(&startRect, sizeof(BRect)); - owner->serverlink->Attach(&style, sizeof(uint32)); - owner->serverlink->Flush(); -} - -void OBView::EndRectTracking(void) -{ - if(!owner) - { - printf("EndRectTracking(): view must be attached to a window\n"); - return; - } - owner->serverlink->SetOpCode(END_RECT_TRACKING); - owner->serverlink->Flush(); -} - -void OBView::GetMouse(BPoint *location, uint32 *buttons, - bool checkMessageQueue=true) -{ -} - -OBView *OBView::FindView(const char *name) -{ - OBView *v; - v=FindViewInChildren(name); - - return v; -} - -OBView *OBView::Parent() const -{ - return parent; -} - -BRect OBView::Bounds() const -{ - BRect rframe=vframe; - rframe.OffsetTo(0,0); - return rframe; -} - -BRect OBView::Frame() const -{ - return vframe; -} - -void OBView::ConvertToScreen(BPoint* pt) const -{ -} - -BPoint OBView::ConvertToScreen(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBView::ConvertFromScreen(BPoint* pt) const -{ -} - -BPoint OBView::ConvertFromScreen(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBView::ConvertToScreen(BRect *r) const -{ -} - -BRect OBView::ConvertToScreen(BRect r) const -{ - return BRect(0,0,0,0); -} - -void OBView::ConvertFromScreen(BRect *r) const -{ -} - -BRect OBView::ConvertFromScreen(BRect r) const -{ - return BRect(0,0,0,0); -} - -void OBView::ConvertToParent(BPoint *pt) const -{ -} - -BPoint OBView::ConvertToParent(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBView::ConvertFromParent(BPoint *pt) const -{ -} - -BPoint OBView::ConvertFromParent(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBView::ConvertToParent(BRect *r) const -{ -} - -BRect OBView::ConvertToParent(BRect r) const -{ - return BRect(0,0,0,0); -} - -void OBView::ConvertFromParent(BRect *r) const -{ -} - -BRect OBView::ConvertFromParent(BRect r) const -{ - return BRect(0,0,0,0); -} - -BPoint OBView::LeftTop() const -{ - return BPoint(-1,-1); -} - -void OBView::GetClippingRegion(BRegion *region) const -{ -} - -void OBView::ConstrainClippingRegion(BRegion *region) -{ -} - -void OBView::SetDrawingMode(drawing_mode mode) -{ -} - -drawing_mode OBView::DrawingMode() const -{ - return B_OP_COPY; -} - -void OBView::SetBlendingMode(source_alpha srcAlpha, alpha_function alphaFunc) -{ -} - -void OBView::GetBlendingMode(source_alpha *srcAlpha, alpha_function *alphaFunc) const -{ -} - -void OBView::SetPenSize(float size) -{ -} - -float OBView::PenSize() const -{ - return 0.0; -} - -void OBView::SetViewColor(rgb_color c) -{ - SET_RGB_COLOR(viewcol,c.red,c.green,c.blue,c.alpha); - owner->drawmsglink->Attach((int32)GFX_SET_VIEW_COLOR); - owner->drawmsglink->Attach((int8)c.red); - owner->drawmsglink->Attach((int8)c.green); - owner->drawmsglink->Attach((int8)c.blue); - owner->drawmsglink->Attach((int8)c.alpha); -} - -void OBView::SetViewColor(uchar r, uchar g, uchar b, uchar a=255) -{ - SET_RGB_COLOR(viewcol,r,g,b,a); - owner->drawmsglink->Attach((int32)GFX_SET_VIEW_COLOR); - owner->drawmsglink->Attach((int8)r); - owner->drawmsglink->Attach((int8)g); - owner->drawmsglink->Attach((int8)b); - owner->drawmsglink->Attach((int8)a); -} - -rgb_color OBView::ViewColor() const -{ - return viewcol; -} - -void OBView::SetHighColor(rgb_color c) -{ - SET_RGB_COLOR(highcol,c.red,c.green,c.blue,c.alpha); - owner->drawmsglink->Attach((int32)GFX_SET_HIGH_COLOR); - owner->drawmsglink->Attach((int8)c.red); - owner->drawmsglink->Attach((int8)c.green); - owner->drawmsglink->Attach((int8)c.blue); - owner->drawmsglink->Attach((int8)c.alpha); -} - -void OBView::SetHighColor(uchar r, uchar g, uchar b, uchar a=255) -{ - SET_RGB_COLOR(highcol,r,g,b,a); - owner->drawmsglink->Attach((int32)GFX_SET_HIGH_COLOR); - owner->drawmsglink->Attach((int8)r); - owner->drawmsglink->Attach((int8)g); - owner->drawmsglink->Attach((int8)b); - owner->drawmsglink->Attach((int8)a); -} - -rgb_color OBView::HighColor() const -{ - return highcol; -} - -void OBView::SetLowColor(rgb_color c) -{ - SET_RGB_COLOR(lowcol,c.red,c.green,c.blue,c.alpha); - owner->drawmsglink->Attach((int32)GFX_SET_LOW_COLOR); - owner->drawmsglink->Attach((int8)c.red); - owner->drawmsglink->Attach((int8)c.green); - owner->drawmsglink->Attach((int8)c.blue); - owner->drawmsglink->Attach((int8)c.alpha); -} - -void OBView::SetLowColor(uchar r, uchar g, uchar b, uchar a=255) -{ - SET_RGB_COLOR(lowcol,r,g,b,a); - owner->drawmsglink->Attach((int32)GFX_SET_LOW_COLOR); - owner->drawmsglink->Attach((int8)r); - owner->drawmsglink->Attach((int8)g); - owner->drawmsglink->Attach((int8)b); - owner->drawmsglink->Attach((int8)a); -} - -rgb_color OBView::LowColor() const -{ - return lowcol; -} - -void OBView::SetFont(const OBFont *font, uint32 mask = B_FONT_ALL) -{ -} - -void OBView::GetFont(OBFont *font) const -{ -} - -void OBView::Invalidate(BRect invalRect) -{ - if(!owner) - { - printf("Invalidate(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach(invalRect); -} - -void OBView::Invalidate(const BRegion *invalRegion) -{ - // undocumented function -} - -void OBView::Invalidate() -{ - if(!owner) - { - printf("Invalidate(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach(Bounds()); -} - -void OBView::SetFlags(uint32 flags) -{ -} - -uint32 OBView::Flags() const -{ - return viewflags; -} - -void OBView::SetResizingMode(uint32 mode) -{ -} - -uint32 OBView::ResizingMode() const -{ - return resizeflags; -} - -void OBView::MoveBy(float dh, float dv) -{ -} - -void OBView::MoveTo(BPoint where) -{ -} - -void OBView::MoveTo(float x, float y) -{ -} - -void OBView::ResizeBy(float dh, float dv) -{ -} - -void OBView::ResizeTo(float width, float height) -{ -} - -void OBView::MakeFocus(bool focusState = true) -{ -} - -bool OBView::IsFocus() const -{ - return has_focus; -} - -void OBView::Show() -{ - hidelevel--; - - for(OBView *v=topchild; v!=NULL; v=v->lowersibling ) - v->Show(); -} - -void OBView::Hide() -{ - hidelevel++; - - for(OBView *v=topchild; v!=NULL; v=v->lowersibling ) - v->Show(); -} - -bool OBView::IsHidden() const -{ - return (hidelevel>0)?true:false; -} - -bool OBView::IsHidden(const OBView* looking_from) const -{ - // undocumented function - return false; -} - -void OBView::Flush() const -{ - // When attachment count inclusion is implemented, it needs to go - // in this function - - owner->drawmsglink->SetOpCode(GFX_FLUSH); - owner->drawmsglink->Flush(); -} - -void OBView::Sync() const -{ - // When attachment count inclusion is implemented, it needs to go - // in this function - - int32 code; - status_t status; - ssize_t buffersize; - - owner->drawmsglink->SetOpCode(GFX_SYNC); - - // Reply received: - - // Code: SYNC - // Attached data: none - // Buffersize: 0 - owner->drawmsglink->FlushWithReply(&code,&status,&buffersize); -} - -void OBView::StrokeRect(BRect r, pattern p=B_SOLID_HIGH) -{ - if(!owner) - { - printf("StrokeRect(): view must be attached to a window\n"); - return; - } - - owner->drawmsglink->Attach((int32)GFX_STROKE_RECT); - owner->drawmsglink->Attach(r); - owner->drawmsglink->Attach(&p, sizeof(pattern)); -} - -void OBView::FillRect(BRect r, pattern p=B_SOLID_HIGH) -{ - if(!owner) - { - printf("FillRect(): view must be attached to a window\n"); - return; - } - - owner->drawmsglink->Attach((int32)GFX_FILL_RECT); - owner->drawmsglink->Attach(r); - owner->drawmsglink->Attach(&p, sizeof(pattern)); -} - -void OBView::MovePenTo(BPoint pt) -{ - if(!owner) - { - printf("MovePenTo(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach((int32)GFX_MOVEPENTO); - owner->drawmsglink->Attach(pt); -} - -void OBView::MovePenTo(float x, float y) -{ - if(!owner) - { - printf("MovePenTo(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach((int32)GFX_MOVEPENTO); - owner->drawmsglink->Attach(BPoint(x,y)); -} - -void OBView::MovePenBy(float x, float y) -{ - if(!owner) - { - printf("MovePenBy(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach((int32)GFX_MOVEPENBY); - owner->drawmsglink->Attach(x); - owner->drawmsglink->Attach(y); -} - -BPoint OBView::PenLocation() const -{ - return BPoint(0,0); -} - -void OBView::StrokeLine(BPoint toPt,pattern p=B_SOLID_HIGH) -{ - if(!owner) - { - printf("StrokeLine(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach((int32)GFX_STROKE_LINE); - owner->drawmsglink->Attach(toPt); - owner->drawmsglink->Attach((pattern *)&p, sizeof(pattern)); -} - -void OBView::StrokeLine(BPoint pt0,BPoint pt1,pattern p=B_SOLID_HIGH) -{ - if(!owner) - { - printf("StrokeLine(): view must be attached to a window\n"); - return; - } - owner->drawmsglink->Attach((int32)GFX_MOVEPENTO); - owner->drawmsglink->Attach(pt0); - - owner->drawmsglink->Attach((int32)GFX_STROKE_LINE); - owner->drawmsglink->Attach(pt1); - owner->drawmsglink->Attach((pattern *)&p, sizeof(pattern)); -} - -// Protected members - -int32 OBView::GetServerToken(void) -{ - // Function which asks the app_server for an ID value - // NOTE that it requires an owner - - if(!owner) - { - printf("GetServerToken(): view must be attached to a window\n"); - return -1; - } - - int32 code; - status_t status; - ssize_t buffersize; - int32 *buffer; - - owner->serverlink->SetOpCode(VIEW_GET_TOKEN); - - // Reply received: - - // Code: GET_VIEW_TOKEN - // Attached data: - // 1) int32 view ID - buffer=(int32*)owner->drawmsglink->FlushWithReply(&code,&status,&buffersize); - id=*buffer; - - // necessary because each reply allocates memory from the heap for - // the returned buffer - delete buffer; - - return id; -} - -void OBView::CallAttached(OBView *view) -{ - // Recursively calls AttachedToWindow() for all children of the view - AddedToWindow(); - AttachedToWindow(); - - for(OBView *v=topchild; v!=NULL; v=v->lowersibling) - { - if(v->topchild) - CallAttached(v->topchild); - } -} - -void OBView::CallDetached(OBView *view) -{ - // Recursively calls DetachedFromWindow() for all children of the view - DetachedFromWindow(); - - for(OBView *v=topchild; v!=NULL; v=v->lowersibling) - { - if(v->topchild) - CallDetached(v->topchild); - } -} - -void OBView::AddedToWindow(void) -{ - // Hook function called during AddChild to take care of setup in server - // of adding a bunch of views at once, not just one - - // Theoretically, shouldn't be needed, but this is here in case I do - // something really stupid. ;) - if(!owner) - return; - - // If we're finally attached to a window, then the child needs to become - // known to the server - - // Create View message. Layers are app_server's view counterparts - - // Attach Data: - // 1) (int32) id of the parent view - // 2) (int32) id of the child view - // 3) (BRect) frame in parent's coordinates - // 4) (int32) resize flags - // 5) (int32) view flags - // 6) (uint16) view's hide level - id=GetServerToken(); - - PortLink *link=new PortLink(owner->outport); - link->SetOpCode(LAYER_CREATE); - link->Attach(parent->id); - link->Attach(id); - link->Attach(vframe); - link->Attach((int32)resizeflags); - link->Attach((int32)viewflags); - link->Attach(&hidelevel,sizeof(uint16)); - link->Flush(); - delete link; -} - -OBView *OBView::FindViewInChildren(const char *name) -{ - // Looks in all children of a view and returns the first view - // with a matching name. - - // Process: - // 1) Search this view's children starting with topchild - // 2) If not found, cycle through them again, this second time - // recursively searching each child. - // 3) If the view is found in the first child search, assign the ** - // and return the *. - // 4) If the view is found in the second child search, break out of the - // search loop by assigning and returning the * - // 5) If we complete the loop, it means that the view was not found. - // We should, thus, return NULL - return NULL; -} diff --git a/src/servers/app/proto7/testobapp/OBView.h b/src/servers/app/proto7/testobapp/OBView.h deleted file mode 100644 index 79aec4dfb2..0000000000 --- a/src/servers/app/proto7/testobapp/OBView.h +++ /dev/null @@ -1,172 +0,0 @@ -#ifndef _OBVIEW_H_ -#define _OBVIEW_H_ - -#include -#include -#include -#include -#include -#include - -class BMessage; -class BString; -class BWindow; -class OBWindow; -class OBFont; - -class OBView : public BHandler -{ -public: -OBView( BRect frame,const char *name,uint32 resizeMask,uint32 flags); -virtual ~OBView(); - -virtual void AttachedToWindow(); -virtual void AllAttached(); -virtual void DetachedFromWindow(); -virtual void AllDetached(); - -virtual void MessageReceived(BMessage *msg); - -void AddChild(OBView *child, OBView *before = NULL); -bool RemoveChild(OBView *child); -bool RemoveSelf(); -int32 CountChildren() const; -OBView *ChildAt(int32 index) const; -OBView *NextSibling() const; -OBView *PreviousSibling() const; - -OBWindow *Window() const; - -virtual void Draw(BRect updateRect); -virtual void MouseDown(BPoint where); -virtual void MouseUp(BPoint where); -virtual void MouseMoved( BPoint where,uint32 code,const BMessage *a_message); -virtual void WindowActivated(bool state); -virtual void KeyDown(const char *bytes, int32 numBytes); -virtual void KeyUp(const char *bytes, int32 numBytes); -virtual void Pulse(); -virtual void FrameMoved(BPoint new_position); -virtual void FrameResized(float new_width, float new_height); - -virtual void TargetedByScrollView(BScrollView *scroll_view); -void BeginRectTracking( BRect startRect,uint32 style = B_TRACK_WHOLE_RECT); -void EndRectTracking(); - -void GetMouse(BPoint *location,uint32 *buttons,bool checkMessageQueue=true); - -OBView *FindView(const char *name); -OBView *Parent() const; -BRect Bounds() const; -BRect Frame() const; -void ConvertToScreen(BPoint* pt) const; -BPoint ConvertToScreen(BPoint pt) const; -void ConvertFromScreen(BPoint* pt) const; -BPoint ConvertFromScreen(BPoint pt) const; -void ConvertToScreen(BRect *r) const; -BRect ConvertToScreen(BRect r) const; -void ConvertFromScreen(BRect *r) const; -BRect ConvertFromScreen(BRect r) const; -void ConvertToParent(BPoint *pt) const; -BPoint ConvertToParent(BPoint pt) const; -void ConvertFromParent(BPoint *pt) const; -BPoint ConvertFromParent(BPoint pt) const; -void ConvertToParent(BRect *r) const; -BRect ConvertToParent(BRect r) const; -void ConvertFromParent(BRect *r) const; -BRect ConvertFromParent(BRect r) const; -BPoint LeftTop() const; - -void GetClippingRegion(BRegion *region) const; -virtual void ConstrainClippingRegion(BRegion *region); - -virtual void SetDrawingMode(drawing_mode mode); -drawing_mode DrawingMode() const; - -void SetBlendingMode(source_alpha srcAlpha, alpha_function alphaFunc); -void GetBlendingMode(source_alpha *srcAlpha, alpha_function *alphaFunc) const; - -virtual void SetPenSize(float size); -float PenSize() const; - -virtual void SetViewColor(rgb_color c); -void SetViewColor(uchar r, uchar g, uchar b, uchar a = 255); -rgb_color ViewColor() const; - -virtual void SetHighColor(rgb_color a_color); -void SetHighColor(uchar r, uchar g, uchar b, uchar a = 255); -rgb_color HighColor() const; - -virtual void SetLowColor(rgb_color a_color); -void SetLowColor(uchar r, uchar g, uchar b, uchar a = 255); -rgb_color LowColor() const; - -virtual void SetFont(const OBFont *font, uint32 mask = B_FONT_ALL); -void GetFont(OBFont *font) const; - -void Invalidate(BRect invalRect); -void Invalidate(const BRegion *invalRegion); -void Invalidate(); - -virtual void SetFlags(uint32 flags); -uint32 Flags() const; -virtual void SetResizingMode(uint32 mode); -uint32 ResizingMode() const; -void MoveBy(float dh, float dv); -void MoveTo(BPoint where); -void MoveTo(float x, float y); -void ResizeBy(float dh, float dv); -void ResizeTo(float width, float height); -virtual void MakeFocus(bool focusState = true); -bool IsFocus() const; - -virtual void Show(); -virtual void Hide(); -bool IsHidden() const; -bool IsHidden(const OBView* looking_from) const; - -void Flush() const; -void Sync() const; - -void StrokeRect(BRect r, pattern p = B_SOLID_HIGH); -void FillRect(BRect r, pattern p = B_SOLID_HIGH); -void MovePenTo(BPoint pt); -void MovePenTo(float x, float y); -void MovePenBy(float x, float y); -BPoint PenLocation() const; -void StrokeLine( BPoint toPt,pattern p = B_SOLID_HIGH); -void StrokeLine( BPoint pt0,BPoint pt1,pattern p = B_SOLID_HIGH); - -protected: - friend OBWindow; - -int32 GetServerToken(void); -void CallAttached(OBView *view); -void CallDetached(OBView *view); -OBView *FindViewInChildren(const char *name); -void AddedToWindow(void); - -int32 id; -uint32 viewflags, resizeflags; -float origin_h; -float origin_v; -OBWindow* owner; - -OBView* parent; -OBView* uppersibling; -OBView* lowersibling; -OBView* topchild; -OBView* bottomchild; - -uint16 hidelevel; -bool topview; -bool has_focus; - -BRect vframe; -BRegion *clipregion; - -rgb_color highcol; -rgb_color lowcol; -rgb_color viewcol; -}; - -#endif diff --git a/src/servers/app/proto7/testobapp/OBWindow.cpp b/src/servers/app/proto7/testobapp/OBWindow.cpp deleted file mode 100644 index 71f48a506d..0000000000 --- a/src/servers/app/proto7/testobapp/OBWindow.cpp +++ /dev/null @@ -1,526 +0,0 @@ -#include -#include -#include -#include "OBApplication.h" -#include "OBView.h" -#include "OBWindow.h" -#include "ServerProtocol.h" -#include "PortLink.h" - -#define DEBUG_OBWINDOW - -OBWindow::OBWindow(BRect frame,const char *title, window_type type, -uint32 flags,uint32 workspace = B_CURRENT_WORKSPACE) -{ -} - -OBWindow::OBWindow(BRect frame,const char *title, window_look look,window_feel feel, -uint32 flags,uint32 workspace = B_CURRENT_WORKSPACE) -{ -#ifdef DEBUG_OBWINDOW -printf("OBWindow(%s)\n",title); -#endif - Lock(); - - // Window starts hidden by default - hidelevel=1; - - wframe=frame; - wlook=look; - wfeel=feel; - wflags=flags; - wkspace=workspace; - - wtitle=new BString(title); - - // Receives messages from server and others - inport=create_port(50,"msgport"); - if(inport==B_BAD_VALUE || inport==B_NO_MORE_PORTS) - printf("OBWindow: Couldn't create message port\n"); - - // Notify BApplication that we exist - OBWindow *win=this; - PortLink *link=new PortLink(obe_app->messageport); - link->SetOpCode(ADDWINDOW); - link->Attach(&win,sizeof(OBWindow*)); - link->Flush(); - delete link; - - // we set this flag because the window starts locked. When Show() is - // called it will unlock the looper and show the window - startlocked=true; - - // We create our serverlink utilizing our application's server port - // because the server's ServerApp will handle window creation - serverlink=new PortLink(obe_app->serverport); - - // make sure that the server port is valid. It will == B_NAME_NOT_FOUND if the - // OBApplication couldn't find the server - - if(obe_app->serverport!=B_NAME_NOT_FOUND) - { - // Notify server of window's existence - serverlink->SetOpCode(CREATE_WINDOW); - serverlink->Attach(wframe); - serverlink->Attach((int32)WindowLookToInteger(wlook)); - serverlink->Attach((int32)WindowFeelToInteger(wfeel)); - serverlink->Attach((int32)wflags); - serverlink->Attach(&inport,sizeof(port_id)); - serverlink->Attach((int32)wkspace); - //We add one so that the string will end up NULL-terminated. Otherwise, when - // we go to use the thing in the app_server, it will sometimes get junk - // characters at the end. - serverlink->Attach((char*)wtitle->String(),wtitle->CountChars()+1); - - // Send and wait for ServerWindow port. Necessary here so we can respond to - // messages as soon as Show() is called. - - int32 replycode; - status_t replystat; - ssize_t replysize; - int8 *replybuffer; - - replybuffer=serverlink->FlushWithReply(&replycode,&replystat,&replysize); - outport=*((port_id*)replybuffer); - serverlink->SetPort(outport); - delete replybuffer; - -#ifdef DEBUG_OBWINDOW -printf("OBWindow(%s): ServerWindow Port %ld\n",wtitle->String(),outport); -#endif - - // Create and attach the top view - top_view=new OBView(wframe.OffsetToCopy(0,0),"top_view",B_FOLLOW_ALL, B_WILL_DRAW); - top_view->owner=this; - top_view->topview=true; - } - else - PostMessage(B_QUIT_REQUESTED); -} - -OBWindow::~OBWindow() -{ -#ifdef DEBUG_OBWINDOW -printf("~OBWindow(%s)\n",wtitle->String()); -#endif - // delete all children. How? OBView recursively deletes its children - delete top_view; - - delete wtitle; - delete serverlink; - delete drawmsglink; - -} - -void OBWindow::Quit() -{ -#ifdef DEBUG_OBWINDOW -printf("%s::Quit()\n",wtitle->String()); -#endif - // I hope this works. If it doesn't, we'll need to do a synchronous msg - OBWindow *win=this; - PortLink *link=new PortLink(obe_app->messageport); - link->SetOpCode(REMOVEWINDOW); - link->Attach(&win,sizeof(OBWindow *)); - link->Flush(); - delete link; - - // Server will need to be notified of window destruction - serverlink->SetOpCode(DELETE_WINDOW); - serverlink->Attach(&ID,sizeof(int32)); - serverlink->Flush(); - - // Quit our looper and delete our self :) - Quit(); -} - -void OBWindow::Close() -{ - Quit(); -} - -void OBWindow::AddChild(OBView *child, OBView *before = NULL) -{ -#ifdef DEBUG_OBWINDOW -printf("%s::AddChild()\n",wtitle->String()); -#endif - top_view->AddChild(child,before); -} - -bool OBWindow::RemoveChild(OBView *child) -{ -#ifdef DEBUG_OBWINDOW -printf("%s::RemoveChild()\n",wtitle->String()); -#endif - return top_view->RemoveChild(child); -} - -int32 OBWindow::CountChildren() const -{ - return top_view->CountChildren(); -} - -OBView *OBWindow::ChildAt(int32 index) const -{ - return top_view->ChildAt(index); -} - -void OBWindow::DispatchMessage(BMessage *message, BHandler *handler) -{ -} - -void OBWindow::MessageReceived(BMessage *message) -{ - // Not sure right now what needs to be handled. - switch(message->what) - { - default: - BLooper::MessageReceived(message); - } -} - -void OBWindow::FrameMoved(BPoint new_position) -{ -} - -void OBWindow::WorkspacesChanged(uint32 old_ws, uint32 new_ws) -{ -} - -void OBWindow::WorkspaceActivated(int32 ws, bool state) -{ -} - -void OBWindow::FrameResized(float new_width, float new_height) -{ -} - -void OBWindow::Minimize(bool minimize) -{ -} - -void OBWindow::Zoom(BPoint rec_position,float rec_width,float rec_height) -{ -} - -void OBWindow::Zoom() -{ -} - -void OBWindow::ScreenChanged(BRect screen_size, color_space depth) -{ -} - -bool OBWindow::NeedsUpdate() const -{ - return false; -} - -void OBWindow::UpdateIfNeeded() -{ -} - -OBView *OBWindow::FindView(const char *view_name) const -{ - return top_view->FindView(view_name); -} - -OBView *OBWindow::FindView(BPoint) const -{ - return NULL; -} - -OBView *OBWindow::CurrentFocus() const -{ - return focusedview; -} - -void OBWindow::Activate(bool=true) -{ -} - -void OBWindow::WindowActivated(bool state) -{ -} - -void OBWindow::ConvertToScreen(BPoint *pt) const -{ -} - -BPoint OBWindow::ConvertToScreen(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBWindow::ConvertFromScreen(BPoint *pt) const -{ -} - -BPoint OBWindow::ConvertFromScreen(BPoint pt) const -{ - return BPoint(-1,-1); -} - -void OBWindow::ConvertToScreen(BRect *rect) const -{ -} - -BRect OBWindow::ConvertToScreen(BRect rect) const -{ - return BRect(0,0,0,0); -} - -void OBWindow::ConvertFromScreen(BRect *rect) const -{ -} - -BRect OBWindow::ConvertFromScreen(BRect rect) const -{ - return BRect(0,0,0,0); -} - -void OBWindow::MoveBy(float dx, float dy) -{ -} - -void OBWindow::MoveTo(BPoint) -{ -} - -void OBWindow::MoveTo(float x, float y) -{ -} - -void OBWindow::ResizeBy(float dx, float dy) -{ -} - -void OBWindow::ResizeTo(float width, float height) -{ -} - -void OBWindow::Show() -{ - if(startlocked) - { - startlocked=false; - Unlock(); - } - hidelevel--; - if(hidelevel==0) - { - serverlink->SetOpCode(SHOW_WINDOW); - serverlink->Flush(); - } -} - -void OBWindow::Hide() -{ - if(hidelevel==0) - { - serverlink->SetOpCode(HIDE_WINDOW); - serverlink->Flush(); - } - hidelevel++; -} - -bool OBWindow::IsHidden() const -{ - return false; -} - -bool OBWindow::IsMinimized() const -{ - return false; -} - -void OBWindow::Flush() const -{ - // When attachment count inclusion is implemented, it needs to go - // in this function - - drawmsglink->SetOpCode(GFX_FLUSH); - drawmsglink->Flush(); -} - -void OBWindow::Sync() const -{ - // When attachment count inclusion is implemented, it needs to go - // in this function - - int32 code; - status_t status; - ssize_t buffersize; - - drawmsglink->SetOpCode(GFX_SYNC); - - // Reply received: - - // Code: SYNC - // Attached data: none - // Buffersize: 0 - drawmsglink->FlushWithReply(&code,&status,&buffersize); -} - -status_t OBWindow::SendBehind(const OBWindow *window) -{ - return B_ERROR; -} - -void OBWindow::DisableUpdates() -{ -} - -void OBWindow::EnableUpdates() -{ -} - -void OBWindow::BeginViewTransaction() -{ -} - -void OBWindow::EndViewTransaction() -{ -} - -BRect OBWindow::Bounds() const -{ - return BRect(0,0,0,0); -} - -BRect OBWindow::Frame() const -{ - return BRect(0,0,0,0); -} - -const char *OBWindow::Title() const -{ - return NULL; -} - -void OBWindow::SetTitle(const char *title) -{ -} - -bool OBWindow::IsFront() const -{ - return false; -} - -bool OBWindow::IsActive() const -{ - return false; -} - -uint32 OBWindow::Workspaces() const -{ - return 0; -} - -void OBWindow::SetWorkspaces(uint32) -{ -} - -OBView *OBWindow::LastMouseMovedView() const -{ - return NULL; -} - -status_t OBWindow::AddToSubset(OBWindow *window) -{ - return B_ERROR; -} - -status_t OBWindow::RemoveFromSubset(OBWindow *window) -{ - return B_ERROR; -} - -bool OBWindow::QuitRequested() -{ - return false; -} - -thread_id OBWindow::Run() -{ - return 0; -} - -uint32 OBWindow::WindowLookToInteger(window_look wl) -{ - switch(wl) - { - case B_BORDERED_WINDOW_LOOK: - return 1; - case B_TITLED_WINDOW_LOOK: - return 2; - case B_DOCUMENT_WINDOW_LOOK: - return 3; - case B_MODAL_WINDOW_LOOK: - return 4; - case B_FLOATING_WINDOW_LOOK: - return 5; - case B_NO_BORDER_WINDOW_LOOK: - default: - return 0; - } -} - -uint32 OBWindow::WindowFeelToInteger(window_feel wf) -{ - switch(wf) - { - case B_MODAL_SUBSET_WINDOW_FEEL: - return 1; - case B_MODAL_APP_WINDOW_FEEL: - return 2; - case B_MODAL_ALL_WINDOW_FEEL: - return 3; - case B_FLOATING_SUBSET_WINDOW_FEEL: - return 4; - case B_FLOATING_APP_WINDOW_FEEL: - return 5; - case B_FLOATING_ALL_WINDOW_FEEL: - return 6; - - case B_NORMAL_WINDOW_FEEL: - default: - return 0; - } -} - -window_look OBWindow::WindowLookFromType(window_type t) -{ - switch(t) - { - case B_TITLED_WINDOW: - return B_TITLED_WINDOW_LOOK; - case B_DOCUMENT_WINDOW: - return B_DOCUMENT_WINDOW_LOOK; - case B_MODAL_WINDOW: - return B_MODAL_WINDOW_LOOK; - case B_FLOATING_WINDOW: - return B_FLOATING_WINDOW_LOOK; - case B_BORDERED_WINDOW: - return B_BORDERED_WINDOW_LOOK; - case B_UNTYPED_WINDOW: - default: - return B_NO_BORDER_WINDOW_LOOK; - } -} - -window_feel OBWindow::WindowFeelFromType(window_type t) -{ - switch(t) - { - case B_MODAL_WINDOW: - return B_MODAL_APP_WINDOW_FEEL; - case B_FLOATING_WINDOW: - return B_FLOATING_APP_WINDOW_FEEL; - - // includes B_UNTYPED_WINDOW, B_BORDERED_WINDOW, B_DOCUMENT_WINDOW, - // and B_TITLED_WINDOW - default: - return B_NORMAL_WINDOW_FEEL; - } -} diff --git a/src/servers/app/proto7/testobapp/OBWindow.h b/src/servers/app/proto7/testobapp/OBWindow.h deleted file mode 100644 index 1a13dd9660..0000000000 --- a/src/servers/app/proto7/testobapp/OBWindow.h +++ /dev/null @@ -1,145 +0,0 @@ -#ifndef _OBWINDOW_H -#define _OBWINDOW_H - -#include -#include -#include -#include -#include -#include -#include -#include - -class BButton; -class BMenuBar; -class BMenuItem; -class BMessage; -class BMessageRunner; -class BMessenger; -class OBView; -class PortLink; - -struct message; -struct _cmd_key_; -struct _view_attr_; - -#define ADDWINDOW '_adw' -#define REMOVEWINDOW '_rmw' - -class OBWindow : public BLooper -{ -public: -OBWindow(BRect frame,const char *title, window_type type, -uint32 flags,uint32 workspace = B_CURRENT_WORKSPACE); - -OBWindow(BRect frame,const char *title, window_look look,window_feel feel, -uint32 flags,uint32 workspace = B_CURRENT_WORKSPACE); - -virtual ~OBWindow(); - -virtual void Quit(); -void Close(); - -void AddChild(OBView *child, OBView *before = NULL); -bool RemoveChild(OBView *child); -int32 CountChildren() const; -OBView *ChildAt(int32 index) const; - -virtual void DispatchMessage(BMessage *message, BHandler *handler); -virtual void MessageReceived(BMessage *message); -virtual void FrameMoved(BPoint new_position); -virtual void WorkspacesChanged(uint32 old_ws, uint32 new_ws); -virtual void WorkspaceActivated(int32 ws, bool state); -virtual void FrameResized(float new_width, float new_height); -virtual void Minimize(bool minimize); -virtual void Zoom( BPoint rec_position, - float rec_width, - float rec_height); -void Zoom(); -virtual void ScreenChanged(BRect screen_size, color_space depth); -bool NeedsUpdate() const; -void UpdateIfNeeded(); -OBView *FindView(const char *view_name) const; -OBView *FindView(BPoint) const; -OBView *CurrentFocus() const; -void Activate(bool = true); -virtual void WindowActivated(bool state); -void ConvertToScreen(BPoint *pt) const; -BPoint ConvertToScreen(BPoint pt) const; -void ConvertFromScreen(BPoint *pt) const; -BPoint ConvertFromScreen(BPoint pt) const; -void ConvertToScreen(BRect *rect) const; -BRect ConvertToScreen(BRect rect) const; -void ConvertFromScreen(BRect *rect) const; -BRect ConvertFromScreen(BRect rect) const; -void MoveBy(float dx, float dy); -void MoveTo(BPoint); -void MoveTo(float x, float y); -void ResizeBy(float dx, float dy); -void ResizeTo(float width, float height); -virtual void Show(); -virtual void Hide(); -bool IsHidden() const; -bool IsMinimized() const; - -void Flush() const; -void Sync() const; - -status_t SendBehind(const OBWindow *window); - -void DisableUpdates(); -void EnableUpdates(); - -void BeginViewTransaction(); -void EndViewTransaction(); - -BRect Bounds() const; -BRect Frame() const; -const char *Title() const; -void SetTitle(const char *title); -bool IsFront() const; -bool IsActive() const; -uint32 Workspaces() const; -void SetWorkspaces(uint32); -OBView *LastMouseMovedView() const; - - -status_t AddToSubset(OBWindow *window); -status_t RemoveFromSubset(OBWindow *window); - -virtual bool QuitRequested(); -virtual thread_id Run(); - -protected: -friend OBView; - -uint32 WindowLookToInteger(window_look wl); -uint32 WindowFeelToInteger(window_feel wf); -window_look WindowLookFromType(window_type t); -window_feel WindowFeelFromType(window_type t); - -BString *wtitle; -int32 ID; -int32 topview_ID; -uint8 hidelevel; -uint32 wflags; - -PortLink *drawmsglink, *serverlink; -port_id inport; -port_id outport; - -OBView *top_view; -OBView *focusedview; -OBView *fLastMouseMovedView; -BRect wframe; - -window_look wlook; -window_feel wfeel; - -bool startlocked; -bool in_update; -bool is_active; -int32 wkspace; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/testobapp/PortLink.cpp b/src/servers/app/proto7/testobapp/PortLink.cpp deleted file mode 100644 index 8fba724569..0000000000 --- a/src/servers/app/proto7/testobapp/PortLink.cpp +++ /dev/null @@ -1,438 +0,0 @@ -/* - PortLink.cpp: - A helper class for port-based messaging - ------------------------------------------------------------------------- -How it works: - The class utilizes a fixed-size array of PortLinkData object pointers. When -data is attached, a new PortLinkData object is allocated and a copy of the -passed data is created inside it. When the time comes for the message to be sent, -the data is pieced together into a flattened array and written to the port. ------------------------------------------------------------------------- -Data members: - -*attachments[] - fixed-size array of pointers used to hold the attached data -opcode - message value which is sent along with any data -target - port to which the message is sent when Flush() is called -replyport - port used with synchronous messaging - FlushWithReply() -bufferlength - total bytes taken up by attachments -num_attachments - internal variable which is used to track which "slot" - will be the next one to receive an attachment object -*/ - -#include "PortLink.h" -#include -#include -#include - -//#define PLDEBUG - -// Internal data storage class for holding attached data whilst it is waiting -// to be Flattened() and then Flushed(). There is no need for this to be called outside -// the PortLink class. -class PortLinkData -{ -public: - PortLinkData(void); - ~PortLinkData(void); - bool Set(void *data, size_t size); - char *buffer; - size_t buffersize; -}; - -PortLink::PortLink(port_id port) -{ - // For this class to be useful (and to prevent a lot of init problems) - // we require a port in the constructor - target=port; - - // We start out without any data attached to the port message - num_attachments=0; - opcode=0; - bufferlength=0; - replyport=create_port(30,"PortLink reply port"); -} - -PortLink::~PortLink(void) -{ - // If, for some odd reason, this is deleted with something attached, - // free the memory used by the attachments. We do not flush the queue - // because the port may no longer be valid in cases such as the app - // is in the process of quitting - MakeEmpty(); -} - -void PortLink::SetOpCode(int32 code) -{ - // Sets the message code. This does not change once the message is sent. - // Another call to SetOpCode() is required for such things. - opcode=code; -} - -void PortLink::SetPort(port_id port) -{ - // Sets the target port. While not necessary in most uses, this exists - // mostly to prevent flexibility problems - target=port; -} - -port_id PortLink::GetPort(void) -{ - // Simply returns the port at which the object is pointed. - return target; -} - -void PortLink::Flush(bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message off to the target, complete with attachments. NOTE: - // the recipient must delete all attachments, being the PortLink object assumes - // no responsiblity for the attachments once the message is sent. - int8 *msgbuffer; - int32 size; - - if(num_attachments>0) - { - FlattenData(&msgbuffer,&size); - - // Dump message to port, reset attachments, and clean up - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,msgbuffer,size,B_TIMEOUT, timeout); - else - write_port(target,opcode,msgbuffer,size); - MakeEmpty(); - } - else - { - if(timeout!=B_INFINITE_TIMEOUT) - write_port_etc(target,opcode,NULL,0,B_TIMEOUT, timeout); - else - write_port(target,opcode,NULL,0); - } -} - -int8* PortLink::FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, bigtime_t timeout=B_INFINITE_TIMEOUT) -{ - // Fires a message to the target and then waits for a reply. The target will - // receive a message with the first item being the port_id to reply to. - // NOTE: like Flush(), any attached data must be deleted. - - // Effectively, an Attach() call inlined for changes - - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - { - *status=B_ERROR; - return NULL; - } - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&replyport,sizeof(port_id))) - { - bufferlength+=sizeof(port_id); - } - else - { - delete pld; - *status=B_ERROR; - return NULL; - } - - // Flatten() inlined to make some necessary changes - int8 *buffer=new int8[bufferlength]; - int8 *bufferindex=buffer; - size_t size=0; - - // attach our port_id first - memcpy(bufferindex, pld->buffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - - // attach everything else - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - size+=pld->buffersize; - } - - // Flush the thing....FOOSH! :P - write_port(target,opcode,buffer,size); - MakeEmpty(); - delete buffer; - - // Now we wait for the reply - if(timeout==B_INFINITE_TIMEOUT) - { - *buffersize=port_buffer_size(replyport); - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - else - { - *buffersize=port_buffer_size_etc(replyport,0,timeout); - if(*buffersize==B_TIMED_OUT) - { - *status=*buffersize; - return NULL; - } - if(*buffersize>0) - buffer=(int8*)new int8[*buffersize]; - read_port(replyport,code, buffer, *buffersize); - } - - // We got this far, so we apparently have some data - *status=B_OK; - return buffer; -} - -void PortLink::Attach(void *data, size_t size) -{ - // This is the member called to attach data to a message. Attachments are - // treated to be in 'Append' mode, tacking on each attached piece of data - // to the end of the list. - - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - if(size==0) - return; - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -// These functions were added for a major convenience in passing common types -// Eventually, I'd like to templatize these, but for now, this'll do - -void PortLink::Attach(int32 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int32); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int16 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int16); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(int8 data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(int8); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(float data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(float); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(bool data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(bool); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BRect data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BRect); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::Attach(BPoint data) -{ - // Prevent parameter problems - if(num_attachments>=_PORTLINK_MAX_ATTACHMENTS) - return; - - int32 size=sizeof(BPoint); - - // create a new storage object and stash the data - PortLinkData *pld=new PortLinkData; - if(pld->Set(&data,size)) - { - num_attachments++; - attachments[num_attachments-1]=pld; - bufferlength+=size; - } - else - { - delete pld; - } -} - -void PortLink::FlattenData(int8 **buffer,int32 *size) -{ - // This function is where all the magic happens, but it is strictly internal. - // It iterates through each PortLinkData object and copies it to the main buffer - // which ends up, ultimately, being written to the PortLink's target port. - - // skip if there aree no attachments - if(bufferlength<1) - return; - - *buffer=new int8[bufferlength]; - int8 *bufferindex=*buffer; - PortLinkData *pld; - *size=0; - - for(int i=0;ibuffer, pld->buffersize); - bufferindex += pld->buffersize; - *size+=pld->buffersize; - } -} - -void PortLink::MakeEmpty(void) -{ - // Nukes all the attachments currently held by the PortLink class - if(num_attachments!=0) - { - for(int i=0; i0) - free(buffer); -} - -bool PortLinkData::Set(void *data, size_t size) -{ - // Function copies the passed to the internal buffers for storage - if(size>0 && buffersize==0 && data!=NULL) - { - buffer=(char *)malloc(size); - if(buffer==NULL) - return false; - memcpy(buffer, data, size); - buffersize=size; - return true; - } - return false; -} diff --git a/src/servers/app/proto7/testobapp/PortLink.h b/src/servers/app/proto7/testobapp/PortLink.h deleted file mode 100644 index 9f5432daab..0000000000 --- a/src/servers/app/proto7/testobapp/PortLink.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef _PORTLINK_H_ -#define _PORTLINK_H_ - -#include -#include -#include -#include - -#ifndef _PORTLINK_BUFFERSIZE -#define _PORTLINK_MAX_ATTACHMENTS 50 -#endif - -class PortLinkData; - -class PortLink -{ -public: - PortLink(port_id port); - ~PortLink(void); - void SetOpCode(int32 code); - void SetPort(port_id port); - port_id GetPort(void); - void Flush(bigtime_t timeout=B_INFINITE_TIMEOUT); - int8* FlushWithReply(int32 *code, status_t *status, ssize_t *buffersize, - bigtime_t timeout=B_INFINITE_TIMEOUT); - void Attach(void *data, size_t size); - void Attach(int32 data); - void Attach(int16 data); - void Attach(int8 data); - void Attach(float data); - void Attach(bool data); - void Attach(BRect data); - void Attach(BPoint data); - void MakeEmpty(void); -protected: - void FlattenData(int8 **buffer,int32 *size); - port_id target, replyport; - int32 opcode, bufferlength; - int num_attachments; - PortLinkData *attachments[_PORTLINK_MAX_ATTACHMENTS]; -}; - -#endif \ No newline at end of file diff --git a/src/servers/app/proto7/testobapp/ServerProtocol.h b/src/servers/app/proto7/testobapp/ServerProtocol.h deleted file mode 100644 index 45e2674c0f..0000000000 --- a/src/servers/app/proto7/testobapp/ServerProtocol.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef _APPSERVER_PROTOCOL_ -#define _APPSERVER_PROTOCOL_ - -#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' - -#define SERVER_PORT_NAME "OBappserver" -#define SERVER_INPUT_PORT "OBinputport" -#define SERVER_FONT_LIST "/boot/home/config/settings/app_server/fontlist" -#define SERVER_SETTINGS_DIR "/boot/home/config/settings/app_server/" - -// Used for quick replies from the app_server -#define SERVER_TRUE 'svtr' -#define SERVER_FALSE 'svfl' - -// 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' - - -// This will be modified. Currently a kludge for the input server until -// BScreens are implemented by the IK Taeam -#define GET_SCREEN_MODE 'gsmd' - -#define SET_UI_COLORS 'suic' -#define GET_UI_COLOR 'guic' -#define SET_DECORATOR 'sdec' -#define GET_DECORATOR 'gdec' - -#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 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' - -#define GFX_SET_HIGH_COLOR 'gshc' -#define GFX_SET_LOW_COLOR 'gslc' -#define GFX_SET_VIEW_COLOR 'gsvc' - -#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' - -#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' - -#define GFX_MOVEPENBY 'gmpb' -#define GFX_MOVEPENTO 'gmpt' -#define GFX_SETPENSIZE 'gsps' - -#define GFX_DRAW_STRING 'gdst' -#define GFX_SET_FONT 'gsft' -#define GFX_SET_FONT_SIZE 'gsfs' - -#define GFX_FLUSH 'gfsh' -#define GFX_SYNC 'gsyn' - -#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 BEGIN_RECT_TRACKING 'rtbg' -#define END_RECT_TRACKING 'rten' - -#define VIEW_GET_TOKEN 'vgtk' -#define VIEW_ADD 'vadd' -#define VIEW_REMOVE 'vrem' -#endif \ No newline at end of file