From e647873a03485259cd36968def0efb2d1329219f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Mon, 1 May 2006 10:14:51 +0000 Subject: [PATCH] implemented TODOs from Desktop::ActivateWindow(): * If the window is on another workspace, the workspace will be activated or the window will come to the current workspace or nothing will happen depending on the windows flags. Tested with WonderBrush, but I just now realise that it will also fix activating a window in the Deskbar, which is on a different workspace. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17284 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Desktop.cpp | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 15b647a3b9..f3c2667dfa 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -1212,24 +1212,47 @@ Desktop::ActivateWindow(WindowLayer* window) { STRACE(("ActivateWindow(%p, %s)\n", window, window ? window->Title() : "")); - // TODO: handle this case correctly! (ie. honour B_NOT_ANCHORED_ON_ACTIVATE, - // B_NO_WORKSPACE_ACTIVATION, switch workspaces, ...) - if (!window->InWorkspace(fCurrentWorkspace)) - return; - if (window == NULL) { fBack = NULL; fFront = NULL; return; } - // TODO: support B_NO_WORKSPACE_ACTIVATION - // TODO: support B_NOT_ANCHORED_ON_ACTIVATE + bool windowOnOtherWorkspace = !window->InWorkspace(fCurrentWorkspace); + + if (windowOnOtherWorkspace + && (window->Flags() & B_NO_WORKSPACE_ACTIVATION) + && !(window->Flags() & B_NOT_ANCHORED_ON_ACTIVATE)) + return; + // TODO: take care about floating windows if (!LockAllWindows()) return; + if (windowOnOtherWorkspace) { + // if the window wants to come to the current workspace, + // do so here - else activate the workspace on which this + // window is + if (window->Flags() & B_NOT_ANCHORED_ON_ACTIVATE) { + // bring the window to the current workspace + // TODO: what if this window is on multiple workspaces?!? + uint32 workspaces = workspace_to_workspaces(fCurrentWorkspace); + SetWindowWorkspaces(window, workspaces); + } else { + // switch to the workspace on which this window is + // (we'll take the first one that the window is on) + uint32 workspaces = window->Workspaces(); + for (int32 i = 0; i < 32; i++) { + uint32 workspace = workspace_to_workspaces(i); + if (workspaces & workspace) { + SetWorkspace(i); + break; + } + } + } + } + if (window == FrontWindow()) { // see if there is a normal B_AVOID_FRONT window still in front of us WindowLayer* avoidsFront = window->NextWindow(fCurrentWorkspace);