[Wayland][GTK3] Context menus get closed by ongoing touch input if the compositor doesn't cancel it on popup grab
In GTK3, context menus on Wayland are implemented as xdg-popups and can usually be triggered via touch input by a long press.
In Mutter, this appears to work well. However, Mutter is the only compositor where it works well.
The reason is that Mutter sends a wl_touch.cancel
event on the touch point that initiates the menu as soon as the popup takes a grab. Other compositors (tested with Weston, KWin, phoc and sway) don't do that and I haven't found anything in the protocol that would suggest that this is the required behavior (in fact, it could be argued that Mutter breaks the protocol, since xdg-shell specifies that "During a popup grab, the client owning the grab will receive pointer and touch events for all their surfaces as normal"). Since on those compositors the touch point isn't canceled right away, GTK receives further motion events that belong to the parent surface which makes GTK close the popup on finger release.
GTK shouldn't expect the initiating touch point to get canceled right away, so it shouldn't dismiss the popup on parent's touch input that was active before the popup has been opened.
Tested with GTK 3.24.34.