From 00d955eb40e625081a69d13c9f0b07bdbc92b1f6 Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Mon, 15 Jun 2009 15:32:23 -0400 Subject: [PATCH] meta_display_list_windows: Exclude override-redirect Don't include override-redirect windows in the list return by meta_display_list_windows(), since we almost never want to handle them when considering "all window" for the display. Add a separate meta_display_list_all_windows() that includes override-redirect windows. http://bugzilla.gnome.org/show_bug.cgi?id=582639 --- src/core/core.c | 2 +- src/core/delete.c | 2 +- src/core/display-private.h | 7 +++++- src/core/display.c | 51 ++++++++++++++++++++++++-------------- src/core/keybindings.c | 2 +- src/core/place.c | 2 +- src/core/screen.c | 5 ++-- src/core/session.c | 4 +-- src/core/window.c | 4 +-- src/core/workspace.c | 13 +++++++--- 10 files changed, 59 insertions(+), 33 deletions(-) diff --git a/src/core/core.c b/src/core/core.c index 00f40fef0..049b1f129 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -766,7 +766,7 @@ meta_invalidate_default_icons (void) if (display == NULL) return; /* We can validly be called before the display is opened. */ - windows = meta_display_list_windows (display); + windows = meta_display_list_windows (display, META_LIST_DEFAULT); for (l = windows; l != NULL; l = l->next) { MetaWindow *window = (MetaWindow*)l->data; diff --git a/src/core/delete.c b/src/core/delete.c index 8cc887ae1..813ae669d 100644 --- a/src/core/delete.c +++ b/src/core/delete.c @@ -253,7 +253,7 @@ meta_window_present_delete_dialog (MetaWindow *window, guint32 timestamp) * mutter-dialog */ - windows = meta_display_list_windows (window->display); + windows = meta_display_list_windows (window->display, META_LIST_DEFAULT); tmp = windows; while (tmp != NULL) { diff --git a/src/core/display-private.h b/src/core/display-private.h index 85277c806..413bf7cda 100644 --- a/src/core/display-private.h +++ b/src/core/display-private.h @@ -61,6 +61,10 @@ typedef void (* MetaWindowPingFunc) (MetaDisplay *display, guint32 timestamp, gpointer user_data); +typedef enum { + META_LIST_DEFAULT = 0, /* normal windows */ + META_LIST_INCLUDE_OVERRIDE_REDIRECT = 1 << 0, /* normal and O-R */ +} MetaListWindowsFlags; #define _NET_WM_STATE_REMOVE 0 /* remove/unset property */ #define _NET_WM_STATE_ADD 1 /* add/set property */ @@ -366,7 +370,8 @@ void meta_display_unregister_x_window (MetaDisplay *display, gboolean meta_display_xwindow_is_a_no_focus_window (MetaDisplay *display, Window xwindow); -GSList* meta_display_list_windows (MetaDisplay *display); +GSList* meta_display_list_windows (MetaDisplay *display, + MetaListWindowsFlags flags); MetaDisplay* meta_display_for_x_display (Display *xdisplay); MetaDisplay* meta_get_display (void); diff --git a/src/core/display.c b/src/core/display.c index 309ff232f..9b22dfe8d 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -812,15 +812,6 @@ meta_display_open (void) return TRUE; } -static void -listify_func (gpointer key, gpointer value, gpointer data) -{ - GSList **listp; - - listp = data; - *listp = g_slist_prepend (*listp, value); -} - static gint ptrcmp (gconstpointer a, gconstpointer b) { @@ -832,17 +823,38 @@ ptrcmp (gconstpointer a, gconstpointer b) return 0; } +/** + * meta_display_list_windows: + * @display: a #MetaDisplay + * @flags: options for listing + * + * Lists windows for the display, the @flags parameter for + * now determines whether override-redirect windows will be + * included. + * + * Return value: (transfer container): the list of windows. + */ GSList* -meta_display_list_windows (MetaDisplay *display) +meta_display_list_windows (MetaDisplay *display, + MetaListWindowsFlags flags) { GSList *winlist; GSList *tmp; GSList *prev; - + GHashTableIter iter; + gpointer key, value; + winlist = NULL; - g_hash_table_foreach (display->window_ids, - listify_func, - &winlist); + + g_hash_table_iter_init (&iter, display->window_ids); + while (g_hash_table_iter_next (&iter, &key, &value)) + { + MetaWindow *window = value; + + if (!window->override_redirect || + (flags & META_LIST_INCLUDE_OVERRIDE_REDIRECT) != 0) + winlist = g_slist_prepend (winlist, window); + } /* Uniquify the list, since both frame windows and plain * windows are in the hash @@ -3931,7 +3943,7 @@ meta_display_queue_retheme_all_windows (MetaDisplay *display) GSList* windows; GSList *tmp; - windows = meta_display_list_windows (display); + windows = meta_display_list_windows (display, META_LIST_DEFAULT); tmp = windows; while (tmp != NULL) { @@ -4441,7 +4453,7 @@ meta_display_get_tab_list (MetaDisplay *display, GSList *tmp; MetaWindow *l_window; - tmp = meta_display_list_windows (display); + tmp = meta_display_list_windows (display, META_LIST_DEFAULT); /* Go through all windows */ while (tmp != NULL) @@ -4824,7 +4836,8 @@ meta_display_unmanage_windows_for_screen (MetaDisplay *display, GSList *tmp; GSList *winlist; - winlist = meta_display_list_windows (display); + winlist = meta_display_list_windows (display, + META_LIST_INCLUDE_OVERRIDE_REDIRECT); winlist = g_slist_sort (winlist, meta_display_stack_cmp); /* Unmanage all windows */ @@ -4916,7 +4929,7 @@ prefs_changed_callback (MetaPreference pref, GSList *windows; GSList *tmp; - windows = meta_display_list_windows (display); + windows = meta_display_list_windows (display, META_LIST_DEFAULT); /* Ungrab all */ tmp = windows; @@ -5018,7 +5031,7 @@ sanity_check_timestamps (MetaDisplay *display, display->last_user_time, timestamp); display->last_user_time = timestamp; - windows = meta_display_list_windows (display); + windows = meta_display_list_windows (display, META_LIST_DEFAULT); tmp = windows; while (tmp != NULL) { diff --git a/src/core/keybindings.c b/src/core/keybindings.c index fd7e9c1d1..522f663e7 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -460,7 +460,7 @@ regrab_key_bindings (MetaDisplay *display) tmp = tmp->next; } - windows = meta_display_list_windows (display); + windows = meta_display_list_windows (display, META_LIST_DEFAULT); tmp = windows; while (tmp != NULL) { diff --git a/src/core/place.c b/src/core/place.c index 280d04bed..5c1bc6a60 100644 --- a/src/core/place.c +++ b/src/core/place.c @@ -839,7 +839,7 @@ meta_window_place (MetaWindow *window, GSList *all_windows; GSList *tmp; - all_windows = meta_display_list_windows (window->display); + all_windows = meta_display_list_windows (window->display, META_LIST_DEFAULT); tmp = all_windows; while (tmp != NULL) diff --git a/src/core/screen.c b/src/core/screen.c index 0a9c79ab6..0426da496 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -934,7 +934,8 @@ meta_screen_composite_all_windows (MetaScreen *screen) if (!display->compositor) return; - windows = meta_display_list_windows (display); + windows = meta_display_list_windows (display, + META_LIST_INCLUDE_OVERRIDE_REDIRECT); for (tmp = windows; tmp != NULL; tmp = tmp->next) meta_compositor_add_window (display->compositor, tmp->data); g_slist_free (windows); @@ -2476,7 +2477,7 @@ queue_windows_showing (MetaScreen *screen) * active_workspace's window list, because the active_workspace's * window list may not contain the on_all_workspace windows. */ - windows = meta_display_list_windows (screen->display); + windows = meta_display_list_windows (screen->display, META_LIST_DEFAULT); tmp = windows; while (tmp != NULL) diff --git a/src/core/session.c b/src/core/session.c index 8eb110c2f..10034ff95 100644 --- a/src/core/session.c +++ b/src/core/session.c @@ -889,7 +889,7 @@ save_state (void) fprintf (outfile, "\n", client_id); - windows = meta_display_list_windows (meta_get_display ()); + windows = meta_display_list_windows (meta_get_display (), META_LIST_DEFAULT); stack_position = 0; windows = g_slist_sort (windows, meta_display_stack_cmp); @@ -1768,7 +1768,7 @@ warn_about_lame_clients_and_finish_interact (gboolean shutdown) GSList *tmp; GSList *columns = NULL; - windows = meta_display_list_windows (meta_get_display ()); + windows = meta_display_list_windows (meta_get_display (), META_LIST_DEFAULT); tmp = windows; while (tmp != NULL) { diff --git a/src/core/window.c b/src/core/window.c index 09fc8d73a..29eee4d5c 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -4440,7 +4440,7 @@ get_modal_transient (MetaWindow *window) */ modal_transient = window; - windows = meta_display_list_windows (window->display); + windows = meta_display_list_windows (window->display, META_LIST_DEFAULT); tmp = windows; while (tmp != NULL) { @@ -8157,7 +8157,7 @@ meta_window_foreach_transient (MetaWindow *window, GSList *windows; GSList *tmp; - windows = meta_display_list_windows (window->display); + windows = meta_display_list_windows (window->display, META_LIST_DEFAULT); tmp = windows; while (tmp != NULL) diff --git a/src/core/workspace.c b/src/core/workspace.c index 8e7c19ad0..481b564c7 100644 --- a/src/core/workspace.c +++ b/src/core/workspace.c @@ -620,8 +620,14 @@ meta_workspace_update_window_hints (MetaWorkspace *workspace) } } -/* get windows contained on workspace, including workspace->windows - * and also sticky windows. +/** + * meta_workspace_list_windows: + * @display: a #MetaDisplay + * + * Gets windows contained on the workspace, including workspace->windows + * and also sticky windows. Override-redirect windows are not included. + * + * Return value: (transfer container): the list of windows. */ GList* meta_workspace_list_windows (MetaWorkspace *workspace) @@ -630,7 +636,8 @@ meta_workspace_list_windows (MetaWorkspace *workspace) GSList *tmp; GList *workspace_windows; - display_windows = meta_display_list_windows (workspace->screen->display); + display_windows = meta_display_list_windows (workspace->screen->display, + META_LIST_DEFAULT); workspace_windows = NULL; tmp = display_windows;