Removed locking from Workspace class. Rootlayer should be the only one who uses this class. Also changed Workspace::AddLayerPtr() into AddWinBorder.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8374 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -846,7 +846,7 @@ void Desktop::RemoveSubsetWindow(WinBorder* wb)
|
||||
|
||||
int32 countWKs = rl->WorkspaceCount();
|
||||
for (int32 i=0; i < countWKs; i++)
|
||||
rl->WorkspaceAt(i+1)->RemoveLayerPtr(wb);
|
||||
rl->WorkspaceAt(i+1)->RemoveWinBorder(wb);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ void RootLayer::AddWinBorderToWorkspaces(WinBorder* winBorder, uint32 wks)
|
||||
for( int32 i=0; i < 32; i++)
|
||||
{
|
||||
if( wks & (0x00000001 << i) && i < WorkspaceCount())
|
||||
WorkspaceAt(i+1)->AddLayerPtr(winBorder);
|
||||
WorkspaceAt(i+1)->AddWinBorder(winBorder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,7 +349,7 @@ void RootLayer::RemoveWinBorder(WinBorder* winBorder)
|
||||
|
||||
int32 count = WorkspaceCount();
|
||||
for(int32 i=0; i < count; i++)
|
||||
WorkspaceAt(i+1)->RemoveLayerPtr(winBorder);
|
||||
WorkspaceAt(i+1)->RemoveWinBorder(winBorder);
|
||||
}
|
||||
else
|
||||
{ // for B_NORMAL_WINDOW_FEEL
|
||||
@@ -358,7 +358,7 @@ void RootLayer::RemoveWinBorder(WinBorder* winBorder)
|
||||
for( int32 i=0; i < 32 && i < count; i++)
|
||||
{
|
||||
if( workspaces & (0x00000001UL << i))
|
||||
WorkspaceAt(i+1)->RemoveLayerPtr(winBorder);
|
||||
WorkspaceAt(i+1)->RemoveWinBorder(winBorder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,12 +399,12 @@ void RootLayer::ChangeWorkspacesFor(WinBorder* winBorder, uint32 newWorkspaces)
|
||||
else
|
||||
if(oldWorkspaces & (0x00000001 << i))
|
||||
{
|
||||
WorkspaceAt(i+1)->RemoveLayerPtr(winBorder);
|
||||
WorkspaceAt(i+1)->RemoveWinBorder(winBorder);
|
||||
}
|
||||
else
|
||||
if (newWorkspaces & (0x00000001 << i))
|
||||
{
|
||||
WorkspaceAt(i+1)->AddLayerPtr(winBorder);
|
||||
WorkspaceAt(i+1)->AddWinBorder(winBorder);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -560,7 +560,7 @@ void RootLayer::SetWorkspaceCount(const int32 count)
|
||||
else
|
||||
{
|
||||
Workspace *ws;
|
||||
ws = new Workspace(fColorSpace, i+1, BGColor(), this);
|
||||
ws = new Workspace(fColorSpace, i+1, BGColor());
|
||||
newWSPtrList.AddItem(ws);
|
||||
}
|
||||
}
|
||||
@@ -653,7 +653,7 @@ void RootLayer::RemoveAppWindow(WinBorder *wb)
|
||||
|
||||
int32 count = WorkspaceCount();
|
||||
for(int32 i=0; i < count; i++)
|
||||
WorkspaceAt(i+1)->RemoveLayerPtr(wb);
|
||||
WorkspaceAt(i+1)->RemoveWinBorder(wb);
|
||||
}
|
||||
|
||||
void RootLayer::PrintToStream()
|
||||
|
||||
@@ -515,7 +515,7 @@ void WinBorder::AddToSubsetOf(WinBorder* main)
|
||||
{
|
||||
Workspace *ws = rl->WorkspaceAt(i+1);
|
||||
if(ws->FrontLayer() == main)
|
||||
ws->AddLayerPtr(this);
|
||||
ws->AddWinBorder(this);
|
||||
}
|
||||
|
||||
rl->fMainLock.Unlock();
|
||||
@@ -549,7 +549,7 @@ void WinBorder::RemoveFromSubsetOf(WinBorder* main)
|
||||
|
||||
// if its main window is in 'i' workspaces, remove it from
|
||||
// workspace 'i' if it's in there...
|
||||
ws->RemoveLayerPtr(this);
|
||||
ws->RemoveWinBorder(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
// Author: Adi Oanca <[email protected]>
|
||||
// Description: Tracks workspaces
|
||||
//
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
// Notes: IMPORTANT WARNING
|
||||
// This object does not use any locking mechanism. It is designed
|
||||
// to be used only by RootLayer class. DO NOT USE from another class!
|
||||
//------------------------------------------------------------------------------
|
||||
#include <stdio.h>
|
||||
#include <Window.h>
|
||||
@@ -35,8 +39,6 @@
|
||||
#include "RGBColor.h"
|
||||
#include "Globals.h"
|
||||
#include "FMWList.h"
|
||||
#include "RootLayer.h"
|
||||
#include "Desktop.h"
|
||||
|
||||
//#define DEBUG_WORKSPACE
|
||||
|
||||
@@ -56,14 +58,12 @@
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
Workspace::Workspace(const uint32 colorspace, int32 ID, const RGBColor& BGColor, RootLayer *owner)
|
||||
Workspace::Workspace(const uint32 colorspace, int32 ID, const RGBColor& BGColor)
|
||||
{
|
||||
fID = ID;
|
||||
fSpace = colorspace;
|
||||
fBGColor = BGColor;
|
||||
|
||||
fOwner = owner;
|
||||
|
||||
fBottomItem = NULL;
|
||||
fTopItem = NULL;
|
||||
fCurrentItem= NULL;
|
||||
@@ -115,7 +115,7 @@ Workspace::~Workspace(void)
|
||||
to give focus to, having as preferred 'layer'.
|
||||
Remember, some windows having B_AVOID_FOCUS can't have the focus state.
|
||||
*/
|
||||
bool Workspace::AddLayerPtr(WinBorder *layer)
|
||||
bool Workspace::AddWinBorder(WinBorder *layer)
|
||||
{
|
||||
if (layer == NULL)
|
||||
debugger("NULL pointer in Workspace::AddLayerPtr\n");
|
||||
@@ -128,12 +128,9 @@ bool Workspace::AddLayerPtr(WinBorder *layer)
|
||||
item->upperItem = NULL;
|
||||
item->lowerItem = NULL;
|
||||
|
||||
fOpLock.Lock();
|
||||
|
||||
// insert 'item' at the end. It doesn't matter where we add it,
|
||||
// it will be placed correctly by SearchAndSetNewFront(item->layerPtr);
|
||||
InsertItem(item, NULL);
|
||||
fOpLock.Unlock();
|
||||
|
||||
STRACE(("\n*AddLayerPtr(%s) -", layer->GetName()));
|
||||
|
||||
@@ -154,9 +151,9 @@ bool Workspace::AddLayerPtr(WinBorder *layer)
|
||||
If this window was the front/focus one it calls SearchAndSetNew(Front/Focus)
|
||||
to give the respective state to the window below her.
|
||||
*/
|
||||
bool Workspace::RemoveLayerPtr(WinBorder *layer)
|
||||
bool Workspace::RemoveWinBorder(WinBorder *layer)
|
||||
{
|
||||
if(!layer)
|
||||
if (layer == NULL)
|
||||
return false;
|
||||
|
||||
STRACE(("\n*Workspace(%ld)::RemoveLayerPtr(%s)\n", ID(), layer->GetName()));
|
||||
@@ -166,7 +163,6 @@ bool Workspace::RemoveLayerPtr(WinBorder *layer)
|
||||
// search to see if this workspace has WinBorder's pointer in its list
|
||||
ListData *item = NULL;
|
||||
|
||||
fOpLock.Lock();
|
||||
if((item = HasItem(layer)))
|
||||
{
|
||||
ListData *nextItem = NULL;
|
||||
@@ -201,7 +197,6 @@ bool Workspace::RemoveLayerPtr(WinBorder *layer)
|
||||
RemoveItem(item);
|
||||
delete item;
|
||||
STRACESTREAM();
|
||||
fOpLock.Unlock();
|
||||
|
||||
// reset some internal variables
|
||||
layer->SetMainWinBorder(NULL);
|
||||
@@ -215,7 +210,6 @@ bool Workspace::RemoveLayerPtr(WinBorder *layer)
|
||||
else
|
||||
{
|
||||
STRACE(("Layer %s NOT found in Workspace No %ld\n", layer->GetName(), ID()));
|
||||
fOpLock.Unlock();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -230,7 +224,6 @@ bool Workspace::HideSubsetWindows(WinBorder *layer)
|
||||
// search to see if this workspace has WinBorder's pointer in its list
|
||||
ListData *item = NULL;
|
||||
|
||||
fOpLock.Lock();
|
||||
if((item = HasItem(layer)))
|
||||
{
|
||||
ListData *nextItem = NULL;
|
||||
@@ -259,13 +252,10 @@ bool Workspace::HideSubsetWindows(WinBorder *layer)
|
||||
}
|
||||
}
|
||||
|
||||
fOpLock.Unlock();
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
fOpLock.Unlock();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -552,7 +542,6 @@ ListData *Workspace::FindPlace(ListData *pref)
|
||||
void Workspace::SearchAndSetNewFront(WinBorder *preferred)
|
||||
{
|
||||
STRACE(("*WS(%ld)::SASNF(%s)\n", ID(), preferred? preferred->GetName(): "NULL"));
|
||||
fOpLock.Lock();
|
||||
|
||||
// the new front must not be the same as the previous one.
|
||||
if(fFrontItem && fFrontItem->layerPtr == preferred && !(preferred->IsHidden()))
|
||||
@@ -562,7 +551,6 @@ void Workspace::SearchAndSetNewFront(WinBorder *preferred)
|
||||
STRACESTREAM();
|
||||
STRACE(("#WS(%ld)::SASNF(%s) ENDED 1\n", ID(), preferred? preferred->GetName(): "NULL"));
|
||||
|
||||
fOpLock.Unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -581,7 +569,6 @@ void Workspace::SearchAndSetNewFront(WinBorder *preferred)
|
||||
STRACESTREAM();
|
||||
STRACE(("#WS(%ld)::SASNF(%s) ENDED 2\n", ID(), preferred? preferred->GetName(): "NULL"));
|
||||
|
||||
fOpLock.Unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1086,7 +1073,6 @@ void Workspace::SearchAndSetNewFront(WinBorder *preferred)
|
||||
fFrontItem = newFrontItem;
|
||||
// TODO: call a method like... WinBorder::MakeFront(true);
|
||||
}
|
||||
fOpLock.Unlock();
|
||||
|
||||
STRACE(("#WS(%ld)::SASNF(%s) ENDED! Workspace data...", ID(), preferred? preferred->GetName(): "NULL"));
|
||||
STRACESTREAM();
|
||||
@@ -1102,8 +1088,6 @@ void Workspace::SearchAndSetNewFocus(WinBorder *preferred)
|
||||
{
|
||||
STRACE(("*WS(%ld)::SASNFocus(%s)\n", ID(), preferred? preferred->GetName(): "NULL"));
|
||||
|
||||
fOpLock.Lock();
|
||||
|
||||
if(!preferred)
|
||||
preferred = fBottomItem? fBottomItem->layerPtr : NULL;
|
||||
|
||||
@@ -1175,8 +1159,6 @@ void Workspace::SearchAndSetNewFocus(WinBorder *preferred)
|
||||
// TODO: Rebuild & Redraw.
|
||||
fFocusItem = item;
|
||||
}
|
||||
|
||||
fOpLock.Unlock();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
@@ -1194,7 +1176,6 @@ void Workspace::BringToFrontANormalWindow(WinBorder *layer)
|
||||
case B_FLOATING_APP_WINDOW_FEEL:
|
||||
case B_MODAL_APP_WINDOW_FEEL:
|
||||
{
|
||||
fOpLock.Lock();
|
||||
ListData *item = fBottomItem;
|
||||
team_id tid = layer->Window()->ClientTeamID();
|
||||
while(item)
|
||||
@@ -1210,7 +1191,6 @@ void Workspace::BringToFrontANormalWindow(WinBorder *layer)
|
||||
if(item)
|
||||
SearchAndSetNewFront(item->layerPtr);
|
||||
|
||||
fOpLock.Unlock();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
// Author: Adi Oanca <[email protected]>
|
||||
// Description: Tracks workspaces
|
||||
//
|
||||
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
// Notes: IMPORTANT WARNING
|
||||
// This object does not use any locking mechanism. It is designed
|
||||
// to be used only by RootLayer class. DO NOT USE from another class!
|
||||
//------------------------------------------------------------------------------
|
||||
#ifndef _WORKSPACE_H_
|
||||
#define _WORKSPACE_H_
|
||||
@@ -34,8 +38,6 @@
|
||||
#include "RGBColor.h"
|
||||
|
||||
class WinBorder;
|
||||
class RBGColor;
|
||||
class RootLayer;
|
||||
|
||||
struct ListData
|
||||
{
|
||||
@@ -47,12 +49,11 @@ struct ListData
|
||||
class Workspace
|
||||
{
|
||||
public:
|
||||
Workspace(const uint32 colorspace, int32 ID, const RGBColor& BGColor,
|
||||
RootLayer *owner);
|
||||
Workspace(const uint32 colorspace, int32 ID, const RGBColor& BGColor);
|
||||
~Workspace(void);
|
||||
|
||||
bool AddLayerPtr(WinBorder *layer);
|
||||
bool RemoveLayerPtr(WinBorder *layer);
|
||||
bool AddWinBorder(WinBorder *layer);
|
||||
bool RemoveWinBorder(WinBorder *layer);
|
||||
bool HideSubsetWindows(WinBorder *layer);
|
||||
WinBorder *FocusLayer(void) const;
|
||||
WinBorder *FrontLayer(void) const;
|
||||
@@ -89,13 +90,12 @@ public:
|
||||
void SearchAndSetNewFocus(WinBorder *preferred);
|
||||
void BringToFrontANormalWindow(WinBorder *layer);
|
||||
|
||||
ListData *HasItem(WinBorder *layer);
|
||||
|
||||
private:
|
||||
|
||||
void InsertItem(ListData *item, ListData *before);
|
||||
void RemoveItem(ListData *item);
|
||||
ListData *HasItem(ListData *item);
|
||||
ListData *HasItem(WinBorder *layer);
|
||||
|
||||
ListData *FindPlace(ListData *pref);
|
||||
|
||||
@@ -103,23 +103,19 @@ private:
|
||||
uint32 fSpace;
|
||||
RGBColor fBGColor;
|
||||
|
||||
BLocker fOpLock;
|
||||
|
||||
RootLayer *fOwner;
|
||||
|
||||
// first visible onscreen
|
||||
ListData *fBottomItem;
|
||||
|
||||
// the last visible(or covered by other Layers)
|
||||
ListData *fTopItem;
|
||||
|
||||
// pointer to the currect element in the list
|
||||
// pointer to the current element in the list
|
||||
ListData *fCurrentItem;
|
||||
|
||||
// the focus WinBorder - for keyboard events
|
||||
ListData *fFocusItem;
|
||||
|
||||
// the one the mouse can bring in front as possible(in its set)
|
||||
// the item that is the target of mouse operations
|
||||
ListData *fFrontItem;
|
||||
|
||||
// settings for each workspace -- example taken from R5's app_server_settings file
|
||||
|
||||
Reference in New Issue
Block a user