gtk: Fix grabbing a random widget when closing popup
Together the two commits address the issue of grabbing a random widget when closing a popup with a touchpad (or with very fast and awkward mouse clicks too).
Notice how the "new tab" button in the top-left randomly gets a grab, and doesn't release it until my cursor moves outside the window.
The input sequence to reproduce the bug is as written in the first commit message:
- Tap with two fingers to open a context menu
- Quickly release both fingers, then hold one finger down
- libinput will process this as holding down the right click
- Hover an action that would close the popup
- With the same finger, push down the touchpad to click
- this will trigger a
- release right-click (invokes the action, closes the popup)
- press left-click (takes a grab on a random widget -- fixed by commit 1)
- wl_pointer::leave (leaving the popup surface)
- wl_pointer::enter (entering the main window again, resets modifiers)
- release right-click (does not release the grab because there were no modifiers -- fixed by commit 2)
- this will trigger a
Edited by Alessandro Astone