From cba2278c3ab3479f8805f04dc7e80a8356e1d54d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 22 Jan 2016 17:59:19 +1000 Subject: touchpad: add a config option to disable tap-and-drag There are a number of use-cases where tapping may be desirable, but tap-and-drag is not, e.g. where tapping is used to select multiple items in a list. Having tap-and-drag on hinders this, and the nature of the interaction means it cannot be detected based on timeouts, movement thresholds, etc. Provide an option instead to turn tap-an-drag off. Tap-and-drag remains enabled by default (though tapping is disabled by default). For the touchpad tap state diagram, the new option disables the transition from state TOUCH to state TAPPED and releases the button immediately instead. This means that multitap-and-drag is disabled too since we now just loop around in the single-tap state for multitap. It also makes tapping more responsive - we don't have to wait for the timeout before we know whether it's a tap event. The first touch time is noted, we now send the button press with the time of the first touch and the release with the time of the release. This ensures a realistic time diff between the two events. https://bugs.freedesktop.org/show_bug.cgi?id=93502 Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- tools/libinput-list-devices.c | 13 +++++++++++++ tools/shared.c | 16 ++++++++++++++++ tools/shared.h | 1 + 3 files changed, 30 insertions(+) (limited to 'tools') diff --git a/tools/libinput-list-devices.c b/tools/libinput-list-devices.c index 21685d9b..96c5b0d8 100644 --- a/tools/libinput-list-devices.c +++ b/tools/libinput-list-devices.c @@ -47,6 +47,18 @@ tap_default(struct libinput_device *device) return "disabled"; } +static const char * +drag_default(struct libinput_device *device) +{ + if (!libinput_device_config_tap_get_finger_count(device)) + return "n/a"; + + if (libinput_device_config_tap_get_default_drag_enabled(device)) + return "enabled"; + else + return "disabled"; +} + static const char * draglock_default(struct libinput_device *device) { @@ -260,6 +272,7 @@ print_device_notify(struct libinput_event *ev) printf("\n"); printf("Tap-to-click: %s\n", tap_default(dev)); + printf("Tap-and-drag: %s\n", drag_default(dev)); printf("Tap drag lock: %s\n", draglock_default(dev)); printf("Left-handed: %s\n", left_handed_default(dev)); printf("Nat.scrolling: %s\n", nat_scroll_default(dev)); diff --git a/tools/shared.c b/tools/shared.c index 5fe5862c..29af9ef5 100644 --- a/tools/shared.c +++ b/tools/shared.c @@ -45,6 +45,8 @@ enum options { OPT_VERBOSE, OPT_TAP_ENABLE, OPT_TAP_DISABLE, + OPT_DRAG_ENABLE, + OPT_DRAG_DISABLE, OPT_DRAG_LOCK_ENABLE, OPT_DRAG_LOCK_DISABLE, OPT_NATURAL_SCROLL_ENABLE, @@ -82,6 +84,8 @@ tools_usage() "Features:\n" "--enable-tap\n" "--disable-tap.... enable/disable tapping\n" + "--enable-drag\n" + "--disable-drag.... enable/disable tap-n-drag\n" "--enable-drag-lock\n" "--disable-drag-lock.... enable/disable tapping drag lock\n" "--enable-natural-scrolling\n" @@ -117,6 +121,7 @@ tools_init_context(struct tools_context *context) memset(options, 0, sizeof(*options)); options->tapping = -1; + options->drag = -1; options->drag_lock = -1; options->natural_scroll = -1; options->left_handed = -1; @@ -147,6 +152,8 @@ tools_parse_args(int argc, char **argv, struct tools_context *context) { "verbose", 0, 0, OPT_VERBOSE }, { "enable-tap", 0, 0, OPT_TAP_ENABLE }, { "disable-tap", 0, 0, OPT_TAP_DISABLE }, + { "enable-drag", 0, 0, OPT_DRAG_ENABLE }, + { "disable-drag", 0, 0, OPT_DRAG_DISABLE }, { "enable-drag-lock", 0, 0, OPT_DRAG_LOCK_ENABLE }, { "disable-drag-lock", 0, 0, OPT_DRAG_LOCK_DISABLE }, { "enable-natural-scrolling", 0, 0, OPT_NATURAL_SCROLL_ENABLE }, @@ -199,6 +206,12 @@ tools_parse_args(int argc, char **argv, struct tools_context *context) case OPT_TAP_DISABLE: options->tapping = 0; break; + case OPT_DRAG_ENABLE: + options->drag = 1; + break; + case OPT_DRAG_DISABLE: + options->drag = 0; + break; case OPT_DRAG_LOCK_ENABLE: options->drag_lock = 1; break; @@ -438,6 +451,9 @@ tools_device_apply_config(struct libinput_device *device, { if (options->tapping != -1) libinput_device_config_tap_set_enabled(device, options->tapping); + if (options->drag != -1) + libinput_device_config_tap_set_drag_enabled(device, + options->drag); if (options->drag_lock != -1) libinput_device_config_tap_set_drag_lock_enabled(device, options->drag_lock); diff --git a/tools/shared.h b/tools/shared.h index 0065fcc0..14ed9ccb 100644 --- a/tools/shared.h +++ b/tools/shared.h @@ -39,6 +39,7 @@ struct tools_options { int verbose; int tapping; + int drag; int drag_lock; int natural_scroll; int left_handed; -- cgit v1.2.3