From a64cbc8d91a00e75f4822498808ba1ffd90bb9bb Mon Sep 17 00:00:00 2001 From: Poor Yorick <201906libinput@pooryorick.com> Date: Tue, 2 Jul 2019 11:00:58 +0200 Subject: [PATCH 1/4] Make drag lock timeout a configurable option. --- include/libinput-properties.h | 3 ++ src/xf86libinput.c | 70 +++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/include/libinput-properties.h b/include/libinput-properties.h index a701316..bf6fe9f 100644 --- a/include/libinput-properties.h +++ b/include/libinput-properties.h @@ -42,6 +42,9 @@ /* Tap drag lock default enabled/disabled: BOOL, 1 value, read-only */ #define LIBINPUT_PROP_TAP_DRAG_LOCK_DEFAULT "libinput Tapping Drag Lock Enabled Default" +/* Tap drag lock timeout in milliseonds: INT 300 */ +#define LIBINPUT_PROP_TAP_DRAG_LOCK_TIMEOUT "libinput Tapping Drag Lock Timeout" + /* Tap button order: BOOL, 2 values in order LRM, LMR, only one may be set at any time */ #define LIBINPUT_PROP_TAP_BUTTONMAP "libinput Tapping Button Mapping Enabled" diff --git a/src/xf86libinput.c b/src/xf86libinput.c index 5792224..6bbc4a8 100644 --- a/src/xf86libinput.c +++ b/src/xf86libinput.c @@ -150,6 +150,7 @@ struct xf86libinput { BOOL tapping; BOOL tap_drag; BOOL tap_drag_lock; + int tap_drag_lock_timeout; enum libinput_config_tap_button_map tap_button_map; BOOL natural_scrolling; BOOL left_handed; @@ -593,6 +594,15 @@ LibinputApplyConfigTap(DeviceIntPtr dev, "Failed to set Tapping DragLock to %d\n", driver_data->options.tap_drag_lock); + + + if (libinput_device_config_tap_get_finger_count(device) > 0 && + libinput_device_config_tap_set_drag_lock_timeout(device, + driver_data->options.tap_drag_lock_timeout) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping DragLock Timeout to %d\n", + driver_data->options.tap_drag_lock_timeout); + if (libinput_device_config_tap_get_finger_count(device) > 0 && libinput_device_config_tap_set_drag_enabled(device, driver_data->options.tap_drag) != LIBINPUT_CONFIG_STATUS_SUCCESS) @@ -3342,6 +3352,9 @@ xf86libinput_pre_init(InputDriverPtr drv, pInfo->switch_mode = NULL; driver_data = calloc(1, sizeof(*driver_data)); + + driver_data->options.tap_drag_lock_timeout = 300; + if (!driver_data) goto fail; @@ -3541,6 +3554,7 @@ static Atom prop_tap_drag; static Atom prop_tap_drag_default; static Atom prop_tap_drag_lock; static Atom prop_tap_drag_lock_default; +static Atom prop_tap_drag_lock_timeout; static Atom prop_tap_buttonmap; static Atom prop_tap_buttonmap_default; static Atom prop_calibration; @@ -3795,6 +3809,39 @@ LibinputSetPropertyTapDragLock(DeviceIntPtr dev, return Success; } +static inline int +LibinputSetPropertyTapDragLockTimeout(DeviceIntPtr dev, + Atom atom, + XIPropertyValuePtr val, + BOOL checkonly) +{ + InputInfoPtr pInfo = dev->public.devicePrivate; + struct xf86libinput *driver_data = pInfo->private; + struct libinput_device *device = driver_data->shared_device->device; + int* data; + + + if (val->format != 32 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + + data = (int*)val->data; + if (checkonly) { + if (*data < -1 || *data > 65535) + return BadValue; + + if (!xf86libinput_check_device(dev, atom)) + return BadMatch; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return BadMatch; + } else { + driver_data->options.tap_drag_lock_timeout = *data; + } + + return Success; +} + + static inline int LibinputSetPropertyTapButtonmap(DeviceIntPtr dev, Atom atom, @@ -4494,6 +4541,8 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, rc = LibinputSetPropertyTapDrag(dev, atom, val, checkonly); else if (atom == prop_tap_drag_lock) rc = LibinputSetPropertyTapDragLock(dev, atom, val, checkonly); + else if (atom == prop_tap_drag_lock_timeout) + rc = LibinputSetPropertyTapDragLockTimeout(dev, atom, val, checkonly); else if (atom == prop_tap_buttonmap) rc = LibinputSetPropertyTapButtonmap(dev, atom, val, checkonly); else if (atom == prop_calibration) @@ -4677,6 +4726,26 @@ LibinputInitTapDragLockProperty(DeviceIntPtr dev, 1, &drag_lock); } + +static void +LibinputInitTapDragLockTimeoutProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + int drag_lock = driver_data->options.tap_drag_lock_timeout; + + if (!subdevice_has_capabilities(dev, CAP_POINTER)) + return; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return; + + prop_tap_drag_lock_timeout = LibinputMakeProperty(dev, + LIBINPUT_PROP_TAP_DRAG_LOCK_TIMEOUT, + XA_INTEGER, 32, + 1, &drag_lock); +} + static void LibinputInitTapButtonmapProperty(DeviceIntPtr dev, struct xf86libinput *driver_data, @@ -5464,6 +5533,7 @@ LibinputInitProperty(DeviceIntPtr dev) LibinputInitTapProperty(dev, driver_data, device); LibinputInitTapDragProperty(dev, driver_data, device); LibinputInitTapDragLockProperty(dev, driver_data, device); + LibinputInitTapDragLockTimeoutProperty(dev, driver_data ,device); LibinputInitTapButtonmapProperty(dev, driver_data, device); LibinputInitNaturalScrollProperty(dev, driver_data, device); LibinputInitDisableWhileTypingProperty(dev, driver_data, device); -- GitLab From b70fda73615321783cb57cdec09d20e72f997e13 Mon Sep 17 00:00:00 2001 From: Poor Yorick <201906libinput@pooryorick.com> Date: Tue, 2 Jul 2019 14:48:56 +0200 Subject: [PATCH 2/4] Use the libinput drag log timeout default to initialize the corresponding property --- src/xf86libinput.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/xf86libinput.c b/src/xf86libinput.c index 6bbc4a8..b3ed096 100644 --- a/src/xf86libinput.c +++ b/src/xf86libinput.c @@ -3353,8 +3353,6 @@ xf86libinput_pre_init(InputDriverPtr drv, driver_data = calloc(1, sizeof(*driver_data)); - driver_data->options.tap_drag_lock_timeout = 300; - if (!driver_data) goto fail; @@ -3393,6 +3391,7 @@ xf86libinput_pre_init(InputDriverPtr drv, if (!parent_driver_data) /* parent already removed again */ goto fail; + xf86IDrvMsg(pInfo, X_INFO, "is a virtual subdevice\n"); shared_device = xf86libinput_shared_ref(parent_driver_data->shared_device); device = shared_device->device; @@ -4697,6 +4696,9 @@ LibinputInitTapDragProperty(DeviceIntPtr dev, LIBINPUT_PROP_TAP_DRAG_DEFAULT, XA_INTEGER, 8, 1, &drag); + driver_data->options.tap_drag_lock_timeout + = libinput_device_config_tap_get_default_drag_lock_timeout(device); + } static void -- GitLab From 18683e6ff4d2bce7ba75db3a1d1d1ffb2042da24 Mon Sep 17 00:00:00 2001 From: Poor Yorick <201906libinput@pooryorick.com> Date: Wed, 3 Jul 2019 18:03:03 +0200 Subject: [PATCH 3/4] Finish X configuration option handling for TapDragLockTimeout --- src/xf86libinput.c | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/src/xf86libinput.c b/src/xf86libinput.c index b3ed096..b7a17c5 100644 --- a/src/xf86libinput.c +++ b/src/xf86libinput.c @@ -595,7 +595,6 @@ LibinputApplyConfigTap(DeviceIntPtr dev, driver_data->options.tap_drag_lock); - if (libinput_device_config_tap_get_finger_count(device) > 0 && libinput_device_config_tap_set_drag_lock_timeout(device, driver_data->options.tap_drag_lock_timeout) != LIBINPUT_CONFIG_STATUS_SUCCESS) @@ -2550,6 +2549,32 @@ xf86libinput_parse_tap_drag_lock_option(InputInfoPtr pInfo, return drag_lock; } +static inline int +xf86libinput_parse_tap_drag_lock_timeout_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + int drag_lock_timeout; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return FALSE; + + + drag_lock_timeout = xf86SetIntOption(pInfo->options, + "TappingDragLockTimeout", + libinput_device_config_tap_get_default_drag_lock_timeout(device) + ); + + if (libinput_device_config_tap_set_drag_lock_timeout(device, drag_lock_timeout) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping Drag Lock Timeout to %d\n", + drag_lock_timeout); + } + + + return drag_lock_timeout; +} + static inline enum libinput_config_tap_button_map xf86libinput_parse_tap_buttonmap_option(InputInfoPtr pInfo, struct libinput_device *device) @@ -3103,6 +3128,7 @@ xf86libinput_parse_options(InputInfoPtr pInfo, options->tapping = xf86libinput_parse_tap_option(pInfo, device); options->tap_drag = xf86libinput_parse_tap_drag_option(pInfo, device); options->tap_drag_lock = xf86libinput_parse_tap_drag_lock_option(pInfo, device); + options->tap_drag_lock_timeout = xf86libinput_parse_tap_drag_lock_timeout_option(pInfo, device); options->tap_button_map = xf86libinput_parse_tap_buttonmap_option(pInfo, device); options->speed = xf86libinput_parse_accel_option(pInfo, device); options->accel_profile = xf86libinput_parse_accel_profile_option(pInfo, device); @@ -4696,8 +4722,6 @@ LibinputInitTapDragProperty(DeviceIntPtr dev, LIBINPUT_PROP_TAP_DRAG_DEFAULT, XA_INTEGER, 8, 1, &drag); - driver_data->options.tap_drag_lock_timeout - = libinput_device_config_tap_get_default_drag_lock_timeout(device); } @@ -4726,6 +4750,7 @@ LibinputInitTapDragLockProperty(DeviceIntPtr dev, LIBINPUT_PROP_TAP_DRAG_LOCK_DEFAULT, XA_INTEGER, 8, 1, &drag_lock); + } @@ -4734,18 +4759,20 @@ LibinputInitTapDragLockTimeoutProperty(DeviceIntPtr dev, struct xf86libinput *driver_data, struct libinput_device *device) { - int drag_lock = driver_data->options.tap_drag_lock_timeout; - if (!subdevice_has_capabilities(dev, CAP_POINTER)) return; if (libinput_device_config_tap_get_finger_count(device) == 0) return; + int drag_lock_timeout + = libinput_device_config_tap_get_drag_lock_timeout(device); + + prop_tap_drag_lock_timeout = LibinputMakeProperty(dev, LIBINPUT_PROP_TAP_DRAG_LOCK_TIMEOUT, XA_INTEGER, 32, - 1, &drag_lock); + 1, &drag_lock_timeout); } static void -- GitLab From 954cc70ebee989549790f0750bb02ef0b14a244d Mon Sep 17 00:00:00 2001 From: Poor Yorick <201906libinput@pooryorick.com> Date: Tue, 9 Jul 2019 10:30:07 +0200 Subject: [PATCH 4/4] Add prop_tap_drag_lock_timeout_default, and a few cleanup changes. --- include/libinput-properties.h | 5 ++++- src/xf86libinput.c | 17 +++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/include/libinput-properties.h b/include/libinput-properties.h index bf6fe9f..30555c4 100644 --- a/include/libinput-properties.h +++ b/include/libinput-properties.h @@ -42,9 +42,12 @@ /* Tap drag lock default enabled/disabled: BOOL, 1 value, read-only */ #define LIBINPUT_PROP_TAP_DRAG_LOCK_DEFAULT "libinput Tapping Drag Lock Enabled Default" -/* Tap drag lock timeout in milliseonds: INT 300 */ +/* Tap drag lock timeout in milliseonds: INT 1 value */ #define LIBINPUT_PROP_TAP_DRAG_LOCK_TIMEOUT "libinput Tapping Drag Lock Timeout" +/* Tap drag lock timeout in milliseonds: INT 1 value */ +#define LIBINPUT_PROP_TAP_DRAG_LOCK_TIMEOUT_DEFAULT "libinput Tapping Drag Lock Timeout Default" + /* Tap button order: BOOL, 2 values in order LRM, LMR, only one may be set at any time */ #define LIBINPUT_PROP_TAP_BUTTONMAP "libinput Tapping Button Mapping Enabled" diff --git a/src/xf86libinput.c b/src/xf86libinput.c index b7a17c5..929f689 100644 --- a/src/xf86libinput.c +++ b/src/xf86libinput.c @@ -2558,7 +2558,6 @@ xf86libinput_parse_tap_drag_lock_timeout_option(InputInfoPtr pInfo, if (libinput_device_config_tap_get_finger_count(device) == 0) return FALSE; - drag_lock_timeout = xf86SetIntOption(pInfo->options, "TappingDragLockTimeout", libinput_device_config_tap_get_default_drag_lock_timeout(device) @@ -2571,7 +2570,6 @@ xf86libinput_parse_tap_drag_lock_timeout_option(InputInfoPtr pInfo, drag_lock_timeout); } - return drag_lock_timeout; } @@ -3580,6 +3578,7 @@ static Atom prop_tap_drag_default; static Atom prop_tap_drag_lock; static Atom prop_tap_drag_lock_default; static Atom prop_tap_drag_lock_timeout; +static Atom prop_tap_drag_lock_timeout_default; static Atom prop_tap_buttonmap; static Atom prop_tap_buttonmap_default; static Atom prop_calibration; @@ -3851,7 +3850,7 @@ LibinputSetPropertyTapDragLockTimeout(DeviceIntPtr dev, data = (int*)val->data; if (checkonly) { - if (*data < -1 || *data > 65535) + if (*data < 0 || *data > 65535) return BadValue; if (!xf86libinput_check_device(dev, atom)) @@ -4759,13 +4758,15 @@ LibinputInitTapDragLockTimeoutProperty(DeviceIntPtr dev, struct xf86libinput *driver_data, struct libinput_device *device) { + int drag_lock_timeout; + if (!subdevice_has_capabilities(dev, CAP_POINTER)) return; if (libinput_device_config_tap_get_finger_count(device) == 0) return; - int drag_lock_timeout + drag_lock_timeout = libinput_device_config_tap_get_drag_lock_timeout(device); @@ -4773,6 +4774,14 @@ LibinputInitTapDragLockTimeoutProperty(DeviceIntPtr dev, LIBINPUT_PROP_TAP_DRAG_LOCK_TIMEOUT, XA_INTEGER, 32, 1, &drag_lock_timeout); + + if (!prop_tap_drag_lock_timeout) + return; + drag_lock_timeout = libinput_device_config_tap_get_default_drag_lock_timeout(device); + prop_tap_drag_lock_timeout_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_TAP_DRAG_LOCK_TIMEOUT_DEFAULT, + XA_INTEGER, 32, + 1, &drag_lock_timeout); } static void -- GitLab