Immediate dismissal of a grabbing popup breaks input processing
Steps to reproduce
- Use Mutter, Weston, or Niri. (Other compositors I'm aware of don't validate popup grab serials and therefore don't dismiss the popup.)
- Open a program which opens a grabbing popup in response to a button press (tested with gtk4-demo-application).
- Hover the cursor over the element which opens the popup (e.g. a menu bar item).
- Press the right mouse button.
- Press the left mouse button. This should open the popup, but compositors
listed expect the
xdg_popup.grab
serial to match that one of the right mouse button press event, so the popup is dismissed. - Release both mouse buttons.
Current behavior
Despite the popup being dismissed, the program behaves as if the popup grab is active: keyboard focus is ignored and pointer button events aren't processed.
Expected outcome
Input events are processed correctly.
Version information
- GTK version: commit f05eac61
- Mutter version: 46.6
- Weston version: commit 10ecf6084885acaf0b07ca69987f0110759677c5
- Niri version: commit 1a0612cbfd0abee0796efa86470226686ae78f21
Additional information
Relevant parts of a Wayland client log:
$ WAYLAND_DISPLAY=wayland-0 WAYLAND_DEBUG=1 build/demos/gtk-demo/gtk4-demo-application 2>&1 | rg '(xdg_popup|button)'
[ 363021.874] {Default Queue} wl_pointer#25.button(5, 182185182, 273, 1)
[ 363268.463] {Default Queue} wl_pointer#25.button(6, 182185429, 272, 1)
[ 363276.785] -> xdg_surface#134.get_popup(new id xdg_popup#135, xdg_surface#69, xdg_positioner#133)
[ 363276.808] -> xdg_popup#135.grab(wl_seat#31, 6)
[ 363280.859] xdg_popup#135.popup_done()
[ 363284.067] -> xdg_popup#135.destroy()
[ 363286.191] -> xdg_surface#125.get_popup(new id xdg_popup#121, xdg_surface#69, xdg_positioner#129)
[ 363286.214] -> xdg_popup#121.grab(wl_seat#31, 6)
[ 363289.335] xdg_popup#121.popup_done()
[ 363290.398] -> xdg_popup#121.destroy()
[ 363392.306] {Default Queue} wl_pointer#25.button(7, 182185553, 272, 0)
[ 363848.344] {Default Queue} wl_pointer#25.button(8, 182186009, 273, 0)
For some reason, the program tries to open a popup twice.