[PATCH libinput 04/11] touchpad: ignore thumbs when counting clickfingers
Peter Hutterer
peter.hutterer at who-t.net
Tue Jul 21 22:09:24 PDT 2015
We may have four fingers on the touchpad - three real ones + a thumb. Count it
as three-finger click then.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evdev-mt-touchpad-buttons.c | 3 +++
test/touchpad.c | 39 ++++++++++++++++++++++++++++++++++++++-
2 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c
index b8dcb51..687a613 100644
--- a/src/evdev-mt-touchpad-buttons.c
+++ b/src/evdev-mt-touchpad-buttons.c
@@ -872,6 +872,9 @@ tp_clickfinger_set_button(struct tp_dispatch *tp)
if (t->state != TOUCH_BEGIN && t->state != TOUCH_UPDATE)
continue;
+ if (t->is_thumb)
+ continue;
+
if (!first)
first = t;
else if (!second)
diff --git a/test/touchpad.c b/test/touchpad.c
index 3e053ee..40d9c33 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -364,6 +364,7 @@ START_TEST(touchpad_4fg_clickfinger)
{
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
+ struct libinput_event *event;
if (libevdev_get_num_slots(dev->evdev) < 4)
return;
@@ -387,6 +388,18 @@ START_TEST(touchpad_4fg_clickfinger)
libinput_dispatch(li);
+ litest_wait_for_event(li);
+ event = libinput_get_event(li);
+ litest_is_button_event(event,
+ BTN_MIDDLE,
+ LIBINPUT_BUTTON_STATE_PRESSED);
+ libinput_event_destroy(event);
+ event = libinput_get_event(li);
+ litest_is_button_event(event,
+ BTN_MIDDLE,
+ LIBINPUT_BUTTON_STATE_RELEASED);
+ libinput_event_destroy(event);
+
litest_assert_empty_queue(li);
}
END_TEST
@@ -395,6 +408,7 @@ START_TEST(touchpad_4fg_clickfinger_btntool_2slots)
{
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
+ struct libinput_event *event;
if (libevdev_get_num_slots(dev->evdev) >= 3 ||
!libevdev_has_event_code(dev->evdev, EV_KEY, BTN_TOOL_QUADTAP))
@@ -419,7 +433,17 @@ START_TEST(touchpad_4fg_clickfinger_btntool_2slots)
litest_touch_up(dev, 0);
litest_touch_up(dev, 1);
- libinput_dispatch(li);
+ litest_wait_for_event(li);
+ event = libinput_get_event(li);
+ litest_is_button_event(event,
+ BTN_MIDDLE,
+ LIBINPUT_BUTTON_STATE_PRESSED);
+ libinput_event_destroy(event);
+ event = libinput_get_event(li);
+ litest_is_button_event(event,
+ BTN_MIDDLE,
+ LIBINPUT_BUTTON_STATE_RELEASED);
+ libinput_event_destroy(event);
litest_assert_empty_queue(li);
}
@@ -429,6 +453,7 @@ START_TEST(touchpad_4fg_clickfinger_btntool_3slots)
{
struct litest_device *dev = litest_current_device();
struct libinput *li = dev->libinput;
+ struct libinput_event *event;
if (libevdev_get_num_slots(dev->evdev) >= 4 ||
!libevdev_has_event_code(dev->evdev, EV_KEY, BTN_TOOL_TRIPLETAP))
@@ -457,6 +482,18 @@ START_TEST(touchpad_4fg_clickfinger_btntool_3slots)
libinput_dispatch(li);
+ litest_wait_for_event(li);
+ event = libinput_get_event(li);
+ litest_is_button_event(event,
+ BTN_MIDDLE,
+ LIBINPUT_BUTTON_STATE_PRESSED);
+ libinput_event_destroy(event);
+ event = libinput_get_event(li);
+ litest_is_button_event(event,
+ BTN_MIDDLE,
+ LIBINPUT_BUTTON_STATE_RELEASED);
+ libinput_event_destroy(event);
+
litest_assert_empty_queue(li);
}
END_TEST
--
2.4.3
More information about the wayland-devel
mailing list