diff --git a/include/libinput-properties.h b/include/libinput-properties.h index a701316890d3d45511199f40207145bb08de4b4f..30555c4c70f7a34be0478e6bdf4eb89e37b138ae 100644 --- a/include/libinput-properties.h +++ b/include/libinput-properties.h @@ -42,6 +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 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 579222485ece745be59ecae854d9053eea90e6f1..929f689d2bda28430ed4188b16cf916c5569441a 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,14 @@ 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) @@ -2540,6 +2549,30 @@ 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) @@ -3093,6 +3126,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); @@ -3342,6 +3376,7 @@ xf86libinput_pre_init(InputDriverPtr drv, pInfo->switch_mode = NULL; driver_data = calloc(1, sizeof(*driver_data)); + if (!driver_data) goto fail; @@ -3380,6 +3415,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; @@ -3541,6 +3577,8 @@ 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_drag_lock_timeout_default; static Atom prop_tap_buttonmap; static Atom prop_tap_buttonmap_default; static Atom prop_calibration; @@ -3795,6 +3833,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 < 0 || *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 +4565,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) @@ -4648,6 +4721,7 @@ LibinputInitTapDragProperty(DeviceIntPtr dev, LIBINPUT_PROP_TAP_DRAG_DEFAULT, XA_INTEGER, 8, 1, &drag); + } static void @@ -4675,6 +4749,39 @@ LibinputInitTapDragLockProperty(DeviceIntPtr dev, LIBINPUT_PROP_TAP_DRAG_LOCK_DEFAULT, XA_INTEGER, 8, 1, &drag_lock); + +} + + +static void +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; + + 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_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 @@ -5464,6 +5571,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);