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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3631>
This commit is contained in:
Jonas Dreßler 2024-03-02 00:39:56 +01:00 committed by Marge Bot
parent 6b3a289ab5
commit 79a79b3450

View File

@ -160,10 +160,13 @@ popup_grab_release (MetaWaylandEventHandler *handler,
MetaWaylandPopupGrab *popup_grab = user_data; MetaWaylandPopupGrab *popup_grab = user_data;
ClutterInputDevice *device = clutter_event_get_source_device (event); ClutterInputDevice *device = clutter_event_get_source_device (event);
ClutterEventSequence *sequence = clutter_event_get_event_sequence (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); popup_grab->press_count = MAX (0, popup_grab->press_count - 1);
if (popup_grab->press_count == 0) if (close_popup)
{ {
MetaWaylandSurface *surface; MetaWaylandSurface *surface;