From e5660302980787297fc8970fa91742fd0602a2fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 9 Dec 2005 14:23:51 +0000 Subject: [PATCH] * SetFocusWindow() now makes sure no hidden window is taken as focus window... * When switching workspaces, usually the focus switches to the front window. This no longer happens in case a floating window had focus and is still visible in the new workspace - in that case, focus is kept with the floating window. * SetFocusWindow() now chooses the topmost window in case the specified window has either a modal or there is no front window. Desktop::RemoveWindow() now makes sure the window is hidden before removing it. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15447 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Desktop.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 35803446d6..7244f0cc1b 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -675,7 +675,10 @@ Desktop::SetWorkspace(int32 index) _UpdateFronts(false); _UpdateFloating(previousIndex, index); - SetFocusWindow(FrontWindow()); + // Set new focus to the front window, but keep focus to a floating + // window if still visible + if (!_Windows(index).HasWindow(FocusWindow()) || !FocusWindow()->IsFloating()) + SetFocusWindow(FrontWindow()); MarkDirty(dirty); @@ -881,12 +884,20 @@ Desktop::SetFocusWindow(WindowLayer* focus) return; } - if (focus == NULL || hasModal) + if (focus == NULL || hasModal) { focus = FrontWindow(); + if (focus == NULL) { + // there might be no front window in case of only a single + // window with B_FLOATING_ALL_WINDOW_FEEL + focus = _CurrentWindows().LastWindow(); + } + } // make sure no window is chosen that doesn't want focus or cannot have it while (focus != NULL - && ((focus->Flags() & B_AVOID_FOCUS) != 0 || _WindowHasModal(focus))) { + && ((focus->Flags() & B_AVOID_FOCUS) != 0 + || _WindowHasModal(focus) + || focus->IsHidden())) { focus = focus->PreviousWindow(fCurrentWorkspace); } @@ -1366,6 +1377,9 @@ Desktop::RemoveWindow(WindowLayer *window) { BAutolock _(this); + if (!window->IsHidden()) + HideWindow(window); + fAllWindows.RemoveWindow(window); if (!window->IsNormal()) fSubsetWindows.RemoveWindow(window);