From 9c62a907c5371e936f6a40efd282bd3353c9802f Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 15 Aug 2014 20:02:21 -0400 Subject: [PATCH] screen: Make meta_screen_foreach_window scan Wayland windows Scanning over the hash table of XIDs is a terrible idea. Not only were we excluding Wayland windows, but we were also looking at alarms and barriers, too. We were lucky that that only contained GObjects where our checks would work. --- src/core/screen.c | 48 +++++++---------------------------------------- 1 file changed, 7 insertions(+), 41 deletions(-) diff --git a/src/core/screen.c b/src/core/screen.c index a73c4f0b1..7f61acf2a 100644 --- a/src/core/screen.c +++ b/src/core/screen.c @@ -958,27 +958,6 @@ get_screen_name (MetaDisplay *display, return scr; } -static gint -ptrcmp (gconstpointer a, gconstpointer b) -{ - if (a < b) - return -1; - else if (a > b) - return 1; - else - return 0; -} - -static void -listify_func (gpointer key, gpointer value, gpointer data) -{ - GSList **listp; - - listp = data; - - *listp = g_slist_prepend (*listp, value); -} - /** * meta_screen_foreach_window: * @screen: a #MetaScreen @@ -993,34 +972,21 @@ meta_screen_foreach_window (MetaScreen *screen, MetaScreenWindowFunc func, gpointer data) { - GSList *winlist, *l; + GSList *windows, *l; /* If we end up doing this often, just keeping a list * of windows might be sensible. */ - winlist = NULL; - g_hash_table_foreach (screen->display->xids, - listify_func, - &winlist); + windows = meta_display_list_windows (screen->display, META_LIST_DEFAULT); - winlist = g_slist_sort (winlist, ptrcmp); - - for (l = winlist; l != NULL; l = l->next) + for (l = windows; l != NULL; l = l->next) { - /* If the next node doesn't contain this window - * a second time, delete the window. - */ - if (l->next == NULL || - (l->next && l->next->data != l->data)) - { - MetaWindow *window = l->data; - - if (META_IS_WINDOW (window) && !window->override_redirect) - (* func) (screen, window, data); - } + MetaWindow *window = l->data; + func (screen, window, data); } - g_slist_free (winlist); + + g_slist_free (windows); } int