summaryrefslogtreecommitdiff
path: root/test/test-pointer.c
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2018-06-29 13:43:15 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2018-06-29 13:52:17 +1000
commit1f3f681fa70a04b80a87011a24cb6e2b827ab231 (patch)
tree9c09c5a947b1274425d3d44aa257de4d8957cb80 /test/test-pointer.c
parent1ec17d5e2a579f9162ecd5d2b700046599042bef (diff)
downloadlibinput-1f3f681fa70a04b80a87011a24cb6e2b827ab231.tar.gz
fallback: cancel the debounce timers during device remove, not destroy
destroy isn't called until the last libinput_device_unref(), so we may trigger a debounce timer after the device was removed. The same fix is neded for the touchpad interface. Fixes https://gitlab.freedesktop.org/libinput/libinput/issues/72 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'test/test-pointer.c')
-rw-r--r--test/test-pointer.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/test-pointer.c b/test/test-pointer.c
index d6ff4ffe..ff0b3c61 100644
--- a/test/test-pointer.c
+++ b/test/test-pointer.c
@@ -2533,6 +2533,58 @@ START_TEST(debounce_spurious_switch_to_otherbutton)
}
END_TEST
+START_TEST(debounce_remove_device_button_up)
+{
+ struct libinput *li;
+ struct litest_device *dev;
+
+ li = litest_create_context();
+
+ dev = litest_add_device(li, LITEST_MOUSE);
+ litest_drain_events(li);
+
+ litest_event(dev, EV_KEY, BTN_LEFT, 1);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+ litest_event(dev, EV_KEY, BTN_LEFT, 0);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+ libinput_dispatch(li);
+
+ /* delete the device while the timer is still active */
+ litest_delete_device(dev);
+ libinput_dispatch(li);
+
+ litest_timeout_debounce();
+ libinput_dispatch(li);
+
+ libinput_unref(li);
+}
+END_TEST
+
+START_TEST(debounce_remove_device_button_down)
+{
+ struct libinput *li;
+ struct litest_device *dev;
+
+ li = litest_create_context();
+
+ dev = litest_add_device(li, LITEST_MOUSE);
+ litest_drain_events(li);
+
+ litest_event(dev, EV_KEY, BTN_LEFT, 1);
+ litest_event(dev, EV_SYN, SYN_REPORT, 0);
+ libinput_dispatch(li);
+
+ /* delete the device the timer is still active */
+ litest_delete_device(dev);
+ libinput_dispatch(li);
+
+ litest_timeout_debounce();
+ libinput_dispatch(li);
+
+ libinput_unref(li);
+}
+END_TEST
+
TEST_COLLECTION(pointer)
{
struct range axis_range = {ABS_X, ABS_Y + 1};
@@ -2607,4 +2659,6 @@ TEST_COLLECTION(pointer)
litest_add("pointer:debounce_otherbutton", debounce_spurious_dont_enable_on_otherbutton, LITEST_BUTTON, LITEST_TOUCHPAD|LITEST_NO_DEBOUNCE);
litest_add("pointer:debounce_otherbutton", debounce_spurious_cancel_debounce_otherbutton, LITEST_BUTTON, LITEST_TOUCHPAD|LITEST_NO_DEBOUNCE);
litest_add("pointer:debounce_otherbutton", debounce_spurious_switch_to_otherbutton, LITEST_BUTTON, LITEST_TOUCHPAD|LITEST_NO_DEBOUNCE);
+ litest_add_no_device("pointer:debounce", debounce_remove_device_button_down);
+ litest_add_no_device("pointer:debounce", debounce_remove_device_button_up);
}