mirror of
https://github.com/X11Libre/xf86-input-libinput.git
synced 2026-03-25 09:59:16 +00:00
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 <peter.hutterer@who-t.net>
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user