From 7c9ed03c4235197cd38a760e7d207ff35ce517ca Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 18 Jun 2019 10:21:13 +1000 Subject: [PATCH] touchpad: add a helper function for counting touches for gestures Currently the same as tp_touch_active() but this will change. No functional changes. Extracted from Matt Mayfield's thumb detection patches. Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad-gestures.c | 6 +++--- src/evdev-mt-touchpad.c | 11 +++++++++++ src/evdev-mt-touchpad.h | 4 ++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/evdev-mt-touchpad-gestures.c b/src/evdev-mt-touchpad-gestures.c index 75a54f8..47e4ed8 100644 --- a/src/evdev-mt-touchpad-gestures.c +++ b/src/evdev-mt-touchpad-gestures.c @@ -55,7 +55,7 @@ tp_get_touches_delta(struct tp_dispatch *tp, bool average) for (i = 0; i < tp->num_slots; i++) { t = &tp->touches[i]; - if (!tp_touch_active(tp, t)) + if (!tp_touch_active_for_gesture(tp, t)) continue; nactive++; @@ -174,7 +174,7 @@ tp_gesture_get_active_touches(const struct tp_dispatch *tp, memset(touches, 0, count * sizeof(struct tp_touch *)); tp_for_each_touch(tp, t) { - if (tp_touch_active(tp, t)) { + if (tp_touch_active_for_gesture(tp, t)) { touches[n++] = t; if (n == count) return count; @@ -758,7 +758,7 @@ tp_gesture_handle_state(struct tp_dispatch *tp, uint64_t time) struct tp_touch *t; tp_for_each_touch(tp, t) { - if (tp_touch_active(tp, t)) + if (tp_touch_active_for_gesture(tp, t)) active_touches++; } diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index ca7e74f..51b7ef7 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -779,6 +779,17 @@ tp_touch_active(const struct tp_dispatch *tp, const struct tp_touch *t) tp_edge_scroll_touch_active(tp, t); } +bool +tp_touch_active_for_gesture(const struct tp_dispatch *tp, const struct tp_touch *t) +{ + return (t->state == TOUCH_BEGIN || t->state == TOUCH_UPDATE) && + t->palm.state == PALM_NONE && + !t->pinned.is_pinned && + !tp_thumb_ignored(tp, t) && + tp_button_touch_active(tp, t) && + tp_edge_scroll_touch_active(tp, t); +} + static inline bool tp_palm_was_in_side_edge(const struct tp_dispatch *tp, const struct tp_touch *t) { diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index aac47a7..9c2d1f4 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -569,6 +569,10 @@ tp_filter_motion_unaccelerated(struct tp_dispatch *tp, bool tp_touch_active(const struct tp_dispatch *tp, const struct tp_touch *t); +bool +tp_touch_active_for_gesture(const struct tp_dispatch *tp, + const struct tp_touch *t); + int tp_tap_handle_state(struct tp_dispatch *tp, uint64_t time); -- 2.7.4