linux-surface / iptsd

Userspace daemon for Intel Precise Touch & Stylus
GNU General Public License v2.0
94 stars 46 forks source link

iptsd hangs when touch becomes marked as a palm in xorg #17

Closed tmarkov closed 3 years ago

tmarkov commented 3 years ago

Sometimes, iptsd detects a touch and forwards it to the input driver, only to later find out that it was a palm touch instead. Then it is marked as a palm here,

This works well on wayland, however on xorg (with libinput) it causes the touch to never be lifted, and all subsequent touches get ignored. Restarting iptsd fixes he issue.

A workaround would be to lift it instead of marking it as palm:

--- a/src/touch.c
+++ b/src/touch.c
@@ -41,7 +41,10 @@ static int iptsd_touch_handle_heatmap(struct iptsd_context *iptsd,
                        continue;

                if (in.is_palm || blocked) {
-                       iptsd_touch_emit(touch.dev, in, MT_TOOL_PALM);
+                       //iptsd_touch_emit(touch.dev, in, MT_TOOL_PALM);
+                       iptsd_devices_emit(touch.dev, EV_ABS, ABS_MT_TRACKING_ID, -1);
+                       iptsd_devices_emit(touch.dev, EV_ABS, ABS_MT_POSITION_X, 0);
+                       iptsd_devices_emit(touch.dev, EV_ABS, ABS_MT_POSITION_Y, 0);
                        continue;
                }

However this prevents apps from undoing the touch.

Alternatively, this patch by @StollD to libinput fixes the issue: https://gist.github.com/StollD/05b6955c3fe0ad9e6394f27e5ddff1b7

@whot Does this patch make sense from libinput point of view, or is there a reason palms don't get lifted on xorg?

whot commented 3 years ago

whoah, that's definitely a bug in the xf86-input-libinput driver, we should handle touch cancel correctly. Please submit a PR to the libinput driver gitlab instance and I'll get it merged.

FTR, the xorg libinput driver != libinput itself, it's a wrapper around libinput to map it to the server API. This is a bug in that layer, using a Wayland compositor that uses libinput directly (gnome shell, kwin, sway, ...) shouldn't see the same bug.

StollD commented 3 years ago

@whot Thank you for chiming in! I've submitted a MR on gitlab, with my patch that is linked above. Hope that I didn't miss anything important.