From d5297230487adfa67f7bd74ad3c88c463c451353 Mon Sep 17 00:00:00 2001 From: DarkWyrm Date: Wed, 12 Feb 2003 11:24:26 +0000 Subject: [PATCH] Added skeleton for desktop management classes Implemented parts of desktop management functions in Desktop.h git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2696 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/server/Desktop.cpp | 23 +++- src/servers/app/server/DesktopClasses.cpp | 130 ++++++++++++++++++++++ src/servers/app/server/DesktopClasses.h | 62 +++++++++++ src/servers/app/server/Jamfile | 2 + src/servers/app/server/Layer.h | 6 +- src/servers/app/server/RootLayer.cpp | 63 +++++++++++ src/servers/app/server/RootLayer.h | 27 +++++ 7 files changed, 304 insertions(+), 9 deletions(-) create mode 100644 src/servers/app/server/DesktopClasses.cpp create mode 100644 src/servers/app/server/DesktopClasses.h create mode 100644 src/servers/app/server/RootLayer.cpp create mode 100644 src/servers/app/server/RootLayer.h diff --git a/src/servers/app/server/Desktop.cpp b/src/servers/app/server/Desktop.cpp index a9fc1f8ce9..905817fa1c 100644 --- a/src/servers/app/server/Desktop.cpp +++ b/src/servers/app/server/Desktop.cpp @@ -27,26 +27,37 @@ #include "DisplayDriver.h" #include "Desktop.h" -#ifdef VIEWDRIVER #include "ViewDriver.h" -#endif -#ifdef SCREENDRIVER + +#if DISPLAYDRIVER == SCREENDRIVER #include "ScreenDriver.h" #endif -#ifdef HWDRIVER + +#if DISPLAYDRIVER == HWDRIVER #include "AccelerantDriver.h" #endif -//#include "ServerWindow.h" +#include "ServerWindow.h" +//! This namespace encapsulates all globals specifically for the desktop namespace desktop_private { int8 *dragmessage; int32 dragmessagesize; - sem_id draglock; + sem_id draglock, + layerlock, + workspacelock; + BList *screenlist; } +/*! + \brief Initializes the desktop for use. + + InitDesktop creates all workspaces, starts up the appropriate DisplayDriver, and + generally gets everything ready for the server to use. +*/ void InitDesktop(void) { + } void ShutdownDesktop(void) diff --git a/src/servers/app/server/DesktopClasses.cpp b/src/servers/app/server/DesktopClasses.cpp new file mode 100644 index 0000000000..5da8abf582 --- /dev/null +++ b/src/servers/app/server/DesktopClasses.cpp @@ -0,0 +1,130 @@ +#include "DesktopClasses.h" + +Workspace::Workspace(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo) +{ + _gcinfo=gcinfo; + _fbinfo=fbinfo; + + //TODO: create the root layer here based on gcinfo and fbinfo. + _rootlayer=NULL; +} + +Workspace::~Workspace(void) +{ + if(_rootlayer) + { + _rootlayer->PruneTree(); + delete _rootlayer; + } +} + +void Workspace::SetBGColor(const RGBColor &c) +{ + _rootlayer->SetColor(c); +} + +RootLayer *Workspace::GetRoot(void) +{ + return _rootlayer; +} + +void Workspace::SetData(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo) +{ + _gcinfo=gcinfo; + _fbinfo=fbinfo; +} + +void Workspace::GetData(graphics_card_info *gcinfo, frame_buffer_info *fbinfo) +{ + *gcinfo=_gcinfo; + *fbinfo=_fbinfo; +} + +Screen::Screen(DisplayDriver *gfxmodule, uint8 workspaces) +{ + // TODO: implement + _workspacelist=NULL; + _resolution=0; + _activewin=NULL; + _currentworkspace=-1; + _workspacecount=0; + _driver=NULL; + _init=false; +} + +Screen::~Screen(void) +{ +} + +void Screen::AddWorkspace(int32 index=-1) +{ +} + +void Screen::DeleteWorkspace(int32 index) +{ +} + +int32 Screen::CountWorkspaces(void) +{ + return _workspacecount; +} + +void Screen::SetWorkspaceCount(int32 count) +{ +} + +int32 Screen::CurrentWorkspace(void) +{ + return _currentworkspace; +} + +void Screen::SetWorkspace(int32 index) +{ +} + +void Screen::Activate(bool active=true) +{ +} + +DisplayDriver *Screen::GetGfxDriver(void) +{ + return _driver; +} + +status_t Screen::SetSpace(int32 index, int32 res,bool stick=true) +{ + return B_OK; +} + +void Screen::AddWindow(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE) +{ +} + +void Screen::RemoveWindow(ServerWindow *win) +{ +} + +ServerWindow *Screen::ActiveWindow(void) +{ + return _activewin; +} + +void Screen::SetActiveWindow(ServerWindow *win) +{ +} + +Layer *Screen::GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE) +{ + return (Layer*)_activeworkspace->GetRoot(); +} + +bool Screen::IsInitialized(void) +{ + return _init; +} + +Workspace *Screen::GetActiveWorkspace(void) +{ + return _activeworkspace; +} + diff --git a/src/servers/app/server/DesktopClasses.h b/src/servers/app/server/DesktopClasses.h new file mode 100644 index 0000000000..398bb41838 --- /dev/null +++ b/src/servers/app/server/DesktopClasses.h @@ -0,0 +1,62 @@ +#ifndef DESKTOPCLASSES_H +#define DESKTOPCLASSES_H + +#include +#include +#include // for workspace defs +#include "RootLayer.h" + +class DisplayDriver; +class ServerWindow; +class RGBColor; + +class Workspace +{ +public: + Workspace(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo); + ~Workspace(void); + void SetBGColor(const RGBColor &c); + RootLayer *GetRoot(void); + void SetData(const graphics_card_info &gcinfo, const frame_buffer_info &fbinfo); + void GetData(graphics_card_info *gcinfo, frame_buffer_info *fbinfo); + +protected: + RootLayer *_rootlayer; + graphics_card_info _gcinfo; + frame_buffer_info _fbinfo; +}; + +class Screen +{ +public: + Screen(DisplayDriver *gfxmodule, uint8 workspaces); + ~Screen(void); + void AddWorkspace(int32 index=-1); + void DeleteWorkspace(int32 index); + int32 CountWorkspaces(void); + void SetWorkspaceCount(int32 count); + int32 CurrentWorkspace(void); + void SetWorkspace(int32 index); + void Activate(bool active=true); + DisplayDriver *GetGfxDriver(void); + status_t SetSpace(int32 index, int32 res,bool stick=true); + void AddWindow(ServerWindow *win, int32 workspace=B_CURRENT_WORKSPACE); + void RemoveWindow(ServerWindow *win); + ServerWindow *ActiveWindow(void); + void SetActiveWindow(ServerWindow *win); + Layer *GetRootLayer(int32 workspace=B_CURRENT_WORKSPACE); + bool IsInitialized(void); + Workspace *GetActiveWorkspace(void); + +protected: + int32 _resolution; + ServerWindow *_activewin; + int32 _currentworkspace; + int32 _workspacecount; + BList *_workspacelist; + DisplayDriver *_driver; + bool _init; + Workspace *_activeworkspace; +}; + +#endif \ No newline at end of file diff --git a/src/servers/app/server/Jamfile b/src/servers/app/server/Jamfile index 10277fd70a..9e1043e994 100644 --- a/src/servers/app/server/Jamfile +++ b/src/servers/app/server/Jamfile @@ -31,8 +31,10 @@ Server app_server : # Display Classes AccelerantDriver.cpp Decorator.cpp + DesktopClasses.cpp DisplayDriver.cpp Layer.cpp + RootLayer.cpp ScreenDriver.cpp ServerBitmap.cpp ServerCursor.cpp diff --git a/src/servers/app/server/Layer.h b/src/servers/app/server/Layer.h index c1a00931a9..94a8f72db4 100644 --- a/src/servers/app/server/Layer.h +++ b/src/servers/app/server/Layer.h @@ -38,6 +38,7 @@ class ServerWindow; class PortLink; +class RootLayer; /*! \class Layer Layer.h @@ -93,6 +94,8 @@ public: void PruneTree(void); protected: + friend RootLayer; + BRect _frame; Layer *_parent, @@ -118,7 +121,4 @@ protected: PortLink *_portlink; }; -extern BLocker *layerlock; -extern BList *layerlist; -extern Layer *rootlayer; #endif diff --git a/src/servers/app/server/RootLayer.cpp b/src/servers/app/server/RootLayer.cpp new file mode 100644 index 0000000000..59f800b2e5 --- /dev/null +++ b/src/servers/app/server/RootLayer.cpp @@ -0,0 +1,63 @@ +#include +#include "RootLayer.h" +#include "Desktop.h" +#include "DisplayDriver.h" + +RootLayer::RootLayer(BRect rect, const char *layername) + : Layer(rect,layername,B_FOLLOW_NONE,0, NULL) +{ + _driver=GetGfxDriver(); +} + +RootLayer::~RootLayer(void) +{ +} + +void RootLayer::RequestDraw(void) +{ + if(!_invalid) + return; + + // Redraw the base + for(int32 i=0; _invalid->CountRects();i++) + { + if(_invalid->RectAt(i).IsValid()) + _driver->FillRect(_invalid->RectAt(i),_layerdata, 0LL); + 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(lay->Bounds()); + } + +} + +void RootLayer::SetColor(const RGBColor &col) +{ + _layerdata->lowcolor=col; +} + +RGBColor RootLayer::GetColor(void) const +{ + return _layerdata->lowcolor; +} + +void RootLayer::MoveBy(float x, float y) +{ +} + +void RootLayer::MoveBy(BPoint pt) +{ +} + +void RootLayer::RebuildRegions(bool recursive) +{ +} \ No newline at end of file diff --git a/src/servers/app/server/RootLayer.h b/src/servers/app/server/RootLayer.h new file mode 100644 index 0000000000..632ce1528d --- /dev/null +++ b/src/servers/app/server/RootLayer.h @@ -0,0 +1,27 @@ +#ifndef _ROOTLAYER_H_ +#define _ROOTLAYER_H_ + +#include "Layer.h" + +class DisplayDriver; +class RGBColor; + +class RootLayer : public Layer +{ +public: + RootLayer(BRect frame, const char *name); + ~RootLayer(void); + void RequestDraw(void); + void MoveBy(float x, float y); + void MoveBy(BPoint pt); + void SetDriver(DisplayDriver *driver); + void SetColor(const RGBColor &col); + RGBColor GetColor(void) const; + void RebuildRegions(bool recursive=false); +private: + DisplayDriver *_driver; + RGBColor *_bgcolor; + bool _visible; +}; + +#endif