[PATCH xf86-input-libinput] Use xf86AddEnabledDevice instead of AddEnabledDevice when threaded [v2]

Keith Packard keithp at keithp.com
Mon May 30 08:00:36 UTC 2016


libinput can't run at SIGIO time, so it has been using
AddEnabledDevice to run in non-signal context.

Threaded input runs all input in non-signal context, so we want to use
xf86AddEnabledDevice at last.

v2: use XINPUT ABI version check instead of testing for presence of
    AddEnabledDevice, which can't get removed from the server until
    a few more patches past the threaded input change are merged.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 src/xf86libinput.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index 7034796..4af8cb4 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -55,6 +55,10 @@
 #undef HAVE_VMASK_UNACCEL
 #endif
 
+#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 23
+#define HAVE_THREADED_INPUT	1
+#endif
+
 #define TOUCHPAD_NUM_AXES 4 /* x, y, hscroll, vscroll */
 #define TABLET_NUM_BUTTONS 7 /* we need scroll buttons */
 #define TOUCH_MAX_SLOTS 15
@@ -522,8 +526,12 @@ xf86libinput_on(DeviceIntPtr dev)
 	pInfo->fd = libinput_get_fd(libinput);
 
 	if (driver_context.device_enabled_count == 0) {
+#if HAVE_THREADED_INPUT
+		xf86AddEnabledDevice(pInfo);
+#else
 		/* Can't use xf86AddEnabledDevice on an epollfd */
 		AddEnabledDevice(pInfo->fd);
+#endif
 	}
 
 	driver_context.device_enabled_count++;
@@ -542,7 +550,11 @@ xf86libinput_off(DeviceIntPtr dev)
 	struct xf86libinput_device *shared_device = driver_data->shared_device;
 
 	if (--driver_context.device_enabled_count == 0) {
+#if HAVE_THREADED_INPUT
+		xf86RemoveEnabledDevice(pInfo);
+#else
 		RemoveEnabledDevice(pInfo->fd);
+#endif
 	}
 
 	if (use_server_fd(pInfo)) {
@@ -2522,6 +2534,9 @@ xf86libinput_pre_init(InputDriverPtr drv,
 	pInfo->read_input = xf86libinput_read_input;
 	pInfo->control_proc = NULL;
 	pInfo->switch_mode = NULL;
+#ifdef XI86_SIGNAL_IO
+	pInfo->flags &= ~XI86_SIGNAL_IO;
+#endif
 
 	driver_data = calloc(1, sizeof(*driver_data));
 	if (!driver_data)
-- 
2.8.1



More information about the xorg-devel mailing list