From 2e0cd7af5eb9b267bb8de110a6324fb4ee4637f5 Mon Sep 17 00:00:00 2001 From: Tomas Frydrych Date: Tue, 7 Apr 2009 13:02:57 +0100 Subject: [PATCH] Fixed focus handling in finish_minize(). When the window being hidden/mimimized has focus, is modal, but is not on the currently active workspace (e.g., during workspace switch before the new focus window is activated), we must prevent focus being passed to the modal window ancestor (otherwise the ancestor ends up being forcefully moved onto the active workspace). --- src/core/window.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/core/window.c b/src/core/window.c index 46bbfbc7a..28a0e255e 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -1662,8 +1662,22 @@ finish_minimize (gpointer data) meta_window_hide (window); if (window->has_focus) { + MetaWindow *not_this_one = NULL; + MetaWorkspace *my_workspace = meta_window_get_workspace (window); + + /* + * If this window is modal, passing the not_this_one window to + * _focus_default_window() makes the focus to be given to this window's + * ancestor. This can only be the case if the window is on the currently + * active workspace; when it is not, we need to pass in NULL, so as to + * focus the default window for the active workspace (this scenario + * arises when we are switching workspaces). + */ + if (my_workspace == window->screen->active_workspace) + not_this_one = window; + meta_workspace_focus_default_window (window->screen->active_workspace, - window, + not_this_one, timestamp); } }