From 6d03666d2d17828d7a1908638884fbeec875c3e0 Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Mon, 11 Mar 2024 11:32:40 +0100 Subject: [PATCH] window/x11: Try harder to find the associated group Otherwise we would try to create a new group later on which would crash Fixes #3329 Part-of: --- src/x11/window-x11.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/x11/window-x11.c b/src/x11/window-x11.c index 745c45db1..e57bc8622 100644 --- a/src/x11/window-x11.c +++ b/src/x11/window-x11.c @@ -4549,9 +4549,11 @@ static void meta_window_x11_compute_group (MetaWindow *window) { MetaGroup *group = NULL; - MetaWindow *ancestor; MetaX11Display *x11_display = window->display->x11_display; + MetaWindow *ancestor = meta_window_find_root_ancestor (window); Window win_leader = meta_window_x11_get_xgroup_leader (window); + Window xwindow = meta_window_x11_get_xwindow (window); + Window ancestor_leader = meta_window_x11_get_xgroup_leader (ancestor); MetaWindowX11Private *priv = meta_window_x11_get_private (META_WINDOW_X11 (window)); @@ -4560,21 +4562,19 @@ meta_window_x11_compute_group (MetaWindow *window) /* Determine the ancestor of the window; its group setting will override the * normal grouping rules; see bug 328211. */ - ancestor = meta_window_find_root_ancestor (window); if (x11_display->groups_by_leader) { - if (ancestor != window) + if (ancestor != window && ancestor_leader != None) group = meta_window_x11_get_group (ancestor); - else if (win_leader != None) + + if (win_leader != None && group == NULL) group = g_hash_table_lookup (x11_display->groups_by_leader, &win_leader); - else - { - Window xwindow = meta_window_x11_get_xwindow (window); - group = g_hash_table_lookup (x11_display->groups_by_leader, - &xwindow); - } + + if (group == NULL) + group = g_hash_table_lookup (x11_display->groups_by_leader, + &xwindow); } if (group != NULL) @@ -4584,17 +4584,13 @@ meta_window_x11_compute_group (MetaWindow *window) } else { - Window ancestor_leader = meta_window_x11_get_xgroup_leader (ancestor); if (ancestor != window && ancestor_leader != None) - group = meta_group_new (x11_display, - ancestor_leader); + group = meta_group_new (x11_display, ancestor_leader); else if (win_leader != None) - group = meta_group_new (x11_display, - win_leader); + group = meta_group_new (x11_display, win_leader); else - group = meta_group_new (x11_display, - meta_window_x11_get_xwindow (window)); + group = meta_group_new (x11_display, xwindow); priv->group = group; }