From 525cb7e10e95d41e4eebc503792afbcef17d7c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 15 Dec 2021 19:02:24 +0100 Subject: [PATCH] display: Add meta_display_list_all_windows() We now have a use case in gnome-shell for getting a list of all windows (including OR ones), but the existing API is private. https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4751 Part-of: --- src/core/display.c | 25 +++++++++++++++++++++++++ src/meta/display.h | 3 +++ 2 files changed, 28 insertions(+) diff --git a/src/core/display.c b/src/core/display.c index c99edc8f0..60b8add77 100644 --- a/src/core/display.c +++ b/src/core/display.c @@ -2389,6 +2389,31 @@ mru_cmp (gconstpointer a, return 0; } +/** + * meta_display_list_all_windows: + * @display: a #MetaDisplay + * + * List all windows, including override-redirect ones. The windows are + * in no particular order. + * + * Returns: (transfer container) (element-type Meta.Window): List of windows + */ +GList * +meta_display_list_all_windows (MetaDisplay *display) +{ + GList *all_windows = NULL; + g_autoptr (GSList) windows = NULL; + GSList *l; + + windows = meta_display_list_windows (display, + META_LIST_INCLUDE_OVERRIDE_REDIRECT); + + /* Yay for mixing GList and GSList in the API */ + for (l = windows; l; l = l->next) + all_windows = g_list_prepend (all_windows, l->data); + return all_windows; +} + /** * meta_display_get_tab_list: * @display: a #MetaDisplay diff --git a/src/meta/display.h b/src/meta/display.h index 23bcbd0f5..e59bd0393 100644 --- a/src/meta/display.h +++ b/src/meta/display.h @@ -110,6 +110,9 @@ guint32 meta_display_get_current_time (MetaDisplay *display); META_EXPORT guint32 meta_display_get_current_time_roundtrip (MetaDisplay *display); +META_EXPORT +GList * meta_display_list_all_windows (MetaDisplay *display); + META_EXPORT GList* meta_display_get_tab_list (MetaDisplay *display, MetaTabList type,