From 1fce95d0cc4f575a4e8153a469ba08f4b3781c8a Mon Sep 17 00:00:00 2001 From: lkn Date: Sun, 7 Jun 2026 15:54:38 +0200 Subject: [PATCH] add comments clarifying the xdg configure lifecycle after NULL-buffer unmap --- WINGs/wclient_wl.c | 8 ++++++++ WINGs/wview_wl.c | 9 +++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/WINGs/wclient_wl.c b/WINGs/wclient_wl.c index ad354e8..9ad4c4a 100644 --- a/WINGs/wclient_wl.c +++ b/WINGs/wclient_wl.c @@ -413,6 +413,9 @@ static const struct xdg_toplevel_listener xdg_toplevel_listener = { static void wl_client_toplevel_commit_locked(WLClientToplevel *top) { + /* configured==0 means the surface was unmapped via NULL buffer + * and we are waiting for a fresh configure from the compositor. + * All buffer attachments are blocked until it arrives. */ if (!top || !top->configured || !top->buf || !top->buf->wl_buf) return; wl_surface_attach(top->surface, top->buf->wl_buf, 0, 0); @@ -568,6 +571,11 @@ wl_client_view_unmap(WNativeWindow id) /* Attach NULL + commit: the standard Wayland way * for a client to hide a surface from the compositor. * The xdg_toplevel object stays alive for remap. */ + /* Attach NULL + commit: the standard Wayland way for a client to + * hide a surface. This triggers a wlroots unmap and the compositor + * will send a new xdg_surface.configure before we can re-attach a + * real buffer. We set configured=0 so wl_client_toplevel_commit_locked + * blocks all buffer attachments until the configure arrives. */ wl_surface_attach(top->surface, NULL, 0, 0); wl_surface_commit(top->surface); top->configured = 0; diff --git a/WINGs/wview_wl.c b/WINGs/wview_wl.c index f350668..f17eeda 100644 --- a/WINGs/wview_wl.c +++ b/WINGs/wview_wl.c @@ -222,10 +222,11 @@ static void wl_unmap(void *vctx, W_View *view) } else wwarning("wl_unmap: W_ViewSceneNodeSetEnabledFn is NULL"); /* Scene node disabled in the diagnostic block above. */ - /* In client mode (e.g. WPrefs), W_ViewSceneNodeSetEnabledFn may be - * NULL because the compositor-side function is not available in the - * client process. Attach NULL to the wl_surface, which is the - * standard Wayland way for a client to hide a surface. */ + /* W_ViewSceneNodeSetEnabledFn is NULL in client-only builds (e.g. + * WPrefs) because the compositor-side function is not linked into + * the client process. Fall back to the standard Wayland unmap: + * attach NULL + commit. This triggers a fresh xdg_surface.configure + * which wl_client_toplevel_commit_locked will await via configured=0. */ if (view->flags.topLevel && view->flags.popup && !W_ViewSceneNodeSetEnabledFn) { extern void wl_client_view_unmap(WNativeWindow id);