Thumb detection at upper side of the touchpad (patch)

Roemer Claasen roemer.claasen at gmail.com
Fri Mar 3 09:29:46 UTC 2023


Hi all,

I would like your opinion about the following: thumb detection on the upper
side of the touchpad.

Here's the story. I recently bought a new laptop (T14s AMD gen3) with
pretty shallow keys. I use the touchpad buttons quite often, and with the
shallower trackpad buttons, my thumb is detected as a pointer movement
every now and then.

My proposed solution: copy the thumb detection areas to the top as well.

The attached patch does this (at least, I tried to do this in a clean way).
Feedback is more than welcome, I would love to clean this up and submit it
for merging.

Thanks for your time,

Roemer







-----------------------------

diff --git a/src/evdev-mt-touchpad-thumb.c b/src/evdev-mt-touchpad-thumb.c
index ceb123ef..d3d3aae3 100644
--- a/src/evdev-mt-touchpad-thumb.c
+++ b/src/evdev-mt-touchpad-thumb.c
@@ -85,11 +85,20 @@ static bool
 tp_thumb_in_exclusion_area(const struct tp_dispatch *tp,
    const struct tp_touch *t)
 {
- return (t->point.y > tp->thumb.lower_thumb_line &&
+ return ((t->point.y > tp->thumb.lower_thumb_line ||
+            t->point.y < tp->thumb.upper_top_thumb_line) &&
  tp->scroll.method != LIBINPUT_CONFIG_SCROLL_EDGE);

 }

+static bool
+tp_thumb_in_main_area(const struct tp_dispatch *tp,
+                           const struct tp_touch *t)
+{
+    return (t->point.y < tp->thumb.upper_thumb_line &&
+            t->point.y > tp->thumb.lower_top_thumb_line);
+}
+
 static bool
 tp_thumb_detect_pressure_size(const struct tp_dispatch *tp,
       const struct tp_touch *t)
@@ -114,9 +123,9 @@ tp_thumb_detect_pressure_size(const struct tp_dispatch
*tp,
 static bool
 tp_thumb_needs_jail(const struct tp_dispatch *tp, const struct tp_touch *t)
 {
- if (t->point.y < tp->thumb.upper_thumb_line ||
-    tp->scroll.method == LIBINPUT_CONFIG_SCROLL_EDGE)
- return false;
+ if (tp_thumb_in_main_area(tp, t) ||
+            tp->scroll.method == LIBINPUT_CONFIG_SCROLL_EDGE)
+        return false;

  if (!tp_thumb_in_exclusion_area(tp, t) &&
            (tp->thumb.use_size || tp->thumb.use_pressure) &&
@@ -360,7 +369,8 @@ tp_thumb_update_multifinger(struct tp_dispatch *tp)

  if (newest &&
     (newest->initial_time - oldest->initial_time) < THUMB_TIMEOUT &&
-    first->point.y < tp->thumb.lower_thumb_line) {
+            (first->point.y < tp->thumb.lower_thumb_line &&
+            first->point.y > tp->thumb.upper_top_thumb_line)) {
  tp_thumb_lift(tp);
  return;
  }
@@ -417,7 +427,16 @@ tp_init_thumb(struct tp_dispatch *tp)
  edges = evdev_device_mm_to_units(device, &mm);
  tp->thumb.lower_thumb_line = edges.y;

- quirks = evdev_libinput_context(device)->quirks;
+    /* ThinkPad trackpad button fix */
+    mm.y = h * 0.15;
+    edges = evdev_device_mm_to_units(device, &mm);
+    tp->thumb.lower_top_thumb_line = edges.y;
+
+    mm.y = h * 0.08;
+    edges = evdev_device_mm_to_units(device, &mm);
+    tp->thumb.upper_top_thumb_line = edges.y;
+
+    quirks = evdev_libinput_context(device)->quirks;
  q = quirks_fetch_for_device(quirks, device->udev_device);

  if (libevdev_has_event_code(device->evdev, EV_ABS, ABS_MT_PRESSURE)) {
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index c99b190f..c46a3edc 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -489,6 +489,10 @@ struct tp_dispatch {
  int upper_thumb_line;
  int lower_thumb_line;

+        /* ThinkPad trackpad button fix */
+        int upper_top_thumb_line;
+        int lower_top_thumb_line;
+
  bool use_pressure;
  int pressure_threshold;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20230303/9cda72b8/attachment.htm>


More information about the wayland-devel mailing list