From b6486ac2c04960dc21062e4c3bb20dd75f45e24f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sun, 11 Apr 2010 19:12:39 +0000 Subject: [PATCH] bonefish + axeld: * When moving a window to another workspace (using the mouse or the keyboard), the fLastWorkspaceFocus array of the old workspace could still point to that window. * This could also lead to a stale pointer and might have caused crashes in SetFocusWindow(). This should fix #5124, and its duplicates #5294, and #5688. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36165 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Desktop.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 85c83002c3..f61959a143 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -179,7 +179,7 @@ KeyboardFilter::Filter(BMessage* message, EventTarget** _target, { STRACE(("Set Workspace %ld\n", key - 1)); - fDesktop->SetWorkspaceAsync(key - 2, + fDesktop->SetWorkspaceAsync(key - B_F1_KEY, (modifiers & B_SHIFT_KEY) != 0); return B_SKIP_MESSAGE; } @@ -1620,7 +1620,8 @@ Desktop::KeyboardEventTarget() /*! Tries to set the focus to the specified \a focus window. It will make sure, - however, that the window actually can have focus. + however, that the window actually can have focus. You are allowed to pass + in a NULL pointer for \a focus. Besides the B_AVOID_FOCUS flag, a modal window, or a BWindowScreen can both prevent it from getting focus. @@ -3119,7 +3120,10 @@ Desktop::_SetWorkspace(int32 index, bool moveFocusWindow) movedWindow->Anchor(index).position = movedWindow->Frame().LeftTop(); } - fLastWorkspaceFocus[previousIndex] = FocusWindow(); + if (movedWindow == NULL || movedWindow->InWorkspace(previousIndex)) + fLastWorkspaceFocus[previousIndex] = FocusWindow(); + else + fLastWorkspaceFocus[previousIndex] = NULL; // build region of windows that are no longer visible in the new workspace