mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-09 15:18:06 +02:00
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>
(cherry picked from commit 1f3f681fa7)
This commit is contained in:
parent
0fa22c8c5a
commit
e3034096c1
3 changed files with 60 additions and 3 deletions
|
|
@ -1012,6 +1012,9 @@ fallback_interface_remove(struct evdev_dispatch *evdev_dispatch)
|
||||||
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
|
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
|
||||||
struct evdev_paired_keyboard *kbd, *tmp;
|
struct evdev_paired_keyboard *kbd, *tmp;
|
||||||
|
|
||||||
|
libinput_timer_cancel(&dispatch->debounce.timer);
|
||||||
|
libinput_timer_cancel(&dispatch->debounce.timer_short);
|
||||||
|
|
||||||
libinput_device_remove_event_listener(&dispatch->tablet_mode.other.listener);
|
libinput_device_remove_event_listener(&dispatch->tablet_mode.other.listener);
|
||||||
|
|
||||||
list_for_each_safe(kbd,
|
list_for_each_safe(kbd,
|
||||||
|
|
@ -1081,10 +1084,9 @@ fallback_interface_destroy(struct evdev_dispatch *evdev_dispatch)
|
||||||
{
|
{
|
||||||
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
|
struct fallback_dispatch *dispatch = fallback_dispatch(evdev_dispatch);
|
||||||
|
|
||||||
libinput_timer_cancel(&dispatch->debounce.timer);
|
|
||||||
libinput_timer_destroy(&dispatch->debounce.timer);
|
libinput_timer_destroy(&dispatch->debounce.timer);
|
||||||
libinput_timer_cancel(&dispatch->debounce.timer_short);
|
|
||||||
libinput_timer_destroy(&dispatch->debounce.timer_short);
|
libinput_timer_destroy(&dispatch->debounce.timer_short);
|
||||||
|
|
||||||
free(dispatch->mt.slots);
|
free(dispatch->mt.slots);
|
||||||
free(dispatch);
|
free(dispatch);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1786,6 +1786,8 @@ tp_interface_remove(struct evdev_dispatch *dispatch)
|
||||||
{
|
{
|
||||||
struct tp_dispatch *tp = tp_dispatch(dispatch);
|
struct tp_dispatch *tp = tp_dispatch(dispatch);
|
||||||
|
|
||||||
|
libinput_timer_cancel(&tp->arbitration.arbitration_timer);
|
||||||
|
|
||||||
tp_remove_tap(tp);
|
tp_remove_tap(tp);
|
||||||
tp_remove_buttons(tp);
|
tp_remove_buttons(tp);
|
||||||
tp_remove_sendevents(tp);
|
tp_remove_sendevents(tp);
|
||||||
|
|
@ -1798,7 +1800,6 @@ tp_interface_destroy(struct evdev_dispatch *dispatch)
|
||||||
{
|
{
|
||||||
struct tp_dispatch *tp = tp_dispatch(dispatch);
|
struct tp_dispatch *tp = tp_dispatch(dispatch);
|
||||||
|
|
||||||
libinput_timer_cancel(&tp->arbitration.arbitration_timer);
|
|
||||||
libinput_timer_destroy(&tp->arbitration.arbitration_timer);
|
libinput_timer_destroy(&tp->arbitration.arbitration_timer);
|
||||||
libinput_timer_destroy(&tp->palm.trackpoint_timer);
|
libinput_timer_destroy(&tp->palm.trackpoint_timer);
|
||||||
libinput_timer_destroy(&tp->dwt.keyboard_timer);
|
libinput_timer_destroy(&tp->dwt.keyboard_timer);
|
||||||
|
|
|
||||||
|
|
@ -2533,6 +2533,58 @@ START_TEST(debounce_spurious_switch_to_otherbutton)
|
||||||
}
|
}
|
||||||
END_TEST
|
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)
|
TEST_COLLECTION(pointer)
|
||||||
{
|
{
|
||||||
struct range axis_range = {ABS_X, ABS_Y + 1};
|
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_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_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("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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue