* Added a separate focus list that will contain all windows in the order

of the last focus.
* When choosing a new focus window, this list is now used to find the
  new focus window instead of just choosing the next window in the
  workspace list.
* With the normal mode mouse, this shouldn't change anything, but with
  focus follows mouse turned on, this will behave much better if you 
  don't actually move the mouse - and it also fixes bug #1886.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24234 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-03-04 12:47:34 +00:00
parent 017fb2f082
commit d01879e5a6
3 changed files with 30 additions and 25 deletions
+17 -14
View File
@@ -316,6 +316,7 @@ Desktop::Desktop(uid_t userID)
fCurrentWorkspace(0), fCurrentWorkspace(0),
fAllWindows(kAllWindowList), fAllWindows(kAllWindowList),
fSubsetWindows(kSubsetList), fSubsetWindows(kSubsetList),
fFocusList(kFocusList),
fWorkspacesLayer(NULL), fWorkspacesLayer(NULL),
fActiveScreen(NULL), fActiveScreen(NULL),
@@ -1147,7 +1148,7 @@ Desktop::_UpdateFloating(int32 previousWorkspace, int32 nextWorkspace,
_HideWindow(floating); _HideWindow(floating);
if (FocusWindow() == floating) if (FocusWindow() == floating)
SetFocusWindow(_CurrentWindows().LastWindow()); SetFocusWindow();
} }
} }
} }
@@ -1324,21 +1325,16 @@ Desktop::SetFocusWindow(WindowLayer* focus)
return; return;
} }
if (focus == NULL || hasModal) { if (focus == NULL || hasModal)
focus = FrontWindow(); focus = fFocusList.LastWindow();
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 // make sure no window is chosen that doesn't want focus or cannot have it
while (focus != NULL while (focus != NULL
&& ((focus->Flags() & B_AVOID_FOCUS) != 0 && (!focus->InWorkspace(fCurrentWorkspace)
|| (focus->Flags() & B_AVOID_FOCUS) != 0
|| _WindowHasModal(focus) || _WindowHasModal(focus)
|| focus->IsHidden())) { || focus->IsHidden())) {
focus = focus->PreviousWindow(fCurrentWorkspace); focus = focus->PreviousWindow(kFocusList);
} }
if (fFocus == focus) { if (fFocus == focus) {
@@ -1360,6 +1356,10 @@ Desktop::SetFocusWindow(WindowLayer* focus)
if (fFocus != NULL) { if (fFocus != NULL) {
fFocus->SetFocus(true); fFocus->SetFocus(true);
newActiveApp = fFocus->ServerWindow()->App()->ClientTeam(); newActiveApp = fFocus->ServerWindow()->App()->ClientTeam();
// move current focus to the end of the focus list
fFocusList.RemoveWindow(fFocus);
fFocusList.AddWindow(fFocus);
} }
if (newActiveApp == -1) { if (newActiveApp == -1) {
@@ -1571,7 +1571,7 @@ Desktop::SendWindowBehind(WindowLayer* window, WindowLayer* behindOf)
MarkDirty(dirty); MarkDirty(dirty);
_UpdateFronts(); _UpdateFronts();
SetFocusWindow(_CurrentWindows().LastWindow()); SetFocusWindow();
_WindowChanged(window); _WindowChanged(window);
UnlockAllWindows(); UnlockAllWindows();
@@ -1587,6 +1587,7 @@ Desktop::ShowWindow(WindowLayer* window)
LockAllWindows(); LockAllWindows();
window->SetHidden(false); window->SetHidden(false);
fFocusList.AddWindow(window);
if (window->InWorkspace(fCurrentWorkspace)) { if (window->InWorkspace(fCurrentWorkspace)) {
_ShowWindow(window, true); _ShowWindow(window, true);
@@ -1625,6 +1626,8 @@ Desktop::HideWindow(WindowLayer* window)
return; return;
window->SetHidden(true); window->SetHidden(true);
fFocusList.RemoveWindow(window);
if (fMouseEventWindow == window) if (fMouseEventWindow == window)
fMouseEventWindow = NULL; fMouseEventWindow = NULL;
@@ -1634,7 +1637,7 @@ Desktop::HideWindow(WindowLayer* window)
_UpdateFronts(); _UpdateFronts();
if (FocusWindow() == window) if (FocusWindow() == window)
SetFocusWindow(_CurrentWindows().LastWindow()); SetFocusWindow();
} else } else
_WindowChanged(window); _WindowChanged(window);
@@ -2157,7 +2160,7 @@ Desktop::SetWindowFeel(WindowLayer *window, window_feel newFeel)
_UpdateFronts(); _UpdateFronts();
if (window == FocusWindow() && !window->IsVisible()) if (window == FocusWindow() && !window->IsVisible())
SetFocusWindow(_CurrentWindows().LastWindow()); SetFocusWindow();
UnlockAllWindows(); UnlockAllWindows();
} }
+3 -2
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright 2001-2006, Haiku. * Copyright 2001-2008, Haiku.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -153,7 +153,7 @@ class Desktop : public MessageLooper, public ScreenOwner {
void SetViewUnderMouse(const WindowLayer* window, int32 viewToken); void SetViewUnderMouse(const WindowLayer* window, int32 viewToken);
int32 ViewUnderMouse(const WindowLayer* window); int32 ViewUnderMouse(const WindowLayer* window);
void SetFocusWindow(WindowLayer* window); void SetFocusWindow(WindowLayer* window = NULL);
EventTarget* KeyboardEventTarget(); EventTarget* KeyboardEventTarget();
WindowLayer* FindWindowLayerByClientToken(int32 token, team_id teamID); WindowLayer* FindWindowLayerByClientToken(int32 token, team_id teamID);
@@ -253,6 +253,7 @@ class Desktop : public MessageLooper, public ScreenOwner {
WindowList fAllWindows; WindowList fAllWindows;
WindowList fSubsetWindows; WindowList fSubsetWindows;
WindowList fFocusList;
WorkspacesLayer* fWorkspacesLayer; WorkspacesLayer* fWorkspacesLayer;
Screen* fActiveScreen; Screen* fActiveScreen;
+2 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2005, Haiku, Inc. * Copyright (c) 2005-2008, Haiku, Inc.
* Distributed under the terms of the MIT license. * Distributed under the terms of the MIT license.
* *
* Authors: * Authors:
@@ -41,6 +41,7 @@ class WindowList {
enum window_lists { enum window_lists {
kAllWindowList = 32, kAllWindowList = 32,
kSubsetList, kSubsetList,
kFocusList,
kWorkingList, kWorkingList,
kListCount kListCount