summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2016-01-27 13:54:00 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2016-01-27 13:54:00 +1000
commitae41aa146de6f377a7f9b433d92da3cb0bab85d2 (patch)
tree4de3a660c6624d999e335a0cb17cd8d883690e9b /src
parentde3f1fa6fa23cebef17640dc1eb4ea8df270ecd9 (diff)
parentcba2278c3ab3479f8805f04dc7e80a8356e1d54d (diff)
Merge branch 'master' into tablet-support
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.sym8
6 files changed, 171 insertions, 4 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 3dff3a84..bc7000d7 100644
--- a/src/libinput-private.h
+++ b/src/libinput-private.h
@@ -145,6 +145,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 aaeff9a3..2bcd416e 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -2899,6 +2899,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 500224df..8ed5632b 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -3094,6 +3094,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 666f3668..40143d8d 100644
--- a/src/libinput.sym
+++ b/src/libinput.sym
@@ -181,6 +181,12 @@ LIBINPUT_1.1 {
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;
+
/* tablet APIs, they are not part of any stable API promise yet.
* keep them separate */
LIBINPUT_TABLET_SUPPORT {
@@ -232,4 +238,4 @@ LIBINPUT_TABLET_SUPPORT {
libinput_tablet_tool_ref;
libinput_tablet_tool_set_user_data;
libinput_tablet_tool_unref;
-} LIBINPUT_1.1;
+} LIBINPUT_1.2;