diff --git a/src/servers/app/server/Desktop.cpp b/src/servers/app/server/Desktop.cpp index cc4f26d25a..d0d3c20645 100644 --- a/src/servers/app/server/Desktop.cpp +++ b/src/servers/app/server/Desktop.cpp @@ -231,7 +231,8 @@ void Desktop::SetFrontWinBorder(WinBorder* winBorder){ // TODO: implement } //--------------------------------------------------------------------------- -void Desktop::SetFoocusWinBorder(WinBorder* winBorder){ +// TODO: remove shortly? +void Desktop::SetFoooocusWinBorder(WinBorder* winBorder){ if (FocusWinBorder() == winBorder && (winBorder && !winBorder->IsHidden())) return; @@ -312,9 +313,7 @@ void Desktop::MouseEventHandler(PortMessage *msg){ rl->fMainLock.Lock(); ws->SearchAndSetNewFront(target); -// NOTE: !!! Be VERY careful about this method !!!! - SetFoocusWinBorder(target); - //ws->SetFocusLayer(target); + ws->SetFocusLayer(target); rl->fMainLock.Unlock(); fGeneralLock.Unlock(); diff --git a/src/servers/app/server/Desktop.h b/src/servers/app/server/Desktop.h index d537ad2e88..053f74577e 100644 --- a/src/servers/app/server/Desktop.h +++ b/src/servers/app/server/Desktop.h @@ -41,7 +41,7 @@ public: void RemoveWinBorder(WinBorder* winBorder); bool HasWinBorder(WinBorder* winBorder); void SetFrontWinBorder(WinBorder* winBorder); - void SetFoocusWinBorder(WinBorder* winBorder); + void SetFoooocusWinBorder(WinBorder* winBorder); WinBorder* FrontWinBorder(void) const; WinBorder* FocusWinBorder(void) const; diff --git a/src/servers/app/server/RootLayer.cpp b/src/servers/app/server/RootLayer.cpp index 5f6f9b7aac..578f2281a2 100644 --- a/src/servers/app/server/RootLayer.cpp +++ b/src/servers/app/server/RootLayer.cpp @@ -153,6 +153,9 @@ Layer* RootLayer::VirtualBottomChild() const{ } //--------------------------------------------------------------------------- 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; diff --git a/src/servers/app/server/ServerWindow.cpp b/src/servers/app/server/ServerWindow.cpp index 3e9b06904f..b9ebe098b7 100644 --- a/src/servers/app/server/ServerWindow.cpp +++ b/src/servers/app/server/ServerWindow.cpp @@ -289,10 +289,14 @@ ServerApp *ServerWindow::GetApp(void) //! Shows the window's WinBorder void ServerWindow::Show(void) { + if(!_winborder->IsHidden()) + return; + STRACE(("ServerWindow %s: Show\n",_title->String())); if(_winborder) { - RootLayer *rl = _winborder->GetRootLayer(); + RootLayer *rl = _winborder->GetRootLayer(); + int32 wksCount; desktop->fGeneralLock.Lock(); printf("ServerWindow(%s)::Show() - General lock acquired\n", _winborder->GetName()); @@ -300,8 +304,16 @@ printf("ServerWindow(%s)::Show() - General lock acquired\n", _winborder->GetName printf("ServerWindow(%s)::Show() - Main lock acquired\n", _winborder->GetName()); _winborder->Show(); + + if ((_feel == B_FLOATING_SUBSET_WINDOW_FEEL || _feel == B_MODAL_SUBSET_WINDOW_FEEL) + && _winborder->MainWinBorder() == NULL) + { + // This window hasn't been added to a normal window subset, + // so don't call placement or redrawing methods! + goto goOut; + } - int32 wksCount= rl->WorkspaceCount(); + wksCount = rl->WorkspaceCount(); for(int32 i = 0; i < wksCount; i++){ if (fWorkspaces & (0x00000001UL << i)){ Workspace *ws = rl->WorkspaceAt(i+1); @@ -309,6 +321,9 @@ printf("ServerWindow(%s)::Show() - Main lock acquired\n", _winborder->GetName()) ws->SetFocusLayer(_winborder); } } + + goOut: + rl->fMainLock.Unlock(); printf("ServerWindow(%s)::Show() - Main lock released\n", _winborder->GetName()); desktop->fGeneralLock.Unlock(); @@ -319,6 +334,9 @@ printf("ServerWindow(%s)::Show() - General lock released\n", _winborder->GetName //! Hides the window's WinBorder void ServerWindow::Hide(void) { + if(_winborder->IsHidden()) + return; + STRACE(("ServerWindow %s: Hide\n",_title->String())); if(_winborder){ RootLayer *rl = _winborder->GetRootLayer(); diff --git a/src/servers/app/server/WinBorder.cpp b/src/servers/app/server/WinBorder.cpp index eb4a48dba7..ed6bc36769 100644 --- a/src/servers/app/server/WinBorder.cpp +++ b/src/servers/app/server/WinBorder.cpp @@ -737,23 +737,16 @@ void WinBorder::AddToSubsetOf(WinBorder* main){ printf("WinBorder(%s)::AddToSubsetOf() - General lock acquired\n", GetName()); rl->fMainLock.Lock(); printf("WinBorder(%s)::AddToSubsetOf() - Main lock acquired\n", GetName()); + for(int32 i = 0; i < rl->WorkspaceCount(); i++){ Workspace *ws = rl->WorkspaceAt(i+1); - if(ws->FrontLayer() == main){ -printf("\n@\n@\n"); -ws->PrintToStream(); + if(ws->FrontLayer() == main) ws->AddLayerPtr(this); - if(rl->ActiveWorkspace() == ws && !IsHidden()){ - ws->Invalidate(); -printf("\n#\n#\n"); -ws->PrintToStream(); -printf("\n#\n#\n"); - } - } } - rl->fMainLock.Unlock(); + + rl->fMainLock.Unlock(); printf("WinBorder(%s)::AddToSubsetOf() - Main lock released\n", GetName()); - desktop->fGeneralLock.Unlock(); + desktop->fGeneralLock.Unlock(); printf("WinBorder(%s)::AddToSubsetOf() - General lock released\n", GetName()); } } diff --git a/src/servers/app/server/Workspace.cpp b/src/servers/app/server/Workspace.cpp index 04540376b0..18f5824023 100644 --- a/src/servers/app/server/Workspace.cpp +++ b/src/servers/app/server/Workspace.cpp @@ -83,12 +83,14 @@ bool Workspace::AddLayerPtr(WinBorder* layer){ opLock.Unlock(); STRACE(("\n*AddLayerPtr(%s) -", layer->GetName())); - // do a *smart* search and set the new 'front' - SearchAndSetNewFront(layer); - // do a *smart* search and set the new 'focus' - //SearchAndSetNewFocus(layer); // - it WILL be called! - // this also does a redraw - SetFocusLayer(layer); + + // this may happen in case of subset windows. + 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 + SetFocusLayer(layer); + } return true; } @@ -162,13 +164,33 @@ printf("Layer %s NOT found in Workspace No %ld\n", layer->GetName(), ID()); //--------------------------------------------------------------------------- WinBorder* Workspace::SetFocusLayer(WinBorder* layer){ STRACE(("\n@Workspace(%ld)::SetFOCUSLayer( %s )\n", ID(), layer? layer->GetName(): "NULL")); - - SearchAndSetNewFocus(layer); -STRACESTREAM(); -// TODO: there had to be a Invalidate() vresion witch takes a BRegion parameter - Invalidate(); - return fFocusItem? fFocusItem->layerPtr : 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->SetFocus(false); + + if (FocusLayer()){ + FocusLayer()->SetFocus(true); + } + +// TODO: there had to be a Invalidate() vresion witch takes a BRegion parameter + Invalidate(); + } + else{ + // Do nothing! + } + +STRACESTREAM(); +STRACE(("\n#Workspace(%ld)::SetFOCUSLayer( %s ) ENDED\n", ID(), layer? layer->GetName(): "NULL")); + + return FocusLayer(); } //--------------------------------------------------------------------------- WinBorder* Workspace::FocusLayer() const{ @@ -177,6 +199,10 @@ WinBorder* Workspace::FocusLayer() const{ //--------------------------------------------------------------------------- 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: there had to be a Invalidate() vresion witch takes a BRegion parameter diff --git a/src/servers/app/server/Workspace.h b/src/servers/app/server/Workspace.h index 9c6c38c3c2..1e75df1442 100644 --- a/src/servers/app/server/Workspace.h +++ b/src/servers/app/server/Workspace.h @@ -61,12 +61,13 @@ public: void SearchAndSetNewFront(WinBorder* preferred); void SearchAndSetNewFocus(WinBorder* preferred); + ListData* HasItem(ListData* item); + 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);