Janitorial work and minor ServerWindow tweaks

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@7907 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2004-06-11 14:47:36 +00:00
parent 768ec791c9
commit 70e337a0b4
4 changed files with 702 additions and 809 deletions
+115 -106
View File
@@ -53,34 +53,35 @@
//#define DISPLAYDRIVER_TEST_HACK //#define DISPLAYDRIVER_TEST_HACK
//---------------------------------------------------------------------------
RootLayer::RootLayer(const char *name, int32 workspaceCount, RootLayer::RootLayer(const char *name, int32 workspaceCount,
Desktop *desktop, DisplayDriver *driver) Desktop *desktop, DisplayDriver *driver)
: Layer(BRect(0,0,0,0), name, 0, B_FOLLOW_ALL, B_WILL_DRAW, driver) : Layer(BRect(0,0,0,0), name, 0, B_FOLLOW_ALL, B_WILL_DRAW, driver)
{ {
fDesktop = desktop; fDesktop = desktop;
//NOTE: be careful about this one.
fRootLayer = this; //NOTE: be careful about this one.
fActiveWorkspace = NULL; fRootLayer = this;
fRows = 0; fActiveWorkspace = NULL;
fColumns = 0; fRows = 0;
fColumns = 0;
// TODO: read these 3 from a configuration file. // TODO: read these 3 from a configuration file.
fScreenXResolution = 0; fScreenXResolution = 0;
fScreenYResolution = 0; fScreenYResolution = 0;
fColorSpace = B_RGB32; fColorSpace = B_RGB32;
_view_token = 0; // is this used for WinBorders? _view_token = 0; // is this used for WinBorders?
_hidden = false; _hidden = false;
SetWorkspaceCount(workspaceCount); SetWorkspaceCount(workspaceCount);
} }
//---------------------------------------------------------------------------
RootLayer::~RootLayer() RootLayer::~RootLayer()
{ {
// RootLayer object just uses Screen objects, it is not allowed to delete them. // RootLayer object just uses Screen objects, it is not allowed to delete them.
} }
//---------------------------------------------------------------------------
void RootLayer::Draw(const BRect &r) void RootLayer::Draw(const BRect &r)
{ {
// REMOVEME: This method is here because of DisplayDriver testing ONLY. // REMOVEME: This method is here because of DisplayDriver testing ONLY.
@@ -90,9 +91,9 @@ void RootLayer::Draw(const BRect &r)
RGBColor c(51,102,152); RGBColor c(51,102,152);
fDriver->FillRect(r, c); fDriver->FillRect(r, c);
STRACE(("#RootLayer(%s)::Draw(r) END\n", GetName())); STRACE(("#RootLayer(%s)::Draw(r) END\n", GetName()));
#ifdef DISPLAYDRIVER_TEST_HACK #ifdef DISPLAYDRIVER_TEST_HACK
DisplayDriver *_driver = fDriver; DisplayDriver *_driver = fDriver;
int8 pattern[8]; int8 pattern[8];
@@ -131,14 +132,14 @@ void RootLayer::Draw(const BRect &r)
polygon[4].y = 100; polygon[4].y = 100;
polygon[5].x = 200; polygon[5].x = 200;
polygon[5].y = 200; polygon[5].y = 200;
_layerdata->highcolor.SetColor(255,0,0,255); _layerdata->highcolor.SetColor(255,0,0,255);
_layerdata->lowcolor.SetColor(255,255,255,255); _layerdata->lowcolor.SetColor(255,255,255,255);
_driver->FillRect(r1,_layerdata,pattern); _driver->FillRect(r1,_layerdata,pattern);
_layerdata->highcolor.SetColor(255,255,0,255); _layerdata->highcolor.SetColor(255,255,0,255);
_driver->StrokeLine(BPoint(100,100),BPoint(1500,1100),_layerdata,pattern); _driver->StrokeLine(BPoint(100,100),BPoint(1500,1100),_layerdata,pattern);
_layerdata->highcolor.SetColor(0,0,255,255); _layerdata->highcolor.SetColor(0,0,255,255);
_driver->StrokeBezier(pts,_layerdata,pattern); _driver->StrokeBezier(pts,_layerdata,pattern);
_driver->StrokeArc(BRect(200,300,400,600),30,270,_layerdata,pattern); _driver->StrokeArc(BRect(200,300,400,600),30,270,_layerdata,pattern);
@@ -154,39 +155,40 @@ void RootLayer::Draw(const BRect &r)
_driver->FillRoundRect(BRect(800,1000,1200,1090),30,40,_layerdata,pattern2); _driver->FillRoundRect(BRect(800,1000,1200,1090),30,40,_layerdata,pattern2);
_driver->FillPolygon(polygon,6,polygonRect,_layerdata,pattern); _driver->FillPolygon(polygon,6,polygonRect,_layerdata,pattern);
// _driver->FillTriangle(triangle,triangleRect,_layerdata,pattern); // _driver->FillTriangle(triangle,triangleRect,_layerdata,pattern);
#endif
#endif // end DISPLAYDRIVER_TEST_HACK
} }
//---------------------------------------------------------------------------
void RootLayer::MoveBy(float x, float y) void RootLayer::MoveBy(float x, float y)
{ {
} }
//---------------------------------------------------------------------------
void RootLayer::ResizeBy(float x, float y) void RootLayer::ResizeBy(float x, float y)
{ {
// TODO: implement // TODO: implement
} }
//---------------------------------------------------------------------------
Layer* RootLayer::VirtualTopChild() const Layer* RootLayer::VirtualTopChild() const
{ {
return fActiveWorkspace->GoToTopItem(); return fActiveWorkspace->GoToTopItem();
} }
//---------------------------------------------------------------------------
Layer* RootLayer::VirtualLowerSibling() const Layer* RootLayer::VirtualLowerSibling() const
{ {
return fActiveWorkspace->GoToLowerItem(); return fActiveWorkspace->GoToLowerItem();
} }
//---------------------------------------------------------------------------
Layer* RootLayer::VirtualUpperSibling() const Layer* RootLayer::VirtualUpperSibling() const
{ {
return fActiveWorkspace->GoToUpperItem(); return fActiveWorkspace->GoToUpperItem();
} }
//---------------------------------------------------------------------------
Layer* RootLayer::VirtualBottomChild() const Layer* RootLayer::VirtualBottomChild() const
{ {
return fActiveWorkspace->GoToBottomItem(); return fActiveWorkspace->GoToBottomItem();
} }
//---------------------------------------------------------------------------
void RootLayer::AddWinBorderToWorkspaces(WinBorder* winBorder, uint32 wks) void RootLayer::AddWinBorderToWorkspaces(WinBorder* winBorder, uint32 wks)
{ {
if (!(fMainLock.IsLocked())) if (!(fMainLock.IsLocked()))
@@ -197,14 +199,14 @@ void RootLayer::AddWinBorderToWorkspaces(WinBorder* winBorder, uint32 wks)
ActiveWorkspace()->AddLayerPtr(winBorder); ActiveWorkspace()->AddLayerPtr(winBorder);
return; return;
} }
for( int32 i=0; i < 32; i++) for( int32 i=0; i < 32; i++)
{ {
if( wks & (0x00000001 << i) && i < WorkspaceCount()) if( wks & (0x00000001 << i) && i < WorkspaceCount())
WorkspaceAt(i+1)->AddLayerPtr(winBorder); WorkspaceAt(i+1)->AddLayerPtr(winBorder);
} }
} }
//---------------------------------------------------------------------------
void RootLayer::AddWinBorder(WinBorder* winBorder) void RootLayer::AddWinBorder(WinBorder* winBorder)
{ {
// The main job of this function, besides adding winBorder as a child, is to determine // The main job of this function, besides adding winBorder as a child, is to determine
@@ -221,10 +223,10 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
// in case we want to be added to the current workspace // in case we want to be added to the current workspace
if (winBorder->Window()->Workspaces() == 0) if (winBorder->Window()->Workspaces() == 0)
winBorder->Window()->QuietlySetWorkspaces(0x00000001 << (ActiveWorkspaceIndex()-1)); winBorder->Window()->QuietlySetWorkspaces(0x00000001 << (ActiveWorkspaceIndex()-1));
// add winBorder to the known list of WinBorders so we can keep track of it. // add winBorder to the known list of WinBorders so we can keep track of it.
AddChild(winBorder, this); AddChild(winBorder, this);
// add winBorder to the desired workspaces // add winBorder to the desired workspaces
switch(winBorder->Window()->Feel()) switch(winBorder->Window()->Feel())
{ {
@@ -235,7 +237,6 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
// will be called. // will be called.
break; break;
} }
case B_MODAL_APP_WINDOW_FEEL: case B_MODAL_APP_WINDOW_FEEL:
{ {
// add to app's list of Floating/Modal windows (as opposed to the system's) // add to app's list of Floating/Modal windows (as opposed to the system's)
@@ -317,7 +318,6 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
AddWinBorderToWorkspaces(winBorder, winBorder->Window()->Workspaces()); AddWinBorderToWorkspaces(winBorder, winBorder->Window()->Workspaces());
break; break;
} }
case B_SYSTEM_LAST: case B_SYSTEM_LAST:
case B_SYSTEM_FIRST: case B_SYSTEM_FIRST:
{ {
@@ -331,103 +331,107 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
fMainLock.Unlock(); fMainLock.Unlock();
STRACE(("*RootLayer::AddWinBorder(%s) - Main lock released\n", winBorder->GetName())); STRACE(("*RootLayer::AddWinBorder(%s) - Main lock released\n", winBorder->GetName()));
desktop->fGeneralLock.Unlock(); desktop->fGeneralLock.Unlock();
STRACE(("*RootLayer::AddWinBorder(%s) - General lock released\n", winBorder->GetName())); STRACE(("*RootLayer::AddWinBorder(%s) - General lock released\n", winBorder->GetName()));
STRACE(("#RootLayer::AddWinBorder(%s)\n", winBorder->GetName())); STRACE(("#RootLayer::AddWinBorder(%s)\n", winBorder->GetName()));
} }
//---------------------------------------------------------------------------
void RootLayer::RemoveWinBorder(WinBorder* winBorder) void RootLayer::RemoveWinBorder(WinBorder* winBorder)
{ {
// This method does 3 things: // This method does 3 things:
// 1) Removes MODAL/SUBSET windows from system/app/window subset list. // 1) Removes MODAL/SUBSET windows from system/app/window subset list.
// 2) Removes this window from any workspace it appears in. // 2) Removes this window from any workspace it appears in.
// 3) Removes this window from RootLayer's list of chilren. // 3) Removes this window from RootLayer's list of children.
desktop->fGeneralLock.Lock(); desktop->fGeneralLock.Lock();
fMainLock.Lock(); fMainLock.Lock();
int32 feel = winBorder->Window()->Feel(); int32 feel = winBorder->Window()->Feel();
if(feel == B_MODAL_SUBSET_WINDOW_FEEL || feel == B_FLOATING_SUBSET_WINDOW_FEEL) if(feel == B_MODAL_SUBSET_WINDOW_FEEL || feel == B_FLOATING_SUBSET_WINDOW_FEEL)
{ {
desktop->RemoveSubsetWindow(winBorder); desktop->RemoveSubsetWindow(winBorder);
} }
else if (feel == B_MODAL_APP_WINDOW_FEEL || feel == B_FLOATING_APP_WINDOW_FEEL) else
if (feel == B_MODAL_APP_WINDOW_FEEL || feel == B_FLOATING_APP_WINDOW_FEEL)
{ {
RemoveAppWindow(winBorder); RemoveAppWindow(winBorder);
} }
else if(feel == B_MODAL_ALL_WINDOW_FEEL || feel == B_FLOATING_ALL_WINDOW_FEEL else
if(feel == B_MODAL_ALL_WINDOW_FEEL || feel == B_FLOATING_ALL_WINDOW_FEEL
|| feel == B_SYSTEM_FIRST || feel == B_SYSTEM_LAST) || feel == B_SYSTEM_FIRST || feel == B_SYSTEM_LAST)
{ {
if(feel == B_MODAL_ALL_WINDOW_FEEL || feel == B_FLOATING_ALL_WINDOW_FEEL) if(feel == B_MODAL_ALL_WINDOW_FEEL || feel == B_FLOATING_ALL_WINDOW_FEEL)
fMainFMWList.RemoveItem(winBorder); fMainFMWList.RemoveItem(winBorder);
int32 count = WorkspaceCount(); int32 count = WorkspaceCount();
for(int32 i=0; i < count; i++) for(int32 i=0; i < count; i++)
WorkspaceAt(i+1)->RemoveLayerPtr(winBorder); WorkspaceAt(i+1)->RemoveLayerPtr(winBorder);
} }
else else
{ // for B_NORMAL_WINDOW_FEEL { // for B_NORMAL_WINDOW_FEEL
uint32 workspaces = winBorder->Window()->Workspaces(); uint32 workspaces = winBorder->Window()->Workspaces();
int32 count = WorkspaceCount(); int32 count = WorkspaceCount();
for( int32 i=0; i < 32 && i < count; i++) for( int32 i=0; i < 32 && i < count; i++)
{
if( workspaces & (0x00000001UL << i)) if( workspaces & (0x00000001UL << i))
WorkspaceAt(i+1)->RemoveLayerPtr(winBorder); WorkspaceAt(i+1)->RemoveLayerPtr(winBorder);
}
} }
RemoveChild(winBorder); RemoveChild(winBorder);
fMainLock.Unlock(); fMainLock.Unlock();
desktop->fGeneralLock.Unlock(); desktop->fGeneralLock.Unlock();
} }
//---------------------------------------------------------------------------
void RootLayer::ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces) void RootLayer::ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces)
{ {
// only normal windows are affected by this change // only normal windows are affected by this change
if(!winBorder->_level != B_NORMAL_FEEL) if(!winBorder->_level != B_NORMAL_FEEL)
return; return;
uint32 oldWorkspaces = winBorder->Window()->Workspaces(); uint32 oldWorkspaces = winBorder->Window()->Workspaces();
for(int32 i=0; i < WorkspaceCount(); i++) for(int32 i=0; i < WorkspaceCount(); i++)
{ {
if ((oldWorkspaces & (0x00000001 << i)) && (newWorkspaces & (0x00000001 << i))) if ((oldWorkspaces & (0x00000001 << i)) && (newWorkspaces & (0x00000001 << i)))
{ {
// do nothing. // do nothing.
} }
else if(oldWorkspaces & (0x00000001 << i)) else
if(oldWorkspaces & (0x00000001 << i))
{ {
WorkspaceAt(i+1)->RemoveLayerPtr(winBorder); WorkspaceAt(i+1)->RemoveLayerPtr(winBorder);
} }
else if (newWorkspaces & (0x00000001 << i)) else
if (newWorkspaces & (0x00000001 << i))
{ {
WorkspaceAt(i+1)->AddLayerPtr(winBorder); WorkspaceAt(i+1)->AddLayerPtr(winBorder);
} }
} }
} }
//---------------------------------------------------------------------------
bool RootLayer::SetFrontWinBorder(WinBorder* winBorder) bool RootLayer::SetFrontWinBorder(WinBorder* winBorder)
{ {
if(!winBorder) if(!winBorder)
return false; return false;
STRACE(("*RootLayer::SetFrontWinBorder(%s)\n", winBorder? winBorder->GetName():"NULL")); STRACE(("*RootLayer::SetFrontWinBorder(%s)\n", winBorder? winBorder->GetName():"NULL"));
fMainLock.Lock(); fMainLock.Lock();
STRACE(("*RootLayer::SetFrontWinBorder(%s) - main lock acquired\n", winBorder? winBorder->GetName():"NULL")); STRACE(("*RootLayer::SetFrontWinBorder(%s) - main lock acquired\n", winBorder? winBorder->GetName():"NULL"));
if (!winBorder) if (!winBorder)
{ {
ActiveWorkspace()->SetFrontLayer(NULL); ActiveWorkspace()->SetFrontLayer(NULL);
return true; return true;
} }
uint32 workspaces = winBorder->Window()->Workspaces(); uint32 workspaces = winBorder->Window()->Workspaces();
int32 count = WorkspaceCount(); int32 count = WorkspaceCount();
int32 newWorkspace= 0; int32 newWorkspace= 0;
if (workspaces & (0x00000001UL << (ActiveWorkspaceIndex()-1)) ) if (workspaces & (0x00000001UL << (ActiveWorkspaceIndex()-1)) )
{ {
newWorkspace = ActiveWorkspaceIndex(); newWorkspace = ActiveWorkspaceIndex();
@@ -436,12 +440,14 @@ bool RootLayer::SetFrontWinBorder(WinBorder* winBorder)
{ {
int32 i; int32 i;
for( i = 0; i < 32 && i < count; i++) for( i = 0; i < 32 && i < count; i++)
{
if( workspaces & (0x00000001UL << i)) if( workspaces & (0x00000001UL << i))
{ {
newWorkspace = i+1; newWorkspace = i+1;
break; break;
} }
}
if (i == count || i == 32) if (i == count || i == 32)
newWorkspace = ActiveWorkspaceIndex(); newWorkspace = ActiveWorkspaceIndex();
} }
@@ -451,16 +457,17 @@ bool RootLayer::SetFrontWinBorder(WinBorder* winBorder)
WorkspaceAt(newWorkspace)->SetFrontLayer(winBorder); WorkspaceAt(newWorkspace)->SetFrontLayer(winBorder);
SetActiveWorkspaceByIndex(newWorkspace); SetActiveWorkspaceByIndex(newWorkspace);
} }
else{ else
{
ActiveWorkspace()->SetFrontLayer(winBorder); ActiveWorkspace()->SetFrontLayer(winBorder);
} }
fMainLock.Unlock(); fMainLock.Unlock();
STRACE(("*RootLayer::SetFrontWinBorder(%s) - main lock released\n", winBorder? winBorder->GetName():"NULL")); STRACE(("*RootLayer::SetFrontWinBorder(%s) - main lock released\n", winBorder? winBorder->GetName():"NULL"));
STRACE(("#RootLayer::SetFrontWinBorder(%s)\n", winBorder? winBorder->GetName():"NULL")); STRACE(("#RootLayer::SetFrontWinBorder(%s)\n", winBorder? winBorder->GetName():"NULL"));
return true; return true;
} }
//---------------------------------------------------------------------------
void RootLayer::SetScreens(Screen *screen[], int32 rows, int32 columns) void RootLayer::SetScreens(Screen *screen[], int32 rows, int32 columns)
{ {
// NOTE: All screens *must* have the same resolution // NOTE: All screens *must* have the same resolution
@@ -469,39 +476,42 @@ void RootLayer::SetScreens(Screen *screen[], int32 rows, int32 columns)
for (int32 i=0; i < rows; i++) for (int32 i=0; i < rows; i++)
{ {
if (i==0) if (i==0)
{
for(int32 j=0; j < columns; j++) for(int32 j=0; j < columns; j++)
{ {
fScreenPtrList.AddItem(screen[i*rows + j]); fScreenPtrList.AddItem(screen[i*rows + j]);
newFrame.right += screen[i*rows + j]->Resolution().x; newFrame.right += screen[i*rows + j]->Resolution().x;
} }
}
newFrame.bottom += screen[i*rows]->Resolution().y; newFrame.bottom += screen[i*rows]->Resolution().y;
} }
newFrame.right -= 1; newFrame.right -= 1;
newFrame.bottom -= 1; newFrame.bottom -= 1;
_frame = newFrame;
fRows = rows;
fColumns = columns;
fScreenXResolution = (int32)(screen[0]->Resolution().x);
fScreenYResolution = (int32)(screen[0]->Resolution().y);
_frame = newFrame; // NOTE: a RebuildFullRegion() followed by FullInvalidate() are required after calling
fRows = rows; // this method!
fColumns = columns;
fScreenXResolution = (int32)(screen[0]->Resolution().x);
fScreenYResolution = (int32)(screen[0]->Resolution().y);
// NOTE: a RebuildFullRegion() followed by FullInvalidate() are required after calling this method!
} }
//---------------------------------------------------------------------------
Screen** RootLayer::Screens() Screen **RootLayer::Screens()
{ {
return (Screen**)fScreenPtrList.Items(); return (Screen**)fScreenPtrList.Items();
} }
//---------------------------------------------------------------------------
bool RootLayer::SetScreenResolution(int32 width, int32 height, uint32 colorspace) bool RootLayer::SetScreenResolution(int32 width, int32 height, uint32 colorspace)
{ {
if (fScreenXResolution == width && fScreenYResolution == height && if (fScreenXResolution == width && fScreenYResolution == height &&
fColorSpace == colorspace) fColorSpace == colorspace)
return false; return false;
bool accepted = true; bool accepted = true;
for (int i=0; i < fScreenPtrList.CountItems(); i++) for (int i=0; i < fScreenPtrList.CountItems(); i++)
{ {
Screen *screen; Screen *screen;
@@ -517,19 +527,19 @@ bool RootLayer::SetScreenResolution(int32 width, int32 height, uint32 colorspace
{ {
Screen *screen; Screen *screen;
screen = static_cast<Screen*>(fScreenPtrList.ItemAt(i)); screen = static_cast<Screen*>(fScreenPtrList.ItemAt(i));
screen->SetResolution(BPoint(width, height), colorspace); screen->SetResolution(BPoint(width, height), colorspace);
} }
Screen **screens = (Screen**)fScreenPtrList.Items(); Screen **screens = (Screen**)fScreenPtrList.Items();
SetScreens(screens, fRows, fColumns); SetScreens(screens, fRows, fColumns);
return true; return true;
} }
return false; return false;
} }
//---------------------------------------------------------------------------
void RootLayer::SetWorkspaceCount(const int32 count) void RootLayer::SetWorkspaceCount(const int32 count)
{ {
STRACE(("*RootLayer::SetWorkspaceCount(%ld)\n", count)); STRACE(("*RootLayer::SetWorkspaceCount(%ld)\n", count));
@@ -538,10 +548,10 @@ void RootLayer::SetWorkspaceCount(const int32 count)
return; return;
int32 exActiveWorkspaceIndex = ActiveWorkspaceIndex(); int32 exActiveWorkspaceIndex = ActiveWorkspaceIndex();
BList newWSPtrList; BList newWSPtrList;
void *workspacePtr; void *workspacePtr;
fMainLock.Lock(); fMainLock.Lock();
STRACE(("*RootLayer::SetWorkspaceCount(%ld) - main lock acquired\n", count)); STRACE(("*RootLayer::SetWorkspaceCount(%ld) - main lock acquired\n", count));
@@ -579,27 +589,27 @@ void RootLayer::SetWorkspaceCount(const int32 count)
if (exActiveWorkspaceIndex > count) if (exActiveWorkspaceIndex > count)
SetActiveWorkspaceByIndex(count); SetActiveWorkspaceByIndex(count);
// if true, this is the first time this method is called. // if true, this is the first time this method is called.
if (exActiveWorkspaceIndex == -1) if (exActiveWorkspaceIndex == -1)
SetActiveWorkspaceByIndex(1); SetActiveWorkspaceByIndex(1);
STRACE(("#RootLayer::SetWorkspaceCount(%ld)\n", count)); STRACE(("#RootLayer::SetWorkspaceCount(%ld)\n", count));
} }
//---------------------------------------------------------------------------
int32 RootLayer::WorkspaceCount() const int32 RootLayer::WorkspaceCount() const
{ {
return fWSPtrList.CountItems(); return fWSPtrList.CountItems();
} }
//---------------------------------------------------------------------------
Workspace* RootLayer::WorkspaceAt(const int32 index) const Workspace* RootLayer::WorkspaceAt(const int32 index) const
{ {
Workspace *ws = NULL; Workspace *ws = NULL;
ws = static_cast<Workspace*>(fWSPtrList.ItemAt(index-1)); ws = static_cast<Workspace*>(fWSPtrList.ItemAt(index-1));
return ws; return ws;
} }
//---------------------------------------------------------------------------
void RootLayer::SetActiveWorkspaceByIndex(const int32 index) void RootLayer::SetActiveWorkspaceByIndex(const int32 index)
{ {
Workspace *ws = NULL; Workspace *ws = NULL;
@@ -607,53 +617,53 @@ void RootLayer::SetActiveWorkspaceByIndex(const int32 index)
if (ws) if (ws)
SetActiveWorkspace(ws); SetActiveWorkspace(ws);
} }
//---------------------------------------------------------------------------
void RootLayer::SetActiveWorkspace(Workspace *ws) void RootLayer::SetActiveWorkspace(Workspace *ws)
{ {
if (fActiveWorkspace == ws || !ws) if (fActiveWorkspace == ws || !ws)
return; return;
fActiveWorkspace = ws; fActiveWorkspace = ws;
// RebuildRegions(Frame()); // RebuildRegions(Frame());
// Invalidate(Frame()); // Invalidate(Frame());
} }
//---------------------------------------------------------------------------
int32 RootLayer::ActiveWorkspaceIndex() const{ int32 RootLayer::ActiveWorkspaceIndex() const{
if (fActiveWorkspace) if (fActiveWorkspace)
return fActiveWorkspace->ID(); return fActiveWorkspace->ID();
else else
return -1; return -1;
} }
//---------------------------------------------------------------------------
Workspace* RootLayer::ActiveWorkspace() const Workspace* RootLayer::ActiveWorkspace() const
{ {
return fActiveWorkspace; return fActiveWorkspace;
} }
//---------------------------------------------------------------------------
void RootLayer::SetBGColor(const RGBColor &col) void RootLayer::SetBGColor(const RGBColor &col)
{ {
ActiveWorkspace()->SetBGColor(col); ActiveWorkspace()->SetBGColor(col);
_layerdata->viewcolor = col; _layerdata->viewcolor = col;
// Invalidate(Frame()); // Invalidate(Frame());
} }
//---------------------------------------------------------------------------
RGBColor RootLayer::BGColor(void) const RGBColor RootLayer::BGColor(void) const
{ {
return _layerdata->viewcolor; return _layerdata->viewcolor;
} }
//---------------------------------------------------------------------------
void RootLayer::RemoveAppWindow(WinBorder *wb) void RootLayer::RemoveAppWindow(WinBorder *wb)
{ {
wb->Window()->App()->fAppFMWList.RemoveItem(wb); wb->Window()->App()->fAppFMWList.RemoveItem(wb);
int32 count = WorkspaceCount(); int32 count = WorkspaceCount();
for(int32 i=0; i < count; i++) for(int32 i=0; i < count; i++)
WorkspaceAt(i+1)->RemoveLayerPtr(wb); WorkspaceAt(i+1)->RemoveLayerPtr(wb);
} }
//---------------------------------------------------------------------------
void RootLayer::PrintToStream() void RootLayer::PrintToStream()
{ {
printf("\nRootLayer '%s' internals:\n", GetName()); printf("\nRootLayer '%s' internals:\n", GetName());
@@ -671,5 +681,4 @@ void RootLayer::PrintToStream()
printf("~~~~~~~~\n"); printf("~~~~~~~~\n");
} }
printf("Active Workspace: %ld\n", fActiveWorkspace? fActiveWorkspace->ID(): -1); printf("Active Workspace: %ld\n", fActiveWorkspace? fActiveWorkspace->ID(): -1);
} }
+56 -55
View File
@@ -52,63 +52,64 @@ class DisplayDriver;
class RootLayer : public Layer class RootLayer : public Layer
{ {
public: public:
RootLayer(const char *name, RootLayer(const char *name, int32 workspaceCount, Desktop *desktop,
int32 workspaceCount, Desktop *desktop, DisplayDriver *driver); DisplayDriver *driver);
virtual ~RootLayer(); virtual ~RootLayer(void);
virtual void Draw(const BRect &r);
virtual void MoveBy(float x, float y);
virtual void ResizeBy(float x, float y);
// For the active workspaces
virtual Layer *VirtualTopChild(void) const;
virtual Layer *VirtualLowerSibling(void) const;
virtual Layer *VirtualUpperSibling(void) const;
virtual Layer *VirtualBottomChild(void) const;
void AddWinBorder(WinBorder *winBorder);
void RemoveWinBorder(WinBorder *winBorder);
void ChangeWorkspacesFor(WinBorder *winBorder, uint32 newWorkspaces);
bool SetFrontWinBorder(WinBorder *winBorder);
void SetScreens(Screen *screen[], int32 rows, int32 columns);
Screen **Screens(void);
bool SetScreenResolution(int32 width, int32 height, uint32 colorspace);
int32 ScreenRows(void) const { return fRows; }
int32 ScreenColumns(void) const { return fColumns; }
void SetWorkspaceCount(const int32 count);
int32 WorkspaceCount(void) const;
Workspace *WorkspaceAt(const int32 index) const;
void SetActiveWorkspaceByIndex(const int32 index);
void SetActiveWorkspace(Workspace *ws);
int32 ActiveWorkspaceIndex(void) const;
Workspace *ActiveWorkspace(void) const;
void SetBGColor(const RGBColor &col);
RGBColor BGColor(void) const;
void AddWinBorderToWorkspaces(WinBorder *winBorder, uint32 wks);
void PrintToStream(void);
// "Private" to app_server :-) - they should not be used
void RemoveAppWindow(WinBorder *wb);
FMWList fMainFMWList;
BLocker fMainLock;
virtual void Draw(const BRect &r);
virtual void MoveBy(float x, float y);
virtual void ResizeBy(float x, float y);
virtual Layer* VirtualTopChild() const; //
virtual Layer* VirtualLowerSibling() const; // ... for the active workspace
virtual Layer* VirtualUpperSibling() const; //
virtual Layer* VirtualBottomChild() const; //
void AddWinBorder(WinBorder* winBorder);
void RemoveWinBorder(WinBorder* winBorder);
void ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces);
bool SetFrontWinBorder(WinBorder* winBorder);
void SetScreens(Screen *screen[], int32 rows, int32 columns);
Screen** Screens();
bool SetScreenResolution(int32 width, int32 height, uint32 colorspace);
int32 ScreenRows() const { return fRows; }
int32 ScreenColumns() const { return fColumns; }
void SetWorkspaceCount(const int32 count);
int32 WorkspaceCount(void) const;
Workspace* WorkspaceAt(const int32 index) const;
void SetActiveWorkspaceByIndex(const int32 index);
void SetActiveWorkspace(Workspace *ws);
int32 ActiveWorkspaceIndex(void) const;
Workspace* ActiveWorkspace(void) const;
void SetBGColor(const RGBColor &col);
RGBColor BGColor(void) const;
void AddWinBorderToWorkspaces(WinBorder* winBorder,
uint32 wks);
// ------- debugging methods -------
void PrintToStream();
// "Private" to app_server :-) - they should not be used
void RemoveAppWindow(WinBorder *wb);
FMWList fMainFMWList;
BLocker fMainLock;
private: private:
Desktop *fDesktop; Desktop *fDesktop;
BList fScreenPtrList; BList fScreenPtrList;
int32 fRows; int32 fRows;
int32 fColumns; int32 fColumns;
int32 fScreenXResolution; int32 fScreenXResolution;
int32 fScreenYResolution; int32 fScreenYResolution;
uint32 fColorSpace; uint32 fColorSpace;
BList fWSPtrList; BList fWSPtrList;
Workspace *fActiveWorkspace; Workspace *fActiveWorkspace;
}; };
#endif #endif
File diff suppressed because it is too large Load Diff
+95 -115
View File
@@ -65,127 +65,107 @@ class Layer;
class ServerWindow class ServerWindow
{ {
public: public:
ServerWindow( BRect rect, ServerWindow(BRect rect, const char *string, uint32 wlook, uint32 wfeel, uint32 wflags,
const char *string, ServerApp *winapp, port_id winport, port_id looperPort, port_id replyport,
uint32 wlook, uint32 index,int32 handlerID);
uint32 wfeel, virtual ~ServerWindow(void);
uint32 wflags,
ServerApp *winapp, void Init();
port_id winport,
port_id looperPort, void ReplaceDecorator(void);
port_id replyport, void Quit(void);
uint32 index, void Show(void);
int32 handlerID); void Hide(void);
virtual ~ServerWindow(void); bool IsHidden(void);
void Minimize(bool status);
void Zoom(void);
void SetFocus(bool value);
bool HasFocus(void);
void RequestDraw(BRect rect);
void RequestDraw(void);
void WorkspaceActivated(int32 workspace, bool active);
void WorkspacesChanged(int32 oldone,int32 newone);
void WindowActivated(bool active);
void ScreenModeChanged(const BRect frame, const color_space cspace);
void SetFrame(const BRect &rect);
BRect Frame(void);
status_t Lock(void);
void Unlock(void);
bool IsLocked(void);
thread_id ThreadID(void) const { return fMonitorThreadID;}
void DispatchMessage(int32 code);
void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer);
static int32 MonitorWin(void *data);
void PostMessage(int32 code, size_t size=0, int8 *buffer=NULL);
//! Returns the index of the workspaces to which it belongs
int32 GetWorkspaceIndex(void) { return fWorkspaces; }
Workspace *GetWorkspace(void);
void SetWorkspace(Workspace *wkspc);
//! Returns the window's title
const char *Title(void) { return fTitle.String(); }
Layer *CreateLayerTree(Layer *localRoot);
void SetLayerState(Layer *layer);
void SetLayerFontState(Layer *layer);
Layer *FindLayer(const Layer *start, int32 token) const;
void SendMessageToClient( const BMessage *msg ) const;
int32 Look(void) const { return fLook; }
int32 Feel(void) const { return fFeel; }
uint32 Flags(void) const { return fFlags; }
team_id ClientTeamID(void) const { return fClientTeamID; }
ServerApp *App(void) const { return fServerApp; }
uint32 Workspaces(void) const { return fWorkspaces; }
WinBorder *GetWinBorder(void) const { return fWinBorder; }
// server "private" - try not to use
void QuietlySetWorkspaces(uint32 wks) { fWorkspaces = wks; }
void QuietlySetFeel(int32 feel) { fFeel = feel; }
int32 ClientToken(void) const { return fHandlerToken; }
FMWList fWinFMWList;
void Init();
void ReplaceDecorator(void);
void Quit(void);
void Show(void);
void Hide(void);
bool IsHidden(void);
void Minimize(bool status);
void Zoom(void);
void SetFocus(bool value);
bool HasFocus(void);
void RequestDraw(BRect rect);
void RequestDraw(void);
void WorkspaceActivated(int32 workspace, bool active);
void WorkspacesChanged(int32 oldone,int32 newone);
void WindowActivated(bool active);
void ScreenModeChanged(const BRect frame, const color_space cspace);
void SetFrame(const BRect &rect);
BRect Frame(void);
status_t Lock(void);
void Unlock(void);
bool IsLocked(void);
thread_id ThreadID(void) const
{ return fMonitorThreadID;}
void DispatchMessage(int32 code);
void DispatchGraphicsMessage(int32 msgsize, int8 *msgbuffer);
static int32 MonitorWin(void *data);
static void HandleMouseEvent(PortMessage *msg);
static void HandleKeyEvent(int32 code, int8 *buffer);
void PostMessage(int32 code, size_t size=0, int8 *buffer=NULL);
//! Returns the index of the workspaces to which it belongs
int32 GetWorkspaceIndex(void)
{ return fWorkspaces; }
Workspace* GetWorkspace(void);
void SetWorkspace(Workspace *wkspc);
//! Returns the window's title
const char* Title(void)
{ return fTitle.String(); }
Layer* CreateLayerTree(Layer *localRoot);
void SetLayerState(Layer *layer);
void SetLayerFontState(Layer *layer);
Layer* FindLayer(const Layer* start, int32 token) const;
void SendMessageToClient( const BMessage* msg ) const;
int32 Look(void) const
{ return fLook; }
int32 Feel(void) const
{ return fFeel; }
uint32 Flags(void) const
{ return fFlags; }
team_id ClientTeamID(void) const
{ return fClientTeamID; }
ServerApp* App(void) const
{ return fServerApp; }
uint32 Workspaces(void) const
{ return fWorkspaces; }
WinBorder* GetWinBorder(void) const
{ return fWinBorder; }
// server "private" - try not to use
void QuietlySetWorkspaces(uint32 wks)
{ fWorkspaces = wks; }
void QuietlySetFeel(int32 feel)
{ fFeel = feel; }
int32 ClientToken(void) const
{ return fHandlerToken; }
FMWList fWinFMWList;
protected: protected:
friend class ServerApp; friend class ServerApp;
friend class WinBorder; friend class WinBorder;
friend class Screen; friend class Screen;
friend class Layer; friend class Layer;
BString fTitle; BString fTitle;
int32 fLook, int32 fLook;
fFeel, int32 fFeel;
fFlags; int32 fFlags;
uint32 fWorkspaces; uint32 fWorkspaces;
Workspace* fWorkspace; Workspace *fWorkspace;
bool fIsActive; bool fIsActive;
ServerApp* fServerApp; ServerApp *fServerApp;
WinBorder* fWinBorder; WinBorder *fWinBorder;
team_id fClientTeamID; team_id fClientTeamID;
thread_id fMonitorThreadID; thread_id fMonitorThreadID;
port_id fMessagePort;
port_id fClientWinPort;
port_id fClientLooperPort;
BLocker fLocker;
BRect fFrame;
uint32 fToken;
int32 fHandlerToken;
BSession *fSession;
Layer *fTopLayer;
port_id fMessagePort; // cl is short for currentLayer. We'll use it a lot, that's why it's short :-)
port_id fClientWinPort; Layer *cl;
port_id fClientLooperPort;
BLocker fLocker;
BRect fFrame;
uint32 fToken;
int32 fHandlerToken;
BSession* fSession;
Layer* fTopLayer;
Layer* cl; // short for currentLayer. We'll use it a lot, that's why it's short :-)
}; };
#endif #endif