Commit 17826b06 authored by Peter Hutterer's avatar Peter Hutterer

Keep track of the enabled devices

All libinput devices share the same file descriptor so make sure we don't
remove from the server's select loop until the last device is disabled.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent 54da5169
......@@ -54,6 +54,7 @@
struct xf86libinput_driver {
struct libinput *libinput;
int device_count;
int device_enabled_count;
};
static struct xf86libinput_driver driver_context;
......@@ -91,8 +92,13 @@ xf86libinput_on(DeviceIntPtr dev)
driver_data->device = device;
pInfo->fd = libinput_get_fd(libinput);
/* Can't use xf86AddEnabledDevice on an epollfd */
AddEnabledDevice(pInfo->fd);
if (driver_context.device_enabled_count == 0) {
/* Can't use xf86AddEnabledDevice on an epollfd */
AddEnabledDevice(pInfo->fd);
}
driver_context.device_enabled_count++;
dev->public.on = TRUE;
return Success;
......@@ -104,7 +110,10 @@ xf86libinput_off(DeviceIntPtr dev)
InputInfoPtr pInfo = dev->public.devicePrivate;
struct xf86libinput *driver_data = pInfo->private;
RemoveEnabledDevice(pInfo->fd);
if (--driver_context.device_enabled_count == 0) {
RemoveEnabledDevice(pInfo->fd);
}
pInfo->fd = -1;
dev->public.on = FALSE;
......@@ -433,6 +442,9 @@ xf86libinput_handle_event(struct libinput_event *event)
device = libinput_event_get_device(event);
pInfo = libinput_device_get_user_data(device);
if (pInfo && !pInfo->dev->public.on)
return;
switch (libinput_event_get_type(event)) {
case LIBINPUT_EVENT_NONE:
case LIBINPUT_EVENT_DEVICE_ADDED:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment