Skip to content

Implement tap-and-drag for two-finger and three-finger taps

satrmb requested to merge satrmb/libinput:multifinger-tapndrag into master

Closes #1 (closed)

After using a hackier variant of this implementation for a few years as part of my custom libinput build, I finally got around to cleaning it up enough to feel like I have a chance at getting this accepted. Compared to the two competing merge requests !86 (closed) and !436 (closed) (their implementations are quite similar to each other, actually) this one comes with three-finger tap-and-drag for free (the others only offer two-finger), and I've tried to reduce the additional maintenance burden by avoiding code duplication as much as possible. Overview of the changes:

  • Tap states TAPPED, DRAGGING, DRAGGING_WAIT, DRAGGING_OR_TAP, DRAGGING_OR_DOUBLETAP and DRAGGING_2 have all been split into three variants (prefixed 1FGTAP_, 2FGTAP_, and 3FGTAP_, should be self-explanatory) which share 100% of their code.
    • The functions dealing with these states now take an additional parameter (a number representing the tap's finger count), which is used in tp_tap_notify calls, and is also used to determine the precise target state (i.e. retaining finger count) in almost all transitions between these states. The exception is the transition from DRAGGING_OR_DOUBLETAP to TAPPED via a RELEASE event, because in that case a new one-finger tap-and-drag starts, regardless of how many fingers were used in the tap before that.
  • There are two new states to track the release of fingers in a three-finger tap. Previously three-finger taps emitted a (middle or right, depending on configuration) click on the release of the first finger, whereas two-finger taps required both fingers to be lifted (by going through the additional TOUCH_2_RELEASE state). Now three-finger taps work just like two-finger taps. One of the new states (TOUCH_3_RELEASE_2) shares its code with TOUCH_2_RELEASE in the same manner as the TAPPED and DRAGGING* states, the other one (TOUCH_3_RELEASE) is all-new.

Todo (and reasons why this is marked as WIP):

  • Tests. I have next to no experience with libinput's test suite, so I haven't done anything in that department for this MR. !436 (closed) has tests though, so combining this implementation with those tests (expanded to also cover three-finger taps, of course) might be an option.
  • The state machine diagram. I've modified that one before, so I know how to do it, but I'm not sure what's the best way to represent the trios of almost-identical states ... just duplicate them? Use human-comprehensible wildcards like the "any finger" + "that finger" labels that are already in there (and if so, what should they look like)?
Edited by Peter Hutterer

Merge request reports