Re: [PATCH xf86-input-libinput] Add property/option for enabling/disabling tap-n-drag
Hi, On 27-01-16 02:20, Peter Hutterer wrote: Signed-off-by: Peter HuttererPatch looks good to me: Reviewed-by: Hans de Goede Regards, Hans --- include/libinput-properties.h | 6 +++ man/libinput.man | 8 src/xf86libinput.c| 94 +++ 3 files changed, 108 insertions(+) diff --git a/include/libinput-properties.h b/include/libinput-properties.h index 098ce48..d117729 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 enabled/disabled: BOOL, 1 value */ +#define LIBINPUT_PROP_TAP_DRAG "libinput Tapping Drag Enabled" + +/* Tap drag default enabled/disabled: BOOL, 1 value */ +#define LIBINPUT_PROP_TAP_DRAG_DEFAULT "libinput Tapping Drag Enabled Default" + /* Tap drag lock enabled/disabled: BOOL, 1 value */ #define LIBINPUT_PROP_TAP_DRAG_LOCK "libinput Tapping Drag Lock Enabled" diff --git a/man/libinput.man b/man/libinput.man index b6f476e..43beda7 100644 --- a/man/libinput.man +++ b/man/libinput.man @@ -129,6 +129,14 @@ mouse is connected". .BI "Option \*qTapping\*q \*q" bool \*q Enables or disables tap-to-click behavior. .TP 7 +.BI "Option \*qTappingDrag\*q \*q" bool \*q +Enables or disables drag during tapping behavior ("tap-and-drag"). When +enabled, a tap followed by a finger held down causes a single button down +only, all motions of that finger thus translate into dragging motion. +Tap-and-drag requires option +.B Tapping +to be enabled. +.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 diff --git a/src/xf86libinput.c b/src/xf86libinput.c index fd07cf3..b520b26 100644 --- a/src/xf86libinput.c +++ b/src/xf86libinput.c @@ -112,6 +112,7 @@ struct xf86libinput { struct options { BOOL tapping; + BOOL tap_drag; BOOL tap_drag_lock; BOOL natural_scrolling; BOOL left_handed; @@ -386,6 +387,13 @@ LibinputApplyConfig(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_enabled(device, + driver_data->options.tap_drag) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping Drag to %d\n", + driver_data->options.tap_drag); + if (libinput_device_config_calibration_has_matrix(device) && libinput_device_config_calibration_set_matrix(device, driver_data->options.matrix) != LIBINPUT_CONFIG_STATUS_SUCCESS) @@ -1277,6 +1285,30 @@ xf86libinput_parse_tap_option(InputInfoPtr pInfo, } static inline BOOL +xf86libinput_parse_tap_drag_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + BOOL drag; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return FALSE; + + drag = xf86SetBoolOption(pInfo->options, +"TappingDrag", + libinput_device_config_tap_get_drag_enabled(device)); + + if (libinput_device_config_tap_set_drag_enabled(device, drag) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping Drag Lock to %d\n", + drag); + drag = libinput_device_config_tap_get_drag_enabled(device); + } + + return drag; +} + +static inline BOOL xf86libinput_parse_tap_drag_lock_option(InputInfoPtr pInfo, struct libinput_device *device) { @@ -1683,6 +1715,7 @@ xf86libinput_parse_options(InputInfoPtr pInfo, /* libinput options */ 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->speed = xf86libinput_parse_accel_option(pInfo, device); options->accel_profile = xf86libinput_parse_accel_profile_option(pInfo, device); @@ -2046,6 +2079,8 @@ _X_EXPORT XF86ModuleData libinputModuleData = { /* libinput-specific properties */ static Atom prop_tap; static Atom prop_tap_default; +static Atom prop_tap_drag; +static Atom prop_tap_drag_default; static Atom
[PATCH xf86-input-libinput] Add property/option for enabling/disabling tap-n-drag
Signed-off-by: Peter Hutterer--- include/libinput-properties.h | 6 +++ man/libinput.man | 8 src/xf86libinput.c| 94 +++ 3 files changed, 108 insertions(+) diff --git a/include/libinput-properties.h b/include/libinput-properties.h index 098ce48..d117729 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 enabled/disabled: BOOL, 1 value */ +#define LIBINPUT_PROP_TAP_DRAG "libinput Tapping Drag Enabled" + +/* Tap drag default enabled/disabled: BOOL, 1 value */ +#define LIBINPUT_PROP_TAP_DRAG_DEFAULT "libinput Tapping Drag Enabled Default" + /* Tap drag lock enabled/disabled: BOOL, 1 value */ #define LIBINPUT_PROP_TAP_DRAG_LOCK "libinput Tapping Drag Lock Enabled" diff --git a/man/libinput.man b/man/libinput.man index b6f476e..43beda7 100644 --- a/man/libinput.man +++ b/man/libinput.man @@ -129,6 +129,14 @@ mouse is connected". .BI "Option \*qTapping\*q \*q" bool \*q Enables or disables tap-to-click behavior. .TP 7 +.BI "Option \*qTappingDrag\*q \*q" bool \*q +Enables or disables drag during tapping behavior ("tap-and-drag"). When +enabled, a tap followed by a finger held down causes a single button down +only, all motions of that finger thus translate into dragging motion. +Tap-and-drag requires option +.B Tapping +to be enabled. +.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 diff --git a/src/xf86libinput.c b/src/xf86libinput.c index fd07cf3..b520b26 100644 --- a/src/xf86libinput.c +++ b/src/xf86libinput.c @@ -112,6 +112,7 @@ struct xf86libinput { struct options { BOOL tapping; + BOOL tap_drag; BOOL tap_drag_lock; BOOL natural_scrolling; BOOL left_handed; @@ -386,6 +387,13 @@ LibinputApplyConfig(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_enabled(device, + driver_data->options.tap_drag) != LIBINPUT_CONFIG_STATUS_SUCCESS) + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping Drag to %d\n", + driver_data->options.tap_drag); + if (libinput_device_config_calibration_has_matrix(device) && libinput_device_config_calibration_set_matrix(device, driver_data->options.matrix) != LIBINPUT_CONFIG_STATUS_SUCCESS) @@ -1277,6 +1285,30 @@ xf86libinput_parse_tap_option(InputInfoPtr pInfo, } static inline BOOL +xf86libinput_parse_tap_drag_option(InputInfoPtr pInfo, + struct libinput_device *device) +{ + BOOL drag; + + if (libinput_device_config_tap_get_finger_count(device) == 0) + return FALSE; + + drag = xf86SetBoolOption(pInfo->options, +"TappingDrag", + libinput_device_config_tap_get_drag_enabled(device)); + + if (libinput_device_config_tap_set_drag_enabled(device, drag) != + LIBINPUT_CONFIG_STATUS_SUCCESS) { + xf86IDrvMsg(pInfo, X_ERROR, + "Failed to set Tapping Drag Lock to %d\n", + drag); + drag = libinput_device_config_tap_get_drag_enabled(device); + } + + return drag; +} + +static inline BOOL xf86libinput_parse_tap_drag_lock_option(InputInfoPtr pInfo, struct libinput_device *device) { @@ -1683,6 +1715,7 @@ xf86libinput_parse_options(InputInfoPtr pInfo, /* libinput options */ 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->speed = xf86libinput_parse_accel_option(pInfo, device); options->accel_profile = xf86libinput_parse_accel_profile_option(pInfo, device); @@ -2046,6 +2079,8 @@ _X_EXPORT XF86ModuleData libinputModuleData = { /* libinput-specific properties */ static Atom prop_tap; static Atom prop_tap_default; +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_calibration; @@ -2136,6 +2171,37 @@ LibinputSetPropertyTap(DeviceIntPtr dev, }