[PATCH libinput v2 1/2] evdev: Add a remove callback to the evdev_dispatch_interface

Peter Hutterer peter.hutterer at who-t.net
Mon Dec 8 15:35:36 PST 2014


On Mon, Dec 08, 2014 at 10:46:43AM +0100, Hans de Goede wrote:
> Some dispatchers may want to do some cleanup at remove time, rather then at
> destroy time.
> 
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  src/evdev-mt-touchpad.c | 1 +
>  src/evdev.c             | 4 ++++
>  src/evdev.h             | 3 +++
>  3 files changed, 8 insertions(+)
> 
> diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c
> index ad6b377..5af0062 100644
> --- a/src/evdev-mt-touchpad.c
> +++ b/src/evdev-mt-touchpad.c
> @@ -863,6 +863,7 @@ tp_tag_device(struct evdev_device *device,
>  
>  static struct evdev_dispatch_interface tp_interface = {
>  	tp_process,
> +	NULL, /* remove */
>  	tp_destroy,
>  	tp_device_added,
>  	tp_device_removed,
> diff --git a/src/evdev.c b/src/evdev.c
> index fbfbcd3..4490562 100644
> --- a/src/evdev.c
> +++ b/src/evdev.c
> @@ -737,6 +737,7 @@ evdev_calibration_get_default_matrix(struct libinput_device *libinput_device,
>  
>  struct evdev_dispatch_interface fallback_interface = {
>  	fallback_process,
> +	NULL, /* remove */
>  	fallback_destroy,
>  	NULL, /* device_added */
>  	NULL, /* device_removed */
> @@ -2039,6 +2040,9 @@ evdev_device_remove(struct evdev_device *device)
>  			d->dispatch->interface->device_removed(d, device);
>  	}
>  
> +	if (device->dispatch->interface->remove)
> +		device->dispatch->interface->remove(device->dispatch);
> +
>  	evdev_device_suspend(device);

I wonder, logically wouldn't it make more sense to suspend first and then
call the remove callback?

Cheers,
   Peter

>  
>  	/* A device may be removed while suspended, mark it to
> diff --git a/src/evdev.h b/src/evdev.h
> index 033d455..820fdcc 100644
> --- a/src/evdev.h
> +++ b/src/evdev.h
> @@ -166,6 +166,9 @@ struct evdev_dispatch_interface {
>  			struct input_event *event,
>  			uint64_t time);
>  
> +	/* Device is being removed (may be NULL) */
> +	void (*remove)(struct evdev_dispatch *dispatch);
> +
>  	/* Destroy an event dispatch handler and free all its resources. */
>  	void (*destroy)(struct evdev_dispatch *dispatch);
>  
> -- 
> 2.1.0
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> 


More information about the wayland-devel mailing list