diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2019-06-18 10:21:13 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2019-07-15 13:08:47 +1000 |
commit | 7c9ed03c4235197cd38a760e7d207ff35ce517ca (patch) | |
tree | 524d0250485f48831503507172b15e143d27eaa1 /src | |
parent | 6e27a100b58588e3fc58ae8f6594eb4a1487d867 (diff) |
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 <peter.hutterer@who-t.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/evdev-mt-touchpad-gestures.c | 6 | ||||
-rw-r--r-- | src/evdev-mt-touchpad.c | 11 | ||||
-rw-r--r-- | 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 75a54f88..47e4ed85 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 ca7e74fb..51b7ef71 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 aac47a78..9c2d1f44 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); |