Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add implicit pointer grabs in Wayland. (#4540)
* Add implicit pointer grabs in Wayland. A Wayland client expects to receive pointer motion events from the time a button is pressed until it is released, even if the pointer leaves the client's surface while the button is held. This is crucial for scrollbar functionality: a scrollbar should continue to drag even if the pointer leaves the window. This does not currently work in qtile. For instance, in Chrome, if you drag the scrollbar, move the mouse off the Chrome window, release the button, then move the pointer back onto the Chrome window, Chrome will resume scrolling without any button press. In X11, this functionality is implemented on the client side using XGrabPointer or XIGrabDevice. Wayland provides no such mechanism: this behavior must be implemented in the compositor. This does not seem to be well documented. However, if you look in gdk_wayland_device_grab in the gtk source, you'll see that grabbing the pointer in GDK is basically a no-op: it does some internal accounting and changes the cursor, then simply assumes the pointer is already grabbed. Implicit grabs are implemented in Sway (see sway/sway/input/seatop_{default,down}.c), although that's not what they're called. In short, pressing a button on a client surface switches the cursor handling code into "down" mode, which short-cuts most of the WM pointer processing logic and sends events directly to the client, until the button is released. (This is part of a more general mechanism in Sway: pointer events can be processed in several modes, e.g. for moving floating windows.) This commit implements basic implicit grabs in qtile Wayland, following what Sway does (functionally, not structurally). Pressing a button creates an ImplicitGrab object in the Core; releasing the button destroys it. While the ImplicitGrab object is alive, all pointer events (button, {absolute_,}motion, axis) are sent directly to wlroots, bypassing qtile's event processing. This seems to produce the desired UI behavior. Implicit grabs should also be implemented for touch and tablet tool events, if and when those are added to qtile. * Fix implicit pointer grab in Wayland. Move grab initation until *after* giving qtile a chance to process the button event. * Tweaked implicit pointer grabs in Wayland. --------- Co-authored-by: Joe Rabinoff <rabinoff@post.harvard.edu>
- Loading branch information