Skip to content

Commit

Permalink
touchpad: revamp thumb detection
Browse files Browse the repository at this point in the history
Instead of a simple yes/no/maybe for thumbs, have a more extensive state
machine that keeps track of the thumb. Since we only support one thumb anyway,
the tracking moves to the tp_dispatch struct.

Test case changes:
touchpad_clickfinger_3fg_tool_position:
  with better thumb detection we can now handle this properly and expect a
  right button (2fg) press for the test case
touchpad_thumb_no_doublethumb_with_timeout:
  two thumbs are now always two fingers, so let's switch to axis events here

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
  • Loading branch information
mdmayfield authored and whot committed Jul 16, 2019
1 parent dda6f73 commit 4536b5b
Show file tree
Hide file tree
Showing 9 changed files with 294 additions and 285 deletions.
16 changes: 11 additions & 5 deletions src/evdev-mt-touchpad-gestures.c
Expand Up @@ -549,10 +549,16 @@ tp_gesture_handle_state_unknown(struct tp_dispatch *tp, uint64_t time)
return GESTURE_STATE_SCROLL;
}

/* If we get here, either both fingers have passed the inner
* threshold (handled below), or >2 fingers are involved
* (handled in a future event when both have moved enough).
/* If more than 2 fingers are involved, and the thumb moves
* while the fingers stay still, assume a pinch if eligible.
*/
if (finger_mm < inner &&
tp->gesture.finger_count > 2 &&
tp->gesture.enabled &&
tp->thumb.pinch_eligible) {
tp_gesture_init_pinch(tp);
return GESTURE_STATE_PINCH;
}
}

/* If either touch is still inside the inner threshold, we can't
Expand Down Expand Up @@ -711,8 +717,8 @@ tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time)
if (tp->gesture.finger_count == 0)
return;

/* When tap-and-dragging, or a clickpad is clicked force 1fg mode */
if (tp_tap_dragging(tp) || (tp->buttons.is_clickpad && tp->buttons.state)) {
/* When tap-and-dragging, force 1fg mode. */
if (tp_tap_dragging(tp)) {
tp_gesture_cancel(tp, time);
tp->gesture.finger_count = 1;
tp->gesture.finger_count_pending = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/evdev-mt-touchpad-tap.c
Expand Up @@ -1015,7 +1015,7 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time)
/* The simple version: if a touch is a thumb on
* begin we ignore it. All other thumb touches
* follow the normal tap state for now */
if (tp_thumb_ignored(tp, t)) {
if (tp_thumb_ignored_for_tap(tp, t)) {
t->tap.is_thumb = true;
continue;
}
Expand Down

0 comments on commit 4536b5b

Please sign in to comment.