touchpad: move clickfinger finger decision into a helper function
authorPeter Hutterer <peter.hutterer@who-t.net>
Wed, 3 Jun 2015 01:06:54 +0000 (11:06 +1000)
committerPeter Hutterer <peter.hutterer@who-t.net>
Wed, 3 Jun 2015 04:43:58 +0000 (14:43 +1000)
No functional changes.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
src/evdev-mt-touchpad-buttons.c

index 4b1d6ab595d91725e154d2c72da6077425fa1f63..f0c39b62acf61f1ee10f04e0694f8cf21fa5e745 100644 (file)
@@ -784,6 +784,24 @@ tp_post_physical_buttons(struct tp_dispatch *tp, uint64_t time)
        return 0;
 }
 
+static uint32_t
+tp_clickfinger_set_button(struct tp_dispatch *tp)
+{
+       uint32_t button;
+
+       switch (tp->nfingers_down) {
+       case 0:
+       case 1: button = BTN_LEFT; break;
+       case 2: button = BTN_RIGHT; break;
+       case 3: button = BTN_MIDDLE; break;
+       default:
+               button = 0;
+               break;
+       }
+
+       return button;
+}
+
 static int
 tp_notify_clickpadbutton(struct tp_dispatch *tp,
                         uint64_t time,
@@ -818,14 +836,7 @@ tp_notify_clickpadbutton(struct tp_dispatch *tp,
         */
        if (tp->buttons.click_method == LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER &&
            state == LIBINPUT_BUTTON_STATE_PRESSED) {
-               switch (tp->nfingers_down) {
-               case 0:
-               case 1: button = BTN_LEFT; break;
-               case 2: button = BTN_RIGHT; break;
-               case 3: button = BTN_MIDDLE; break;
-               default:
-                       button = 0;
-               }
+               button = tp_clickfinger_set_button(tp);
                tp->buttons.active = button;
 
                if (!button)