touchpad: Filter motion in a certain number of tap states
authorPeter Hutterer <peter.hutterer@who-t.net>
Sun, 9 Feb 2014 21:44:59 +0000 (07:44 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Mon, 24 Mar 2014 04:56:41 +0000 (14:56 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-mt-touchpad-tap.c
src/evdev-mt-touchpad.c
src/evdev-mt-touchpad.h

index 7ac592b3b7e320832ccf3fbe3a81c61d312625ab..bc7acbd0a4fd84d41e68e85497c7e34683b6489c 100644 (file)
@@ -504,6 +504,7 @@ int
 tp_tap_handle_state(struct tp_dispatch *tp, uint32_t time)
 {
        struct tp_touch *t;
+       int filter_motion = 0;
 
        if (tp->queued & TOUCHPAD_EVENT_BUTTON_PRESS)
                tp_tap_handle_event(tp, TAP_EVENT_BUTTON, time);
@@ -521,7 +522,27 @@ tp_tap_handle_state(struct tp_dispatch *tp, uint32_t time)
                        tp_tap_handle_event(tp, TAP_EVENT_MOTION, time);
        }
 
-       return 0;
+       /**
+        * In any state where motion exceeding the move threshold would
+        * move to the next state, filter that motion until we actually
+        * exceed it. This prevents small motion events while we're waiting
+        * on a decision if a tap is a tap.
+        */
+       switch (tp->tap.state) {
+       case TAP_STATE_TOUCH:
+       case TAP_STATE_TAPPED:
+       case TAP_STATE_DRAGGING_OR_DOUBLETAP:
+       case TAP_STATE_TOUCH_2:
+       case TAP_STATE_TOUCH_3:
+               filter_motion = 1;
+               break;
+
+       default:
+               break;
+
+       }
+
+       return filter_motion;
 }
 
 static void
index d1268f6ecb162ee03f7927a05e5cbe95d2f41be4..873ddf0c35e5d5ce60d1d02c365cc17688a57173 100644 (file)
@@ -369,20 +369,20 @@ tp_post_events(struct tp_dispatch *tp, uint32_t time)
                return;
        }
 
-       tp_tap_handle_state(tp, time);
-
-       if (t->history.count < 4)
+       if (tp_tap_handle_state(tp, time) != 0)
                return;
 
-       tp_get_delta(t, &dx, &dy);
-       tp_filter_motion(tp, &dx, &dy, time);
+       if (t->history.count >= TOUCHPAD_MIN_SAMPLES) {
+               tp_get_delta(t, &dx, &dy);
+               tp_filter_motion(tp, &dx, &dy, time);
 
-       if (dx != 0 || dy != 0)
-               pointer_notify_motion(
-                       &tp->device->base,
-                       time,
-                       li_fixed_from_double(dx),
-                       li_fixed_from_double(dy));
+               if (dx != 0 || dy != 0)
+                       pointer_notify_motion(
+                               &tp->device->base,
+                               time,
+                               li_fixed_from_double(dx),
+                               li_fixed_from_double(dy));
+       }
 
        tp_post_button_events(tp, time);
 }
index 973b4784aac0520c6ab31f429309373d43d30e1a..a5cfaa6e89ef695c40dda8be236a52e7d1f7deb4 100644 (file)
@@ -30,6 +30,7 @@
 #include "filter.h"
 
 #define TOUCHPAD_HISTORY_LENGTH 4
+#define TOUCHPAD_MIN_SAMPLES 4
 
 enum touchpad_event {
        TOUCHPAD_EVENT_NONE             = 0,