From 0b63cc935f7c494199615b6c16055520bfd1018d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 24 Nov 2009 15:28:12 +0000 Subject: [PATCH] * We now store the last window having focus in a separate array, or else the windows visible on more than one workspace destroy the FFM experience (ie. restoring the last window that had focus on a workspace switch). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34207 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Desktop.cpp | 8 +++++++- src/servers/app/Desktop.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 2b28f8ddf5..e67b69ed0e 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -339,6 +339,8 @@ Desktop::Desktop(uid_t userID, const char* targetScreen) fFront(NULL), fBack(NULL) { + memset(fLastWorkspaceFocus, 0, sizeof(fLastWorkspaceFocus)); + char name[B_OS_NAME_LENGTH]; Desktop::_GetLooperName(name, sizeof(name)); @@ -2656,6 +2658,8 @@ Desktop::_ChangeWindowWorkspaces(Window* window, uint32 oldWorkspaces, // window is on this workspace, is it anymore? if (!workspace_in_workspaces(i, newWorkspaces)) { _Windows(i).RemoveWindow(window); + if (fLastWorkspaceFocus[i] == window) + fLastWorkspaceFocus[i] = NULL; if (i == CurrentWorkspace()) { // remove its appearance from the current workspace @@ -3120,6 +3124,8 @@ Desktop::_SetWorkspace(int32 index, bool moveFocusWindow) movedWindow->Anchor(index).position = movedWindow->Frame().LeftTop(); } + fLastWorkspaceFocus[previousIndex] = FocusWindow(); + // build region of windows that are no longer visible in the new workspace BRegion dirty; @@ -3248,7 +3254,7 @@ Desktop::_SetWorkspace(int32 index, bool moveFocusWindow) // Set new focus, but keep focus to a floating window if still visible if (!_Windows(index).HasWindow(FocusWindow()) || !FocusWindow()->IsFloating()) - SetFocusWindow(); + SetFocusWindow(fLastWorkspaceFocus[index]); _WindowChanged(NULL); MarkDirty(dirty); diff --git a/src/servers/app/Desktop.h b/src/servers/app/Desktop.h index e90277d357..10a000e7a2 100644 --- a/src/servers/app/Desktop.h +++ b/src/servers/app/Desktop.h @@ -327,6 +327,7 @@ private: WindowList fAllWindows; WindowList fSubsetWindows; WindowList fFocusList; + Window* fLastWorkspaceFocus[kMaxWorkspaces]; BObjectList fWorkspacesViews; BLocker fWorkspacesLock;