diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2016-06-15 09:07:48 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2016-06-15 10:23:18 +1000 |
commit | 4bb0adfc1cf756196095eb6049e8dbc839c9acb9 (patch) | |
tree | 95f792f1e26f481151efe4ff61799760aa30a278 /src | |
parent | 92b21247f434037202e9ebb4355f08775d007ae2 (diff) |
touchpad: split palm movement detection into a helper function
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/evdev-mt-touchpad.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index d01461c5..8c6b3964 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -631,14 +631,31 @@ tp_palm_detect_trackpoint(struct tp_dispatch *tp, return 0; } -static void -tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) +static inline bool +tp_palm_detect_move_out_of_edge(struct tp_dispatch *tp, + struct tp_touch *t, + uint64_t time) { const int PALM_TIMEOUT = ms2us(200); const int DIRECTIONS = NE|E|SE|SW|W|NW; 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)) { + delta = device_delta(t->point, t->palm.first); + dirs = normalized_get_direction(tp_normalize_delta(tp, delta)); + if ((dirs & DIRECTIONS) && !(dirs & ~DIRECTIONS)) + return true; + } + + return false; +} + +static void +tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) +{ + if (tp_palm_detect_dwt(tp, t, time)) goto out; @@ -650,16 +667,10 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) the direction is within 45 degrees of the horizontal. */ if (t->palm.state == PALM_EDGE) { - if (time < t->palm.time + PALM_TIMEOUT && - (t->point.x > tp->palm.left_edge && t->point.x < tp->palm.right_edge)) { - delta = device_delta(t->point, t->palm.first); - dirs = normalized_get_direction( - tp_normalize_delta(tp, delta)); - if ((dirs & DIRECTIONS) && !(dirs & ~DIRECTIONS)) { - t->palm.state = PALM_NONE; - log_debug(tp_libinput_context(tp), - "palm: touch released, out of edge zone\n"); - } + if (tp_palm_detect_move_out_of_edge(tp, t, time)) { + t->palm.state = PALM_NONE; + log_debug(tp_libinput_context(tp), + "palm: touch released, out of edge zone\n"); } return; } |