diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2017-05-24 08:42:02 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2017-05-29 08:15:20 +1000 |
commit | 87f9fe3a6fafe60134c69419c0e551b9dbc112b7 (patch) | |
tree | f6e3a18de8f15ebebeb0418e31c9c630b48c98e5 /src | |
parent | 0c657e0dcff4cff06a0d4cbea7dfac2a1d505cc3 (diff) |
Only initialize properties that match capabilities on a subdevice
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 settings 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@who-t.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/xf86libinput.c | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/src/xf86libinput.c b/src/xf86libinput.c index 8e63fd6..fa31b78 100644 --- a/src/xf86libinput.c +++ b/src/xf86libinput.c @@ -5231,6 +5231,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) { @@ -5243,21 +5256,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; |