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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3211>
This commit is contained in:
Bilal Elmoussaoui 2023-08-24 14:52:16 +02:00 committed by Robert Mader
parent 5e098eadce
commit 19a36b8879
5 changed files with 35 additions and 25 deletions

View File

@ -203,7 +203,6 @@ struct _MetaWindow
char *gtk_app_menu_object_path; char *gtk_app_menu_object_path;
char *gtk_menubar_object_path; char *gtk_menubar_object_path;
Window xtransient_for;
MetaWindow *transient_for; MetaWindow *transient_for;
/* Initial workspace property */ /* Initial workspace property */

View File

@ -1103,8 +1103,6 @@ meta_window_constructed (GObject *object)
window->has_valid_cgroup = TRUE; window->has_valid_cgroup = TRUE;
window->cgroup_path = NULL; window->cgroup_path = NULL;
window->xtransient_for = None;
window->type = META_WINDOW_NORMAL; window->type = META_WINDOW_NORMAL;
window->struts = NULL; window->struts = NULL;
@ -6709,13 +6707,7 @@ meta_window_get_transient_for (MetaWindow *window)
{ {
g_return_val_if_fail (META_IS_WINDOW (window), NULL); g_return_val_if_fail (META_IS_WINDOW (window), NULL);
if (window->transient_for)
return 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;
} }
/** /**

View File

@ -1683,7 +1683,7 @@ check_xtransient_for_loop (MetaWindow *window,
return TRUE; return TRUE;
parent = meta_x11_display_lookup_x_window (parent->display->x11_display, parent = meta_x11_display_lookup_x_window (parent->display->x11_display,
parent->xtransient_for); meta_window_x11_get_xtransient_for (parent));
} }
return FALSE; return FALSE;
@ -1695,7 +1695,7 @@ reload_transient_for (MetaWindow *window,
gboolean initial) gboolean initial)
{ {
MetaWindow *parent = NULL; MetaWindow *parent = NULL;
Window transient_for; Window transient_for, current_transient_for;
if (value->type != META_PROP_VALUE_INVALID) if (value->type != META_PROP_VALUE_INVALID)
{ {
@ -1713,8 +1713,8 @@ reload_transient_for (MetaWindow *window,
{ {
const gchar *window_kind = window->override_redirect ? const gchar *window_kind = window->override_redirect ?
"override-redirect" : "top-level"; "override-redirect" : "top-level";
Window parent_xtransient_for = meta_window_x11_get_xtransient_for (parent);
if (parent->xtransient_for != None) if (parent_xtransient_for != None)
{ {
/* We don't have to go through the parents, as per this code it is /* 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 * 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 " "according to the standard, so we'll fallback to "
"the first non-override-redirect window 0x%lx.", "the first non-override-redirect window 0x%lx.",
parent->desc, window->desc, window_kind, parent->desc, window->desc, window_kind,
parent->xtransient_for); parent_xtransient_for);
transient_for = parent->xtransient_for; transient_for = parent_xtransient_for;
parent = parent =
meta_x11_display_lookup_x_window (parent->display->x11_display, meta_x11_display_lookup_x_window (parent->display->x11_display,
transient_for); transient_for);
@ -1753,18 +1753,19 @@ reload_transient_for (MetaWindow *window,
else else
transient_for = None; 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; return;
window->xtransient_for = transient_for;
if (window->xtransient_for != None) current_transient_for = transient_for;
meta_verbose ("Window %s transient for 0x%lx", window->desc, window->xtransient_for); if (current_transient_for != None)
meta_verbose ("Window %s transient for 0x%lx", window->desc, current_transient_for);
else else
meta_verbose ("Window %s is not transient", window->desc); meta_verbose ("Window %s is not transient", window->desc);
if (window->xtransient_for == None || if (current_transient_for == None ||
window->xtransient_for == window->display->x11_display->xroot) current_transient_for == window->display->x11_display->xroot)
meta_window_set_transient_for (window, NULL); meta_window_set_transient_for (window, NULL);
else else
{ {

View File

@ -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_user_time_window (MetaWindow *window);
Window meta_window_x11_get_xtransient_for (MetaWindow *window);
G_END_DECLS G_END_DECLS

View File

@ -2005,6 +2005,7 @@ meta_window_x11_set_transient_for (MetaWindow *window,
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window); MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = MetaWindowX11Private *priv =
meta_window_x11_get_instance_private (window_x11); meta_window_x11_get_instance_private (window_x11);
Window xtransient_for;
meta_window_x11_recalc_window_type (window); meta_window_x11_recalc_window_type (window);
if (!window->constructing) 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 * equivalent to making it your group leader, to work around shortcomings
* in programs such as xmms-- see #328211. * 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 && priv->xgroup_leader != None &&
window->xtransient_for != priv->xgroup_leader) xtransient_for != priv->xgroup_leader)
meta_window_group_leader_changed (window); meta_window_group_leader_changed (window);
return TRUE; return TRUE;
@ -4447,3 +4449,17 @@ meta_window_x11_get_user_time_window (MetaWindow *window)
return priv->user_time_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;
}