[PATCH libinput] touchpad: fix the button timestamps for double/tripletap
Peter Hutterer
peter.hutterer at who-t.net
Thu Apr 27 04:44:57 UTC 2017
Both events had the same timestamp but we have the timestamp from the original
event - use it.
https://bugs.freedesktop.org/show_bug.cgi?id=100796
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/evdev-mt-touchpad-tap.c | 10 +++++--
test/test-touchpad-tap.c | 68 ++++++++++++++++++++++++++++++++++-----------
2 files changed, 60 insertions(+), 18 deletions(-)
diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
index 29989c9..6c989d9 100644
--- a/src/evdev-mt-touchpad-tap.c
+++ b/src/evdev-mt-touchpad-tap.c
@@ -341,7 +341,10 @@ tp_tap_touch2_release_handle_event(struct tp_dispatch *tp,
tp_tap_clear_timer(tp);
break;
case TAP_EVENT_RELEASE:
- tp_tap_notify(tp, time, 2, LIBINPUT_BUTTON_STATE_PRESSED);
+ tp_tap_notify(tp,
+ tp->tap.first_press_time,
+ 2,
+ LIBINPUT_BUTTON_STATE_PRESSED);
tp_tap_notify(tp, time, 2, LIBINPUT_BUTTON_STATE_RELEASED);
tp->tap.state = TAP_STATE_IDLE;
break;
@@ -376,7 +379,10 @@ tp_tap_touch3_handle_event(struct tp_dispatch *tp,
case TAP_EVENT_RELEASE:
tp->tap.state = TAP_STATE_TOUCH_2_HOLD;
if (t->tap.state == TAP_TOUCH_STATE_TOUCH) {
- tp_tap_notify(tp, time, 3, LIBINPUT_BUTTON_STATE_PRESSED);
+ tp_tap_notify(tp,
+ tp->tap.first_press_time,
+ 3,
+ LIBINPUT_BUTTON_STATE_PRESSED);
tp_tap_notify(tp, time, 3, LIBINPUT_BUTTON_STATE_RELEASED);
}
break;
diff --git a/test/test-touchpad-tap.c b/test/test-touchpad-tap.c
index cc0d86f..2739f85 100644
--- a/test/test-touchpad-tap.c
+++ b/test/test-touchpad-tap.c
@@ -916,6 +916,9 @@ START_TEST(touchpad_2fg_tap)
struct libinput *li = dev->libinput;
enum libinput_config_tap_button_map map = _i; /* ranged test */
unsigned int button = 0;
+ struct libinput_event *ev;
+ struct libinput_event_pointer *ptrev;
+ uint64_t ptime, rtime;
litest_enable_tap(dev->libinput_device);
litest_set_tap_map(dev->libinput_device, map);
@@ -940,11 +943,20 @@ START_TEST(touchpad_2fg_tap)
libinput_dispatch(li);
- litest_assert_button_event(li, button,
- LIBINPUT_BUTTON_STATE_PRESSED);
- litest_timeout_tap();
- litest_assert_button_event(li, button,
- LIBINPUT_BUTTON_STATE_RELEASED);
+ ev = libinput_get_event(li);
+ ptrev = litest_is_button_event(ev,
+ button,
+ LIBINPUT_BUTTON_STATE_PRESSED);
+ ptime = libinput_event_pointer_get_time_usec(ptrev);
+ libinput_event_destroy(ev);
+ ev = libinput_get_event(li);
+ ptrev = litest_is_button_event(ev,
+ button,
+ LIBINPUT_BUTTON_STATE_RELEASED);
+ rtime = libinput_event_pointer_get_time_usec(ptrev);
+ libinput_event_destroy(ev);
+
+ ck_assert_int_lt(ptime, rtime);
litest_assert_empty_queue(li);
}
@@ -956,6 +968,9 @@ START_TEST(touchpad_2fg_tap_inverted)
struct libinput *li = dev->libinput;
enum libinput_config_tap_button_map map = _i; /* ranged test */
unsigned int button = 0;
+ struct libinput_event *ev;
+ struct libinput_event_pointer *ptrev;
+ uint64_t ptime, rtime;
litest_enable_tap(dev->libinput_device);
litest_set_tap_map(dev->libinput_device, map);
@@ -980,11 +995,20 @@ START_TEST(touchpad_2fg_tap_inverted)
libinput_dispatch(li);
- litest_assert_button_event(li, button,
- LIBINPUT_BUTTON_STATE_PRESSED);
- litest_timeout_tap();
- litest_assert_button_event(li, button,
- LIBINPUT_BUTTON_STATE_RELEASED);
+ ev = libinput_get_event(li);
+ ptrev = litest_is_button_event(ev,
+ button,
+ LIBINPUT_BUTTON_STATE_PRESSED);
+ ptime = libinput_event_pointer_get_time_usec(ptrev);
+ libinput_event_destroy(ev);
+ ev = libinput_get_event(li);
+ ptrev = litest_is_button_event(ev,
+ button,
+ LIBINPUT_BUTTON_STATE_RELEASED);
+ rtime = libinput_event_pointer_get_time_usec(ptrev);
+ libinput_event_destroy(ev);
+
+ ck_assert_int_lt(ptime, rtime);
litest_assert_empty_queue(li);
}
@@ -1379,6 +1403,10 @@ START_TEST(touchpad_3fg_tap)
}
for (i = 0; i < 3; i++) {
+ uint64_t ptime, rtime;
+ struct libinput_event *ev;
+ struct libinput_event_pointer *ptrev;
+
litest_drain_events(li);
litest_touch_down(dev, 0, 50, 50);
@@ -1391,13 +1419,21 @@ START_TEST(touchpad_3fg_tap)
libinput_dispatch(li);
- litest_assert_button_event(li, button,
- LIBINPUT_BUTTON_STATE_PRESSED);
- litest_timeout_tap();
- litest_assert_button_event(li, button,
- LIBINPUT_BUTTON_STATE_RELEASED);
+ ev = libinput_get_event(li);
+ ptrev = litest_is_button_event(ev,
+ button,
+ LIBINPUT_BUTTON_STATE_PRESSED);
+ ptime = libinput_event_pointer_get_time_usec(ptrev);
+ libinput_event_destroy(ev);
+ ev = libinput_get_event(li);
+ ptrev = litest_is_button_event(ev,
+ button,
+ LIBINPUT_BUTTON_STATE_RELEASED);
+ rtime = libinput_event_pointer_get_time_usec(ptrev);
+ libinput_event_destroy(ev);
+
+ ck_assert_int_lt(ptime, rtime);
- litest_assert_empty_queue(li);
}
}
END_TEST
--
2.9.3
More information about the wayland-devel
mailing list