From 8658268847b63805d6cba9382e888234dbe03697 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Sun, 26 Oct 2003 16:22:51 +0000 Subject: [PATCH] if a window is focused which is not either a dock or a transient in the 2003-10-25 Havoc Pennington * src/window.c (meta_window_notify_focus): if a window is focused which is not either a dock or a transient in the same group as a dock, shuffle all dock/desktop windows to the end of the MRU list so they won't annoyingly get focus all the time. #123816 --- ChangeLog | 7 ++++++ src/window.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7d259b58e..be54b043c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2003-10-25 Havoc Pennington + + * src/window.c (meta_window_notify_focus): if a window is focused + which is not either a dock or a transient in the same group as a + dock, shuffle all dock/desktop windows to the end of the MRU list + so they won't annoyingly get focus all the time. #123816 + 2003-10-15 Yukihiro Nakai Gettextize metacity-theme-viewer. #121747 diff --git a/src/window.c b/src/window.c index b6cc5d577..b24620e58 100644 --- a/src/window.c +++ b/src/window.c @@ -3896,6 +3896,72 @@ meta_window_client_message (MetaWindow *window, return FALSE; } +static gboolean +is_in_dock_group (MetaWindow *window) +{ + MetaGroup *group; + GSList *list; + GSList *tmp; + + if (META_WINDOW_IN_DOCK_TAB_CHAIN (window)) + return TRUE; + + if (window->type == META_WINDOW_NORMAL) + return FALSE; + + /* If a transient-type window is in dock group, + * return TRUE + */ + group = meta_window_get_group (window); + list = meta_group_list_windows (group); + tmp = list; + while (tmp != NULL) + { + MetaWindow *gw = tmp->data; + + if (META_WINDOW_IN_DOCK_TAB_CHAIN (gw)) + { + g_slist_free (list); + return TRUE; + } + + tmp = tmp->next; + } + + g_slist_free (list); + return FALSE; +} + +static int +docks_at_end_cmp (const void *a, + const void *b) +{ + MetaWindow *window_a = (MetaWindow*) a; + MetaWindow *window_b = (MetaWindow*) b; + + if (META_WINDOW_IN_DOCK_TAB_CHAIN (window_a)) + { + if (META_WINDOW_IN_DOCK_TAB_CHAIN (window_b)) + return 0; + else + return 1; /* a > b since a is a dock */ + } + else + { + if (META_WINDOW_IN_DOCK_TAB_CHAIN (window_b)) + return -1; /* b > a since b is a dock */ + else + return 0; + } +} + +static void +shuffle_docks_to_end (GList **mru_list_p) +{ + *mru_list_p = g_list_sort (*mru_list_p, + docks_at_end_cmp); +} + gboolean meta_window_notify_focus (MetaWindow *window, XEvent *event) @@ -3991,6 +4057,8 @@ meta_window_notify_focus (MetaWindow *window, window->screen->active_workspace->mru_list = g_list_prepend (window->screen->active_workspace->mru_list, window); + if (!is_in_dock_group (window)) + shuffle_docks_to_end (&window->screen->active_workspace->mru_list); } if (window->frame)