From 6fa2c78c2e8f78880ca134608ec0dd2e80cc306b Mon Sep 17 00:00:00 2001 From: lkn Date: Sat, 6 Jun 2026 16:19:08 +0200 Subject: [PATCH] wayland: avoid misclassifying WINGs toplevels as dialogs --- src/backend/wayland/wl_xdg.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backend/wayland/wl_xdg.c b/src/backend/wayland/wl_xdg.c index 3db8fb6..b835bac 100644 --- a/src/backend/wayland/wl_xdg.c +++ b/src/backend/wayland/wl_xdg.c @@ -22,6 +22,7 @@ /* Forward declarations for functions defined in other wl_*.c files */ extern void W_UnregisterBacking(unsigned long id); +extern W_View *W_GetViewForWindow(WNativeWindow id); void view_attach_scene_destroy_listener(struct wl_toplevel_view *view); void wl_pointer_warp_to(int x, int y); void wm_dock_app_add(struct wl_toplevel_view *v); @@ -240,7 +241,12 @@ handle_toplevel_map(struct wl_listener *listener, void *data) if (app_id_check && strcmp(app_id_check, "WINGs") == 0) { struct wl_frame_buf *_fb, *_next; wl_list_for_each_safe(_fb, _next, &wl_state.frame_list, link) { - if (_fb->id >= 0x20000000 && !wl_find_view_by_id(_fb->id)) { + /* WINGs view windows and synthetic backing IDs both live in the + * 0x20000000+ range. A regular WINGs toplevel (like WPrefs) is + * already present in the view table by the time it maps, while a + * pre-created dialog backing from wl_client_reparent is not. + * Only steal the id for the latter case. */ + if (_fb->id >= 0x20000000 && !W_GetViewForWindow(_fb->id)) { /* Stale WINGs frame_buf from a previous session — clean it * up if its scene buffer was auto-destroyed (parent tree was * destroyed, cascade nulled the pointer) or if the parent