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:
parent
ca0206bf09
commit
0732418e3b
@ -259,6 +259,14 @@ void Desktop::AddWinBorder(WinBorder* winBorder)
|
||||
// other windows are added to the current RootLayer only.
|
||||
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.
|
||||
fLayerLock.Lock();
|
||||
fWinBorderList.AddItem(winBorder);
|
||||
@ -345,7 +353,8 @@ printf("Focus: %s\n", ws->FocusLayer()->GetName());
|
||||
ws->BringToFrontANormalWindow(target);
|
||||
ws->SearchAndSetNewFront(target);
|
||||
previousFocus = ws->FocusLayer();
|
||||
activeFocus = ws->SetFocusLayer(target);
|
||||
ws->SearchAndSetNewFocus(target);
|
||||
activeFocus = ws->FocusLayer();
|
||||
|
||||
activeFocus->Window()->Lock();
|
||||
|
||||
|
@ -446,7 +446,15 @@ void Layer::RequestDraw(const BRegion ®, Layer *startFrom)
|
||||
int redraw = false;
|
||||
if (startFrom == NULL)
|
||||
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)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
// TODO/NOTE: this should be an empty method! the next lines are for testing only
|
||||
|
||||
#ifdef DEBUG_LAYER
|
||||
printf("Layer::Draw: ");
|
||||
r.PrintToStream();
|
||||
|
@ -216,12 +216,6 @@ void RootLayer::AddWinBorderToWorkspaces(WinBorder* winBorder, uint32 wks)
|
||||
if (!(fMainLock.IsLocked()))
|
||||
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++)
|
||||
{
|
||||
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()));
|
||||
|
||||
// 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));
|
||||
|
||||
// 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())
|
||||
{
|
||||
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
|
||||
// to main window's subset when winBorder::AddToSubsetOf(main)
|
||||
// will be called.
|
||||
break;
|
||||
}
|
||||
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)
|
||||
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;
|
||||
|
||||
// TODO: change later when you put this code into the server
|
||||
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);
|
||||
for (WinBorder *wb = ws->GoToBottomItem(); wb!=NULL; wb = ws->GoToUpperItem())
|
||||
{
|
||||
if ( !(wb->IsHidden()) &&
|
||||
winBorder->Window()->ClientTeamID() == wb->Window()->ClientTeamID())
|
||||
if ( winBorder->Window()->ClientTeamID() == wb->Window()->ClientTeamID())
|
||||
{
|
||||
wks = wks | winBorder->Window()->Workspaces();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// by using _bottomchild and _uppersibling.
|
||||
|
||||
AddWinBorderToWorkspaces(winBorder, wks);
|
||||
break;
|
||||
}
|
||||
|
||||
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:
|
||||
{
|
||||
printf("XXXXXXXX1: 26\n");
|
||||
// add to system's list of Floating/Modal Windows (as opposed to the app's list)
|
||||
// add to system's list of Floating/Modal Windows
|
||||
fMainFMWList.AddItem(winBorder);
|
||||
|
||||
// add this winBorder to all workspaces
|
||||
@ -342,25 +293,24 @@ printf("XXXXXXXX1: 26\n");
|
||||
|
||||
case B_NORMAL_WINDOW_FEEL:
|
||||
{
|
||||
printf("XXXXXXXX1: 27\n");
|
||||
// add this winBorder to the specified workspaces
|
||||
AddWinBorderToWorkspaces(winBorder, winBorder->Window()->Workspaces());
|
||||
break;
|
||||
}
|
||||
|
||||
case B_SYSTEM_LAST:
|
||||
case B_SYSTEM_FIRST:
|
||||
{
|
||||
printf("XXXXXXXX1: 28\n");
|
||||
// add this winBorder to all workspaces
|
||||
AddWinBorderToWorkspaces(winBorder, 0xffffffffUL);
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
printf("XXXXXXXX1: 29\n");
|
||||
debugger("RootLayer::AddWinBorder() - what kind of window is this?");
|
||||
break;
|
||||
}
|
||||
} // end switch(winborder->Feel())
|
||||
printf("XXXXXXXX1: 4\n");
|
||||
|
||||
fMainLock.Unlock();
|
||||
STRACE(("*RootLayer::AddWinBorder(%s) - Main lock released\n", winBorder->GetName()));
|
||||
|
||||
@ -456,7 +406,7 @@ bool RootLayer::SetFrontWinBorder(WinBorder* winBorder)
|
||||
|
||||
if (!winBorder)
|
||||
{
|
||||
ActiveWorkspace()->SetFrontLayer(NULL);
|
||||
ActiveWorkspace()->SearchAndSetNewFront(NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -486,12 +436,12 @@ bool RootLayer::SetFrontWinBorder(WinBorder* winBorder)
|
||||
|
||||
if(newWorkspace != ActiveWorkspaceIndex())
|
||||
{
|
||||
WorkspaceAt(newWorkspace)->SetFrontLayer(winBorder);
|
||||
WorkspaceAt(newWorkspace)->SearchAndSetNewFront(winBorder);
|
||||
SetActiveWorkspaceByIndex(newWorkspace);
|
||||
}
|
||||
else
|
||||
{
|
||||
ActiveWorkspace()->SetFrontLayer(winBorder);
|
||||
ActiveWorkspace()->SearchAndSetNewFront(winBorder);
|
||||
}
|
||||
|
||||
fMainLock.Unlock();
|
||||
|
@ -288,7 +288,7 @@ void ServerWindow::Show(void)
|
||||
ws->BringToFrontANormalWindow(fWinBorder);
|
||||
ws->SearchAndSetNewFront(fWinBorder);
|
||||
previousFocus = ws->FocusLayer();
|
||||
ws->SetFocusLayer(fWinBorder);
|
||||
ws->SearchAndSetNewFocus(fWinBorder);
|
||||
// TODO: only do this in for the active workspace!
|
||||
// first redraw previous window's decorator. It has lost focus state.
|
||||
if (previousFocus)
|
||||
@ -351,12 +351,12 @@ void ServerWindow::Hide(void)
|
||||
if (ws->FrontLayer() == fWinBorder)
|
||||
{
|
||||
ws->HideSubsetWindows(fWinBorder);
|
||||
ws->SetFocusLayer(ws->FrontLayer());
|
||||
ws->SearchAndSetNewFocus(ws->FrontLayer());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ws->FocusLayer() == fWinBorder)
|
||||
ws->SetFocusLayer(fWinBorder);
|
||||
ws->SearchAndSetNewFocus(fWinBorder);
|
||||
else
|
||||
ws->Invalidate();
|
||||
}
|
||||
|
@ -113,6 +113,9 @@ Workspace::~Workspace(void)
|
||||
*/
|
||||
bool Workspace::AddLayerPtr(WinBorder *layer)
|
||||
{
|
||||
if (layer == NULL)
|
||||
debugger("NULL pointer in Workspace::AddLayerPtr\n");
|
||||
|
||||
// allocate a new item
|
||||
ListData *item;
|
||||
item = new ListData;
|
||||
@ -130,15 +133,13 @@ bool Workspace::AddLayerPtr(WinBorder *layer)
|
||||
|
||||
STRACE(("\n*AddLayerPtr(%s) -", layer->GetName()));
|
||||
|
||||
// this may happen in case of subset windows.
|
||||
if(!(layer->IsHidden()))
|
||||
{
|
||||
// do a *smart* search and set the new 'front'
|
||||
SearchAndSetNewFront(layer);
|
||||
BringToFrontANormalWindow(layer);
|
||||
|
||||
// do a *smart* search and set the new 'focus' + a redraw
|
||||
SetFocusLayer(layer);
|
||||
}
|
||||
// do a *smart* search and set the new 'front'
|
||||
SearchAndSetNewFront(layer);
|
||||
|
||||
// do a *smart* search and set the new 'focus'
|
||||
SearchAndSetNewFocus(layer);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -200,14 +201,9 @@ bool Workspace::RemoveLayerPtr(WinBorder *layer)
|
||||
// reset some internal variables
|
||||
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()));
|
||||
|
||||
if(wasFocus)
|
||||
SetFocusLayer(nextItem? nextItem->layerPtr: NULL);
|
||||
else
|
||||
Invalidate();
|
||||
SearchAndSetNewFocus(nextItem? nextItem->layerPtr: NULL);
|
||||
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
return fFrontItem? fFrontItem->layerPtr: NULL;
|
||||
|
@ -54,9 +54,7 @@ public:
|
||||
bool AddLayerPtr(WinBorder *layer);
|
||||
bool RemoveLayerPtr(WinBorder *layer);
|
||||
bool HideSubsetWindows(WinBorder *layer);
|
||||
WinBorder *SetFocusLayer(WinBorder *layer);
|
||||
WinBorder *FocusLayer(void) const;
|
||||
WinBorder *SetFrontLayer(WinBorder *layer);
|
||||
WinBorder *FrontLayer(void) const;
|
||||
|
||||
void MoveToBack(WinBorder *newLast);
|
||||
|
Loading…
Reference in New Issue
Block a user