touchpad: add helper function for stopping current actions
authorPeter Hutterer <peter.hutterer@who-t.net>
Mon, 3 Apr 2017 05:15:01 +0000 (15:15 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Fri, 21 Apr 2017 00:03:16 +0000 (10:03 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-mt-touchpad.c

index 21fdc46..f41dd68 100644 (file)
@@ -276,6 +276,14 @@ tp_end_sequence(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
        tp_end_touch(tp, t, time);
 }
 
+static void
+tp_stop_actions(struct tp_dispatch *tp, uint64_t time)
+{
+       tp_edge_scroll_stop_events(tp, time);
+       tp_gesture_cancel(tp, time);
+       tp_tap_suspend(tp, time);
+}
+
 struct normalized_coords
 tp_get_delta(struct tp_touch *t)
 {
@@ -1395,9 +1403,7 @@ tp_trackpoint_event(uint64_t time, struct libinput_event *event, void *data)
                return;
 
        if (!tp->palm.trackpoint_active) {
-               tp_edge_scroll_stop_events(tp, time);
-               tp_gesture_cancel(tp, time);
-               tp_tap_suspend(tp, time);
+               tp_stop_actions(tp, time);
                tp->palm.trackpoint_active = true;
        }
 
@@ -1510,9 +1516,7 @@ tp_keyboard_event(uint64_t time, struct libinput_event *event, void *data)
                                     ARRAY_LENGTH(tp->dwt.mod_mask)))
                    return;
 
-               tp_edge_scroll_stop_events(tp, time);
-               tp_gesture_cancel(tp, time);
-               tp_tap_suspend(tp, time);
+               tp_stop_actions(tp, time);
                tp->dwt.keyboard_active = true;
                timeout = DEFAULT_KEYBOARD_ACTIVITY_TIMEOUT_1;
        } else {