xwayland: Handle GetCurrentClient returning NULL in xwl_reparent_window

It's not the WM client in that case.

Fixes crash.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/work_items/1885
Fixes: 6aacf04f51 ("xwayland: Add heuristic for WM windows based on reparenting")
(cherry picked from commit 6357c9afce)

Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/2189>
This commit is contained in:
Michel Dänzer 2026-04-21 12:46:01 +02:00 committed by Marge Bot
parent 0ca92fb4be
commit e75146412a

View file

@ -1878,6 +1878,7 @@ xwl_reparent_window(WindowPtr window, WindowPtr prior_parent)
ScreenPtr screen = window->drawable.pScreen;
struct xwl_screen *xwl_screen = xwl_screen_get(screen);
WindowPtr parent = window->parent;
ClientPtr current_client;
Bool *is_wm_window;
if (xwl_screen->ReparentWindow) {
@ -1887,8 +1888,10 @@ xwl_reparent_window(WindowPtr window, WindowPtr prior_parent)
screen->ReparentWindow = xwl_reparent_window;
}
current_client = GetCurrentClient();
if (!parent->parent ||
GetCurrentClient()->index != xwl_screen->wm_client_id)
!current_client ||
current_client->index != xwl_screen->wm_client_id)
return;
/* If the WM client reparents a window, mark the new parent as a WM window */