[mutter] window: Add has_attached_dialogs() function



commit 40d9d26229cf3067929dc7fa5f18ab136d9fe3cb
Author: Florian Müllner <fmuellner gnome org>
Date:   Tue Nov 30 16:49:20 2021 +0100

    window: Add has_attached_dialogs() function
    
    We currently only expose a function to check whether a window *is* an
    attached modal dialog, not whether it *has* any.
    
    The latter is interesting as well, but the code currently lives in a
    gnome-shell helper function. Mutter is in a better position to filter
    out unmanaging windows though, so add corresponding API.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4825
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2123>

 src/core/window.c | 36 ++++++++++++++++++++++++++++++++++++
 src/meta/window.h |  3 +++
 2 files changed, 39 insertions(+)
---
diff --git a/src/core/window.c b/src/core/window.c
index 3e5cec1aa2..b66042e62f 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -7985,6 +7985,42 @@ meta_window_is_attached_dialog (MetaWindow *window)
   return window->attached;
 }
 
+static gboolean
+has_attached_foreach_func (MetaWindow *window,
+                           void       *data)
+{
+  gboolean *is_attached = data;
+
+  *is_attached = window->attached && !window->unmanaging;
+
+  if (*is_attached)
+    return FALSE;
+
+  return TRUE;
+}
+
+
+/**
+ * meta_window_has_attached_dialogs:
+ * @window: a #MetaWindow
+ *
+ * Tests if @window has any transients attached to it.
+ * (If the "attach_modal_dialogs" option is not enabled, this will
+ * always return %FALSE.)
+ *
+ * Return value: whether @window has attached transients
+ */
+gboolean
+meta_window_has_attached_dialogs (MetaWindow *window)
+{
+  gboolean has_attached = FALSE;
+
+  meta_window_foreach_transient (window,
+                                 has_attached_foreach_func,
+                                 &has_attached);
+  return has_attached;
+}
+
 /**
  * meta_window_get_tile_match:
  * @window: a #MetaWindow
diff --git a/src/meta/window.h b/src/meta/window.h
index 2b69269d13..d5d07a061e 100644
--- a/src/meta/window.h
+++ b/src/meta/window.h
@@ -343,6 +343,9 @@ gboolean    meta_window_is_remote (MetaWindow *window);
 META_EXPORT
 gboolean    meta_window_is_attached_dialog (MetaWindow *window);
 
+META_EXPORT
+gboolean    meta_window_has_attached_dialogs (MetaWindow *window);
+
 META_EXPORT
 const char *meta_window_get_mutter_hints (MetaWindow *window);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]