Files
haiku-beta6/src/servers/app/server/RootLayer.cpp
T

690 lines
20 KiB
C++
Raw Normal View History

2004-01-17 18:37:57 +00:00
//------------------------------------------------------------------------------
// Copyright (c) 2001-2003, OpenBeOS
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// File Name: RootLayer.cpp
// Author: Gabe Yoder <[email protected]>
// DarkWyrm <[email protected]>
// Adi Oanca <[email protected]>
// Description: Class used for the top layer of each workspace's Layer tree
//
//------------------------------------------------------------------------------
#include <stdio.h>
#include <Window.h>
#include <List.h>
#include "Globals.h"
#include "RootLayer.h"
#include "Layer.h"
#include "Workspace.h"
#include "ServerScreen.h"
#include "WinBorder.h"
#include "ServerWindow.h"
2004-01-13 00:56:36 +00:00
#include "ServerApp.h"
#include "Desktop.h"
#include "FMWList.h"
2004-01-13 00:56:36 +00:00
#include "DisplayDriver.h"
2004-01-17 18:37:57 +00:00
//#define DEBUG_ROOTLAYER
#ifdef DEBUG_ROOTLAYER
#define STRACE(a) printf(a)
#else
#define STRACE(a) /* nothing */
#endif
2004-01-13 00:56:36 +00:00
//#define DISPLAYDRIVER_TEST_HACK
//---------------------------------------------------------------------------
RootLayer::RootLayer(const char *layername, int32 workspaceCount, Desktop *desktop)
: Layer(BRect(0,0,0,0), layername, 0, B_NORMAL_WINDOW_FEEL, 0, NULL)
{
fDesktop = desktop;
fActiveWorkspace = NULL;
fRows = 0;
fColumns = 0;
2004-01-17 18:37:57 +00:00
// TODO: read these 3 from a configuration file.
fScreenXResolution = 0;
fScreenYResolution = 0;
fColorSpace = B_RGB32;
_view_token = 0; // is this used for WinBorders?
_hidden = false;
SetWorkspaceCount(workspaceCount);
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
RootLayer::~RootLayer()
{
// RootLayer object just uses Screen objects, it is not allowed to delete them.
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
void RootLayer::Draw(const BRect &r)
{
// REMOVEME: This method is here because of DisplayDriver testing ONLY.
// It should be removed when testing is finished
STRACE(("*RootLayer(%s)::Draw(r)\n", GetName()));
// NOTE: fMainLock MUST be locked when this method is called
2004-01-13 00:56:36 +00:00
if (!fMainLock.IsLocked())
2004-01-17 18:37:57 +00:00
printf("\n\n\tWARNING: fMainLock MUST be locked when calling RootLayer::Draw\n\n");
// NOTE: desktop->fGeneralLock MUST be locked when this method is called!!!
2004-01-13 00:56:36 +00:00
if (!desktop->fGeneralLock.IsLocked())
2004-01-17 18:37:57 +00:00
printf("\n\n\tWARNING: desktop->fGeneralLock MUST be locked when calling RootLayer::Draw()\n\n");
2004-01-13 00:56:36 +00:00
2004-01-17 18:37:57 +00:00
// NOTE: in case you have problems - ActiveWorkspace()->opLock was
// acquired in Workspace::Invalidate()
2004-01-13 00:56:36 +00:00
RGBColor c(51,102,152);
fDriver->FillRect(Bounds(), c);
Workspace *as = ActiveWorkspace();
WinBorder *wb = NULL;
2004-01-17 18:37:57 +00:00
for (wb = as->GoToTopItem(); wb; wb = as->GoToLowerItem())
{
STRACE(("requesting draw? %s from %s\n", wb->IsHidden()?"NO":"YES", wb->GetName()));
2004-01-13 00:56:36 +00:00
if (!(wb->IsHidden()))
wb->Draw(wb->Bounds());
}
2004-01-17 18:37:57 +00:00
STRACE(("#RootLayer(%s)::Draw(r) END\n", GetName()));
#ifdef DISPLAYDRIVER_TEST_HACK
2004-01-13 00:56:36 +00:00
DisplayDriver *_driver = fDriver;
int8 pattern[8];
int8 pattern2[8];
memset(pattern,255,8);
memset(pattern2,128+64+32+16,8);
BRect r1(100,100,1500,1100);
BPoint pts[4];
pts[0].x = 200;
pts[0].y = 200;
pts[1].x = 400;
pts[1].y = 1000;
pts[2].x = 600;
pts[2].y = 400;
pts[3].x = 1200;
pts[3].y = 800;
BPoint triangle[3];
BRect triangleRect(100,100,400,300);
triangle[0].x = 100;
triangle[0].y = 100;
triangle[1].x = 100;
triangle[1].y = 300;
triangle[2].x = 400;
triangle[2].y = 300;
BPoint polygon[6];
BRect polygonRect(100,100,300,400);
polygon[0].x = 100;
polygon[0].y = 100;
polygon[1].x = 100;
polygon[1].y = 400;
polygon[2].x = 200;
polygon[2].y = 300;
polygon[3].x = 300;
polygon[3].y = 400;
polygon[4].x = 300;
polygon[4].y = 100;
polygon[5].x = 200;
polygon[5].y = 200;
_layerdata->highcolor.SetColor(255,0,0,255);
_layerdata->lowcolor.SetColor(255,255,255,255);
_driver->FillRect(r1,_layerdata,pattern);
_layerdata->highcolor.SetColor(255,255,0,255);
_driver->StrokeLine(BPoint(100,100),BPoint(1500,1100),_layerdata,pattern);
_layerdata->highcolor.SetColor(0,0,255,255);
_driver->StrokeBezier(pts,_layerdata,pattern);
_driver->StrokeArc(BRect(200,300,400,600),30,270,_layerdata,pattern);
_driver->StrokeEllipse(BRect(200,700,400,900),_layerdata,pattern);
_driver->StrokeRect(BRect(650,1000,750,1090),_layerdata,pattern);
_driver->StrokeRoundRect(BRect(200,1000,600,1090),30,40,_layerdata,pattern);
// _driver->StrokePolygon(polygon,6,polygonRect,_layerdata,pattern);
// _driver->StrokeTriangle(triangle,triangleRect,_layerdata,pattern);
_layerdata->highcolor.SetColor(255,0,255,255);
_driver->FillArc(BRect(1250,300,1450,600),30,270,_layerdata,pattern);
// _driver->FillBezier(pts,_layerdata,pattern);
_driver->FillEllipse(BRect(800,300,1200,600),_layerdata,pattern);
_driver->FillRoundRect(BRect(800,1000,1200,1090),30,40,_layerdata,pattern2);
_driver->FillPolygon(polygon,6,polygonRect,_layerdata,pattern);
// _driver->FillTriangle(triangle,triangleRect,_layerdata,pattern);
#endif
2004-01-13 00:56:36 +00:00
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
void RootLayer::MoveBy(float x, float y)
{
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
void RootLayer::ResizeBy(float x, float y)
{
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
Layer* RootLayer::VirtualTopChild() const
{
return fActiveWorkspace->GoToTopItem();
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
Layer* RootLayer::VirtualLowerSibling() const
{
return fActiveWorkspace->GoToLowerItem();
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
Layer* RootLayer::VirtualUpperSibling() const
{
return fActiveWorkspace->GoToUpperItem();
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
Layer* RootLayer::VirtualBottomChild() const
{
return fActiveWorkspace->GoToBottomItem();
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
void RootLayer::AddWinBorderToWorkspaces(WinBorder* winBorder, uint32 wks)
{
2004-01-14 15:55:10 +00:00
if (!(fMainLock.IsLocked()))
debugger("RootLayer::AddWinBorderToWorkspaces - fMainLock has to be locked!\n");
2004-01-17 18:37:57 +00:00
if (wks == B_CURRENT_WORKSPACE)
{
ActiveWorkspace()->AddLayerPtr(winBorder);
return;
}
2004-01-17 18:37:57 +00:00
for( int32 i=0; i < 32; i++)
{
if( wks & (0x00000001 << i) && i < WorkspaceCount())
WorkspaceAt(i+1)->AddLayerPtr(winBorder);
}
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
void RootLayer::AddWinBorder(WinBorder* winBorder)
{
// The main job of this function, besides adding winBorder as a child, is to determine
// in which workspaces to add this window.
STRACE(("*RootLayer::AddWinBorder(%s)\n", winBorder->GetName()));
desktop->fGeneralLock.Lock();
STRACE(("*RootLayer::AddWinBorder(%s) - General lock acquired\n", winBorder->GetName()));
fMainLock.Lock();
STRACE(("*RootLayer::AddWinBorder(%s) - Main lock acquired\n", winBorder->GetName()));
// add winBorder to the known list of WinBorders so we can keep track of it.
AddChild(winBorder, this);
2004-01-17 18:37:57 +00:00
// add winBorder to the desired workspaces
switch(winBorder->Window()->Feel())
{
case B_MODAL_SUBSET_WINDOW_FEEL:
{
// this kind of window isn't added anywhere. It will be added
// to main window's subset when winBorder::AddToSubsetOf(main)
// will be called.
break;
}
2004-01-17 18:37:57 +00:00
case B_MODAL_APP_WINDOW_FEEL:
{
// add to app's list of Floating/Modal windows (as opposed to the system's)
2004-01-13 00:56:36 +00:00
winBorder->Window()->App()->fAppFMWList.AddItem(winBorder);
2003-11-14 00:15:29 +00:00
2004-01-17 18:37:57 +00:00
// determine in witch workspaces to add this winBorder.
uint32 wks = 0;
2004-01-17 18:37:57 +00:00
// TODO: change later when you put this code into the server
for (int32 i=0; i<WorkspaceCount(); i++)
{
Workspace *ws = WorkspaceAt(i+1);
2004-01-17 18:37:57 +00:00
for (WinBorder *wb = ws->GoToBottomItem(); wb!=NULL; wb = ws->GoToUpperItem())
{
if ( !(wb->IsHidden()) &&
2004-01-13 00:56:36 +00:00
winBorder->Window()->ClientTeamID() == wb->Window()->ClientTeamID())
{
2004-01-13 00:56:36 +00:00
wks = wks | winBorder->Window()->Workspaces();
break;
}
}
}
2004-01-17 18:37:57 +00:00
// by using _bottomchild and _uppersibling.
2003-11-14 00:15:29 +00:00
AddWinBorderToWorkspaces(winBorder, wks);
break;
}
2004-01-17 18:37:57 +00:00
case B_MODAL_ALL_WINDOW_FEEL:
{
// add to system's list of Floating/Modal Windows (as opposed to the app's list)
fMainFMWList.AddItem(winBorder);
2004-01-17 18:37:57 +00:00
// add this winBorder to all workspaces
AddWinBorderToWorkspaces(winBorder, 0xffffffffUL);
break;
}
2004-01-17 18:37:57 +00:00
case B_FLOATING_SUBSET_WINDOW_FEEL:
{
// this kind of window isn't added anywhere. It *will* be added to WS's list
// when its main window will become the front one.
// Also, it will be added to MainWinBorder's list when
// winBorder::AddToSubset(main) is called.
break;
}
2004-01-17 18:37:57 +00:00
case B_FLOATING_APP_WINDOW_FEEL:
{
// add to app's list of Floating/Modal windows (as opposed to the system's)
2004-01-13 00:56:36 +00:00
winBorder->Window()->App()->fAppFMWList.AddItem(winBorder);
for (int32 i=0; i<WorkspaceCount(); i++){
Workspace *ws = WorkspaceAt(i+1);
WinBorder *wb = ws->FrontLayer();
2004-01-13 00:56:36 +00:00
if(wb && wb->Window()->ClientTeamID() == winBorder->Window()->ClientTeamID()
&& wb->Window()->Feel() == B_NORMAL_WINDOW_FEEL)
{
ws->AddLayerPtr(winBorder);
}
}
break;
}
2004-01-17 18:37:57 +00:00
case B_FLOATING_ALL_WINDOW_FEEL:
{
// add to system's list of Floating/Modal Windows (as opposed to the app's list)
fMainFMWList.AddItem(winBorder);
2004-01-17 18:37:57 +00:00
// add this winBorder to all workspaces
AddWinBorderToWorkspaces(winBorder, 0xffffffffUL);
break;
}
2004-01-17 18:37:57 +00:00
case B_NORMAL_WINDOW_FEEL:
{
// add this winBorder to the specified workspaces
2004-01-13 00:56:36 +00:00
AddWinBorderToWorkspaces(winBorder, winBorder->Window()->Workspaces());
break;
}
case B_SYSTEM_LAST:
2004-01-17 18:37:57 +00:00
case B_SYSTEM_FIRST:
{
// add this winBorder to all workspaces
AddWinBorderToWorkspaces(winBorder, 0xffffffffUL);
break;
}
default:
break;
2004-01-17 18:37:57 +00:00
} // end switch(winborder->Feel())
fMainLock.Unlock();
STRACE(("*RootLayer::AddWinBorder(%s) - Main lock released\n", winBorder->GetName()));
desktop->fGeneralLock.Unlock();
STRACE(("*RootLayer::AddWinBorder(%s) - General lock released\n", winBorder->GetName()));
STRACE(("#RootLayer::AddWinBorder(%s)\n", winBorder->GetName()));
}
2004-01-17 18:37:57 +00:00
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
void RootLayer::RemoveWinBorder(WinBorder* winBorder)
{
// This method does 3 things:
// 1) Removes MODAL/SUBSET windows from system/app/window subset list.
// 2) Removes this window from any workspace it appears in.
// 3) Removes this window from RootLayer's list of chilren.
desktop->fGeneralLock.Lock();
fMainLock.Lock();
2004-01-13 00:56:36 +00:00
int32 feel = winBorder->Window()->Feel();
2004-01-17 18:37:57 +00:00
if(feel == B_MODAL_SUBSET_WINDOW_FEEL || feel == B_FLOATING_SUBSET_WINDOW_FEEL)
{
desktop->RemoveSubsetWindow(winBorder);
}
2004-01-17 18:37:57 +00:00
else if (feel == B_MODAL_APP_WINDOW_FEEL || feel == B_FLOATING_APP_WINDOW_FEEL)
{
RemoveAppWindow(winBorder);
}
else if(feel == B_MODAL_ALL_WINDOW_FEEL || feel == B_FLOATING_ALL_WINDOW_FEEL
|| feel == B_SYSTEM_FIRST || feel == B_SYSTEM_LAST)
{
if(feel == B_MODAL_ALL_WINDOW_FEEL || feel == B_FLOATING_ALL_WINDOW_FEEL)
fMainFMWList.RemoveItem(winBorder);
int32 count = WorkspaceCount();
for(int32 i=0; i < count; i++)
WorkspaceAt(i+1)->RemoveLayerPtr(winBorder);
}
2004-01-17 18:37:57 +00:00
else
{ // for B_NORMAL_WINDOW_FEEL
2004-01-13 00:56:36 +00:00
uint32 workspaces = winBorder->Window()->Workspaces();
int32 count = WorkspaceCount();
for( int32 i=0; i < 32 && i < count; i++)
2004-01-17 18:37:57 +00:00
if( workspaces & (0x00000001UL << i))
WorkspaceAt(i+1)->RemoveLayerPtr(winBorder);
}
RemoveChild(winBorder);
2004-01-17 18:37:57 +00:00
fMainLock.Unlock();
desktop->fGeneralLock.Unlock();
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
void RootLayer::ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces)
{
// only normal windows are affected by this change
if(!winBorder->_level != B_NORMAL_FEEL)
return;
2004-01-13 00:56:36 +00:00
uint32 oldWorkspaces = winBorder->Window()->Workspaces();
2004-01-17 18:37:57 +00:00
for(int32 i=0; i < WorkspaceCount(); i++)
{
if ((oldWorkspaces & (0x00000001 << i)) && (newWorkspaces & (0x00000001 << i)))
{
// do nothing.
}
2004-01-17 18:37:57 +00:00
else if(oldWorkspaces & (0x00000001 << i))
{
WorkspaceAt(i+1)->RemoveLayerPtr(winBorder);
}
2004-01-17 18:37:57 +00:00
else if (newWorkspaces & (0x00000001 << i))
{
WorkspaceAt(i+1)->AddLayerPtr(winBorder);
}
}
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
bool RootLayer::SetFrontWinBorder(WinBorder* winBorder)
{
if(!winBorder)
return false;
STRACE(("*RootLayer::SetFrontWinBorder(%s)\n", winBorder? winBorder->GetName():"NULL"));
fMainLock.Lock();
STRACE(("*RootLayer::SetFrontWinBorder(%s) - main lock acquired\n", winBorder? winBorder->GetName():"NULL"));
if (!winBorder)
{
2004-01-13 00:56:36 +00:00
ActiveWorkspace()->SetFrontLayer(NULL);
return true;
}
2004-01-17 18:37:57 +00:00
uint32 workspaces = winBorder->Window()->Workspaces();
int32 count = WorkspaceCount();
int32 newWorkspace= 0;
2004-01-13 00:56:36 +00:00
2004-01-17 18:37:57 +00:00
if (workspaces & (0x00000001UL << (ActiveWorkspaceIndex()-1)) )
{
2004-01-13 00:56:36 +00:00
newWorkspace = ActiveWorkspaceIndex();
}
2004-01-17 18:37:57 +00:00
else
{
2004-01-13 00:56:36 +00:00
int32 i;
for( i = 0; i < 32 && i < count; i++)
2004-01-17 18:37:57 +00:00
if( workspaces & (0x00000001UL << i))
{
2004-01-13 00:56:36 +00:00
newWorkspace = i+1;
break;
}
if (i == count || i == 32)
newWorkspace = ActiveWorkspaceIndex();
}
2004-01-17 18:37:57 +00:00
if(newWorkspace != ActiveWorkspaceIndex())
{
2004-01-13 00:56:36 +00:00
WorkspaceAt(newWorkspace)->SetFrontLayer(winBorder);
SetActiveWorkspaceByIndex(newWorkspace);
}
else{
ActiveWorkspace()->SetFrontLayer(winBorder);
}
2004-01-17 18:37:57 +00:00
fMainLock.Unlock();
STRACE(("*RootLayer::SetFrontWinBorder(%s) - main lock released\n", winBorder? winBorder->GetName():"NULL"));
STRACE(("#RootLayer::SetFrontWinBorder(%s)\n", winBorder? winBorder->GetName():"NULL"));
2004-01-13 00:56:36 +00:00
return true;
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
void RootLayer::SetScreens(Screen *screen[], int32 rows, int32 columns)
{
// NOTE: All screens *must* have the same resolution
fScreenPtrList.MakeEmpty();
BRect newFrame(0, 0, 0, 0);
2004-01-17 18:37:57 +00:00
for (int32 i=0; i < rows; i++)
{
if (i==0)
2004-01-17 18:37:57 +00:00
for(int32 j=0; j < columns; j++)
{
fScreenPtrList.AddItem(screen[i*rows + j]);
newFrame.right += screen[i*rows + j]->Resolution().x;
}
newFrame.bottom += screen[i*rows]->Resolution().y;
}
newFrame.right -= 1;
newFrame.bottom -= 1;
_frame = newFrame;
fRows = rows;
fColumns = columns;
fScreenXResolution = (int32)(screen[0]->Resolution().x);
fScreenYResolution = (int32)(screen[0]->Resolution().y);
// RebuildRegions(Frame());
// Invalidate(Frame());
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
Screen** RootLayer::Screens()
{
return (Screen**)fScreenPtrList.Items();
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
bool RootLayer::SetScreenResolution(int32 width, int32 height, uint32 colorspace)
{
if (fScreenXResolution == width && fScreenYResolution == height &&
fColorSpace == colorspace)
return false;
2004-01-17 18:37:57 +00:00
bool accepted = true;
2004-01-17 18:37:57 +00:00
for (int i=0; i < fScreenPtrList.CountItems(); i++)
{
Screen *screen;
screen = static_cast<Screen*>(fScreenPtrList.ItemAt(i));
if ( !(screen->SupportsResolution(BPoint(width, height), colorspace)) )
2004-01-17 18:37:57 +00:00
accepted = false;
}
2004-01-17 18:37:57 +00:00
if (accepted)
{
for (int i=0; i < fScreenPtrList.CountItems(); i++)
{
Screen *screen;
screen = static_cast<Screen*>(fScreenPtrList.ItemAt(i));
screen->SetResolution(BPoint(width, height), colorspace);
}
Screen **screens = (Screen**)fScreenPtrList.Items();
SetScreens(screens, fRows, fColumns);
return true;
}
return false;
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
void RootLayer::SetWorkspaceCount(const int32 count)
{
STRACE(("*RootLayer::SetWorkspaceCount(%ld)\n", count));
if ((count < 1 && count > 32) || count == WorkspaceCount())
return;
2004-01-17 18:37:57 +00:00
int32 exActiveWorkspaceIndex = ActiveWorkspaceIndex();
2004-01-17 18:37:57 +00:00
BList newWSPtrList;
void *workspacePtr;
2003-02-15 15:28:22 +00:00
2004-01-17 18:37:57 +00:00
fMainLock.Lock();
STRACE(("*RootLayer::SetWorkspaceCount(%ld) - main lock acquired\n", count));
for(int i=0; i < count; i++)
{
workspacePtr = fWSPtrList.ItemAt(i);
2004-01-17 18:37:57 +00:00
if (workspacePtr)
newWSPtrList.AddItem(workspacePtr);
2004-01-17 18:37:57 +00:00
else
{
Workspace *ws;
2004-01-17 18:37:57 +00:00
ws = new Workspace(fColorSpace, i+1, BGColor(), this);
newWSPtrList.AddItem(ws);
}
}
2004-01-17 18:37:57 +00:00
// delete other Workspace objects if the count is smaller than current one.
for (int j=count; j < fWSPtrList.CountItems(); j++)
{
Workspace *ws = NULL;
2004-01-17 18:37:57 +00:00
ws = static_cast<Workspace*>(fWSPtrList.ItemAt(j));
if (ws)
delete ws;
2004-01-17 18:37:57 +00:00
else
{
STRACE(("\nSERVER: PANIC: in RootLayer::SetWorkspaceCount()\n\n"));
return;
}
}
2004-01-17 18:37:57 +00:00
fWSPtrList = newWSPtrList;
2004-01-13 00:56:36 +00:00
2004-01-17 18:37:57 +00:00
fMainLock.Unlock();
STRACE(("*RootLayer::SetWorkspaceCount(%ld) - main lock released\n", count));
if (exActiveWorkspaceIndex > count)
SetActiveWorkspaceByIndex(count);
2003-02-15 15:28:22 +00:00
2004-01-17 18:37:57 +00:00
// if true, this is the first time this method is called.
if (exActiveWorkspaceIndex == -1)
SetActiveWorkspaceByIndex(1);
2004-01-17 18:37:57 +00:00
STRACE(("#RootLayer::SetWorkspaceCount(%ld)\n", count));
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
int32 RootLayer::WorkspaceCount() const
{
return fWSPtrList.CountItems();
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
Workspace* RootLayer::WorkspaceAt(const int32 index) const
{
Workspace *ws = NULL;
ws = static_cast<Workspace*>(fWSPtrList.ItemAt(index-1));
2003-11-14 00:15:29 +00:00
return ws;
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
void RootLayer::SetActiveWorkspaceByIndex(const int32 index)
{
Workspace *ws = NULL;
ws = static_cast<Workspace*>(fWSPtrList.ItemAt(index-1));
if (ws)
SetActiveWorkspace(ws);
2003-02-15 15:28:22 +00:00
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
void RootLayer::SetActiveWorkspace(Workspace *ws)
{
if (fActiveWorkspace == ws || !ws)
return;
fActiveWorkspace = ws;
// RebuildRegions(Frame());
// Invalidate(Frame());
}
//---------------------------------------------------------------------------
int32 RootLayer::ActiveWorkspaceIndex() const{
if (fActiveWorkspace)
return fActiveWorkspace->ID();
else
return -1;
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
Workspace* RootLayer::ActiveWorkspace() const
{
return fActiveWorkspace;
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
void RootLayer::SetBGColor(const RGBColor &col)
{
ActiveWorkspace()->SetBGColor(col);
_layerdata->viewcolor = col;
// Invalidate(Frame());
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
RGBColor RootLayer::BGColor(void) const
{
return _layerdata->viewcolor;
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
void RootLayer::RemoveAppWindow(WinBorder *wb)
{
2004-01-13 00:56:36 +00:00
wb->Window()->App()->fAppFMWList.RemoveItem(wb);
int32 count = WorkspaceCount();
2004-01-17 18:37:57 +00:00
for(int32 i=0; i < count; i++)
WorkspaceAt(i+1)->RemoveLayerPtr(wb);
}
//---------------------------------------------------------------------------
2004-01-17 18:37:57 +00:00
void RootLayer::PrintToStream()
{
printf("\nRootLayer '%s' internals:\n", GetName());
printf("Screen list:\n");
2004-01-17 18:37:57 +00:00
for(int32 i=0; i<fScreenPtrList.CountItems(); i++)
printf("\t%ld\n", ((Screen*)fScreenPtrList.ItemAt(i))->ScreenNumber());
2004-01-17 18:37:57 +00:00
printf("Screen rows: %ld\nScreen columns: %ld\n", fRows, fColumns);
printf("Resolution for all Screens: %ldx%ldx%ld\n", fScreenXResolution, fScreenYResolution, fColorSpace);
printf("Workspace list:\n");
2004-01-17 18:37:57 +00:00
for(int32 i=0; i<fWSPtrList.CountItems(); i++)
{
printf("\t~~~Workspace: %ld\n", ((Workspace*)fWSPtrList.ItemAt(i))->ID());
((Workspace*)fWSPtrList.ItemAt(i))->PrintToStream();
printf("~~~~~~~~\n");
}
printf("Active Workspace: %ld\n", fActiveWorkspace? fActiveWorkspace->ID(): -1);
2003-02-15 15:28:22 +00:00
}