grab mouse wheel with XI2
peter.hutterer at who-t.net
Mon Nov 11 00:53:40 UTC 2019
On Fri, Nov 08, 2019 at 10:39:27AM +0100, Jonathan Michalon wrote:
> Thanks for your answer.
> Le Thu, 7 Nov 2019 09:52:48 +1000,
> Peter Hutterer <peter.hutterer at who-t.net> a écrit :
> > Unfortunately that is your only option, not being able to grab the
> > mouse wheel events was an unfortunate and unintended side-effect of
> > the smooth scrolling.
> Is there maybe some way then to disable smooth scrolling? I checked
> with runtime tools like libinput or xinput but didn't manage to do it.
> Also I tried to switch to evdev for the sake of completeness and be
> sure that indeed libinput was the emitter but same issue.
there isn't a toggle. the big difference with smooth scrolling is that
drivers now  denote some axes as being the scroll axes. on those axes the
drivers just submit the motion events to the server and the legacy scroll
button emulation is handled by the server. which means that the drivers are
basically unaware of the button emulation even happening.
 where the value of "now" is of course "for the last decade or so" :)
> Because I see several drawbacks to permanently actively grab the
> - Seems we have to follow the actual devices we want to grab as
> "The fake deviceids of XIAllDevices or XIAllMasterDevices will
> result in a BadDevice error." (your blog post XI2 recipes, Part 5).
> - It seems we have to re-grab each time a popup or dropdown etc. is
> open which is painful (but logical).
> - I didn't manage for now to deal with XIAllowEvents (but that's
> probably due to my low knownledge of X.org stuff).
it's a bit worse than the above. tracking devices is relatively trivial, the
real killer is that any active grab disallows event replay on the next
client. So while you're grabbing the device no-one else can receive events
from that device and you're effectively making this device useless. You'd
have to do some magic with raw events to even guess when to grab the device
- something like "whenever a raw event comes in from device D with scroll
data grab it until the first non-scroll event". That this is racy is
Since you can't passive grab on specific axis, the window-manager-like sync
grab is out. So basically - I don't see any options here.
> Looks like it's sad to trigger events and then workaround to kill them.
> Maybe worth adding an option somewhere? If this is possible at all I
> could manage to provide a patch somehow…
There may be a use-case for grabbing specific axis events, but the
devil's in the detail and this is a massive amount of work. So "a patch
somehow" is more likely 6 man-months of full-time work. I would recommend
More information about the xorg