summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2016-01-22 17:59:19 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2016-01-27 10:03:28 +1000
commitcba2278c3ab3479f8805f04dc7e80a8356e1d54d (patch)
treef6c650c9bd668db7c91c0e9c2b943874147fd51e /src
parentf8bcbc2dbb8cbbd5f1dea614238fcaa0c4cb2da0 (diff)
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 <peter.hutterer@who-t.netto> Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/evdev-mt-touchpad-tap.c54
-rw-r--r--src/evdev-mt-touchpad.h2
-rw-r--r--src/libinput-private.h5
-rw-r--r--src/libinput.c33
-rw-r--r--src/libinput.h73
-rw-r--r--src/libinput.sym6
6 files changed, 170 insertions, 3 deletions
diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c
index 5556ee94..232cd6a5 100644
--- a/src/evdev-mt-touchpad-tap.c
+++ b/src/evdev-mt-touchpad-tap.c
@@ -153,6 +153,7 @@ tp_tap_idle_handle_event(struct tp_dispatch *tp,
switch (event) {
case TAP_EVENT_TOUCH:
tp->tap.state = TAP_STATE_TOUCH;
+ tp->tap.first_press_time = time;
tp_tap_set_timer(tp, time);
break;
case TAP_EVENT_RELEASE:
@@ -185,9 +186,14 @@ tp_tap_touch_handle_event(struct tp_dispatch *tp,
tp_tap_set_timer(tp, time);
break;
case TAP_EVENT_RELEASE:
- tp->tap.state = TAP_STATE_TAPPED;
- tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_PRESSED);
- tp_tap_set_timer(tp, time);
+ tp_tap_notify(tp, tp->tap.first_press_time, 1, LIBINPUT_BUTTON_STATE_PRESSED);
+ if (tp->tap.drag_enabled) {
+ tp->tap.state = TAP_STATE_TAPPED;
+ tp_tap_set_timer(tp, time);
+ } else {
+ tp_tap_notify(tp, time, 1, LIBINPUT_BUTTON_STATE_RELEASED);
+ tp->tap.state = TAP_STATE_IDLE;
+ }
break;
case TAP_EVENT_TIMEOUT:
case TAP_EVENT_MOTION:
@@ -929,6 +935,44 @@ tp_tap_config_get_default(struct libinput_device *device)
}
static enum libinput_config_status
+tp_tap_config_set_drag_enabled(struct libinput_device *device,
+ enum libinput_config_drag_state enabled)
+{
+ struct evdev_dispatch *dispatch = ((struct evdev_device *) device)->dispatch;
+ struct tp_dispatch *tp = NULL;
+
+ tp = container_of(dispatch, tp, base);
+ tp->tap.drag_enabled = enabled;
+
+ return LIBINPUT_CONFIG_STATUS_SUCCESS;
+}
+
+static enum libinput_config_drag_state
+tp_tap_config_get_drag_enabled(struct libinput_device *device)
+{
+ struct evdev_device *evdev = (struct evdev_device *)device;
+ struct tp_dispatch *tp = NULL;
+
+ tp = container_of(evdev->dispatch, tp, base);
+
+ return tp->tap.drag_enabled;
+}
+
+static inline enum libinput_config_drag_state
+tp_drag_default(struct evdev_device *device)
+{
+ return LIBINPUT_CONFIG_DRAG_ENABLED;
+}
+
+static enum libinput_config_drag_state
+tp_tap_config_get_default_drag_enabled(struct libinput_device *device)
+{
+ struct evdev_device *evdev = (struct evdev_device *)device;
+
+ return tp_drag_default(evdev);
+}
+
+static enum libinput_config_status
tp_tap_config_set_draglock_enabled(struct libinput_device *device,
enum libinput_config_drag_lock_state enabled)
{
@@ -973,6 +1017,9 @@ tp_init_tap(struct tp_dispatch *tp)
tp->tap.config.set_enabled = tp_tap_config_set_enabled;
tp->tap.config.get_enabled = tp_tap_config_is_enabled;
tp->tap.config.get_default = tp_tap_config_get_default;
+ tp->tap.config.set_drag_enabled = tp_tap_config_set_drag_enabled;
+ tp->tap.config.get_drag_enabled = tp_tap_config_get_drag_enabled;
+ tp->tap.config.get_default_drag_enabled = tp_tap_config_get_default_drag_enabled;
tp->tap.config.set_draglock_enabled = tp_tap_config_set_draglock_enabled;
tp->tap.config.get_draglock_enabled = tp_tap_config_get_draglock_enabled;
tp->tap.config.get_default_draglock_enabled = tp_tap_config_get_default_draglock_enabled;
@@ -980,6 +1027,7 @@ tp_init_tap(struct tp_dispatch *tp)
tp->tap.state = TAP_STATE_IDLE;
tp->tap.enabled = tp_tap_default(tp->device);
+ tp->tap.drag_enabled = tp_drag_default(tp->device);
tp->tap.drag_lock_enabled = tp_drag_lock_default(tp->device);
libinput_timer_init(&tp->tap.timer,
diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h
index 8564a103..0053122b 100644
--- a/src/evdev-mt-touchpad.h
+++ b/src/evdev-mt-touchpad.h
@@ -312,7 +312,9 @@ struct tp_dispatch {
struct libinput_timer timer;
enum tp_tap_state state;
uint32_t buttons_pressed;
+ uint64_t first_press_time;
+ bool drag_enabled;
bool drag_lock_enabled;
} tap;
diff --git a/src/libinput-private.h b/src/libinput-private.h
index efffe35c..eee200d1 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -120,6 +120,11 @@ struct libinput_device_config_tap {
enum libinput_config_tap_state (*get_enabled)(struct libinput_device *device);
enum libinput_config_tap_state (*get_default)(struct libinput_device *device);
+ enum libinput_config_status (*set_drag_enabled)(struct libinput_device *device,
+ enum libinput_config_drag_state);
+ enum libinput_config_drag_state (*get_drag_enabled)(struct libinput_device *device);
+ enum libinput_config_drag_state (*get_default_drag_enabled)(struct libinput_device *device);
+
enum libinput_config_status (*set_draglock_enabled)(struct libinput_device *device,
enum libinput_config_drag_lock_state);
enum libinput_config_drag_lock_state (*get_draglock_enabled)(struct libinput_device *device);
diff --git a/src/libinput.c b/src/libinput.c
index 756edfad..4ce98e70 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -2119,6 +2119,39 @@ libinput_device_config_tap_get_default_enabled(struct libinput_device *device)
}
LIBINPUT_EXPORT enum libinput_config_status
+libinput_device_config_tap_set_drag_enabled(struct libinput_device *device,
+ enum libinput_config_drag_state enable)
+{
+ if (enable != LIBINPUT_CONFIG_DRAG_ENABLED &&
+ enable != LIBINPUT_CONFIG_DRAG_DISABLED)
+ return LIBINPUT_CONFIG_STATUS_INVALID;
+
+ if (libinput_device_config_tap_get_finger_count(device) == 0)
+ return enable ? LIBINPUT_CONFIG_STATUS_UNSUPPORTED :
+ LIBINPUT_CONFIG_STATUS_SUCCESS;
+
+ return device->config.tap->set_drag_enabled(device, enable);
+}
+
+LIBINPUT_EXPORT enum libinput_config_drag_state
+libinput_device_config_tap_get_drag_enabled(struct libinput_device *device)
+{
+ if (libinput_device_config_tap_get_finger_count(device) == 0)
+ return LIBINPUT_CONFIG_DRAG_DISABLED;
+
+ return device->config.tap->get_drag_enabled(device);
+}
+
+LIBINPUT_EXPORT enum libinput_config_drag_state
+libinput_device_config_tap_get_default_drag_enabled(struct libinput_device *device)
+{
+ if (libinput_device_config_tap_get_finger_count(device) == 0)
+ return LIBINPUT_CONFIG_DRAG_DISABLED;
+
+ return device->config.tap->get_default_drag_enabled(device);
+}
+
+LIBINPUT_EXPORT enum libinput_config_status
libinput_device_config_tap_set_drag_lock_enabled(struct libinput_device *device,
enum libinput_config_drag_lock_state enable)
{
diff --git a/src/libinput.h b/src/libinput.h
index 79d6e90b..e590d735 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -2182,6 +2182,79 @@ libinput_device_config_tap_get_default_enabled(struct libinput_device *device);
/**
* @ingroup config
+ *
+ * A config status to distinguish or set dragging on a device. Currently
+ * implemented for tap-and-drag only, see
+ * libinput_device_config_tap_set_drag_enabled()
+ */
+enum libinput_config_drag_state {
+ /**
+ * Drag is to be disabled, or is
+ * currently disabled.
+ */
+ LIBINPUT_CONFIG_DRAG_DISABLED,
+ /**
+ * Drag is to be enabled, or is
+ * currently enabled
+ */
+ LIBINPUT_CONFIG_DRAG_ENABLED,
+};
+
+/**
+ * @ingroup config
+ *
+ * Enable or disable tap-and-drag on this device. When enabled, a
+ * single-finger tap immediately followed by a finger down results in a
+ * button down event, subsequent finger motion thus triggers a drag. The
+ * button is released on finger up. See @ref tapndrag for more details.
+ *
+ * @param device The device to configure
+ * @param enable @ref LIBINPUT_CONFIG_DRAG_ENABLED to enable, @ref
+ * LIBINPUT_CONFIG_DRAG_DISABLED to disable tap-and-drag
+ *
+ * @see libinput_device_config_tap_drag_get_enabled
+ * @see libinput_device_config_tap_drag_get_default_enabled
+ */
+enum libinput_config_status
+libinput_device_config_tap_set_drag_enabled(struct libinput_device *device,
+ enum libinput_config_drag_state enable);
+
+/**
+ * @ingroup config
+ *
+ * Return whether tap-and-drag is enabled or disabled on this device.
+ *
+ * @param device The device to check
+ * @retval LIBINPUT_CONFIG_DRAG_ENABLED if tap-and-drag is enabled
+ * @retval LIBINPUT_CONFIG_DRAG_DISABLED if tap-and-drag is
+ * disabled
+ *
+ * @see libinput_device_config_tap_drag_set_enabled
+ * @see libinput_device_config_tap_drag_get_default_enabled
+ */
+enum libinput_config_drag_state
+libinput_device_config_tap_get_drag_enabled(struct libinput_device *device);
+
+/**
+ * @ingroup config
+ *
+ * Return whether tap-and-drag is enabled or disabled by default on this
+ * device.
+ *
+ * @param device The device to check
+ * @retval LIBINPUT_CONFIG_DRAG_ENABLED if tap-and-drag is enabled by
+ * default
+ * @retval LIBINPUT_CONFIG_DRAG_DISABLED if tap-and-drag is
+ * disabled by default
+ *
+ * @see libinput_device_config_tap_drag_set_enabled
+ * @see libinput_device_config_tap_drag_get_enabled
+ */
+enum libinput_config_drag_state
+libinput_device_config_tap_get_default_drag_enabled(struct libinput_device *device);
+
+/**
+ * @ingroup config
*/
enum libinput_config_drag_lock_state {
/** Drag lock is to be disabled, or is currently disabled */
diff --git a/src/libinput.sym b/src/libinput.sym
index 15203c8d..030dd281 100644
--- a/src/libinput.sym
+++ b/src/libinput.sym
@@ -179,3 +179,9 @@ LIBINPUT_1.1 {
libinput_device_config_accel_get_default_profile;
libinput_device_config_accel_set_profile;
} LIBINPUT_0.21.0;
+
+LIBINPUT_1.2 {
+ libinput_device_config_tap_get_drag_enabled;
+ libinput_device_config_tap_get_default_drag_enabled;
+ libinput_device_config_tap_set_drag_enabled;
+} LIBINPUT_1.1;