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>
This commit is contained in:
Florian Müllner 2021-12-11 03:04:24 +01:00
parent 40d9d26229
commit ccf6bbc673
2 changed files with 30 additions and 0 deletions

View File

@ -830,6 +830,7 @@ void meta_window_set_gtk_dbus_properties (MetaWindow *window,
const char *window_object_path); const char *window_object_path);
gboolean meta_window_has_transient_type (MetaWindow *window); gboolean meta_window_has_transient_type (MetaWindow *window);
gboolean meta_window_has_modals (MetaWindow *window);
void meta_window_set_transient_for (MetaWindow *window, void meta_window_set_transient_for (MetaWindow *window,
MetaWindow *parent); MetaWindow *parent);

View File

@ -8021,6 +8021,35 @@ meta_window_has_attached_dialogs (MetaWindow *window)
return has_attached; 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: * meta_window_get_tile_match:
* @window: a #MetaWindow * @window: a #MetaWindow