From 19a36b88790f3619d866986a33c96c773bcb74b8 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Thu, 24 Aug 2023 14:52:16 +0200 Subject: [PATCH] window: Stop storing xtransient_for field Instead retrieve the associated Window from the xwindow property. Avoids having a vfunc to handle the get_transient_for differences between Wayland and x11 Part-of: --- src/core/window-private.h | 1 - src/core/window.c | 10 +--------- src/x11/window-props.c | 27 ++++++++++++++------------- src/x11/window-x11-private.h | 2 ++ src/x11/window-x11.c | 20 ++++++++++++++++++-- 5 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/core/window-private.h b/src/core/window-private.h index 77f8e221a..4116fe23e 100644 --- a/src/core/window-private.h +++ b/src/core/window-private.h @@ -203,7 +203,6 @@ struct _MetaWindow char *gtk_app_menu_object_path; char *gtk_menubar_object_path; - Window xtransient_for; MetaWindow *transient_for; /* Initial workspace property */ diff --git a/src/core/window.c b/src/core/window.c index 9bf9c4177..489f73a73 100644 --- a/src/core/window.c +++ b/src/core/window.c @@ -1103,8 +1103,6 @@ meta_window_constructed (GObject *object) window->has_valid_cgroup = TRUE; window->cgroup_path = NULL; - window->xtransient_for = None; - window->type = META_WINDOW_NORMAL; window->struts = NULL; @@ -6709,13 +6707,7 @@ meta_window_get_transient_for (MetaWindow *window) { g_return_val_if_fail (META_IS_WINDOW (window), NULL); - if (window->transient_for) - return window->transient_for; - else if (window->xtransient_for) - return meta_x11_display_lookup_x_window (window->display->x11_display, - window->xtransient_for); - else - return NULL; + return window->transient_for; } /** diff --git a/src/x11/window-props.c b/src/x11/window-props.c index b853790f7..fdf0c1814 100644 --- a/src/x11/window-props.c +++ b/src/x11/window-props.c @@ -1683,7 +1683,7 @@ check_xtransient_for_loop (MetaWindow *window, return TRUE; parent = meta_x11_display_lookup_x_window (parent->display->x11_display, - parent->xtransient_for); + meta_window_x11_get_xtransient_for (parent)); } return FALSE; @@ -1695,7 +1695,7 @@ reload_transient_for (MetaWindow *window, gboolean initial) { MetaWindow *parent = NULL; - Window transient_for; + Window transient_for, current_transient_for; if (value->type != META_PROP_VALUE_INVALID) { @@ -1712,9 +1712,9 @@ reload_transient_for (MetaWindow *window, else if (parent->override_redirect) { const gchar *window_kind = window->override_redirect ? - "override-redirect" : "top-level"; - - if (parent->xtransient_for != None) + "override-redirect" : "top-level"; + Window parent_xtransient_for = meta_window_x11_get_xtransient_for (parent); + if (parent_xtransient_for != None) { /* We don't have to go through the parents, as per this code it is * not possible that a window has the WM_TRANSIENT_FOR set to an @@ -1724,8 +1724,8 @@ reload_transient_for (MetaWindow *window, "according to the standard, so we'll fallback to " "the first non-override-redirect window 0x%lx.", parent->desc, window->desc, window_kind, - parent->xtransient_for); - transient_for = parent->xtransient_for; + parent_xtransient_for); + transient_for = parent_xtransient_for; parent = meta_x11_display_lookup_x_window (parent->display->x11_display, transient_for); @@ -1753,18 +1753,19 @@ reload_transient_for (MetaWindow *window, else transient_for = None; - if (transient_for == window->xtransient_for) + current_transient_for = meta_window_x11_get_xtransient_for (window); + if (transient_for == current_transient_for) return; - window->xtransient_for = transient_for; - if (window->xtransient_for != None) - meta_verbose ("Window %s transient for 0x%lx", window->desc, window->xtransient_for); + current_transient_for = transient_for; + if (current_transient_for != None) + meta_verbose ("Window %s transient for 0x%lx", window->desc, current_transient_for); else meta_verbose ("Window %s is not transient", window->desc); - if (window->xtransient_for == None || - window->xtransient_for == window->display->x11_display->xroot) + if (current_transient_for == None || + current_transient_for == window->display->x11_display->xroot) meta_window_set_transient_for (window, NULL); else { diff --git a/src/x11/window-x11-private.h b/src/x11/window-x11-private.h index 85a51b2cd..82b4d4d99 100644 --- a/src/x11/window-x11-private.h +++ b/src/x11/window-x11-private.h @@ -98,4 +98,6 @@ Window meta_window_x11_get_xgroup_leader (MetaWindow *window); Window meta_window_x11_get_user_time_window (MetaWindow *window); +Window meta_window_x11_get_xtransient_for (MetaWindow *window); + G_END_DECLS diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 216576ab7..0df482495 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -2005,6 +2005,7 @@ meta_window_x11_set_transient_for (MetaWindow *window, MetaWindowX11 *window_x11 = META_WINDOW_X11 (window); MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11); + Window xtransient_for; meta_window_x11_recalc_window_type (window); if (!window->constructing) @@ -2030,9 +2031,10 @@ meta_window_x11_set_transient_for (MetaWindow *window, * equivalent to making it your group leader, to work around shortcomings * in programs such as xmms-- see #328211. */ - if (window->xtransient_for != None && + xtransient_for = meta_window_x11_get_xtransient_for (window); + if (xtransient_for != None && priv->xgroup_leader != None && - window->xtransient_for != priv->xgroup_leader) + xtransient_for != priv->xgroup_leader) meta_window_group_leader_changed (window); return TRUE; @@ -4447,3 +4449,17 @@ meta_window_x11_get_user_time_window (MetaWindow *window) return priv->user_time_window; } + +Window +meta_window_x11_get_xtransient_for (MetaWindow *window) +{ + MetaWindow *transient_for; + + g_return_val_if_fail (META_IS_WINDOW (window), None); + + transient_for = meta_window_get_transient_for (window); + if (transient_for) + return meta_window_x11_get_xwindow (transient_for); + + return None; +}