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
This commit is contained in:
DarkWyrm 2003-02-12 11:24:26 +00:00
parent 6e4bef603f
commit d529723048
7 changed files with 304 additions and 9 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -0,0 +1,62 @@
#ifndef DESKTOPCLASSES_H
#define DESKTOPCLASSES_H
#include <SupportDefs.h>
#include <GraphicsCard.h>
#include <Window.h> // 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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,63 @@
#include <View.h>
#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)
{
}

View File

@ -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