add comments clarifying the xdg configure lifecycle after NULL-buffer unmap

This commit is contained in:
lkn 2026-06-07 15:54:38 +02:00
parent 931094cce8
commit 1fce95d0cc
2 changed files with 13 additions and 4 deletions

View File

@ -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;

View File

@ -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);