window-props: Don't look for parent multiple times

Once we set the transient_for, we look for parent MetaWindow, so instead
of overwriting this value for loops check, just use another function
and avoid to look for the xwindow again when setting the MetaWindow parent.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/895
This commit is contained in:
Marco Trevisan (Treviño) 2019-10-29 17:14:43 +01:00 committed by Marco Trevisan
parent 13f10e36e4
commit c85fb107c0

View File

@ -1625,6 +1625,22 @@ reload_wm_hints (MetaWindow *window,
meta_window_queue (window, META_QUEUE_UPDATE_ICON | META_QUEUE_MOVE_RESIZE);
}
static gboolean
check_xtransient_for_loop (MetaWindow *window,
MetaWindow *parent)
{
while (parent)
{
if (parent == window)
return TRUE;
parent = meta_x11_display_lookup_x_window (parent->display->x11_display,
parent->xtransient_for);
}
return FALSE;
}
static void
reload_transient_for (MetaWindow *window,
MetaPropValue *value,
@ -1647,18 +1663,11 @@ reload_transient_for (MetaWindow *window,
}
/* Make sure there is not a loop */
while (parent)
if (check_xtransient_for_loop (window, parent))
{
if (parent == window)
{
meta_warning ("WM_TRANSIENT_FOR window 0x%lx for %s would create loop.\n",
transient_for, window->desc);
meta_warning ("WM_TRANSIENT_FOR window 0x%lx for %s would create a "
"loop.\n", transient_for, window->desc);
transient_for = None;
break;
}
parent = meta_x11_display_lookup_x_window (parent->display->x11_display,
parent->xtransient_for);
}
}
else
@ -1679,8 +1688,6 @@ reload_transient_for (MetaWindow *window,
meta_window_set_transient_for (window, NULL);
else
{
parent = meta_x11_display_lookup_x_window (window->display->x11_display,
window->xtransient_for);
meta_window_set_transient_for (window, parent);
}
}