by ComputerGuru · 4y ago · 0 comments
https://neosmart.net/blog/2020/multi-touch-gestures-on-linux...
https://github.com/mqudsi/syngesture
The biggest benefit is that you can use drivers with actually correct acceleration curves like xf86-input-synaptics (if you’re on X11) instead of the offensively bad, NIH reimplementation that ships with libinput.
Oh wait, I’m on HN so I shouldn’t neglect to mention my project is written in rust!
Thanks for that, it gave me a chuckle.
Thank you!
Can you please elaborate?
The libinput dev's response was a combination of incredulity that someone wouldn't have physical buttons (in like 2014) and a statement that the project would never add this feature. I haven't gone back to Wayland since.
https://www.youtube.com/watch?v=HllUoT_WE7Y
libinput is yet another of those fundamental libraries that receive almost no developer attention, but get all the blame when something goes wrong: https://xkcd.com/2347/
You can do this with libinput and Wayland.
In libinput the edge scrolling is hard coded to 7mm and previous attempts at making it configurable were rejected.
The linked project is only the userland daemon that uses the raw Linux Multitouch Protocol events to interpret gestures; to get the acceleration curves working again I recommend using this in conjunction with xf86-input-synaptics as your actual input driver (which provides the correct acceleration curves for compatible hardware - basically all touchpads since they all cloned synaptics’ hardware once upon a time - but doesn’t by itself have gesture support).
Side note: Syngesture (this project) isn’t dependent on X11 or Wayland, but I don’t know if anyone has ported or will port xf86-input-synaptics to Wayland, which is/was pretty much developed along the same lines as libinput: rewrite everything from scratch without taking into account that some things you’re throwing out actually work really well (regardless of the fact that they are built for X11 or not), get rid of all abstractions that made it possible to plug in better components/replacements at various points in the stack, and without a concern for actual feature parity for what they are purportedly replacing.
This is not what happened. The synaptics driver and libinput were/are maintained by the same person, who has written about it extensively and explained why the approach in the synaptics driver does not work well. Specifically, some of the problems with the synaptics driver have directly led to decisions in libinput. You may want to read some of their blog posts if you haven't:
https://who-t.blogspot.com/2016/12/xf86-input-synaptics-is-n...
https://who-t.blogspot.com/2016/04/why-libinput-doesnt-have-...
https://who-t.blogspot.com/2016/03/why-libinput-does-not-hav...
It may seem like a good idea on its surface to have tons of abstractions and features and extension mechanisms, but that fades away when you get deal with the bug reports over a period of years and get to see all the problems it causes.
That’s a very good question as I didn’t consider stateful gestures (where state doesn’t reset when all fingers are removed). It can be shimmed (without touching the code) in the configuration file by replacing the invocation of xdotool (or whatever) with a wrapper script that provides state enabling a “toggle mousedown” rather than just explicit, separate mouseup and mousedown events but I wonder if there’s a clean way to model that into the event loop as serialized to/from the configuration file directly. Feel free to open a GitHub issue if you like.
Not quite.. on macOS, you can enable three-finger drag which means that when you touch down with 3 fingers and drag them on the trackpad, it's the equivalent of clicking-and-dragging with a mouse.
There's no laborious use three fingers then one then three again. Just like swiping with 2 fingers does scrolling, using 3 fingers just grabs whatever's under the cursor and moves it (whether that's a window, or starts selecting text, moves a scrollbar, anything).
In all cases, that is easier to implement in code than a stateful transition like I described since there is no state persisting beyond the gesture itself, it just needs gesture_start and gesture_end support (with the difficulty being in determine if a three-finger gesture has started or if it’s actually a three-finger gesture on its way into becoming a four-finger gesture).
To abstract it a bit: You would need to
1. Trigger an event on the gesture start (detect 3 fingers -> hold alt, mousedown)
2. Have mouse movement enabled
3. Trigger another event on gesture end (lift fingers -> mouseup, lift alt).
https://gitlab.freedesktop.org/xorg/proto/xorgproto/-/merge_...
I just checked, and libinput does have the correct "flat" acceleration curve as an option, so I think we're good. ;-)
https://wayland.freedesktop.org/libinput/doc/latest/pointer-...
Being more serious, that document has a bunch of graphs of libinput's acceleration curves for different devices. I'd love to see a write-up of the curves you've implemented and why they're superior in your opinion.