#include <assert.h>
#include <math.h>
#include <stdbool.h>
+#include <limits.h>
#include "evdev-mt-touchpad.h"
{
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;
}
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);
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);
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);
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);
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);
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);