From 3ccf87ff4fd57e03cbad1575b740045095269153 Mon Sep 17 00:00:00 2001 From: lkn Date: Sun, 7 Jun 2026 12:47:24 +0200 Subject: [PATCH] popup: fix click selection and blank second-open Bug 1: Clicks on menu items did not select the correct item. The WME_BUTTON_PRESS handler always called popUpMenu() which re-mapped the already-open menu and reset highlightedItem to selectedItemIndex, ignoring the click position. Since no motion event follows a click-without-drag, the highlight was never corrected. Fix: distinguish menuView vs main button events via event->window. For menuView clicks, compute highlightedItem from click.y directly without re-opening the menu. Bug 2: Second popup open showed a blank gray box. wl_unmap disabled the compositor scene node via W_ViewSceneNodeSetEnabledFn but wl_map never re-enabled it. On re-map, the buffer was committed to the wl_surface but the scene node stayed disabled. Fix: re-enable scene node in wl_map before redisplay. --- WINGs/wpopupbutton.c | 17 ++++++++++++----- WINGs/wview_wl.c | 4 ++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/WINGs/wpopupbutton.c b/WINGs/wpopupbutton.c index 0be4fa4..06f0841 100644 --- a/WINGs/wpopupbutton.c +++ b/WINGs/wpopupbutton.c @@ -655,13 +655,20 @@ static void handleActionEvents(WMEvent * event, void *data) } break; } - popUpMenu(bPtr); - if (!bPtr->flags.pullsDown) { - bPtr->highlightedItem = bPtr->selectedItemIndex; + /* Button press on the menu view: select item under pointer. + * Button press on the main button view: open the menu. */ + if (event->window == bPtr->menuView->window) { + bPtr->highlightedItem = event->u.button.y / bPtr->view->size.height; bPtr->flags.insideMenu = 1; } else { - bPtr->highlightedItem = -1; - bPtr->flags.insideMenu = 0; + popUpMenu(bPtr); + if (!bPtr->flags.pullsDown) { + bPtr->highlightedItem = bPtr->selectedItemIndex; + bPtr->flags.insideMenu = 1; + } else { + bPtr->highlightedItem = -1; + bPtr->flags.insideMenu = 0; + } } bPtr->view->screen->viewBackend->pointer_grab( bPtr->view->screen->viewBackendCtx, bPtr->menuView, False, WM_CURRENT_TIME); diff --git a/WINGs/wview_wl.c b/WINGs/wview_wl.c index 705564e..2881f07 100644 --- a/WINGs/wview_wl.c +++ b/WINGs/wview_wl.c @@ -305,6 +305,10 @@ static void wl_map(void *vctx, W_View *view) child = child->nextSister; } } + /* Re-enable scene node after unmap so the surface becomes visible again. */ + if (W_ViewSceneNodeSetEnabledFn) + W_ViewSceneNodeSetEnabledFn((unsigned long)view->window, 1); + if (view->flags.topLevel) { wl_redisplay(vctx, view); return;