From f1762f428b0ef2989c81f57ea9e810403d34d946 Mon Sep 17 00:00:00 2001 From: novenary Date: Fri, 10 Mar 2023 15:05:41 +0200 Subject: xwm: ensure stack list only contains mapped managed surfaces --- xwayland/xwm.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 47679284..e744565a 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -411,6 +411,10 @@ static void xwayland_surface_dissociate(struct wlr_xwayland_surface *xsurface) { wl_list_init(&xsurface->unpaired_link); xsurface->surface_id = 0; xsurface->serial = 0; + + wl_list_remove(&xsurface->stack_link); + wl_list_init(&xsurface->stack_link); + xwm_set_net_client_list_stacking(xsurface->xwm); } static void xwayland_surface_destroy(struct wlr_xwayland_surface *xsurface) { @@ -423,7 +427,6 @@ static void xwayland_surface_destroy(struct wlr_xwayland_surface *xsurface) { } wl_list_remove(&xsurface->link); - wl_list_remove(&xsurface->stack_link); wl_list_remove(&xsurface->parent_link); struct wlr_xwayland_surface *child, *next; @@ -999,6 +1002,24 @@ static void xwm_handle_configure_request(struct wlr_xwm *xwm, wl_signal_emit_mutable(&surface->events.request_configure, &wlr_event); } +static void xwm_update_override_redirect(struct wlr_xwayland_surface *xsurface, + bool override_redirect) { + if (xsurface->override_redirect == override_redirect) { + return; + } + xsurface->override_redirect = override_redirect; + + if (override_redirect) { + wl_list_remove(&xsurface->stack_link); + wl_list_init(&xsurface->stack_link); + xwm_set_net_client_list_stacking(xsurface->xwm); + } else if (xsurface->surface != NULL && xsurface->surface->mapped) { + wlr_xwayland_surface_restack(xsurface, NULL, XCB_STACK_MODE_BELOW); + } + + wl_signal_emit_mutable(&xsurface->events.set_override_redirect, NULL); +} + static void xwm_handle_configure_notify(struct wlr_xwm *xwm, xcb_configure_notify_event_t *ev) { struct wlr_xwayland_surface *xsurface = lookup_surface(xwm, ev->window); @@ -1017,10 +1038,7 @@ static void xwm_handle_configure_notify(struct wlr_xwm *xwm, xsurface->height = ev->height; } - if (xsurface->override_redirect != ev->override_redirect) { - xsurface->override_redirect = ev->override_redirect; - wl_signal_emit_mutable(&xsurface->events.set_override_redirect, NULL); - } + xwm_update_override_redirect(xsurface, ev->override_redirect); if (geometry_changed) { wl_signal_emit_mutable(&xsurface->events.set_geometry, NULL); @@ -1116,10 +1134,7 @@ static void xwm_handle_map_notify(struct wlr_xwm *xwm, return; } - if (xsurface->override_redirect != ev->override_redirect) { - xsurface->override_redirect = ev->override_redirect; - wl_signal_emit_mutable(&xsurface->events.set_override_redirect, NULL); - } + xwm_update_override_redirect(xsurface, ev->override_redirect); } static void xwm_handle_unmap_notify(struct wlr_xwm *xwm, -- cgit v1.2.3