From 79a79b345009951ef80cc85082dab809c8d1d9ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= Date: Sat, 2 Mar 2024 00:39:56 +0100 Subject: [PATCH] wayland/popup: Only close popups if press count drops from 1 to 0 We close wayland popups when a button or touch release happens outside of the grab, except we don't want to close them when that button release is actually the release of the press that was opening the grab in the first place. We never see the press event that opened the grab, so the first event we see is actually always a release. Make sure to not close the popup on that event, and instead only close the popup if we see the press count drop from 1 to 0. This fixes a bug where popup would close right after they open. To reproduce, click to open a popup, hold pressed and move the cursor over shell chrome, then release. Or alternatively test with a popup that gets opened with a long-press gesture (eg. long touch long press on libadwaita tabs), just doing the touch long-press and then release. Part-of: --- src/wayland/meta-wayland-popup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/wayland/meta-wayland-popup.c b/src/wayland/meta-wayland-popup.c index 91f9248e0..ffb5b107c 100644 --- a/src/wayland/meta-wayland-popup.c +++ b/src/wayland/meta-wayland-popup.c @@ -160,10 +160,13 @@ popup_grab_release (MetaWaylandEventHandler *handler, MetaWaylandPopupGrab *popup_grab = user_data; ClutterInputDevice *device = clutter_event_get_source_device (event); ClutterEventSequence *sequence = clutter_event_get_event_sequence (event); + gboolean close_popup; + + close_popup = popup_grab->press_count == 1; popup_grab->press_count = MAX (0, popup_grab->press_count - 1); - if (popup_grab->press_count == 0) + if (close_popup) { MetaWaylandSurface *surface;