Cleanup started in Workspace and RootLayer classes. Some 'Invalidat' code moved from Workspace to Desktop class.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8365 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -259,6 +259,14 @@ void Desktop::AddWinBorder(WinBorder* winBorder)
|
|||||||
// other windows are added to the current RootLayer only.
|
// other windows are added to the current RootLayer only.
|
||||||
ActiveRootLayer()->AddWinBorder(winBorder);
|
ActiveRootLayer()->AddWinBorder(winBorder);
|
||||||
|
|
||||||
|
// TODO: try to unify this code with that for B_MOUSE_DOWN
|
||||||
|
winBorder->Window()->Lock();
|
||||||
|
BRegion invalidRegion;
|
||||||
|
invalidRegion.Include(&(winBorder->fFull));
|
||||||
|
invalidRegion.Include(&(winBorder->fTopLayer->fFull));
|
||||||
|
winBorder->fParent->RebuildAndForceRedraw(invalidRegion, winBorder);
|
||||||
|
winBorder->Window()->Unlock();
|
||||||
|
|
||||||
// add that pointer to user winboder list so that we can keep track of them.
|
// add that pointer to user winboder list so that we can keep track of them.
|
||||||
fLayerLock.Lock();
|
fLayerLock.Lock();
|
||||||
fWinBorderList.AddItem(winBorder);
|
fWinBorderList.AddItem(winBorder);
|
||||||
@@ -345,7 +353,8 @@ printf("Focus: %s\n", ws->FocusLayer()->GetName());
|
|||||||
ws->BringToFrontANormalWindow(target);
|
ws->BringToFrontANormalWindow(target);
|
||||||
ws->SearchAndSetNewFront(target);
|
ws->SearchAndSetNewFront(target);
|
||||||
previousFocus = ws->FocusLayer();
|
previousFocus = ws->FocusLayer();
|
||||||
activeFocus = ws->SetFocusLayer(target);
|
ws->SearchAndSetNewFocus(target);
|
||||||
|
activeFocus = ws->FocusLayer();
|
||||||
|
|
||||||
activeFocus->Window()->Lock();
|
activeFocus->Window()->Lock();
|
||||||
|
|
||||||
|
|||||||
@@ -446,7 +446,15 @@ void Layer::RequestDraw(const BRegion ®, Layer *startFrom)
|
|||||||
int redraw = false;
|
int redraw = false;
|
||||||
if (startFrom == NULL)
|
if (startFrom == NULL)
|
||||||
redraw = true;
|
redraw = true;
|
||||||
|
/*
|
||||||
|
srand(real_time_clock_usecs());
|
||||||
|
RGBColor c(rand()/256,34,56);
|
||||||
|
BRegion reg1 = reg;
|
||||||
|
fDriver->ConstrainClippingRegion(®1);
|
||||||
|
fDriver->FillRect(reg.Frame(), c);
|
||||||
|
fDriver->ConstrainClippingRegion(NULL);
|
||||||
|
snooze(1000000);
|
||||||
|
*/
|
||||||
if (fVisible.CountRects() > 0)
|
if (fVisible.CountRects() > 0)
|
||||||
{
|
{
|
||||||
// client side drawing. Send only one UPDATE message!
|
// client side drawing. Send only one UPDATE message!
|
||||||
@@ -526,7 +534,6 @@ void Layer::RequestDraw(const BRegion ®, Layer *startFrom)
|
|||||||
void Layer::Draw(const BRect &r)
|
void Layer::Draw(const BRect &r)
|
||||||
{
|
{
|
||||||
// TODO/NOTE: this should be an empty method! the next lines are for testing only
|
// TODO/NOTE: this should be an empty method! the next lines are for testing only
|
||||||
|
|
||||||
#ifdef DEBUG_LAYER
|
#ifdef DEBUG_LAYER
|
||||||
printf("Layer::Draw: ");
|
printf("Layer::Draw: ");
|
||||||
r.PrintToStream();
|
r.PrintToStream();
|
||||||
|
|||||||
@@ -216,12 +216,6 @@ void RootLayer::AddWinBorderToWorkspaces(WinBorder* winBorder, uint32 wks)
|
|||||||
if (!(fMainLock.IsLocked()))
|
if (!(fMainLock.IsLocked()))
|
||||||
debugger("RootLayer::AddWinBorderToWorkspaces - fMainLock has to be locked!\n");
|
debugger("RootLayer::AddWinBorderToWorkspaces - fMainLock has to be locked!\n");
|
||||||
|
|
||||||
if (wks == B_CURRENT_WORKSPACE)
|
|
||||||
{
|
|
||||||
ActiveWorkspace()->AddLayerPtr(winBorder);
|
|
||||||
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())
|
||||||
@@ -243,7 +237,7 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
|
|||||||
STRACE(("*RootLayer::AddWinBorder(%s) - Main lock acquired\n", winBorder->GetName()));
|
STRACE(("*RootLayer::AddWinBorder(%s) - Main lock acquired\n", winBorder->GetName()));
|
||||||
|
|
||||||
// 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() == B_CURRENT_WORKSPACE)
|
||||||
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.
|
||||||
@@ -253,86 +247,43 @@ void RootLayer::AddWinBorder(WinBorder* winBorder)
|
|||||||
switch(winBorder->Window()->Feel())
|
switch(winBorder->Window()->Feel())
|
||||||
{
|
{
|
||||||
case B_MODAL_SUBSET_WINDOW_FEEL:
|
case B_MODAL_SUBSET_WINDOW_FEEL:
|
||||||
|
case B_FLOATING_SUBSET_WINDOW_FEEL:
|
||||||
{
|
{
|
||||||
printf("XXXXXXXX1: 21\n");
|
|
||||||
// this kind of window isn't added anywhere. It will be added
|
// this kind of window isn't added anywhere. It will be added
|
||||||
// to main window's subset when winBorder::AddToSubsetOf(main)
|
// to main window's subset when winBorder::AddToSubsetOf(main)
|
||||||
// will be called.
|
// will be called.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_MODAL_APP_WINDOW_FEEL:
|
case B_MODAL_APP_WINDOW_FEEL:
|
||||||
|
case B_FLOATING_APP_WINDOW_FEEL:
|
||||||
{
|
{
|
||||||
printf("XXXXXXXX1: 22\n");
|
|
||||||
// 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)
|
||||||
winBorder->Window()->App()->fAppFMWList.AddItem(winBorder);
|
winBorder->Window()->App()->fAppFMWList.AddItem(winBorder);
|
||||||
|
|
||||||
// determine in witch workspaces to add this winBorder.
|
// determine in which workspaces to add this winBorder object.
|
||||||
uint32 wks = 0;
|
uint32 wks = 0;
|
||||||
|
|
||||||
// TODO: change later when you put this code into the server
|
|
||||||
for (int32 i=0; i<WorkspaceCount(); i++)
|
for (int32 i=0; i<WorkspaceCount(); i++)
|
||||||
{
|
{
|
||||||
|
// if we find a window belonging to winBorder's team, add winBorder to that workspace.
|
||||||
Workspace *ws = WorkspaceAt(i+1);
|
Workspace *ws = WorkspaceAt(i+1);
|
||||||
for (WinBorder *wb = ws->GoToBottomItem(); wb!=NULL; wb = ws->GoToUpperItem())
|
for (WinBorder *wb = ws->GoToBottomItem(); wb!=NULL; wb = ws->GoToUpperItem())
|
||||||
{
|
{
|
||||||
if ( !(wb->IsHidden()) &&
|
if ( winBorder->Window()->ClientTeamID() == wb->Window()->ClientTeamID())
|
||||||
winBorder->Window()->ClientTeamID() == wb->Window()->ClientTeamID())
|
|
||||||
{
|
{
|
||||||
wks = wks | winBorder->Window()->Workspaces();
|
wks = wks | winBorder->Window()->Workspaces();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// by using _bottomchild and _uppersibling.
|
|
||||||
|
|
||||||
AddWinBorderToWorkspaces(winBorder, wks);
|
AddWinBorderToWorkspaces(winBorder, wks);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case B_MODAL_ALL_WINDOW_FEEL:
|
case B_MODAL_ALL_WINDOW_FEEL:
|
||||||
{
|
|
||||||
printf("XXXXXXXX1: 23\n");
|
|
||||||
// add to system's list of Floating/Modal Windows (as opposed to the app's list)
|
|
||||||
fMainFMWList.AddItem(winBorder);
|
|
||||||
|
|
||||||
// add this winBorder to all workspaces
|
|
||||||
AddWinBorderToWorkspaces(winBorder, 0xffffffffUL);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case B_FLOATING_SUBSET_WINDOW_FEEL:
|
|
||||||
{
|
|
||||||
printf("XXXXXXXX1: 24\n");
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
case B_FLOATING_APP_WINDOW_FEEL:
|
|
||||||
{
|
|
||||||
printf("XXXXXXXX1: 25\n");
|
|
||||||
// add to app's list of Floating/Modal windows (as opposed to the system's)
|
|
||||||
winBorder->Window()->App()->fAppFMWList.AddItem(winBorder);
|
|
||||||
|
|
||||||
for (int32 i=0; i<WorkspaceCount(); i++){
|
|
||||||
Workspace *ws = WorkspaceAt(i+1);
|
|
||||||
WinBorder *wb = ws->FrontLayer();
|
|
||||||
if(wb && wb->Window()->ClientTeamID() == winBorder->Window()->ClientTeamID()
|
|
||||||
&& wb->Window()->Feel() == B_NORMAL_WINDOW_FEEL)
|
|
||||||
{
|
|
||||||
ws->AddLayerPtr(winBorder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case B_FLOATING_ALL_WINDOW_FEEL:
|
case B_FLOATING_ALL_WINDOW_FEEL:
|
||||||
{
|
{
|
||||||
printf("XXXXXXXX1: 26\n");
|
// add to system's list of Floating/Modal Windows
|
||||||
// add to system's list of Floating/Modal Windows (as opposed to the app's list)
|
|
||||||
fMainFMWList.AddItem(winBorder);
|
fMainFMWList.AddItem(winBorder);
|
||||||
|
|
||||||
// add this winBorder to all workspaces
|
// add this winBorder to all workspaces
|
||||||
@@ -342,25 +293,24 @@ printf("XXXXXXXX1: 26\n");
|
|||||||
|
|
||||||
case B_NORMAL_WINDOW_FEEL:
|
case B_NORMAL_WINDOW_FEEL:
|
||||||
{
|
{
|
||||||
printf("XXXXXXXX1: 27\n");
|
|
||||||
// add this winBorder to the specified workspaces
|
// add this winBorder to the specified workspaces
|
||||||
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:
|
||||||
{
|
{
|
||||||
printf("XXXXXXXX1: 28\n");
|
|
||||||
// add this winBorder to all workspaces
|
// add this winBorder to all workspaces
|
||||||
AddWinBorderToWorkspaces(winBorder, 0xffffffffUL);
|
AddWinBorderToWorkspaces(winBorder, 0xffffffffUL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:{
|
default:{
|
||||||
printf("XXXXXXXX1: 29\n");
|
debugger("RootLayer::AddWinBorder() - what kind of window is this?");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} // end switch(winborder->Feel())
|
} // end switch(winborder->Feel())
|
||||||
printf("XXXXXXXX1: 4\n");
|
|
||||||
fMainLock.Unlock();
|
fMainLock.Unlock();
|
||||||
STRACE(("*RootLayer::AddWinBorder(%s) - Main lock released\n", winBorder->GetName()));
|
STRACE(("*RootLayer::AddWinBorder(%s) - Main lock released\n", winBorder->GetName()));
|
||||||
|
|
||||||
@@ -456,7 +406,7 @@ bool RootLayer::SetFrontWinBorder(WinBorder* winBorder)
|
|||||||
|
|
||||||
if (!winBorder)
|
if (!winBorder)
|
||||||
{
|
{
|
||||||
ActiveWorkspace()->SetFrontLayer(NULL);
|
ActiveWorkspace()->SearchAndSetNewFront(NULL);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,12 +436,12 @@ bool RootLayer::SetFrontWinBorder(WinBorder* winBorder)
|
|||||||
|
|
||||||
if(newWorkspace != ActiveWorkspaceIndex())
|
if(newWorkspace != ActiveWorkspaceIndex())
|
||||||
{
|
{
|
||||||
WorkspaceAt(newWorkspace)->SetFrontLayer(winBorder);
|
WorkspaceAt(newWorkspace)->SearchAndSetNewFront(winBorder);
|
||||||
SetActiveWorkspaceByIndex(newWorkspace);
|
SetActiveWorkspaceByIndex(newWorkspace);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ActiveWorkspace()->SetFrontLayer(winBorder);
|
ActiveWorkspace()->SearchAndSetNewFront(winBorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
fMainLock.Unlock();
|
fMainLock.Unlock();
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ void ServerWindow::Show(void)
|
|||||||
ws->BringToFrontANormalWindow(fWinBorder);
|
ws->BringToFrontANormalWindow(fWinBorder);
|
||||||
ws->SearchAndSetNewFront(fWinBorder);
|
ws->SearchAndSetNewFront(fWinBorder);
|
||||||
previousFocus = ws->FocusLayer();
|
previousFocus = ws->FocusLayer();
|
||||||
ws->SetFocusLayer(fWinBorder);
|
ws->SearchAndSetNewFocus(fWinBorder);
|
||||||
// TODO: only do this in for the active workspace!
|
// TODO: only do this in for the active workspace!
|
||||||
// first redraw previous window's decorator. It has lost focus state.
|
// first redraw previous window's decorator. It has lost focus state.
|
||||||
if (previousFocus)
|
if (previousFocus)
|
||||||
@@ -351,12 +351,12 @@ void ServerWindow::Hide(void)
|
|||||||
if (ws->FrontLayer() == fWinBorder)
|
if (ws->FrontLayer() == fWinBorder)
|
||||||
{
|
{
|
||||||
ws->HideSubsetWindows(fWinBorder);
|
ws->HideSubsetWindows(fWinBorder);
|
||||||
ws->SetFocusLayer(ws->FrontLayer());
|
ws->SearchAndSetNewFocus(ws->FrontLayer());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (ws->FocusLayer() == fWinBorder)
|
if (ws->FocusLayer() == fWinBorder)
|
||||||
ws->SetFocusLayer(fWinBorder);
|
ws->SearchAndSetNewFocus(fWinBorder);
|
||||||
else
|
else
|
||||||
ws->Invalidate();
|
ws->Invalidate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,9 @@ Workspace::~Workspace(void)
|
|||||||
*/
|
*/
|
||||||
bool Workspace::AddLayerPtr(WinBorder *layer)
|
bool Workspace::AddLayerPtr(WinBorder *layer)
|
||||||
{
|
{
|
||||||
|
if (layer == NULL)
|
||||||
|
debugger("NULL pointer in Workspace::AddLayerPtr\n");
|
||||||
|
|
||||||
// allocate a new item
|
// allocate a new item
|
||||||
ListData *item;
|
ListData *item;
|
||||||
item = new ListData;
|
item = new ListData;
|
||||||
@@ -130,15 +133,13 @@ bool Workspace::AddLayerPtr(WinBorder *layer)
|
|||||||
|
|
||||||
STRACE(("\n*AddLayerPtr(%s) -", layer->GetName()));
|
STRACE(("\n*AddLayerPtr(%s) -", layer->GetName()));
|
||||||
|
|
||||||
// this may happen in case of subset windows.
|
BringToFrontANormalWindow(layer);
|
||||||
if(!(layer->IsHidden()))
|
|
||||||
{
|
|
||||||
// do a *smart* search and set the new 'front'
|
|
||||||
SearchAndSetNewFront(layer);
|
|
||||||
|
|
||||||
// do a *smart* search and set the new 'focus' + a redraw
|
// do a *smart* search and set the new 'front'
|
||||||
SetFocusLayer(layer);
|
SearchAndSetNewFront(layer);
|
||||||
}
|
|
||||||
|
// do a *smart* search and set the new 'focus'
|
||||||
|
SearchAndSetNewFocus(layer);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -200,14 +201,9 @@ bool Workspace::RemoveLayerPtr(WinBorder *layer)
|
|||||||
// reset some internal variables
|
// reset some internal variables
|
||||||
layer->SetMainWinBorder(NULL);
|
layer->SetMainWinBorder(NULL);
|
||||||
|
|
||||||
// its RootLayer is set to NULL by Layer::RemoveChild(layer);
|
|
||||||
|
|
||||||
STRACE(("Layer %s found and removed from Workspace No %ld\n", layer->GetName(), ID()));
|
STRACE(("Layer %s found and removed from Workspace No %ld\n", layer->GetName(), ID()));
|
||||||
|
|
||||||
if(wasFocus)
|
SearchAndSetNewFocus(nextItem? nextItem->layerPtr: NULL);
|
||||||
SetFocusLayer(nextItem? nextItem->layerPtr: NULL);
|
|
||||||
else
|
|
||||||
Invalidate();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -267,53 +263,11 @@ bool Workspace::HideSubsetWindows(WinBorder *layer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WinBorder *Workspace::SetFocusLayer(WinBorder *layer)
|
|
||||||
{
|
|
||||||
STRACE(("\n@Workspace(%ld)::SetFOCUSLayer( %s )\n", ID(), layer? layer->GetName(): "NULL"));
|
|
||||||
|
|
||||||
if(!(desktop->fGeneralLock.IsLocked()))
|
|
||||||
debugger("Workspace::SetFocusLayer - desktop->fGeneralLock must be LOCKED!\n");
|
|
||||||
|
|
||||||
WinBorder *previousFocus = FocusLayer();
|
|
||||||
|
|
||||||
SearchAndSetNewFocus(layer);
|
|
||||||
|
|
||||||
if(previousFocus != FocusLayer())
|
|
||||||
{
|
|
||||||
if(previousFocus)
|
|
||||||
previousFocus->HighlightDecorator(false);
|
|
||||||
|
|
||||||
if(FocusLayer())
|
|
||||||
FocusLayer()->HighlightDecorator(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
STRACE(("\n#Workspace(%ld)::SetFOCUSLayer( %s ) ENDED\n", ID(), layer? layer->GetName(): "NULL"));
|
|
||||||
|
|
||||||
return FocusLayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
WinBorder *Workspace::FocusLayer() const
|
WinBorder *Workspace::FocusLayer() const
|
||||||
{
|
{
|
||||||
return fFocusItem ? fFocusItem->layerPtr : NULL;
|
return fFocusItem ? fFocusItem->layerPtr : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
WinBorder *Workspace::SetFrontLayer(WinBorder *layer)
|
|
||||||
{
|
|
||||||
STRACE(("\n@Workspace(%ld)::SetFrontLayer( %s )\n", ID(), layer? layer->GetName(): "NULL"));
|
|
||||||
|
|
||||||
if(!(desktop->fGeneralLock.IsLocked()))
|
|
||||||
debugger("Workspace::SetFRONTLayer - desktop->fGeneralLock must be LOCKED!\n");
|
|
||||||
|
|
||||||
SearchAndSetNewFront(layer);
|
|
||||||
|
|
||||||
STRACESTREAM();
|
|
||||||
|
|
||||||
// TODO: remove?
|
|
||||||
Invalidate();
|
|
||||||
|
|
||||||
return fFrontItem? fFrontItem->layerPtr: NULL;;
|
|
||||||
}
|
|
||||||
|
|
||||||
WinBorder *Workspace::FrontLayer() const
|
WinBorder *Workspace::FrontLayer() const
|
||||||
{
|
{
|
||||||
return fFrontItem? fFrontItem->layerPtr: NULL;
|
return fFrontItem? fFrontItem->layerPtr: NULL;
|
||||||
|
|||||||
@@ -54,9 +54,7 @@ public:
|
|||||||
bool AddLayerPtr(WinBorder *layer);
|
bool AddLayerPtr(WinBorder *layer);
|
||||||
bool RemoveLayerPtr(WinBorder *layer);
|
bool RemoveLayerPtr(WinBorder *layer);
|
||||||
bool HideSubsetWindows(WinBorder *layer);
|
bool HideSubsetWindows(WinBorder *layer);
|
||||||
WinBorder *SetFocusLayer(WinBorder *layer);
|
|
||||||
WinBorder *FocusLayer(void) const;
|
WinBorder *FocusLayer(void) const;
|
||||||
WinBorder *SetFrontLayer(WinBorder *layer);
|
|
||||||
WinBorder *FrontLayer(void) const;
|
WinBorder *FrontLayer(void) const;
|
||||||
|
|
||||||
void MoveToBack(WinBorder *newLast);
|
void MoveToBack(WinBorder *newLast);
|
||||||
|
|||||||
Reference in New Issue
Block a user