Skip to content

Commit

Permalink
touchpad: remove the lid switch listener on device_removed
Browse files Browse the repository at this point in the history
Sequence triggered by the xorg driver, but basically: if the touchpad is
destroyed before the lid switch, the event listener wasn't removed and an
assertion was triggered.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
(cherry picked from commit 9d1fdb0)
  • Loading branch information
whot committed May 11, 2017
1 parent 4d6545a commit ae4384d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/evdev-mt-touchpad.c
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,12 @@ tp_interface_device_removed(struct evdev_device *device,
tp->dwt.keyboard = NULL;
}

if (removed_device == tp->lid_switch.lid_switch) {
libinput_device_remove_event_listener(
&tp->lid_switch.lid_switch_listener);
tp->lid_switch.lid_switch = NULL;
}

if (tp->sendevents.current_mode !=
LIBINPUT_CONFIG_SEND_EVENTS_DISABLED_ON_EXTERNAL_MOUSE)
return;
Expand Down
26 changes: 26 additions & 0 deletions test/test-lid.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,30 @@ START_TEST(lid_open_on_key_touchpad_enabled)
}
END_TEST

START_TEST(lid_suspend_with_touchpad)
{
struct libinput *li;
struct litest_device *touchpad, *sw;

li = litest_create_context();

sw = litest_add_device(li, LITEST_LID_SWITCH);
litest_drain_events(li);

touchpad = litest_add_device(li, LITEST_SYNAPTICS_I2C);
litest_delete_device(touchpad);
touchpad = litest_add_device(li, LITEST_SYNAPTICS_I2C);
litest_drain_events(li);

litest_delete_device(sw);
litest_drain_events(li);
litest_delete_device(touchpad);
litest_drain_events(li);

libinput_unref(li);
}
END_TEST

START_TEST(lid_update_hw_on_key)
{
struct litest_device *sw = litest_current_device();
Expand Down Expand Up @@ -469,5 +493,7 @@ litest_setup_tests_lid(void)
litest_add("lid:keyboard", lid_open_on_key, LITEST_SWITCH, LITEST_ANY);
litest_add("lid:keyboard", lid_open_on_key_touchpad_enabled, LITEST_SWITCH, LITEST_ANY);

litest_add_no_device("lid:disable_touchpad", lid_suspend_with_touchpad);

litest_add_for_device("lid:buggy", lid_update_hw_on_key, LITEST_LID_SWITCH_SURFACE3);
}

0 comments on commit ae4384d

Please sign in to comment.