Apple touchpads don't have visible markings for the software button areas
that almost all other vendors use. OS X provides clickfinger behaviour
instead, where a click with two fingers on the touchpad generate a right
button click. Use that same behaviour in libinput.

For all other touchpads, use the software button areas introduced in a
follow-up commit.

Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net>
---
This should probably be configurable at some point in the future...

 src/evdev-mt-touchpad-buttons.c |  7 ++++++-
 src/evdev-mt-touchpad.h         |  1 +
 test/touchpad.c                 | 12 ++++++++----
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c
index c3c97b0..08783a3 100644
--- a/src/evdev-mt-touchpad-buttons.c
+++ b/src/evdev-mt-touchpad-buttons.c
@@ -60,6 +60,11 @@ tp_init_buttons(struct tp_dispatch *tp,
 
        tp->buttons.motion_dist = diagonal * DEFAULT_BUTTON_MOTION_THRESHOLD;
 
+       if (libevdev_get_id_vendor(device->evdev) == 0x5ac) /* Apple */
+               tp->buttons.use_clickfinger = true;
+       else
+               tp->buttons.use_clickfinger = false;
+
        return 0;
 }
 
@@ -142,7 +147,7 @@ tp_post_button_events(struct tp_dispatch *tp, uint32_t time)
 
        if (tp->buttons.has_buttons)
                rc = tp_post_physical_buttons(tp, time);
-       else
+       else if (tp->buttons.use_clickfinger)
                rc = tp_post_clickfinger_buttons(tp, time);
 
        return rc;
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index 1dee663..f3e5b31 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -135,6 +135,7 @@ struct tp_dispatch {
 
        struct {
                bool has_buttons;               /* true for physical LMR 
buttons */
+               bool use_clickfinger;           /* number of fingers decides 
button number */
                uint32_t state;
                uint32_t old_state;
                uint32_t motion_dist;           /* for pinned touches */
diff --git a/test/touchpad.c b/test/touchpad.c
index f4d7839..bbae6cd 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -217,7 +217,7 @@ END_TEST
 
 START_TEST(touchpad_1fg_clickfinger)
 {
-       struct litest_device *dev = litest_current_device();
+       struct litest_device *dev = litest_create_device(LITEST_BCM5974);
        struct libinput *li = dev->libinput;
        struct libinput_event *event;
        struct libinput_event_pointer *ptrev;
@@ -237,12 +237,14 @@ START_TEST(touchpad_1fg_clickfinger)
                            LIBINPUT_POINTER_BUTTON_STATE_PRESSED);
        assert_button_event(li, BTN_LEFT,
                            LIBINPUT_POINTER_BUTTON_STATE_RELEASED);
+
+       litest_delete_device(dev);
 }
 END_TEST
 
 START_TEST(touchpad_2fg_clickfinger)
 {
-       struct litest_device *dev = litest_current_device();
+       struct litest_device *dev = litest_create_device(LITEST_BCM5974);
        struct libinput *li = dev->libinput;
        struct libinput_event *event;
        struct libinput_event_pointer *ptrev;
@@ -264,6 +266,8 @@ START_TEST(touchpad_2fg_clickfinger)
                            LIBINPUT_POINTER_BUTTON_STATE_PRESSED);
        assert_button_event(li, BTN_RIGHT,
                            LIBINPUT_POINTER_BUTTON_STATE_RELEASED);
+
+       litest_delete_device(dev);
 }
 END_TEST
 
@@ -362,8 +366,8 @@ int main(int argc, char **argv) {
        litest_add("touchpad:tap", touchpad_1fg_tap_n_drag, LITEST_TOUCHPAD, 
LITEST_ANY);
        litest_add("touchpad:tap", touchpad_2fg_tap, LITEST_TOUCHPAD, 
LITEST_SINGLE_TOUCH);
 
-       litest_add("touchpad:clickfinger", touchpad_1fg_clickfinger, 
LITEST_TOUCHPAD, LITEST_ANY);
-       litest_add("touchpad:clickfinger", touchpad_2fg_clickfinger, 
LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
+       litest_add_no_device("touchpad:clickfinger", touchpad_1fg_clickfinger);
+       litest_add_no_device("touchpad:clickfinger", touchpad_2fg_clickfinger);
 
        litest_add("touchpad:click", touchpad_btn_left, LITEST_TOUCHPAD, 
LITEST_CLICKPAD);
        litest_add("touchpad:click", clickpad_btn_left, LITEST_CLICKPAD, 
LITEST_ANY);
-- 
1.8.5.3

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to