touchpad: split disable-while-typing handling into a helper function
authorPeter Hutterer <peter.hutterer@who-t.net>
Thu, 21 May 2015 03:30:24 +0000 (13:30 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 27 May 2015 07:38:25 +0000 (17:38 +1000)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
src/evdev-mt-touchpad.c

index c908ead3842316ec48a9288569584fdd4029d858..0b644d9a7c1156b2816adb40f3a492e5316d3443 100644 (file)
@@ -481,6 +481,22 @@ tp_palm_tap_is_palm(struct tp_dispatch *tp, struct tp_touch *t)
        return false;
 }
 
+static int
+tp_palm_detect_dwt(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
+{
+       if (!tp->dwt.keyboard_active)
+               return 0;
+
+       if (t->state == TOUCH_BEGIN) {
+               t->palm.state = PALM_TYPING;
+               t->palm.time = time;
+               t->palm.first = t->point;
+               return 1;
+       }
+
+       return 0;
+}
+
 static void
 tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
 {
@@ -489,13 +505,8 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time)
        struct device_float_coords delta;
        int dirs;
 
-       if (tp->dwt.keyboard_active &&
-           t->state == TOUCH_BEGIN) {
-               t->palm.state = PALM_TYPING;
-               t->palm.time = time;
-               t->palm.first = t->point;
-               return;
-       }
+       if (tp_palm_detect_dwt(tp, t, time))
+           return;
 
        /* If labelled a touch as palm, we unlabel as palm when
           we move out of the palm edge zone within the timeout, provided