[mutter] window: Add has_modals() function



commit ccf6bbc6731042b80f28dd3daf52fbd41a5dfe82
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Dec 11 03:04:24 2021 +0100

    window: Add has_modals() function
    
    We'll soon use that to enforce modal behavior for foreign transient
    windows. It'll only be used inside mutter (for the time being), so
    keep it private for now.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4825
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2123>

 src/core/window-private.h |  1 +
 src/core/window.c         | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
---
diff --git a/src/core/window-private.h b/src/core/window-private.h
index b4de8a60a5..ccb5b719dd 100644
--- a/src/core/window-private.h
+++ b/src/core/window-private.h
@@ -830,6 +830,7 @@ void meta_window_set_gtk_dbus_properties  (MetaWindow *window,
                                            const char *window_object_path);
 
 gboolean meta_window_has_transient_type   (MetaWindow *window);
+gboolean meta_window_has_modals           (MetaWindow *window);
 
 void meta_window_set_transient_for        (MetaWindow *window,
                                            MetaWindow *parent);
diff --git a/src/core/window.c b/src/core/window.c
index b66042e62f..518cebb347 100644
--- a/src/core/window.c
+++ b/src/core/window.c
@@ -8021,6 +8021,35 @@ meta_window_has_attached_dialogs (MetaWindow *window)
   return has_attached;
 }
 
+static gboolean
+has_modals_foreach_func (MetaWindow *window,
+                         void       *data)
+{
+  gboolean *is_modal = data;
+
+  *is_modal = window->type == META_WINDOW_MODAL_DIALOG && !window->unmanaging;
+
+  if (*is_modal)
+    return FALSE;
+
+  return TRUE;
+}
+
+/**
+ * meta_window_has_modals:
+ * @window: a #MetaWindow
+ *
+ * Return value: whether @window has any modal transients
+ */
+gboolean
+meta_window_has_modals (MetaWindow *window)
+{
+  gboolean has_modals = FALSE;
+
+  meta_window_foreach_transient (window, has_modals_foreach_func, &has_modals);
+  return has_modals;
+}
+
 /**
  * meta_window_get_tile_match:
  * @window: a #MetaWindow


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