fallback: fix touchscreen defuzzing
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 8 Mar 2018 23:41:57 +0000 (09:41 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Thu, 8 Mar 2018 23:49:54 +0000 (09:49 +1000)
The hysteresis-returned point always differs from the current point, even if
the hysteresis kicks in. We need to compare to the hysteresis center.

And the returned point is only the new center if we exceed the margin,
otherwise the center stays as-is.

The touch_fuzz() test only succeeded for this because for the values we were
introducing jitter by, the kernel filtered out all the actual movement so
these paths weren't hit.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-fallback.c

index d1ca81f0f54d23447c51eded09c7997d20709251..269b3f5a2105d77b253a7dc98a1af509d57a1db2 100644 (file)
@@ -130,12 +130,13 @@ fallback_filter_defuzz_touch(struct fallback_dispatch *dispatch,
        point = evdev_hysteresis(&slot->point,
                                 &slot->hysteresis_center,
                                 &dispatch->mt.hysteresis_margin);
+       slot->point = point;
 
-       slot->hysteresis_center = slot->point;
-       if (point.x == slot->point.x && point.y == slot->point.y)
+       if (point.x == slot->hysteresis_center.x &&
+           point.y == slot->hysteresis_center.y)
                return true;
 
-       slot->point = point;
+       slot->hysteresis_center = point;
 
        return false;
 }