From c442b9fd608cd92dc14e97bc9351e5e214feb6db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 17 Oct 2013 23:04:05 +0200 Subject: [PATCH] evdev: Reference count input device's seat capabilities MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the only input device of a certain seat capability is unplugged, stop advertising the capability. Signed-off-by: Jonas Ã…dahl --- src/evdev.c | 11 +++++++++++ src/evdev.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/src/evdev.c b/src/evdev.c index 7397ea1d..eb7631a7 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -565,6 +565,7 @@ evdev_configure_device(struct evdev_device *device) if ((device->caps & (EVDEV_MOTION_ABS | EVDEV_MOTION_REL)) && (device->caps & EVDEV_BUTTON)) { weston_seat_init_pointer(device->seat); + device->seat_caps |= EVDEV_SEAT_POINTER; weston_log("input device %s, %s is a pointer caps =%s%s%s\n", device->devname, device->devnode, device->caps & EVDEV_MOTION_ABS ? " absolute-motion" : "", @@ -574,11 +575,13 @@ evdev_configure_device(struct evdev_device *device) if ((device->caps & EVDEV_KEYBOARD)) { if (weston_seat_init_keyboard(device->seat, NULL) < 0) return -1; + device->seat_caps |= EVDEV_SEAT_KEYBOARD; weston_log("input device %s, %s is a keyboard\n", device->devname, device->devnode); } if ((device->caps & EVDEV_TOUCH)) { weston_seat_init_touch(device->seat); + device->seat_caps |= EVDEV_SEAT_TOUCH; weston_log("input device %s, %s is a touch device\n", device->devname, device->devnode); } @@ -602,6 +605,7 @@ evdev_device_create(struct weston_seat *seat, const char *path, int device_fd) container_of(ec->output_list.next, struct weston_output, link); device->seat = seat; + device->seat_caps = 0; device->is_mt = 0; device->mtdev = NULL; device->devnode = strdup(path); @@ -649,6 +653,13 @@ evdev_device_destroy(struct evdev_device *device) { struct evdev_dispatch *dispatch; + if (device->seat_caps & EVDEV_SEAT_POINTER) + weston_seat_release_pointer(device->seat); + if (device->seat_caps & EVDEV_SEAT_KEYBOARD) + weston_seat_release_keyboard(device->seat); + if (device->seat_caps & EVDEV_SEAT_TOUCH) + weston_seat_release_touch(device->seat); + dispatch = device->dispatch; if (dispatch) dispatch->interface->destroy(dispatch); diff --git a/src/evdev.h b/src/evdev.h index 5e4d11ac..e146d1a4 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -49,6 +49,12 @@ enum evdev_device_capability { EVDEV_TOUCH = (1 << 4), }; +enum evdev_device_seat_capability { + EVDEV_SEAT_POINTER = (1 << 0), + EVDEV_SEAT_KEYBOARD = (1 << 1), + EVDEV_SEAT_TOUCH = (1 << 2) +}; + struct evdev_device { struct weston_seat *seat; struct wl_list link; @@ -80,6 +86,7 @@ struct evdev_device { enum evdev_event_type pending_event; enum evdev_device_capability caps; + enum evdev_device_seat_capability seat_caps; int is_mt; };