From 150e5ed5328209914ca8e349cbe7da50d6da6667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 15 Mar 2006 21:33:12 +0000 Subject: [PATCH] * When the current focus window was closed or invisible, we used to chose the front window as our next focus window - but this proved to be problematic with B_AVOID_FRONT windows. Therefore, we now simply chose the top-most window as the next focus window. This fixes bug #281, and potentially also fixes bug #181. * This also revealed another bug in SetFocusWindow(): when the window to have focus already had focus, but were hidden before, the focus did not change; if that window was subsequently removed, the app_server would have crashed. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16811 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Desktop.cpp | 14 +++++++------- src/servers/app/WindowList.cpp | 6 +++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 69623fa0f5..cc5f8c1127 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -897,7 +897,7 @@ Desktop::_UpdateFloating(int32 previousWorkspace, int32 nextWorkspace) /*! Search the visible windows for a valid back window - (only normal windows can be back windows) + (only desktop windows can't be back windows) */ void Desktop::_UpdateBack() @@ -906,7 +906,7 @@ Desktop::_UpdateBack() for (WindowLayer* window = _CurrentWindows().FirstWindow(); window != NULL; window = window->NextWindow(fCurrentWorkspace)) { - if (window->IsHidden() || !window->SupportsFront()) + if (window->IsHidden() || window->Feel() == kDesktopWindowFeel) continue; fBack = window; @@ -990,8 +990,8 @@ Desktop::SetFocusWindow(WindowLayer* focus) // TODO: test for FFM and B_LOCK_WINDOW_FOCUS - if (focus == fFocus && focus != NULL && (focus->Flags() & B_AVOID_FOCUS) == 0 - && !hasModal) { + if (focus == fFocus && focus != NULL && !focus->IsHidden() + && (focus->Flags() & B_AVOID_FOCUS) == 0 && !hasModal) { // the window that is supposed to get focus already has focus UnlockAllWindows(); return; @@ -1209,7 +1209,7 @@ Desktop::SendWindowBehind(WindowLayer* window, WindowLayer* behindOf) MarkDirty(dirty); _UpdateFronts(); - SetFocusWindow(FrontWindow()); + SetFocusWindow(_CurrentWindows().LastWindow()); _WindowChanged(window); UnlockAllWindows(); @@ -1284,7 +1284,7 @@ Desktop::HideWindow(WindowLayer* window) _UpdateFronts(); if (FocusWindow() == window) - SetFocusWindow(FrontWindow()); + SetFocusWindow(_CurrentWindows().LastWindow()); } if (fWorkspacesLayer != NULL) @@ -1707,7 +1707,7 @@ Desktop::SetWindowFeel(WindowLayer *window, window_feel newFeel) _UpdateFronts(); if (window == FocusWindow() && !window->IsVisible()) - SetFocusWindow(FrontWindow()); + SetFocusWindow(_CurrentWindows().LastWindow()); UnlockAllWindows(); } diff --git a/src/servers/app/WindowList.cpp b/src/servers/app/WindowList.cpp index abc2de6bb0..a50fb1eec2 100644 --- a/src/servers/app/WindowList.cpp +++ b/src/servers/app/WindowList.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Haiku, Inc. + * Copyright (c) 2005-2006, Haiku, Inc. * Distributed under the terms of the MIT license. * * Authors: @@ -47,6 +47,10 @@ WindowList::SetIndex(int32 index) } +/*! + Adds the \a window to the end of the list. If \a before is + given, it will be inserted right before that window. +*/ void WindowList::AddWindow(WindowLayer* window, WindowLayer* before) {