[PATCH libinput 3/7] touchpad: Don't send scroll events during 2 finger tap-n-drag

Hans de Goede hdegoede at redhat.com
Sun Sep 28 04:22:19 PDT 2014


The touchpad tap code explicitly supports 2 finger tap-n-drag, this commit
adds a test-case for this, which fails due to the 2 finger scrolling code
sending scroll events during a 2 finger tap-n-drag.

And this commit fixes the test-case, by not sending scroll events while a
tap-n-drag is active.

Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
 src/evdev-mt-touchpad-tap.c | 13 +++++++++++++
 src/evdev-mt-touchpad.c     |  4 ++++
 src/evdev-mt-touchpad.h     |  3 +++
 test/touchpad.c             | 40 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 60 insertions(+)

diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
index b549067..e352ff4 100644
--- a/src/evdev-mt-touchpad-tap.c
+++ b/src/evdev-mt-touchpad-tap.c
@@ -754,3 +754,16 @@ tp_tap_resume(struct tp_dispatch *tp, uint64_t time)
 	tp->tap.suspended = false;
 	tp_tap_enabled_updated(tp, old_enabled, time);
 }
+
+bool
+tp_tap_dragging(struct tp_dispatch *tp)
+{
+	switch (tp->tap.state) {
+	case TAP_STATE_DRAGGING:
+	case TAP_STATE_DRAGGING_2:
+	case TAP_STATE_DRAGGING_WAIT:
+		return true;
+	default:
+		return false;
+	}
+}
diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
index b7a559f..85d980c 100644
--- a/src/evdev-mt-touchpad.c
+++ b/src/evdev-mt-touchpad.c
@@ -508,6 +508,10 @@ tp_post_scroll_events(struct tp_dispatch *tp, uint64_t time)
 	struct tp_touch *t;
 	int nfingers_down = 0;
 
+	/* No scrolling during tap-n-drag */
+	if (tp_tap_dragging(tp))
+		return 0;
+
 	/* Only count active touches for 2 finger scrolling */
 	tp_for_each_touch(tp, t) {
 		if (tp_touch_active(tp, t))
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index 2fda4ef..91f6e4a 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -291,4 +291,7 @@ tp_tap_suspend(struct tp_dispatch *tp, uint64_t time);
 void
 tp_tap_resume(struct tp_dispatch *tp, uint64_t time);
 
+bool
+tp_tap_dragging(struct tp_dispatch *tp);
+
 #endif
diff --git a/test/touchpad.c b/test/touchpad.c
index 8bd09f1..fba1d58 100644
--- a/test/touchpad.c
+++ b/test/touchpad.c
@@ -200,6 +200,45 @@ START_TEST(touchpad_1fg_tap_n_drag_timeout)
 }
 END_TEST
 
+START_TEST(touchpad_2fg_tap_n_drag)
+{
+	struct litest_device *dev = litest_current_device();
+	struct libinput *li = dev->libinput;
+	struct libinput_event *event;
+
+	libinput_device_config_tap_set_enabled(dev->libinput_device,
+					       LIBINPUT_CONFIG_TAP_ENABLED);
+
+	litest_drain_events(li);
+
+	litest_touch_down(dev, 0, 50, 50);
+	litest_touch_up(dev, 0);
+	litest_touch_down(dev, 0, 50, 50);
+	litest_touch_down(dev, 1, 60, 50);
+	litest_touch_move_to(dev, 0, 50, 50, 80, 80, 5, 40);
+	libinput_dispatch(li);
+
+	litest_assert_button_event(li, BTN_LEFT,
+				   LIBINPUT_BUTTON_STATE_PRESSED);
+
+	while (libinput_next_event_type(li) == LIBINPUT_EVENT_POINTER_MOTION) {
+		event = libinput_get_event(li);
+		libinput_event_destroy(event);
+		libinput_dispatch(li);
+	}
+	litest_assert_empty_queue(li);
+
+	litest_touch_up(dev, 0);
+	litest_touch_up(dev, 1);
+
+	/* This will wait for the DRAGGING_WAIT timeout */
+	litest_assert_button_event(li, BTN_LEFT,
+				   LIBINPUT_BUTTON_STATE_RELEASED);
+
+	litest_assert_empty_queue(li);
+}
+END_TEST
+
 START_TEST(touchpad_2fg_tap)
 {
 	struct litest_device *dev = litest_current_device();
@@ -1934,6 +1973,7 @@ int main(int argc, char **argv) {
 	litest_add("touchpad:tap", touchpad_1fg_tap, LITEST_TOUCHPAD, LITEST_ANY);
 	litest_add("touchpad:tap", touchpad_1fg_tap_n_drag, LITEST_TOUCHPAD, LITEST_ANY);
 	litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_timeout, LITEST_TOUCHPAD, LITEST_ANY);
+	litest_add("touchpad:tap", touchpad_2fg_tap_n_drag, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
 	litest_add("touchpad:tap", touchpad_2fg_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
 	litest_add("touchpad:tap", touchpad_2fg_tap_inverted, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
 	litest_add("touchpad:tap", touchpad_1fg_tap_click, LITEST_TOUCHPAD, LITEST_CLICKPAD);
-- 
2.1.0



More information about the wayland-devel mailing list