From 74a4314621717ef7adfe8e6bb3dfcf69012306fa Mon Sep 17 00:00:00 2001 From: lkn Date: Sat, 6 Jun 2026 14:19:33 +0200 Subject: [PATCH] fix: destroy frame_bufs in handle_toplevel_destroy so they do not leak between WPrefs launches --- src/backend/wayland/wl_xdg.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/backend/wayland/wl_xdg.c b/src/backend/wayland/wl_xdg.c index 44fddf2..3db8fb6 100644 --- a/src/backend/wayland/wl_xdg.c +++ b/src/backend/wayland/wl_xdg.c @@ -434,7 +434,28 @@ handle_toplevel_destroy(struct wl_listener *listener, void *data) wfree(view->wm_command[ci]); wfree(view->wm_command); } + /* Save frame_id before freeing view */ + WNativeWindow frame_id = view->frame_id; wfree(view); + + /* Destroy the frame_buf for this window and any orphaned children. + * Without this, frame_bufs leak in wl_state.frame_list and on the + * next launch the WINGs dialog detection finds a stale 0x20000000+ + * frame_buf, skips wManageWindow, and the window gets no titlebar. */ + if (frame_id) { + struct wl_frame_buf *_fb, *_next; + wl_list_for_each_safe(_fb, _next, &wl_state.frame_list, link) { + if (_fb->id == frame_id || _fb->parent_id == frame_id) { + if (_fb->scene_buf) + wlr_scene_node_destroy(&_fb->scene_buf->node); + if (_fb->tree) + wlr_scene_node_destroy(&_fb->tree->node); + W_UnregisterBacking(_fb->id); + wl_list_remove(&_fb->link); + wlr_buffer_drop(&_fb->base); + } + } + } } /*