From 874f9b1ae0199a3caded91a666efd2f76c5b2762 Mon Sep 17 00:00:00 2001 From: lkn Date: Sun, 7 Jun 2026 17:32:44 +0200 Subject: [PATCH] fix popup reopen: shrink view size on 1x1 unmap; fix cascade commit target Two concrete bugs fixed: 1. Popup reopen with 1x1 buffer: W_ResizeView returns early when view size matches requested size. After 1x1 unmap, view->size.width/height was still the original correct size, so resizeMenu never triggered wl_client_toplevel_resize. Fix: set view size to 1x1 after replacing the buffer. 2. Selected item not updating button display: render_wl_pixmap_copy cascade walks up to rootView (no WLClientToplevel) and commits it (no-op). After paintPopUpButton, the mainAppView backing is updated but never committed. Fix: when the cascade reaches rootView, fall back to committing the first topLevel child that has a client backing. --- .gitignore | 1 + WINGs/wclient_wl.c | 6 ++++++ WINGs/wrender_wl.c | 22 +++++++++++++++++++--- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 49f8337..51b1a52 100644 --- a/.gitignore +++ b/.gitignore @@ -97,3 +97,4 @@ src/wmaker-popup-v1-server-protocol.h # User scratch +cmd +/*Errors diff --git a/WINGs/wclient_wl.c b/WINGs/wclient_wl.c index 52fb8e4..3c75f8e 100644 --- a/WINGs/wclient_wl.c +++ b/WINGs/wclient_wl.c @@ -584,6 +584,12 @@ wl_client_view_unmap(WNativeWindow id) if (!top->buf) { top->buf = old; return; } if (old) wlclient_destroy_shm_buffer(old); W_SetViewBacking(top->view->window, top->buf->image); + /* Shrink the view size to 1x1 so W_ResizeView in resizeMenu detects + * a mismatch on reopen and actually resizes the buffer. Without this, + * W_ResizeView returns early (view already has the correct size from + * the first open) and wl_client_toplevel_resize is never called. */ + top->view->size.width = 1; + top->view->size.height = 1; wl_surface_attach(top->surface, top->buf->wl_buf, 0, 0); wl_surface_damage_buffer(top->surface, 0, 0, 1, 1); wl_surface_commit(top->surface); diff --git a/WINGs/wrender_wl.c b/WINGs/wrender_wl.c index a88d401..5b462a3 100644 --- a/WINGs/wrender_wl.c +++ b/WINGs/wrender_wl.c @@ -85,9 +85,25 @@ render_wl_pixmap_copy(void *rctx, WMDrawable src, WMDrawable dst, } view = view->parent; } - /* Commit the toplevel surface */ - if (view && !view->flags.alreadyDead && W_ViewCommitBackingFn) - W_ViewCommitBackingFn((unsigned long)view->window); + /* Commit the toplevel surface. If the cascade walked up to a + * root view that has no client backing, commit the nearest + * topLevel child instead. */ + if (view && !view->flags.alreadyDead && W_ViewCommitBackingFn) { + /* Check if the topmost parent is committable */ + if (view->flags.topLevel) { + W_ViewCommitBackingFn((unsigned long)view->window); + } else { + /* Walk down to find a topLevel child that has a backing */ + W_View *top = view->childrenList; + while (top) { + if (top->flags.topLevel && top->flags.realized) { + W_ViewCommitBackingFn((unsigned long)top->window); + break; + } + top = top->nextSister; + } + } + } } }