diff options
author | Elijah Newren <newren@gmail.com> | 2005-01-25 17:26:06 +0000 |
---|---|---|
committer | Elijah Newren <newren@src.gnome.org> | 2005-01-25 17:26:06 +0000 |
commit | f31c57a04992dbec8aff86e63d4fa2a51dd3bac4 (patch) | |
tree | dee0e36f705c71e14da96fb20c5245afe95b4626 | |
parent | 3afcb9c963bcced75be5f71f9c23646fb39c5748 (diff) | |
download | metacity-f31c57a04992dbec8aff86e63d4fa2a51dd3bac4.tar.gz |
Refuse to focus a window with a modal transient, and focus the transient
2005-01-25 Elijah Newren <newren@gmail.com>
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.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | src/window.c | 53 |
2 files changed, 62 insertions, 0 deletions
@@ -1,3 +1,12 @@ +2005-01-25 Elijah Newren <newren@gmail.com> + + 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 <newren@gmail.com> * configure.in: post-release version bump to 2.9.13 diff --git a/src/window.c b/src/window.c index 4830d654..defc0830 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) |