Skip to content

wayland/popup: Don't take the opening press's release as a click on the menu - #906

Open
SyberHexen wants to merge 1 commit into
linuxmint:masterfrom
SyberHexen:6.8.6/popup-release-guard
Open

SyberHexen wants to merge 1 commit into
linuxmint:masterfrom
SyberHexen:6.8.6/popup-release-guard

Conversation

@SyberHexen

Copy link
Copy Markdown

Bug: clients anchor a context menu at the pointer, so its xdg_popup can map under the pointer while the button that opened it is still held. The repick then gives the popup pointer focus, the client gets the button release over the menu, and GTK closes it: right-click menus of Wayland apps vanish as soon as the button is let go, now and then.

Reproduce: Cinnamon Wayland session, GNOME System Monitor (GTK 4), right-click processes. With the default Adwaita theme the menu opens 0.1–1 px below the pointer, so moving the pointer down by a pixel while the button is still held (easy with a high-resolution mouse) puts it on the menu, and the release closes the menu. With some themes the app's anchor lands a couple of pixels above the pointer (measured: anchor 55,163 for a pointer at 57.4,165.2), so the menu maps under a pointer that doesn't move and every few right-clicks close it. WAYLAND_DEBUG=client then shows wl_pointer.enter on the popup surface right after it maps, the release, and the client destroying the popup (no popup_done from the compositor).

Fix: while the press that started a popup grab is held, a popup surface under the pointer doesn't get pointer focus; focus stays where the press was, which gets the release. Releasing the button ends this, and so does holding it for 300 ms and dragging more than 4 px, so press-drag-release onto an item still picks it (GTK 3 menus tell a click from a drag by time the same way).

Tested: GNOME System Monitor with the theme where the anchor is off: from about 1 in 5 right-clicks closing to none; press-drag-release onto an item still activates it; menus opened from the keyboard are unaffected. With Adwaita, measured over 15 right-clicks: the menu's top edge is 0.1–1.0 px below the pointer, i.e. one pixel of downward movement during the click reaches it.

…he menu

Clients anchor a context menu at the pointer, so its popup can map under
the pointer while the button that opened it is still held (GNOME System
Monitor's anchor is a couple of pixels off). The repick then gives the
popup pointer focus, the client sees the button's release over the menu,
and GTK closes it again: right-click menus vanish as soon as the button
is let go, now and then.

While the press that started a popup grab is held, a popup surface under
the pointer doesn't get pointer focus; the focus stays where the press
was, which gets the release. Releasing the button ends this, and so does
holding it for 300 ms and dragging more than a few pixels from the press,
so dragging onto an item and releasing still picks it, while the hand's
usual wobble during a click doesn't count (GTK 3 menus tell a click from
a press-drag-release by time the same way).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant