diff options
author | novenary <streetwalkermc@gmail.com> | 2021-04-04 18:40:09 +0300 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2021-05-19 05:12:58 +0000 |
commit | ca3df8a076d54a93b3c2fb8a5eea4326d487050c (patch) | |
tree | bde6e10b0f0bda5585954b28b840e3ed6b4a4011 | |
parent | 939a022cbc8e5c17901646fc2c33b1d1f81e4d9d (diff) | |
download | libinput-ca3df8a076d54a93b3c2fb8a5eea4326d487050c.tar.gz |
Allow reviving a thumb that moves sufficiently
When pinching, the thumb tends to move slower than the finger, so we may
suppress it too early.
Add a grace period during which it may be revived.
Signed-off-by: novenary <streetwalkermc@gmail.com>
-rw-r--r-- | src/evdev-mt-touchpad-gestures.c | 23 | ||||
-rw-r--r-- | src/evdev-mt-touchpad-thumb.c | 16 | ||||
-rw-r--r-- | src/evdev-mt-touchpad.h | 3 |
3 files changed, 42 insertions, 0 deletions
diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c index 16841308..23259ee0 100644 --- a/src/evdev-mt-touchpad-gestures.c +++ b/src/evdev-mt-touchpad-gestures.c @@ -773,6 +773,22 @@ tp_gesture_post_gesture(struct tp_dispatch *tp, uint64_t time) gesture_state_to_str(tp->gesture.state)); } +static bool +tp_gesture_thumb_moved(struct tp_dispatch *tp) +{ + struct tp_touch *thumb; + struct phys_coords thumb_moved; + double thumb_mm; + + thumb = tp_thumb_get_touch(tp); + if (!thumb) + return false; + + thumb_moved = tp_gesture_mm_moved(tp, thumb); + thumb_mm = hypot(thumb_moved.x, thumb_moved.y); + return thumb_mm >= PINCH_DISAMBIGUATION_MOVE_THRESHOLD; +} + void tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time) { @@ -795,6 +811,13 @@ tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time) if (tp->gesture.finger_count_pending) return; + /* When pinching, the thumb tends to move slower than the finger, + * so we may suppress it too early. Give it some time to move. + */ + if (time < (tp->gesture.initial_time + DEFAULT_GESTURE_PINCH_TIMEOUT) && + tp_gesture_thumb_moved(tp)) + tp_thumb_reset(tp); + switch (tp->gesture.finger_count) { case 1: if (tp->queued & TOUCHPAD_EVENT_MOTION) diff --git a/src/evdev-mt-touchpad-thumb.c b/src/evdev-mt-touchpad-thumb.c index 17b324e2..ceb123ef 100644 --- a/src/evdev-mt-touchpad-thumb.c +++ b/src/evdev-mt-touchpad-thumb.c @@ -447,3 +447,19 @@ tp_init_thumb(struct tp_dispatch *tp) tp->thumb.use_pressure ? ", pressure" : "", tp->thumb.use_size ? ", size" : ""); } + +struct tp_touch* +tp_thumb_get_touch(struct tp_dispatch *tp) +{ + struct tp_touch *thumb; + + if (tp->thumb.index == UINT_MAX) + return NULL; + + tp_for_each_touch(tp, thumb) { + if (thumb->index == tp->thumb.index) + return thumb; + } + + return NULL; +} diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index abd05114..a6a04a9d 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -743,4 +743,7 @@ tp_thumb_update_multifinger(struct tp_dispatch *tp); void tp_init_thumb(struct tp_dispatch *tp); +struct tp_touch* +tp_thumb_get_touch(struct tp_dispatch *tp); + #endif |