[PATCH xf86-input-libinput] Only initialize properties that match capabilities on a subdevice

Peter Hutterer peter.hutterer at who-t.net
Tue May 23 22:56:45 UTC 2017


If a device is split into multiple subdevices, usually pointer+keyboard, we
initialized properties matching the libinput device on both devices. This
results in the keyboard having e.g. a Accel Speed or Left Handed setting even
though it cannot send any events of that type.

Filter by capabilities on the subdevice so we only get those properties that
match the subdevice's capabilities.

https://bugs.freedesktop.org/show_bug.cgi?id=100900

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

diff --git a/src/xf86libinput.c b/src/xf86libinput.c
index a529385..2f6d62d 100644
--- a/src/xf86libinput.c
+++ b/src/xf86libinput.c
@@ -5257,6 +5257,19 @@ LibinputInitTabletAreaRatioProperty(DeviceIntPtr dev,
 					       2, data);
 }
 
+static inline bool
+subdevice_filter_for_capabilities(DeviceIntPtr dev,
+				  uint32_t capabilities)
+{
+	InputInfoPtr pInfo  = dev->public.devicePrivate;
+	struct xf86libinput *driver_data = pInfo->private;
+
+	if (!xf86libinput_is_subdevice(pInfo))
+		return false;
+
+	return !(driver_data->capabilities & capabilities);
+}
+
 static void
 LibinputInitProperty(DeviceIntPtr dev)
 {
@@ -5269,21 +5282,35 @@ LibinputInitProperty(DeviceIntPtr dev)
 
 	prop_float = XIGetKnownProperty("FLOAT");
 
-	LibinputInitTapProperty(dev, driver_data, device);
-	LibinputInitTapDragProperty(dev, driver_data, device);
-	LibinputInitTapDragLockProperty(dev, driver_data, device);
-	LibinputInitTapButtonmapProperty(dev, driver_data, device);
-	LibinputInitCalibrationProperty(dev, driver_data, device);
-	LibinputInitAccelProperty(dev, driver_data, device);
-	LibinputInitNaturalScrollProperty(dev, driver_data, device);
+	/* On a subdevice, we likely only have a keyboard, so filter out the
+	 * properties for the capabilities we don't have */
+	if (!subdevice_filter_for_capabilities(dev, CAP_POINTER|CAP_TOUCH)) {
+		LibinputInitTapProperty(dev, driver_data, device);
+		LibinputInitTapDragProperty(dev, driver_data, device);
+		LibinputInitTapDragLockProperty(dev, driver_data, device);
+		LibinputInitTapButtonmapProperty(dev, driver_data, device);
+		LibinputInitNaturalScrollProperty(dev, driver_data, device);
+	}
+
+	if (!subdevice_filter_for_capabilities(dev, CAP_TOUCH|CAP_TABLET)) {
+		LibinputInitCalibrationProperty(dev, driver_data, device);
+		LibinputInitLeftHandedProperty(dev, driver_data, device);
+		LibinputInitAccelProperty(dev, driver_data, device);
+	}
+
+	if (!subdevice_filter_for_capabilities(dev, CAP_POINTER)) {
+		LibinputInitScrollMethodsProperty(dev, driver_data, device);
+		LibinputInitClickMethodsProperty(dev, driver_data, device);
+		LibinputInitMiddleEmulationProperty(dev, driver_data, device);
+		LibinputInitRotationAngleProperty(dev, driver_data, device);
+	}
+
+	if (!subdevice_filter_for_capabilities(dev, CAP_TABLET_PAD)) {
+		LibinputInitModeGroupProperties(dev, driver_data, device);
+	}
+
 	LibinputInitSendEventsProperty(dev, driver_data, device);
-	LibinputInitLeftHandedProperty(dev, driver_data, device);
-	LibinputInitScrollMethodsProperty(dev, driver_data, device);
-	LibinputInitClickMethodsProperty(dev, driver_data, device);
-	LibinputInitMiddleEmulationProperty(dev, driver_data, device);
 	LibinputInitDisableWhileTypingProperty(dev, driver_data, device);
-	LibinputInitModeGroupProperties(dev, driver_data, device);
-	LibinputInitRotationAngleProperty(dev, driver_data, device);
 
 	/* Device node property, read-only  */
 	device_node = driver_data->path;
-- 
2.13.0



More information about the xorg-devel mailing list