<div dir="ltr">Apologies, should have mentioned this concerns <b>libinput.</b> Hope this is the right way to do things here.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 3, 2023 at 10:29 AM Roemer Claasen <<a href="mailto:roemer.claasen@gmail.com">roemer.claasen@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi all,<div><br></div><div>I would like your opinion about the following: thumb detection on the upper side of the touchpad.</div><div><br></div><div>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. </div><div><br></div><div>My proposed solution: copy the thumb detection areas to the top as well. </div><div><br></div><div>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. </div><div><br></div><div>Thanks for your time, </div><div><br></div><div>Roemer</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div>-----------------------------</div><div><br></div><div><font face="monospace">diff --git a/src/evdev-mt-touchpad-thumb.c b/src/evdev-mt-touchpad-thumb.c<br>index ceb123ef..d3d3aae3 100644<br>--- a/src/evdev-mt-touchpad-thumb.c<br>+++ b/src/evdev-mt-touchpad-thumb.c<br>@@ -85,11 +85,20 @@ static bool<br> tp_thumb_in_exclusion_area(const struct tp_dispatch *tp,<br> const struct tp_touch *t)<br> {<br>- return (t->point.y > tp->thumb.lower_thumb_line &&<br>+ return ((t->point.y > tp->thumb.lower_thumb_line ||<br>+ t->point.y < tp->thumb.upper_top_thumb_line) &&<br> tp->scroll.method != LIBINPUT_CONFIG_SCROLL_EDGE);<br> <br> }<br> <br>+static bool<br>+tp_thumb_in_main_area(const struct tp_dispatch *tp,<br>+ const struct tp_touch *t)<br>+{<br>+ return (t->point.y < tp->thumb.upper_thumb_line &&<br>+ t->point.y > tp->thumb.lower_top_thumb_line);<br>+}<br>+<br> static bool<br> tp_thumb_detect_pressure_size(const struct tp_dispatch *tp,<br> const struct tp_touch *t)<br>@@ -114,9 +123,9 @@ tp_thumb_detect_pressure_size(const struct tp_dispatch *tp,<br> static bool<br> tp_thumb_needs_jail(const struct tp_dispatch *tp, const struct tp_touch *t)<br> {<br>- if (t->point.y < tp->thumb.upper_thumb_line ||<br>- tp->scroll.method == LIBINPUT_CONFIG_SCROLL_EDGE)<br>- return false;<br>+ if (tp_thumb_in_main_area(tp, t) ||<br>+ tp->scroll.method == LIBINPUT_CONFIG_SCROLL_EDGE)<br>+ return false;<br> <br> if (!tp_thumb_in_exclusion_area(tp, t) &&<br> (tp->thumb.use_size || tp->thumb.use_pressure) &&<br>@@ -360,7 +369,8 @@ tp_thumb_update_multifinger(struct tp_dispatch *tp)<br> <br> if (newest &&<br> (newest->initial_time - oldest->initial_time) < THUMB_TIMEOUT &&<br>- first->point.y < tp->thumb.lower_thumb_line) {<br>+ (first->point.y < tp->thumb.lower_thumb_line &&<br>+ first->point.y > tp->thumb.upper_top_thumb_line)) {<br> tp_thumb_lift(tp);<br> return;<br> }<br>@@ -417,7 +427,16 @@ tp_init_thumb(struct tp_dispatch *tp)<br> edges = evdev_device_mm_to_units(device, &mm);<br> tp->thumb.lower_thumb_line = edges.y;<br> <br>- quirks = evdev_libinput_context(device)->quirks;<br>+ /* ThinkPad trackpad button fix */<br>+ mm.y = h * 0.15;<br>+ edges = evdev_device_mm_to_units(device, &mm);<br>+ tp->thumb.lower_top_thumb_line = edges.y;<br>+<br>+ mm.y = h * 0.08;<br>+ edges = evdev_device_mm_to_units(device, &mm);<br>+ tp->thumb.upper_top_thumb_line = edges.y;<br>+<br>+ quirks = evdev_libinput_context(device)->quirks;<br> q = quirks_fetch_for_device(quirks, device->udev_device);<br> <br> if (libevdev_has_event_code(device->evdev, EV_ABS, ABS_MT_PRESSURE)) {<br>diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h<br>index c99b190f..c46a3edc 100644<br>--- a/src/evdev-mt-touchpad.h<br>+++ b/src/evdev-mt-touchpad.h<br>@@ -489,6 +489,10 @@ struct tp_dispatch {<br> int upper_thumb_line;<br> int lower_thumb_line;<br> <br>+ /* ThinkPad trackpad button fix */<br>+ int upper_top_thumb_line;<br>+ int lower_top_thumb_line;<br>+<br> bool use_pressure;<br> int pressure_threshold;</font><br></div></div>
</blockquote></div>