From 6b557a70474286dbc9eb4c0301caa4b6098b532e Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Tue, 5 May 2015 15:01:52 -0500 Subject: [PATCH] input: make a function for device removal Break device_removed() out into its own function like device_added(). Signed-off-by: Derek Foreman Reviewed-by: Bryce Harrington --- src/libinput-seat.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/libinput-seat.c b/src/libinput-seat.c index ce79d34e..6353667f 100644 --- a/src/libinput-seat.c +++ b/src/libinput-seat.c @@ -99,6 +99,14 @@ device_added(struct udev_input *input, struct libinput_device *libinput_device) weston_seat_repick(seat); } +static void +device_removed(struct udev_input *input, struct libinput_device *libinput_device) +{ + struct evdev_device *device; + device = libinput_device_get_user_data(libinput_device); + evdev_device_destroy(device); +} + static void udev_seat_remove_devices(struct udev_seat *seat) { @@ -127,7 +135,6 @@ udev_input_process_event(struct libinput_event *event) struct libinput_device *libinput_device = libinput_event_get_device(event); struct udev_input *input = libinput_get_user_data(libinput); - struct evdev_device *device; int handled = 1; switch (libinput_event_get_type(event)) { @@ -135,8 +142,7 @@ udev_input_process_event(struct libinput_event *event) device_added(input, libinput_device); break; case LIBINPUT_EVENT_DEVICE_REMOVED: - device = libinput_device_get_user_data(libinput_device); - evdev_device_destroy(device); + device_removed(input, libinput_device); break; default: handled = 0;