touchpad: hook up drag lock configuration

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Peter Hutterer 2015-06-22 11:06:25 +10:00
parent 75581d5829
commit 875e1d1b10
4 changed files with 506 additions and 347 deletions

File diff suppressed because it is too large Load diff

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 120 KiB

View file

@ -389,8 +389,16 @@ tp_tap_dragging_handle_event(struct tp_dispatch *tp,
tp->tap.state = TAP_STATE_DRAGGING_2;
break;
case TAP_EVENT_RELEASE:
tp->tap.state = TAP_STATE_DRAGGING_WAIT;
tp_tap_set_drag_timer(tp, time);
if (tp->tap.drag_lock_enabled) {
tp->tap.state = TAP_STATE_DRAGGING_WAIT;
tp_tap_set_drag_timer(tp, time);
} else {
tp_tap_notify(tp,
time,
1,
LIBINPUT_BUTTON_STATE_RELEASED);
tp->tap.state = TAP_STATE_IDLE;
}
break;
case TAP_EVENT_MOTION:
case TAP_EVENT_TIMEOUT:
@ -849,11 +857,28 @@ static enum libinput_config_status
tp_tap_config_set_draglock_enabled(struct libinput_device *device,
enum libinput_config_drag_lock_state enabled)
{
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
struct evdev_dispatch *dispatch = ((struct evdev_device *) device)->dispatch;
struct tp_dispatch *tp = NULL;
tp = container_of(dispatch, tp, base);
tp->tap.drag_lock_enabled = enabled;
return LIBINPUT_CONFIG_STATUS_SUCCESS;
}
static enum libinput_config_drag_lock_state
tp_tap_config_get_draglock_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_lock_enabled;
}
static inline enum libinput_config_drag_lock_state
tp_drag_lock_default(struct evdev_device *device)
{
return LIBINPUT_CONFIG_DRAG_LOCK_ENABLED;
}
@ -861,7 +886,9 @@ tp_tap_config_get_draglock_enabled(struct libinput_device *device)
static enum libinput_config_drag_lock_state
tp_tap_config_get_default_draglock_enabled(struct libinput_device *device)
{
return LIBINPUT_CONFIG_DRAG_LOCK_ENABLED;
struct evdev_device *evdev = (struct evdev_device *)device;
return tp_drag_lock_default(evdev);
}
int
@ -878,6 +905,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_lock_enabled = tp_drag_lock_default(tp->device);
libinput_timer_init(&tp->tap.timer,
tp_libinput_context(tp),

View file

@ -269,6 +269,8 @@ struct tp_dispatch {
enum tp_tap_state state;
uint32_t buttons_pressed;
uint64_t multitap_last_time;
bool drag_lock_enabled;
} tap;
struct {

View file

@ -32,6 +32,30 @@
#include "libinput-util.h"
#include "litest.h"
static inline void
enable_drag_lock(struct libinput_device *device)
{
enum libinput_config_status status, expected;
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
status = libinput_device_config_tap_set_drag_lock_enabled(device,
LIBINPUT_CONFIG_DRAG_LOCK_ENABLED);
litest_assert_int_eq(status, expected);
}
static inline void
disable_drag_lock(struct libinput_device *device)
{
enum libinput_config_status status, expected;
expected = LIBINPUT_CONFIG_STATUS_SUCCESS;
status = libinput_device_config_tap_set_drag_lock_enabled(device,
LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
litest_assert_int_eq(status, expected);
}
START_TEST(touchpad_1fg_tap)
{
struct litest_device *dev = litest_current_device();
@ -443,6 +467,7 @@ START_TEST(touchpad_1fg_multitap_n_drag_tap)
ntaps;
litest_enable_tap(dev->libinput_device);
enable_drag_lock(dev->libinput_device);
litest_drain_events(li);
@ -515,6 +540,7 @@ START_TEST(touchpad_1fg_multitap_n_drag_tap_click)
ntaps;
litest_enable_tap(dev->libinput_device);
enable_drag_lock(dev->libinput_device);
litest_drain_events(li);
@ -593,6 +619,7 @@ START_TEST(touchpad_1fg_tap_n_drag)
struct libinput *li = dev->libinput;
litest_enable_tap(dev->libinput_device);
enable_drag_lock(dev->libinput_device);
litest_drain_events(li);
@ -633,6 +660,7 @@ START_TEST(touchpad_1fg_tap_n_drag_tap)
struct libinput *li = dev->libinput;
litest_enable_tap(dev->libinput_device);
enable_drag_lock(dev->libinput_device);
litest_drain_events(li);
@ -674,6 +702,7 @@ START_TEST(touchpad_1fg_tap_n_drag_tap_click)
struct libinput *li = dev->libinput;
litest_enable_tap(dev->libinput_device);
enable_drag_lock(dev->libinput_device);
litest_drain_events(li);
@ -718,6 +747,7 @@ START_TEST(touchpad_1fg_tap_n_drag_timeout)
struct libinput *li = dev->libinput;
litest_enable_tap(dev->libinput_device);
enable_drag_lock(dev->libinput_device);
litest_drain_events(li);
@ -747,6 +777,7 @@ START_TEST(touchpad_2fg_tap_n_drag)
struct libinput *li = dev->libinput;
litest_enable_tap(dev->libinput_device);
disable_drag_lock(dev->libinput_device);
litest_drain_events(li);
@ -765,7 +796,6 @@ START_TEST(touchpad_2fg_tap_n_drag)
litest_touch_up(dev, 0);
litest_touch_up(dev, 1);
/* This will wait for the DRAGGING_WAIT timeout */
litest_assert_button_event(li, BTN_LEFT,
LIBINPUT_BUTTON_STATE_RELEASED);
@ -1625,6 +1655,60 @@ START_TEST(touchpad_tap_invalid)
}
END_TEST
START_TEST(touchpad_drag_lock_default_enabled)
{
struct litest_device *dev = litest_current_device();
struct libinput_device *device = dev->libinput_device;
enum libinput_config_status status;
ck_assert_int_eq(libinput_device_config_tap_get_drag_lock_enabled(device),
LIBINPUT_CONFIG_DRAG_LOCK_ENABLED);
ck_assert_int_eq(libinput_device_config_tap_get_default_drag_lock_enabled(device),
LIBINPUT_CONFIG_DRAG_LOCK_ENABLED);
status = libinput_device_config_tap_set_drag_lock_enabled(device,
LIBINPUT_CONFIG_DRAG_LOCK_ENABLED);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
status = libinput_device_config_tap_set_drag_lock_enabled(device,
LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
status = libinput_device_config_tap_set_drag_lock_enabled(device,
LIBINPUT_CONFIG_DRAG_LOCK_ENABLED);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
status = libinput_device_config_tap_set_drag_lock_enabled(device,
3);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
}
END_TEST
START_TEST(touchpad_drag_lock_default_disabled)
{
struct litest_device *dev = litest_current_device();
struct libinput_device *device = dev->libinput_device;
enum libinput_config_status status;
ck_assert_int_eq(libinput_device_config_tap_get_drag_lock_enabled(device),
LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
ck_assert_int_eq(libinput_device_config_tap_get_default_drag_lock_enabled(device),
LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
status = libinput_device_config_tap_set_drag_lock_enabled(device,
LIBINPUT_CONFIG_DRAG_LOCK_ENABLED);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
status = libinput_device_config_tap_set_drag_lock_enabled(device,
LIBINPUT_CONFIG_DRAG_LOCK_DISABLED);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
status = libinput_device_config_tap_set_drag_lock_enabled(device,
3);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_INVALID);
}
END_TEST
void
litest_setup_tests(void)
{
@ -1680,4 +1764,7 @@ litest_setup_tests(void)
litest_add("touchpad:tap", clickpad_1fg_tap_click, LITEST_CLICKPAD, LITEST_ANY);
litest_add("touchpad:tap", clickpad_2fg_tap_click, LITEST_CLICKPAD, LITEST_SINGLE_TOUCH|LITEST_APPLE_CLICKPAD);
litest_add("touchpad:tap", touchpad_drag_lock_default_enabled, LITEST_TOUCHPAD, LITEST_ANY);
litest_add("touchpad:tap", touchpad_drag_lock_default_disabled, LITEST_ANY, LITEST_TOUCHPAD);
}