From f31c57a04992dbec8aff86e63d4fa2a51dd3bac4 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Tue, 25 Jan 2005 17:26:06 +0000 Subject: [PATCH] Refuse to focus a window with a modal transient, and focus the transient 2005-01-25 Elijah Newren Refuse to focus a window with a modal transient, and focus the transient instead. Fixes #164716. * src/window.c: (get_modal_transient): new function, (meta_window_focus): if the window has a modal transient, make sure it is on the current workspace and then focus it instead. --- ChangeLog | 9 +++++++++ src/window.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/ChangeLog b/ChangeLog index fcd278253..77556d77a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2005-01-25 Elijah Newren + + Refuse to focus a window with a modal transient, and focus the + transient instead. Fixes #164716. + + * src/window.c: (get_modal_transient): new function, + (meta_window_focus): if the window has a modal transient, make + sure it is on the current workspace and then focus it instead. + 2005-01-24 Elijah Newren * configure.in: post-release version bump to 2.9.13 diff --git a/src/window.c b/src/window.c index 4830d654b..defc0830e 100644 --- a/src/window.c +++ b/src/window.c @@ -3245,10 +3245,50 @@ meta_window_get_startup_id (MetaWindow *window) return window->startup_id; } +static MetaWindow* +get_modal_transient (MetaWindow *window) +{ + GSList *windows; + GSList *tmp; + MetaWindow *modal_transient; + + /* A window can't be the transient of itself, but this is just for + * convenience in the loop below; we manually fix things up at the + * end if no real modal transient was found. + */ + modal_transient = window; + + windows = meta_display_list_windows (window->display); + tmp = windows; + while (tmp != NULL) + { + MetaWindow *transient = tmp->data; + + if (transient->xtransient_for == modal_transient->xwindow && + transient->wm_state_modal) + { + modal_transient = transient; + tmp = windows; + continue; + } + + tmp = tmp->next; + } + + g_slist_free (windows); + + if (window == modal_transient) + modal_transient = NULL; + + return modal_transient; +} + void meta_window_focus (MetaWindow *window, Time timestamp) { + MetaWindow *modal_transient; + meta_topic (META_DEBUG_FOCUS, "Setting input focus to window %s, input: %d take_focus: %d\n", window->desc, window->input, window->take_focus); @@ -3262,6 +3302,19 @@ meta_window_focus (MetaWindow *window, return; } + modal_transient = get_modal_transient (window); + if (modal_transient != NULL) + { + meta_topic (META_DEBUG_FOCUS, + "%s has %s as a modal transient, so focusing it instead.\n", + window->desc, modal_transient->desc); + if (!modal_transient->on_all_workspaces && + modal_transient->workspace != window->screen->active_workspace) + meta_window_change_workspace (modal_transient, + window->screen->active_workspace); + window = modal_transient; + } + meta_window_flush_calc_showing (window); if (!window->mapped && !window->shaded)