From 1221f991f37760cac99862999d286dc8e19f2f4b Mon Sep 17 00:00:00 2001 From: Ming-Yang Lu Date: Sun, 2 Jul 2017 18:07:20 +0800 Subject: [PATCH libinput 1/2] Add tp_palm_in_edge helper function. --- src/evdev-mt-touchpad.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 0a57b54b..47c39b3d 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -550,14 +550,20 @@ tp_touch_active(const struct tp_dispatch *tp, const struct tp_touch *t) tp_edge_scroll_touch_active(tp, t); } +static inline bool +tp_palm_in_edge(const struct tp_dispatch *tp, const struct tp_touch *t) +{ + return t->point.x > tp->palm.left_edge && + t->point.x < tp->palm.right_edge; +} + bool tp_palm_tap_is_palm(const struct tp_dispatch *tp, const struct tp_touch *t) { if (t->state != TOUCH_BEGIN) return false; - if (t->point.x > tp->palm.left_edge && - t->point.x < tp->palm.right_edge) + if (tp_palm_in_edge(tp, t)) return false; evdev_log_debug(tp->device, "palm: palm-tap detected\n"); @@ -658,8 +664,7 @@ tp_palm_detect_move_out_of_edge(struct tp_dispatch *tp, struct device_float_coords delta; int dirs; - if (time < t->palm.time + PALM_TIMEOUT && - (t->point.x > tp->palm.left_edge && t->point.x < tp->palm.right_edge)) { + if (time < t->palm.time + PALM_TIMEOUT && tp_palm_in_edge(tp, t)) { delta = device_delta(t->point, t->palm.first); dirs = phys_get_direction(tp_phys_delta(tp, delta)); if ((dirs & DIRECTIONS) && !(dirs & ~DIRECTIONS)) @@ -725,8 +730,7 @@ tp_palm_detect_edge(struct tp_dispatch *tp, /* palm must start in exclusion zone, it's ok to move into the zone without being a palm */ - if (t->state != TOUCH_BEGIN || - (t->point.x > tp->palm.left_edge && t->point.x < tp->palm.right_edge)) + if (t->state != TOUCH_BEGIN || tp_palm_in_edge(tp, t)) return false; /* don't detect palm in software button areas, it's -- 2.13.2