[PATCH xf86-input-libinput] Ensure parent devices are actual parent devices

Peter Hutterer peter.hutterer at who-t.net
Mon Aug 15 00:57:27 UTC 2016


The list returned by xf86FirstLocalDevice() includes our own device. If the
parent device is removed before the hotplug callback is invoked, the first
match with the same shared-device ID is our own device (or potentially another
subdevice on the same already-removed parent). Avoid this by making sure the
matched device is actually a parent device.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 src/xf86libinput.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index 3bab392..d661fb2 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -214,6 +214,19 @@ btn_xorg2linux(unsigned int b)
 	return button;
 }
 
+static BOOL
+xf86libinput_is_subdevice(InputInfoPtr pInfo)
+{
+	char *source;
+	BOOL is_subdevice;
+
+	source = xf86SetStrOption(pInfo->options, "_source", "");
+	is_subdevice = strcmp(source, "_driver/libinput") == 0;
+	free(source);
+
+	return is_subdevice;
+}
+
 static inline InputInfoPtr
 xf86libinput_get_parent(InputInfoPtr pInfo)
 {
@@ -228,7 +241,7 @@ xf86libinput_get_parent(InputInfoPtr pInfo)
 		int id = xf86CheckIntOption(parent->options,
 					    "_libinput/shared-device",
 					    -1);
-		if (id == parent_id)
+		if (id == parent_id && !xf86libinput_is_subdevice(parent))
 			return parent;
 	}
 
@@ -2473,19 +2486,6 @@ xf86libinput_create_subdevice(InputInfoPtr pInfo,
 	return NULL;
 }
 
-static BOOL
-xf86libinput_is_subdevice(InputInfoPtr pInfo)
-{
-	char *source;
-	BOOL is_subdevice;
-
-	source = xf86SetStrOption(pInfo->options, "_source", "");
-	is_subdevice = strcmp(source, "_driver/libinput") == 0;
-	free(source);
-
-	return is_subdevice;
-}
-
 static inline uint32_t
 caps_from_options(InputInfoPtr pInfo)
 {
-- 
2.7.4



More information about the xorg-devel mailing list