mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-05 16:58:04 +02:00
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>
This commit is contained in:
parent
939a022cbc
commit
ca3df8a076
3 changed files with 42 additions and 0 deletions
|
|
@ -773,6 +773,22 @@ tp_gesture_post_gesture(struct tp_dispatch *tp, uint64_t time)
|
||||||
gesture_state_to_str(tp->gesture.state));
|
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
|
void
|
||||||
tp_gesture_post_events(struct tp_dispatch *tp, uint64_t time)
|
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)
|
if (tp->gesture.finger_count_pending)
|
||||||
return;
|
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) {
|
switch (tp->gesture.finger_count) {
|
||||||
case 1:
|
case 1:
|
||||||
if (tp->queued & TOUCHPAD_EVENT_MOTION)
|
if (tp->queued & TOUCHPAD_EVENT_MOTION)
|
||||||
|
|
|
||||||
|
|
@ -447,3 +447,19 @@ tp_init_thumb(struct tp_dispatch *tp)
|
||||||
tp->thumb.use_pressure ? ", pressure" : "",
|
tp->thumb.use_pressure ? ", pressure" : "",
|
||||||
tp->thumb.use_size ? ", size" : "");
|
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;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -743,4 +743,7 @@ tp_thumb_update_multifinger(struct tp_dispatch *tp);
|
||||||
void
|
void
|
||||||
tp_init_thumb(struct tp_dispatch *tp);
|
tp_init_thumb(struct tp_dispatch *tp);
|
||||||
|
|
||||||
|
struct tp_touch*
|
||||||
|
tp_thumb_get_touch(struct tp_dispatch *tp);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue