[PATCH libinput 7/7] touchpad: don't init edge palm detection on touchpads less than 8cm across
Peter Hutterer
peter.hutterer at who-t.net
Tue Jul 15 22:18:46 PDT 2014
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 at who-t.net>
---
src/evdev-mt-touchpad.c | 13 +++++++++++++
test/touchpad.c | 28 ++++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index 2cf8b56..1636e7a 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 259b227..bc3658c 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);
--
1.9.3
More information about the wayland-devel
mailing list