summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-07-14 16:38:46 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-07-21 08:56:12 +1000
commitb3c578521e7b53bb9fd0516344d9c24b24e519a1 (patch)
tree645f1586d9719e2560727571fc8ac3646743b97a
parent9ecce8e2f73e9115f680755745d9c0d8c4e50a00 (diff)
downloadlibinput-b3c578521e7b53bb9fd0516344d9c24b24e519a1.tar.gz
touchpad: require a <45 degree movement for a palm to become a touch
Any legitimate finger movement that starts in the palm area is expected to move out of the palm area at an angle roughly orthogonal to the edge of the touchpad. Check for the direction of the movement vector, and if it is within the accepted cardinal/ordinal directions then proceed. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--src/evdev-mt-touchpad.c13
-rw-r--r--src/evdev-mt-touchpad.h1
-rw-r--r--test/touchpad.c15
3 files changed, 26 insertions, 3 deletions
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 830e9fee..2cf8b567 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -363,15 +363,20 @@ static void
tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
{
const int PALM_TIMEOUT = 200; /* ms */
+ const int DIRECTIONS = NE|E|SE|SW|W|NW;
/* If labelled a touch as palm, we unlabel as palm when
- we move out of the palm edge zone within the timeout.
+ we move out of the palm edge zone within the timeout, provided
+ the direction is within 45 degrees of the horizontal.
*/
if (t->palm.is_palm) {
if (time < t->palm.time + PALM_TIMEOUT &&
(t->x > tp->palm.left_edge && t->x < tp->palm.right_edge)) {
- t->palm.is_palm = false;
- tp_set_pointer(tp, t);
+ int dirs = vector_get_direction(t->x - t->palm.x, t->y - t->palm.y);
+ if ((dirs & DIRECTIONS) && !(dirs & ~DIRECTIONS)) {
+ t->palm.is_palm = false;
+ tp_set_pointer(tp, t);
+ }
}
return;
}
@@ -391,6 +396,8 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
t->palm.is_palm = true;
t->palm.time = time;
+ t->palm.x = t->x;
+ t->palm.y = t->y;
}
static void
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index 8255a1cd..47791201 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -142,6 +142,7 @@ struct tp_touch {
struct {
bool is_palm;
+ int32_t x, y; /* first coordinates if is_palm == true */
uint32_t time; /* first timestamp if is_palm == true */
} palm;
};
diff --git a/test/touchpad.c b/test/touchpad.c
index 18427c1a..1d95399c 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -1302,6 +1302,20 @@ START_TEST(touchpad_palm_detect_at_top_corners)
}
END_TEST
+START_TEST(touchpad_palm_detect_palm_stays_palm)
+{
+ struct litest_device *dev = litest_current_device();
+ struct libinput *li = dev->libinput;
+
+ litest_drain_events(li);
+
+ litest_touch_down(dev, 0, 99, 20);
+ litest_touch_move_to(dev, 0, 99, 20, 75, 99, 5);
+ litest_touch_up(dev, 0);
+ litest_assert_empty_queue(li);
+}
+END_TEST
+
START_TEST(touchpad_palm_detect_palm_becomes_pointer)
{
struct litest_device *dev = litest_current_device();
@@ -1419,6 +1433,7 @@ int main(int argc, char **argv) {
litest_add("touchpad:palm", touchpad_palm_detect_at_bottom_corners, LITEST_TOUCHPAD, LITEST_CLICKPAD);
litest_add("touchpad:palm", touchpad_palm_detect_at_top_corners, LITEST_TOUCHPAD, LITEST_TOPBUTTONPAD);
litest_add("touchpad:palm", touchpad_palm_detect_palm_becomes_pointer, LITEST_TOUCHPAD, LITEST_ANY);
+ litest_add("touchpad:palm", touchpad_palm_detect_palm_stays_palm, LITEST_TOUCHPAD, LITEST_ANY);
litest_add("touchpad:palm", touchpad_palm_detect_no_palm_moving_into_edges, LITEST_TOUCHPAD, LITEST_ANY);
return litest_run(argc, argv);