touchpad: Use remove callback to unlink event listener and stop timers
authorHans de Goede <hdegoede@redhat.com>
Fri, 5 Dec 2014 11:50:39 +0000 (12:50 +0100)
committerHans de Goede <hdegoede@redhat.com>
Tue, 9 Dec 2014 08:55:36 +0000 (09:55 +0100)
commit36017fbd3c87aca01dd978f2b65bf634885fd8bc
treeca9d97a114b614d65b331171ae4b860405f461ae
parent4a971a69cff5ff05350e05920f4a917393667050
touchpad: Use remove callback to unlink event listener and stop timers

We use 2 mechanisms to unregister the trackpoint event listener depending on
device removal order.

1) We have a device_removed callback, if the trackpoint gets removed before
the touchpad, this gets called, sees the device being removed is the trackpoint
and unregisters the listener

2) If the touchpad gets removed first, then in tp_destroy we unregister the
listener

2) May be delayed beyond the destruction of the trackpoint itself if the
libinput user has a reference to the libinput_device for the touchpad.
When this happens the trackpoint still has an eventlistener at destroy time
and an assert triggers.

To fix this we must do 2) at the same time as we do 1), so at remove time.

While working on this I noticed that the touchpad code was also cancelling
timers at destroy time rather then remove time, which means that they may
expire between remove and destroy time, and cause events to be emitted from
a removed device, so this commit moves the cancelling of the timers to the
remove callback as well.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
src/evdev-mt-touchpad-buttons.c
src/evdev-mt-touchpad-edge-scroll.c
src/evdev-mt-touchpad-tap.c
src/evdev-mt-touchpad.c
src/evdev-mt-touchpad.h