From 27c42990d85dcffe0114a52bcf5ff66d0f730c7b Mon Sep 17 00:00:00 2001 From: Matt Mayfield Date: Tue, 21 Aug 2018 20:54:58 -0500 Subject: [PATCH] touchpad: fine tune size-based thumb detection In testing on an Apple Magic Trackpad, thumb touches are reliably detected by being quite large in the major dimension, but around half the size in the minor dimension. --- quirks/50-system-apple.quirks | 2 +- src/evdev-mt-touchpad.c | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/quirks/50-system-apple.quirks b/quirks/50-system-apple.quirks index f643ccc6..9f6d172d 100644 --- a/quirks/50-system-apple.quirks +++ b/quirks/50-system-apple.quirks @@ -34,7 +34,7 @@ MatchProduct=0x030E AttrSizeHint=130x110 AttrTouchSizeRange=20:10 AttrPalmSizeThreshold=900 -AttrThumbSizeThreshold=800 +AttrThumbSizeThreshold=700 [Apple Touchpad OneButton] MatchUdevType=touchpad diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 64041752..53e3c22f 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -1133,16 +1133,17 @@ tp_thumb_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) * a thumb. */ if (tp->thumb.use_pressure && - t->pressure > tp->thumb.pressure_threshold) + t->pressure > tp->thumb.pressure_threshold) { t->thumb.state = THUMB_STATE_YES; - else if (tp->thumb.use_size && - (t->major > tp->thumb.size_threshold || - t->minor > tp->thumb.size_threshold)) + } else if (tp->thumb.use_size && + (t->major > tp->thumb.size_threshold) && + (t->minor < (tp->thumb.size_threshold * 0.6))) { t->thumb.state = THUMB_STATE_YES; - else if (t->point.y > tp->thumb.lower_thumb_line && + } else if (t->point.y > tp->thumb.lower_thumb_line && tp->scroll.method != LIBINPUT_CONFIG_SCROLL_EDGE && - t->thumb.first_touch_time + THUMB_MOVE_TIMEOUT < time) + t->thumb.first_touch_time + THUMB_MOVE_TIMEOUT < time) { t->thumb.state = THUMB_STATE_YES; + } /* now what? we marked it as thumb, so: *