stack: Move HAS_TRANSIENT_TYPE macro to window-private

We'll soon need it elsewhere, so move it to a shared location.
While at it, convert it to a function.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/949
This commit is contained in:
Florian Müllner 2019-11-26 23:06:09 +01:00
parent 1c89fce30e
commit 599d8e3287
3 changed files with 17 additions and 12 deletions

View File

@ -40,15 +40,8 @@
#include "meta/workspace.h" #include "meta/workspace.h"
#include "x11/meta-x11-display-private.h" #include "x11/meta-x11-display-private.h"
#define WINDOW_HAS_TRANSIENT_TYPE(w) \
(w->type == META_WINDOW_DIALOG || \
w->type == META_WINDOW_MODAL_DIALOG || \
w->type == META_WINDOW_TOOLBAR || \
w->type == META_WINDOW_MENU || \
w->type == META_WINDOW_UTILITY)
#define WINDOW_TRANSIENT_FOR_WHOLE_GROUP(w) \ #define WINDOW_TRANSIENT_FOR_WHOLE_GROUP(w) \
(WINDOW_HAS_TRANSIENT_TYPE (w) && w->transient_for == NULL) (meta_window_has_transient_type (w) && w->transient_for == NULL)
static void meta_window_set_stack_position_no_sync (MetaWindow *window, static void meta_window_set_stack_position_no_sync (MetaWindow *window,
int position); int position);
@ -552,7 +545,7 @@ compute_layer (MetaWindow *window)
* fullscreen. * fullscreen.
*/ */
if (window->layer != META_LAYER_DESKTOP && if (window->layer != META_LAYER_DESKTOP &&
WINDOW_HAS_TRANSIENT_TYPE(window) && meta_window_has_transient_type (window) &&
window->transient_for == NULL) window->transient_for == NULL)
{ {
/* We only do the group thing if the dialog is NOT transient for /* We only do the group thing if the dialog is NOT transient for
@ -754,7 +747,7 @@ create_constraints (Constraint **constraints,
/* better way I think, so transient-for-group are constrained /* better way I think, so transient-for-group are constrained
* only above non-transient-type windows in their group * only above non-transient-type windows in their group
*/ */
if (!WINDOW_HAS_TRANSIENT_TYPE (group_window)) if (!meta_window_has_transient_type (group_window))
#endif #endif
{ {
meta_topic (META_DEBUG_STACK, "Constraining %s above %s as it's transient for its group\n", meta_topic (META_DEBUG_STACK, "Constraining %s above %s as it's transient for its group\n",
@ -861,7 +854,7 @@ ensure_above (MetaWindow *above,
{ {
gboolean is_transient; gboolean is_transient;
is_transient = WINDOW_HAS_TRANSIENT_TYPE (above) || is_transient = meta_window_has_transient_type (above) ||
above->transient_for == below; above->transient_for == below;
if (is_transient && above->layer < below->layer) if (is_transient && above->layer < below->layer)
{ {

View File

@ -780,6 +780,8 @@ void meta_window_set_gtk_dbus_properties (MetaWindow *window,
const char *application_object_path, const char *application_object_path,
const char *window_object_path); const char *window_object_path);
gboolean meta_window_has_transient_type (MetaWindow *window);
void meta_window_set_transient_for (MetaWindow *window, void meta_window_set_transient_for (MetaWindow *window,
MetaWindow *parent); MetaWindow *parent);

View File

@ -7977,6 +7977,16 @@ check_transient_for_loop (MetaWindow *window,
return FALSE; return FALSE;
} }
gboolean
meta_window_has_transient_type (MetaWindow *window)
{
return (window->type == META_WINDOW_DIALOG ||
window->type == META_WINDOW_MODAL_DIALOG ||
window->type == META_WINDOW_TOOLBAR ||
window->type == META_WINDOW_MENU ||
window->type == META_WINDOW_UTILITY);
}
void void
meta_window_set_transient_for (MetaWindow *window, meta_window_set_transient_for (MetaWindow *window,
MetaWindow *parent) MetaWindow *parent)