summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2014-07-15 14:01:00 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2014-07-21 08:56:12 +1000
commit858f0095653ce4b5f4a099bd2afbdcf616e5764a (patch)
tree2e23ea7b9b284963361dacb9f7d37523e8c7fa2f
parentb3c578521e7b53bb9fd0516344d9c24b24e519a1 (diff)
downloadlibinput-858f0095653ce4b5f4a099bd2afbdcf616e5764a.tar.gz
touchpad: don't init edge palm detection on touchpads less than 8cm across
On small touchpads, a touch that intends to go across the width of the touchpad is likely to start in the edge zone. Likewise, on those touchpads the chances of a palm event happening on the edge is small. A minimum width of 8cm determined by an elaborate process of completely unscientific guesswork: the x220 is roughly 7.5cm across and doesn't suffer much from edge events, the T440s is 10cm across and definitely suffers from it. So the trigger width likely somewhere in between which makes 8cm about as valid as any other guess. Note that this disables palm detection for resolution-less touchpads too - if we don't know how big the touchpad is we can't know if palm detection on the edges is necessary. 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--test/touchpad.c28
2 files changed, 41 insertions, 0 deletions
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 2cf8b567..1636e7a2 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -25,6 +25,7 @@
#include <assert.h>
#include <math.h>
#include <stdbool.h>
+#include <limits.h>
#include "evdev-mt-touchpad.h"
@@ -753,9 +754,21 @@ tp_init_palmdetect(struct tp_dispatch *tp,
{
int width;
+ /* We don't know how big the touchpad is */
+ if (device->abs.absinfo_x->resolution == 1)
+ return 0;
+
width = abs(device->abs.absinfo_x->maximum -
device->abs.absinfo_x->minimum);
+ /* Enable palm detection on touchpads >= 80 mm. Anything smaller
+ probably won't need it, until we find out it does */
+ if (width/device->abs.absinfo_x->resolution < 80) {
+ tp->palm.right_edge = INT_MAX;
+ tp->palm.left_edge = INT_MIN;
+ return 0;
+ }
+
/* palm edges are 5% of the width on each side */
tp->palm.right_edge = device->abs.absinfo_x->maximum - width * 0.05;
tp->palm.left_edge = device->abs.absinfo_x->minimum + width * 0.05;
diff --git a/test/touchpad.c b/test/touchpad.c
index 1d95399c..c1bdbd53 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -1241,11 +1241,24 @@ START_TEST(touchpad_tap_default)
}
END_TEST
+static int
+touchpad_has_palm_detect_size(struct litest_device *dev)
+{
+ double width, height;
+
+ libinput_device_get_size(dev->libinput_device, &width, &height);
+
+ return width >= 80;
+}
+
START_TEST(touchpad_palm_detect_at_edge)
{
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
+ if (!touchpad_has_palm_detect_size(dev))
+ return;
+
litest_drain_events(li);
litest_touch_down(dev, 0, 99, 50);
@@ -1265,6 +1278,9 @@ START_TEST(touchpad_palm_detect_at_bottom_corners)
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
+ if (!touchpad_has_palm_detect_size(dev))
+ return;
+
/* Run for non-clickpads only: make sure the bottom corners trigger
palm detection too */
litest_drain_events(li);
@@ -1286,6 +1302,9 @@ START_TEST(touchpad_palm_detect_at_top_corners)
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
+ if (!touchpad_has_palm_detect_size(dev))
+ return;
+
/* Run for non-clickpads only: make sure the bottom corners trigger
palm detection too */
litest_drain_events(li);
@@ -1307,6 +1326,9 @@ START_TEST(touchpad_palm_detect_palm_stays_palm)
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
+ if (!touchpad_has_palm_detect_size(dev))
+ return;
+
litest_drain_events(li);
litest_touch_down(dev, 0, 99, 20);
@@ -1323,6 +1345,9 @@ START_TEST(touchpad_palm_detect_palm_becomes_pointer)
struct libinput_event *ev;
enum libinput_event_type type;
+ if (!touchpad_has_palm_detect_size(dev))
+ return;
+
litest_drain_events(li);
litest_touch_down(dev, 0, 99, 50);
@@ -1352,6 +1377,9 @@ START_TEST(touchpad_palm_detect_no_palm_moving_into_edges)
struct libinput_event *ev;
enum libinput_event_type type;
+ if (!touchpad_has_palm_detect_size(dev))
+ return;
+
/* moving non-palm into the edge does not label it as palm */
litest_drain_events(li);