Skip to content

Add hold gesture implementation

Merge request to implement the new hold gesture described in !293 (closed) and fix #300 (closed) at least at the libinput level.

Hold gestures are notifications about fingers on the touchpad. As touchpad touches are generally fully abstracted, a client cannot currently know when a user is interacting with the touchpad without moving.

Hold gestures are primarily designed for two interactions:

  • hold-to-interact: where a hold gesture is active for some time a menu could pop up, or some object is selected, etc.
  • hold-to-cancel: where e.g. kinetic scrolling is currently active, the start of a hold gesture can be used to stop the scroll

Since hold gestures by definition do not have movement, there is no need for an "update" stage in the gesture.

Status:

Implementation explanation:

Hold gestures are a little bit special because they are the only gestures that don't require motion to be triggered. That's why you will notice that I had the make a couple of small changes in src/evdev-mt-touchpad.c - tp_post_events and add tp->gesture.filter_motion.

In the next layer, the gesture state machine, I integrated pointer motion as an extra state and moved the motion based gesture recognition (swipe, pinch, scroll and pointer motion) to a common place, emitting gesture_event events when they are recogniced.

Next, I added the hold gesture state, that can be triggered following 2 paths:

  • If tap is not enabled, hold is triggered after DEFAULT_GESTURE_HOLD_TIMEOUT if no motion or gesture is detected
  • If tap is enabled, hold is synchronised with the tap state machine and triggered on TAP_STATE_HOLD, TAP_STATE_TOUCH_2_HOLD or TAP_STATE_TOUCH_3_HOLD

I decided to not change how LIBINPUT_DEVICE_CAP_GESTURE works, even though it is technically possible to add some level of support to devices with !tp->gesture.enabled.

I think that the diff is big and complex enough at this point and I'd rather prefer to improve support in a follow up MR once this get's implemented by clients, we see that hold gestures are useful and/or someone request support.

Edited by José Expósito

Merge request reports

Loading