grab mouse wheel with XI2
Jonathan Michalon
johndescs at gmail.com
Sat Nov 2 18:23:18 UTC 2019
Hi,
Using compiz it is possible to assign shortcuts to various actions.
When such a shortcut is activated, it has to be blocked and not
dispatched to the underlying applications. This works well for keyboard
and button 1 to 3 with grabs. But for mouse wheel (button 4,5) it seems
to have no effect.
We think to have found the issue: with XI2, scroll is now reported as a
special kind of motion, and only emulated as button clicks for legacy
clients. This means that the XGrabButton() call will not prevent
XI2-aware clients from receiving scroll events. We need to somehow grab
XI_Motion events associated with scrolling.
Example in GTK3 for the code in GTK3 generating "smooth scroll" events:
https://gitlab.gnome.org/GNOME/gtk/blob/gtk-3-24/gdk/x11/gdkdevicemanager-xi2.c#L1727
I'm not yet sure how to grab those, but I'm leaning towards
XIGrabDevice(), although it seems a little too aggressive on some
aspects, for example we do not want to block completely the desktop if
something goes wrong in compiz itself and pointer is grabbed.
Is this the only way to go? Is there some better way? No X.org guru on
our side so maybe we miss something obvious… better ask here for
some informations before doing this badly.
(BTW I'm no compiz dev, but willing to submit a patch there and also
I'm not subscribed to the list.)
Thanks in advance!
--
Jonathan Michalon
More information about the xorg
mailing list