diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2015-07-08 10:31:30 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2015-07-09 11:08:23 +1000 |
commit | bfedf7dbac7e92479629713c3f5622e4f19de1f4 (patch) | |
tree | 3f89fe42748c95460a4e47002f3dc9429f4aadb2 | |
parent | 9c5cf971439292661e1f3055ef882526baae6310 (diff) |
Add a property for tap drag lock
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | include/libinput-properties.h | 6 | ||||
-rw-r--r-- | man/libinput.man | 9 | ||||
-rw-r--r-- | src/libinput.c | 94 |
4 files changed, 110 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index e477ffd..5faaa36 100644 --- a/configure.ac +++ b/configure.ac @@ -45,7 +45,7 @@ XORG_DEFAULT_OPTIONS # Obtain compiler/linker options from server and required extensions PKG_CHECK_MODULES(XORG, [xorg-server >= 1.10] xproto [inputproto >= 2.2]) -PKG_CHECK_MODULES(LIBINPUT, [libinput >= 0.14.0]) +PKG_CHECK_MODULES(LIBINPUT, [libinput >= 0.19.0]) # Define a configure option for an alternate input module directory AC_ARG_WITH(xorg-module-dir, diff --git a/include/libinput-properties.h b/include/libinput-properties.h index 6760b50..6135dc8 100644 --- a/include/libinput-properties.h +++ b/include/libinput-properties.h @@ -30,6 +30,12 @@ /* Tapping default enabled/disabled: BOOL, 1 value, read-only */ #define LIBINPUT_PROP_TAP_DEFAULT "libinput Tapping Enabled Default" +/* Tap drag lock enabled/disabled: BOOL, 1 value */ +#define LIBINPUT_PROP_TAP_DRAG_LOCK "libinput Tapping Drag Lock Enabled" + +/* Tap drag lock default enabled/disabled: BOOL, 1 value */ +#define LIBINPUT_PROP_TAP_DRAG_LOCK_DEFAULT "libinput Tapping Drag Lock Enabled Default" + /* Calibration matrix: FLOAT, 9 values of a 3x3 matrix, in rows */ #define LIBINPUT_PROP_CALIBRATION "libinput Calibration Matrix" diff --git a/man/libinput.man b/man/libinput.man index df202a9..f781c59 100644 --- a/man/libinput.man +++ b/man/libinput.man @@ -109,6 +109,12 @@ mouse is connected". .TP 7 .BI "Option \*qTapping\*q \*q" bool \*q Enables or disables tap-to-click behavior. +.TP 7 +.BI "Option \*qTappingDragLock\*q \*q" bool \*q +Enables or disables drag lock during tapping behavior. When enabled, a +finger up during tap-and-drag will not immediately release the button. If +the finger is set down again within the timeout, the draging process +continues. .PP For all options, the options are only parsed if the device supports that configuration option. For all options, the default value is the one used by @@ -126,6 +132,9 @@ driver. .BI "libinput Tapping Enabled" 1 boolean value (8 bit, 0 or 1). 1 enables tapping .TP 7 +.BI "libinput Tapping Drag Lock Enabled" +1 boolean value (8 bit, 0 or 1). 1 enables drag lock during tapping +.TP 7 .BI "libinput Calibration Matrix" 9 32-bit float values, representing a 3x3 calibration matrix, order is row 1, row 2, row 3 diff --git a/src/libinput.c b/src/libinput.c index a06e44f..0733d35 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -98,6 +98,7 @@ struct xf86libinput { struct options { BOOL tapping; + BOOL tap_drag_lock; BOOL natural_scrolling; BOOL left_handed; BOOL middle_emulation; @@ -262,6 +263,13 @@ LibinputApplyConfig(DeviceIntPtr dev) "Failed to set Tapping to %d\n", driver_data->options.tapping); + if (libinput_device_config_tap_get_finger_count(device) > 0 && + libinput_device_config_tap_set_drag_lock_enabled(device, + driver_data->options.tap_drag_lock) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping DragLock to %d\n", + driver_data->options.tap_drag_lock); + if (libinput_device_config_calibration_has_matrix(device) && libinput_device_config_calibration_set_matrix(device, driver_data->options.matrix) != LIBINPUT_CONFIG_STATUS_SUCCESS) @@ -1032,6 +1040,30 @@ xf86libinput_parse_tap_option(InputInfoPtr pInfo, return tap; } +static inline BOOL +xf86libinput_parse_tap_drag_lock_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + BOOL drag_lock; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return FALSE; + + drag_lock = xf86SetBoolOption(pInfo->options, + "TappingDragLock", + libinput_device_config_tap_get_drag_lock_enabled(device)); + + if (libinput_device_config_tap_set_drag_lock_enabled(device, drag_lock) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping Drag Lock to %d\n", + drag_lock); + drag_lock = libinput_device_config_tap_get_drag_lock_enabled(device); + } + + return drag_lock; +} + static inline double xf86libinput_parse_accel_option(InputInfoPtr pInfo, struct libinput_device *device) @@ -1342,6 +1374,7 @@ xf86libinput_parse_options(InputInfoPtr pInfo, /* libinput options */ options->tapping = xf86libinput_parse_tap_option(pInfo, device); + options->tap_drag_lock = xf86libinput_parse_tap_drag_lock_option(pInfo, device); options->speed = xf86libinput_parse_accel_option(pInfo, device); options->natural_scrolling = xf86libinput_parse_natscroll_option(pInfo, device); options->sendevents = xf86libinput_parse_sendevents_option(pInfo, device); @@ -1523,6 +1556,8 @@ _X_EXPORT XF86ModuleData libinputModuleData = { /* libinput-specific properties */ static Atom prop_tap; static Atom prop_tap_default; +static Atom prop_tap_drag_lock; +static Atom prop_tap_drag_lock_default; static Atom prop_calibration; static Atom prop_calibration_default; static Atom prop_accel; @@ -1602,6 +1637,37 @@ LibinputSetPropertyTap(DeviceIntPtr dev, } static inline int +LibinputSetPropertyTapDragLock(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->device; + BOOL* data; + + if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER) + return BadMatch; + + data = (BOOL*)val->data; + if (checkonly) { + if (*data != 0 && *data != 1) + 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 = *data; + } + + return Success; +} + +static inline int LibinputSetPropertyCalibration(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, @@ -1930,6 +1996,8 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, if (atom == prop_tap) rc = LibinputSetPropertyTap(dev, atom, val, checkonly); + else if (atom == prop_tap_drag_lock) + rc = LibinputSetPropertyTapDragLock(dev, atom, val, checkonly); else if (atom == prop_calibration) rc = LibinputSetPropertyCalibration(dev, atom, val, checkonly); @@ -1957,6 +2025,7 @@ LibinputSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, rc = LibinputSetPropertyMiddleEmulation(dev, atom, val, checkonly); else if (atom == prop_device || atom == prop_product_id || atom == prop_tap_default || + atom == prop_tap_drag_lock_default || atom == prop_calibration_default || atom == prop_accel_default || atom == prop_natural_scroll_default || @@ -2025,6 +2094,30 @@ LibinputInitTapProperty(DeviceIntPtr dev, } static void +LibinputInitTapDragLockProperty(DeviceIntPtr dev, + struct xf86libinput *driver_data, + struct libinput_device *device) +{ + BOOL drag_lock = driver_data->options.tap_drag_lock; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return; + + prop_tap_drag_lock = LibinputMakeProperty(dev, + LIBINPUT_PROP_TAP_DRAG_LOCK, + XA_INTEGER, 8, + 1, &drag_lock); + if (!prop_tap_drag_lock) + return; + + drag_lock = libinput_device_config_tap_get_default_enabled(device); + prop_tap_drag_lock_default = LibinputMakeProperty(dev, + LIBINPUT_PROP_TAP_DRAG_LOCK_DEFAULT, + XA_INTEGER, 8, + 1, &drag_lock); +} + +static void LibinputInitCalibrationProperty(DeviceIntPtr dev, struct xf86libinput *driver_data, struct libinput_device *device) @@ -2383,6 +2476,7 @@ LibinputInitProperty(DeviceIntPtr dev) prop_float = XIGetKnownProperty("FLOAT"); LibinputInitTapProperty(dev, driver_data, device); + LibinputInitTapDragLockProperty(dev, driver_data, device); LibinputInitCalibrationProperty(dev, driver_data, device); LibinputInitAccelProperty(dev, driver_data, device); LibinputInitNaturalScrollProperty(dev, driver_data, device); |