From 2c3a1764a434e842133677f765383b7d984bd1c2 Mon Sep 17 00:00:00 2001 From: lkn Date: Sun, 7 Jun 2026 11:32:23 +0200 Subject: [PATCH] popUpMenu: map before render, use makeMenuPixmap for robust initial content MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reorder popUpMenu to: 1. Resize menuView before map (correct backing dimensions) 2. W_MapView first (wl_map calls wl_redisplay which fills background and dispatches WME_EXPOSE — the old redisplay() before map was a no-op on Wayland because wl_redisplay returns early when !mapped) 3. Copy makeMenuPixmap() output into menuView->window backing as a safety net, ensuring the buffer has complete menu content independent of expose-timing correctness 4. paintMenuEntry for initial highlighted item This ensures the first visible popup buffer has all menu items rendered regardless of the order in which the Wayland configure and commit events arrive. --- WINGs/wpopupbutton.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/WINGs/wpopupbutton.c b/WINGs/wpopupbutton.c index 4899230..0be4fa4 100644 --- a/WINGs/wpopupbutton.c +++ b/WINGs/wpopupbutton.c @@ -455,13 +455,33 @@ static void popUpMenu(PopUpButton * bPtr) } W_MoveView(bPtr->menuView, x, y); - scr->viewBackend->redisplay(scr->viewBackendCtx, bPtr->menuView); - + /* Resize before map so the backing has the correct dimensions + * before any rendering or commit happens. */ if (W_VIEW_WIDTH(bPtr->menuView) != W_VIEW_WIDTH(bPtr->view)) resizeMenu(bPtr); + /* Map first — wl_map calls wl_redisplay internally, which fills + * the background and dispatches WME_EXPOSE to paint all entries. + * The old code called redisplay() here BEFORE the map, which was + * a no-op on Wayland (wl_redisplay returns early when !mapped). */ W_MapView(bPtr->menuView); + /* Pre-render the full menu into the backing as a safety net, + * independent of expose-timing. makeMenuPixmap draws every item + * with relief, text, indicator, and disabled shading. */ + { + WMNativePixmap pm = makeMenuPixmap(bPtr); + if (pm) { + const W_RenderBackend *R = scr->renderBackend; + void *rctx = scr->renderBackendCtx; + int total_h = WMGetArrayItemCount(bPtr->items) + * bPtr->view->size.height; + R->pixmap_copy(rctx, pm, (WMDrawable)bPtr->menuView->window, + 0, 0, bPtr->view->size.width, total_h, 0, 0); + R->pixmap_free(rctx, pm); + } + } + bPtr->highlightedItem = 0; if (!bPtr->flags.pullsDown && bPtr->selectedItemIndex < 0) paintMenuEntry(bPtr, bPtr->selectedItemIndex, True);