From 1f4dd9985ac372de9817722109f75912ea00b41d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 19 Jun 2015 16:07:10 +1000 Subject: [PATCH 01/26] tools: drop superfluous linebreaks in ptraccel-debug Signed-off-by: Peter Hutterer --- tools/ptraccel-debug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/ptraccel-debug.c b/tools/ptraccel-debug.c index 8b800ee1..1d895983 100644 --- a/tools/ptraccel-debug.c +++ b/tools/ptraccel-debug.c @@ -165,9 +165,9 @@ usage(void) " delta ... print delta to accelerated delta\n" " accel ... print accel factor\n" " sequence ... print motion for custom delta sequence\n" - "--maxdx=\n ... in motion mode only. Stop increasing dx at maxdx\n" - "--steps=\n ... in motion and delta modes only. Increase dx by step each round\n" - "--speed=\n ... accel speed [-1, 1], default 0\n" + "--maxdx= ... in motion mode only. Stop increasing dx at maxdx\n" + "--steps= ... in motion and delta modes only. Increase dx by step each round\n" + "--speed= ... accel speed [-1, 1], default 0\n" "\n" "If extra arguments are present and mode is not given, mode defaults to 'sequence'\n" "and the arguments are interpreted as sequence of delta x coordinates\n" From f3d6fdae84308098a438254c8530fc52677efe57 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 23 Jun 2015 07:45:36 +1000 Subject: [PATCH 02/26] Extend CODING_STYLE with the if/else requirements Signed-off-by: Peter Hutterer --- CODING_STYLE | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CODING_STYLE b/CODING_STYLE index 1a64ffe6..3648a4e2 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -62,6 +62,17 @@ useit(c); } +- if/else: { on the same line, no curly braces if both blocks are a single + statement. If either if or else block are multiple statements, both must + have curly braces. + + if (foo) { + blah(); + bar(); + } else { + a = 10; + } + - public functions MUST be doxygen-commented, use doxygen's @foo rather than \foo notation From b1fc392268807653956867867dba3fdfabfc4d05 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 9 Apr 2015 16:08:14 +1000 Subject: [PATCH 03/26] udev: prepend the libinput group with the product string Multiple devices plugged into the same USB hub have the same PHYS path and are assigned to the same group. Prepend the content of the PRODUCT env to the phys path, this at least ensures that different devices are never grouped together. https://bugs.freedesktop.org/show_bug.cgi?id=89802 Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- udev/libinput-device-group.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/udev/libinput-device-group.c b/udev/libinput-device-group.c index 50bfbe02..adbd6b7f 100644 --- a/udev/libinput-device-group.c +++ b/udev/libinput-device-group.c @@ -10,8 +10,9 @@ int main(int argc, char **argv) struct udev_device *device = NULL; const char *syspath, *phys = NULL; - char *group, - *str; + const char *product; + char group[1024]; + char *str; if (argc != 2) return 1; @@ -45,9 +46,12 @@ int main(int argc, char **argv) if (!phys) goto out; - group = strdup(phys); - if (!group) - goto out; + /* udev sets PRODUCT on the same device we find PHYS on, let's rely + on that*/ + product = udev_device_get_property_value(device, "PRODUCT"); + if (!product) + product = ""; + snprintf(group, sizeof(group), "%s:%s", product, phys); str = strstr(group, "/input"); if (str) @@ -64,7 +68,6 @@ int main(int argc, char **argv) *str = '\0'; printf("%s\n", group); - free(group); rc = 0; out: From 3fcdba6ca60bdcba4d79746f5c06415ca2f1e8a7 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 17 Jun 2015 10:02:17 +1000 Subject: [PATCH 04/26] test: replace tap config with helper function No functional change, other than that we check for status codes now too. In tests that don't specifically check the interface itself, a short enable_tap() or disable_tap() is a lot more obvious to parse for the reader. Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- test/litest.h | 24 ++++++++++ test/touchpad-tap.c | 109 +++++++++++++++----------------------------- test/touchpad.c | 68 ++++++++++----------------- 3 files changed, 85 insertions(+), 116 deletions(-) diff --git a/test/litest.h b/test/litest.h index b08ac40d..4990fdd1 100644 --- a/test/litest.h +++ b/test/litest.h @@ -414,4 +414,28 @@ void litest_semi_mt_touch_up(struct litest_device *d, #define ck_assert_notnull(ptr) ck_assert_ptr_ne(ptr, NULL) #endif +static inline void +litest_enable_tap(struct libinput_device *device) +{ + enum libinput_config_status status, expected; + + expected = LIBINPUT_CONFIG_STATUS_SUCCESS; + status = libinput_device_config_tap_set_enabled(device, + LIBINPUT_CONFIG_TAP_ENABLED); + + litest_assert_int_eq(status, expected); +} + +static inline void +litest_disable_tap(struct libinput_device *device) +{ + enum libinput_config_status status, expected; + + expected = LIBINPUT_CONFIG_STATUS_SUCCESS; + status = libinput_device_config_tap_set_enabled(device, + LIBINPUT_CONFIG_TAP_DISABLED); + + litest_assert_int_eq(status, expected); +} + #endif /* LITEST_H */ diff --git a/test/touchpad-tap.c b/test/touchpad-tap.c index 22079302..423f89bb 100644 --- a/test/touchpad-tap.c +++ b/test/touchpad-tap.c @@ -38,8 +38,7 @@ START_TEST(touchpad_1fg_tap) struct libinput *li = dev->libinput; struct libinput_event *event; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -68,8 +67,7 @@ START_TEST(touchpad_1fg_doubletap) struct libinput_event_pointer *ptrev; uint32_t oldtime, curtime; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -129,8 +127,7 @@ START_TEST(touchpad_1fg_multitap) int range = _i, /* looped test */ ntaps; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -178,8 +175,7 @@ START_TEST(touchpad_1fg_multitap_n_drag_move) int range = _i, /* looped test */ ntaps; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -245,8 +241,7 @@ START_TEST(touchpad_1fg_multitap_n_drag_2fg) int range = _i, ntaps; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -317,8 +312,7 @@ START_TEST(touchpad_1fg_multitap_n_drag_click) int range = _i, /* looped test */ ntaps; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -378,8 +372,7 @@ START_TEST(touchpad_1fg_multitap_n_drag_timeout) int range = _i, /* looped test */ ntaps; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -449,8 +442,7 @@ START_TEST(touchpad_1fg_multitap_n_drag_tap) int range = _i, /* looped test */ ntaps; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -522,8 +514,7 @@ START_TEST(touchpad_1fg_multitap_n_drag_tap_click) int range = _i, /* looped test */ ntaps; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -601,8 +592,7 @@ START_TEST(touchpad_1fg_tap_n_drag) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -642,8 +632,7 @@ START_TEST(touchpad_1fg_tap_n_drag_tap) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -684,8 +673,7 @@ START_TEST(touchpad_1fg_tap_n_drag_tap_click) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -729,8 +717,7 @@ START_TEST(touchpad_1fg_tap_n_drag_timeout) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -759,8 +746,7 @@ START_TEST(touchpad_2fg_tap_n_drag) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -796,8 +782,7 @@ START_TEST(touchpad_2fg_tap_n_drag_3fg_btntool) ABS_MT_SLOT) > 2) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -842,8 +827,7 @@ START_TEST(touchpad_2fg_tap_n_drag_3fg) ABS_MT_SLOT) <= 2) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -881,8 +865,7 @@ START_TEST(touchpad_2fg_tap) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(dev->libinput); @@ -908,8 +891,7 @@ START_TEST(touchpad_2fg_tap_inverted) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(dev->libinput); @@ -935,8 +917,7 @@ START_TEST(touchpad_2fg_tap_quickrelease) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(dev->libinput); @@ -967,8 +948,7 @@ START_TEST(touchpad_1fg_tap_click) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(dev->libinput); @@ -1000,8 +980,7 @@ START_TEST(touchpad_2fg_tap_click) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(dev->libinput); @@ -1036,8 +1015,7 @@ START_TEST(clickpad_2fg_tap_click) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(dev->libinput); @@ -1068,8 +1046,7 @@ START_TEST(touchpad_2fg_tap_click_apple) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(dev->libinput); @@ -1101,8 +1078,7 @@ START_TEST(touchpad_no_2fg_tap_after_move) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(dev->libinput); /* one finger down, move past threshold, @@ -1125,8 +1101,7 @@ START_TEST(touchpad_no_2fg_tap_after_timeout) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(dev->libinput); /* one finger down, wait past tap timeout, @@ -1152,8 +1127,7 @@ START_TEST(touchpad_no_first_fg_tap_after_move) struct libinput *li = dev->libinput; struct libinput_event *event; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(dev->libinput); @@ -1184,8 +1158,7 @@ START_TEST(touchpad_1fg_double_tap_click) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(dev->libinput); @@ -1220,8 +1193,7 @@ START_TEST(touchpad_1fg_tap_n_drag_click) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(dev->libinput); @@ -1269,8 +1241,7 @@ START_TEST(touchpad_3fg_tap) ABS_MT_SLOT) <= 2) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); for (i = 0; i < 3; i++) { litest_drain_events(li); @@ -1307,8 +1278,7 @@ START_TEST(touchpad_3fg_tap_quickrelease) ABS_MT_SLOT) <= 2) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -1348,7 +1318,7 @@ START_TEST(touchpad_3fg_tap_btntool) ABS_MT_SLOT) > 2) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, 1); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -1387,7 +1357,7 @@ START_TEST(touchpad_3fg_tap_btntool_inverted) ABS_MT_SLOT) > 2) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, 1); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -1427,8 +1397,7 @@ START_TEST(touchpad_4fg_tap) ABS_MT_SLOT) <= 3) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); for (i = 0; i < 4; i++) { litest_drain_events(li); @@ -1462,8 +1431,7 @@ START_TEST(touchpad_4fg_tap_quickrelease) ABS_MT_SLOT) <= 3) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -1502,8 +1470,7 @@ START_TEST(touchpad_5fg_tap) ABS_MT_SLOT) <= 4) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); for (i = 0; i < 5; i++) { litest_drain_events(li); @@ -1539,8 +1506,7 @@ START_TEST(touchpad_5fg_tap_quickrelease) ABS_MT_SLOT) <= 4) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -1576,8 +1542,7 @@ START_TEST(clickpad_1fg_tap_click) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(dev->libinput); diff --git a/test/touchpad.c b/test/touchpad.c index 1179d57e..443c8c1f 100644 --- a/test/touchpad.c +++ b/test/touchpad.c @@ -39,8 +39,7 @@ START_TEST(touchpad_1fg_motion) struct libinput_event *event; struct libinput_event_pointer *ptrev; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_DISABLED); + litest_disable_tap(dev->libinput_device); litest_drain_events(li); @@ -683,8 +682,7 @@ START_TEST(clickpad_softbutton_left_tap_n_drag) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -726,8 +724,7 @@ START_TEST(clickpad_softbutton_right_tap_n_drag) struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -1675,8 +1672,7 @@ START_TEST(touchpad_palm_detect_at_edge) if (!touchpad_has_palm_detect_size(dev)) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_DISABLED); + litest_disable_tap(dev->libinput_device); litest_drain_events(li); @@ -1720,8 +1716,7 @@ START_TEST(touchpad_palm_detect_at_bottom_corners) if (!touchpad_has_palm_detect_size(dev)) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_DISABLED); + litest_disable_tap(dev->libinput_device); /* Run for non-clickpads only: make sure the bottom corners trigger palm detection too */ @@ -1747,8 +1742,7 @@ START_TEST(touchpad_palm_detect_at_top_corners) if (!touchpad_has_palm_detect_size(dev)) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_DISABLED); + litest_disable_tap(dev->libinput_device); /* Run for non-clickpads only: make sure the bottom corners trigger palm detection too */ @@ -1774,8 +1768,7 @@ START_TEST(touchpad_palm_detect_palm_stays_palm) if (!touchpad_has_palm_detect_size(dev)) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_DISABLED); + litest_disable_tap(dev->libinput_device); litest_drain_events(li); @@ -1794,8 +1787,7 @@ START_TEST(touchpad_palm_detect_palm_becomes_pointer) if (!touchpad_has_palm_detect_size(dev)) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_DISABLED); + litest_disable_tap(dev->libinput_device); litest_drain_events(li); @@ -1819,8 +1811,7 @@ START_TEST(touchpad_palm_detect_no_palm_moving_into_edges) if (!touchpad_has_palm_detect_size(dev)) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_DISABLED); + litest_disable_tap(dev->libinput_device); /* moving non-palm into the edge does not label it as palm */ litest_drain_events(li); @@ -1849,8 +1840,7 @@ START_TEST(touchpad_palm_detect_tap) if (!touchpad_has_palm_detect_size(dev)) return; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); litest_drain_events(li); @@ -2028,8 +2018,8 @@ START_TEST(touchpad_left_handed_tapping) struct libinput *li = dev->libinput; enum libinput_config_status status; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); + status = libinput_device_config_left_handed_set(d, 1); ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS); @@ -2059,8 +2049,8 @@ START_TEST(touchpad_left_handed_tapping_2fg) struct libinput *li = dev->libinput; enum libinput_config_status status; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(dev->libinput_device); + status = libinput_device_config_left_handed_set(d, 1); ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS); @@ -3022,8 +3012,7 @@ START_TEST(touchpad_initial_state) dev = litest_current_device(); libinput1 = dev->libinput; - libinput_device_config_tap_set_enabled(dev->libinput_device, - LIBINPUT_CONFIG_TAP_DISABLED); + litest_disable_tap(dev->libinput_device); litest_touch_down(dev, 0, x, y); litest_touch_up(dev, 0); @@ -3088,8 +3077,7 @@ START_TEST(touchpad_dwt) return; keyboard = litest_add_device(li, LITEST_KEYBOARD); - libinput_device_config_tap_set_enabled(touchpad->libinput_device, - LIBINPUT_CONFIG_TAP_DISABLED); + litest_disable_tap(touchpad->libinput_device); litest_drain_events(li); litest_keyboard_key(keyboard, KEY_A, true); @@ -3131,8 +3119,7 @@ START_TEST(touchpad_dwt_enable_touch) return; keyboard = litest_add_device(li, LITEST_KEYBOARD); - libinput_device_config_tap_set_enabled(touchpad->libinput_device, - LIBINPUT_CONFIG_TAP_DISABLED); + litest_disable_tap(touchpad->libinput_device); litest_drain_events(li); litest_keyboard_key(keyboard, KEY_A, true); @@ -3170,8 +3157,7 @@ START_TEST(touchpad_dwt_touch_hold) return; keyboard = litest_add_device(li, LITEST_KEYBOARD); - libinput_device_config_tap_set_enabled(touchpad->libinput_device, - LIBINPUT_CONFIG_TAP_DISABLED); + litest_disable_tap(touchpad->libinput_device); litest_drain_events(li); litest_keyboard_key(keyboard, KEY_A, true); @@ -3208,8 +3194,7 @@ START_TEST(touchpad_dwt_key_hold) return; keyboard = litest_add_device(li, LITEST_KEYBOARD); - libinput_device_config_tap_set_enabled(touchpad->libinput_device, - LIBINPUT_CONFIG_TAP_DISABLED); + litest_disable_tap(touchpad->libinput_device); litest_drain_events(li); litest_keyboard_key(keyboard, KEY_A, true); @@ -3237,8 +3222,7 @@ START_TEST(touchpad_dwt_type) return; keyboard = litest_add_device(li, LITEST_KEYBOARD); - libinput_device_config_tap_set_enabled(touchpad->libinput_device, - LIBINPUT_CONFIG_TAP_DISABLED); + litest_disable_tap(touchpad->libinput_device); litest_drain_events(li); for (i = 0; i < 5; i++) { @@ -3276,8 +3260,7 @@ START_TEST(touchpad_dwt_type_short_timeout) return; keyboard = litest_add_device(li, LITEST_KEYBOARD); - libinput_device_config_tap_set_enabled(touchpad->libinput_device, - LIBINPUT_CONFIG_TAP_DISABLED); + litest_disable_tap(touchpad->libinput_device); litest_drain_events(li); for (i = 0; i < 5; i++) { @@ -3314,8 +3297,7 @@ START_TEST(touchpad_dwt_tap) return; keyboard = litest_add_device(li, LITEST_KEYBOARD); - libinput_device_config_tap_set_enabled(touchpad->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(touchpad->libinput_device); litest_drain_events(li); litest_keyboard_key(keyboard, KEY_A, true); @@ -3345,8 +3327,7 @@ START_TEST(touchpad_dwt_tap_drag) return; keyboard = litest_add_device(li, LITEST_KEYBOARD); - libinput_device_config_tap_set_enabled(touchpad->libinput_device, - LIBINPUT_CONFIG_TAP_ENABLED); + litest_enable_tap(touchpad->libinput_device); litest_drain_events(li); litest_keyboard_key(keyboard, KEY_A, true); @@ -3380,8 +3361,7 @@ START_TEST(touchpad_dwt_click) return; keyboard = litest_add_device(li, LITEST_KEYBOARD); - libinput_device_config_tap_set_enabled(touchpad->libinput_device, - LIBINPUT_CONFIG_TAP_DISABLED); + litest_disable_tap(touchpad->libinput_device); litest_drain_events(li); litest_keyboard_key(keyboard, KEY_A, true); From 75581d58297dfd022dcdf8be2daf8b6306cc0b8c Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 16 Jun 2015 17:02:02 +1000 Subject: [PATCH 05/26] Add configuration interface for tap drag-lock In some applications, notably Inkscape, where it is common to frequently drag objects a short distance the default to drag-lock always-on is frustrating for users. Make it configurable, with the current default to "on". New API: libinput_device_config_tap_set_drag_lock_enabled libinput_device_config_tap_get_drag_lock_enabled libinput_device_config_tap_get_default_drag_lock_enabled Any device capable of tapping is capable of drag lock, there is no explicit availability check for drag lock. Configuration is independent, drag lock may be enabled when tapping is disabled. In the tests, enable/disable drag-lock explicitly where the tests depend on it. https://bugs.freedesktop.org/show_bug.cgi?id=90928 Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- doc/tapping.dox | 19 ++++++--- src/evdev-mt-touchpad-tap.c | 22 ++++++++++ src/libinput-private.h | 5 +++ src/libinput.c | 33 +++++++++++++++ src/libinput.h | 79 +++++++++++++++++++++++++++++++++++ src/libinput.sym | 6 +++ tools/libinput-list-devices.c | 13 ++++++ 7 files changed, 171 insertions(+), 6 deletions(-) diff --git a/doc/tapping.dox b/doc/tapping.dox index 1337fc53..483219ad 100644 --- a/doc/tapping.dox +++ b/doc/tapping.dox @@ -29,17 +29,24 @@ libinput also supports "tap-and-drag" where a tap immediately followed by a finger down and that finger being held down emulates a button press. Moving the finger around can thus drag the selected item on the screen. +Optional is a feature called "drag lock". With drag lock disabled, lifting +the finger will stop any drag process. When enabled, libinput will ignore a +finger up event during a drag process, provided the finger is set down again +within a implementation-specific timeout. Drag lock can be enabled and +disabled with libinput_device_config_tap_set_drag_lock_enabled(). + @image html tap-n-drag.svg "Tap-and-drag process" The above diagram explains the process, a tap (a) followed by a finger held down (b) starts the drag process and logically holds the left mouse button down. A movement of the finger (c) will drag the selected item until the -finger is relased (e). If needed, the finger's position can be reset by -lifting and quickly setting it down again on the touchpad (d). This will be -interpreted as continuing move and is especially useful on small touchpads -or with slow pointer acceleration. -The release of the mouse buttons after the finger release (e) is triggered -by a timeout. To release the button immediately, simply tap again (f). +finger is relased (e). If needed and drag lock is enabled, the finger's +position can be reset by lifting and quickly setting it down again on the +touchpad (d). This will be interpreted as continuing move and is especially +useful on small touchpads or with slow pointer acceleration. +If drag lock is enabled, the release of the mouse buttons after the finger +release (e) is triggered by a timeout. To release the button immediately, +simply tap again (f). If two fingers are supported by the hardware, a second finger can be used to drag while the first is held in-place. diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 2951ee6a..5d986ca8 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -845,6 +845,25 @@ tp_tap_config_get_default(struct libinput_device *device) return tp_tap_default(evdev); } +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; +} + +static enum libinput_config_drag_lock_state +tp_tap_config_get_draglock_enabled(struct libinput_device *device) +{ + return LIBINPUT_CONFIG_DRAG_LOCK_ENABLED; +} + +static enum libinput_config_drag_lock_state +tp_tap_config_get_default_draglock_enabled(struct libinput_device *device) +{ + return LIBINPUT_CONFIG_DRAG_LOCK_ENABLED; +} + int tp_init_tap(struct tp_dispatch *tp) { @@ -852,6 +871,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_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; tp->device->base.config.tap = &tp->tap.config; tp->tap.state = TAP_STATE_IDLE; diff --git a/src/libinput-private.h b/src/libinput-private.h index a7c8838c..5192b651 100644 --- a/src/libinput-private.h +++ b/src/libinput-private.h @@ -117,6 +117,11 @@ struct libinput_device_config_tap { enum libinput_config_tap_state enable); 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_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); + enum libinput_config_drag_lock_state (*get_default_draglock_enabled)(struct libinput_device *device); }; struct libinput_device_config_calibration { diff --git a/src/libinput.c b/src/libinput.c index 7a097c01..319934ac 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -1736,6 +1736,39 @@ libinput_device_config_tap_get_default_enabled(struct libinput_device *device) return device->config.tap->get_default(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) +{ + if (enable != LIBINPUT_CONFIG_DRAG_LOCK_ENABLED && + enable != LIBINPUT_CONFIG_DRAG_LOCK_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_draglock_enabled(device, enable); +} + +LIBINPUT_EXPORT enum libinput_config_drag_lock_state +libinput_device_config_tap_get_drag_lock_enabled(struct libinput_device *device) +{ + if (libinput_device_config_tap_get_finger_count(device) == 0) + return LIBINPUT_CONFIG_DRAG_LOCK_DISABLED; + + return device->config.tap->get_draglock_enabled(device); +} + +LIBINPUT_EXPORT enum libinput_config_drag_lock_state +libinput_device_config_tap_get_default_drag_lock_enabled(struct libinput_device *device) +{ + if (libinput_device_config_tap_get_finger_count(device) == 0) + return LIBINPUT_CONFIG_DRAG_LOCK_DISABLED; + + return device->config.tap->get_default_draglock_enabled(device); +} + LIBINPUT_EXPORT int libinput_device_config_calibration_has_matrix(struct libinput_device *device) { diff --git a/src/libinput.h b/src/libinput.h index 0d3200f3..240900b6 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -1911,6 +1911,85 @@ libinput_device_config_tap_get_enabled(struct libinput_device *device); enum libinput_config_tap_state libinput_device_config_tap_get_default_enabled(struct libinput_device *device); +/** + * @ingroup config + */ +enum libinput_config_drag_lock_state { + /** Drag lock is to be disabled, or is currently disabled */ + LIBINPUT_CONFIG_DRAG_LOCK_DISABLED, + /** Drag lock is to be enabled, or is currently disabled */ + LIBINPUT_CONFIG_DRAG_LOCK_ENABLED, +}; + +/** + * @ingroup config + * + * Enable or disable drag-lock during tapping on this device. When enabled, + * a finger may be lifted and put back on the touchpad within a timeout and + * the drag process continues. When disabled, lifting the finger during a + * tap-and-drag will immediately stop the drag. See @ref tapndrag for + * details. + * + * Enabling drag lock on a device that has tapping disabled is permitted, + * but has no effect until tapping is enabled. + * + * @param device The device to configure + * @param enable @ref LIBINPUT_CONFIG_DRAG_LOCK_ENABLED to enable drag lock + * or @ref LIBINPUT_CONFIG_DRAG_LOCK_DISABLED to disable drag lock + * + * @return A config status code. Disabling drag lock on a device that does not + * support tapping always succeeds. + * + * @see libinput_device_config_tap_get_drag_lock_enabled + * @see libinput_device_config_tap_get_default_drag_lock_enabled + */ +enum libinput_config_status +libinput_device_config_tap_set_drag_lock_enabled(struct libinput_device *device, + enum libinput_config_drag_lock_state enable); + +/** + * @ingroup config + * + * Check if drag-lock during tapping is enabled on this device. If the + * device does not support tapping, this function always returns + * @ref LIBINPUT_CONFIG_DRAG_LOCK_DISABLED. + * + * Drag lock may be enabled even when tapping is disabled. + * + * @param device The device to configure + * + * @retval LIBINPUT_CONFIG_DRAG_LOCK_ENABLED If drag lock is currently enabled + * @retval LIBINPUT_CONFIG_DRAG_LOCK_DISABLED If drag lock is currently disabled + * + * @see libinput_device_config_tap_set_drag_lock_enabled + * @see libinput_device_config_tap_get_default_drag_lock_enabled + */ +enum libinput_config_drag_lock_state +libinput_device_config_tap_get_drag_lock_enabled(struct libinput_device *device); + +/** + * @ingroup config + * + * Check if drag-lock during tapping is enabled by default on this device. + * If the device does not support tapping, this function always returns + * @ref LIBINPUT_CONFIG_DRAG_LOCK_DISABLED. + * + * Drag lock may be enabled by default even when tapping is disabled by + * default. + * + * @param device The device to configure + * + * @retval LIBINPUT_CONFIG_DRAG_LOCK_ENABLED If drag lock is enabled by + * default + * @retval LIBINPUT_CONFIG_DRAG_LOCK_DISABLED If drag lock is disabled by + * default + * + * @see libinput_device_config_tap_set_drag_lock_enabled + * @see libinput_device_config_tap_get_drag_lock_enabled + */ +enum libinput_config_drag_lock_state +libinput_device_config_tap_get_default_drag_lock_enabled(struct libinput_device *device); + /** * @ingroup config * diff --git a/src/libinput.sym b/src/libinput.sym index 9c11174b..2c023367 100644 --- a/src/libinput.sym +++ b/src/libinput.sym @@ -140,3 +140,9 @@ LIBINPUT_0.15.0 { global: libinput_device_keyboard_has_key; } LIBINPUT_0.14.0; + +LIBINPUT_0.19.0 { + libinput_device_config_tap_set_drag_lock_enabled; + libinput_device_config_tap_get_drag_lock_enabled; + libinput_device_config_tap_get_default_drag_lock_enabled; +} LIBINPUT_0.15.0; diff --git a/tools/libinput-list-devices.c b/tools/libinput-list-devices.c index d76e5db5..b3f7e2f9 100644 --- a/tools/libinput-list-devices.c +++ b/tools/libinput-list-devices.c @@ -78,6 +78,18 @@ tap_default(struct libinput_device *device) return "disabled"; } +static const char * +draglock_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_lock_enabled(device)) + return "enabled"; + else + return "disabled"; +} + static const char* left_handed_default(struct libinput_device *device) { @@ -238,6 +250,7 @@ print_device_notify(struct libinput_event *ev) printf("\n"); printf("Tap-to-click: %s\n", tap_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)); printf("Middle emulation: %s\n", middle_emulation_default(dev)); From 875e1d1b100ae92b7d074b63caae876a82b7c4db Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 22 Jun 2015 11:06:25 +1000 Subject: [PATCH 06/26] touchpad: hook up drag lock configuration Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- doc/touchpad-tap-state-machine.svg | 726 +++++++++++++++-------------- src/evdev-mt-touchpad-tap.c | 36 +- src/evdev-mt-touchpad.h | 2 + test/touchpad-tap.c | 89 +++- 4 files changed, 506 insertions(+), 347 deletions(-) diff --git a/doc/touchpad-tap-state-machine.svg b/doc/touchpad-tap-state-machine.svg index 39b0b86b..89c34fa0 100644 --- a/doc/touchpad-tap-state-machine.svg +++ b/doc/touchpad-tap-state-machine.svg @@ -1,16 +1,14 @@ - - - - - - - - + + + + + + @@ -28,15 +26,15 @@ finger down - - + + finger up - - + + @@ -49,8 +47,8 @@ timeout - - + + @@ -58,8 +56,8 @@ threshold - - + + @@ -67,8 +65,8 @@ finger down - - + + @@ -81,8 +79,8 @@ finger up - - + + @@ -102,10 +100,10 @@ timeout - - - - + + + + @@ -120,10 +118,10 @@ release - - - - + + + + @@ -134,8 +132,8 @@ timeout - - + + @@ -143,8 +141,8 @@ finger down - - + + @@ -157,19 +155,19 @@ finger up - + - + btn1 - + release - - + + - - + + @@ -182,15 +180,15 @@ finger down - - + + TOUCH_3 - - + + @@ -214,8 +212,8 @@ threshold - - + + @@ -226,8 +224,8 @@ timeout - - + + @@ -235,8 +233,8 @@ finger up - - + + @@ -249,24 +247,24 @@ finger down - - - - + + + + DRAGGING_OR_DOUBLETAP - - + + timeout - - + + @@ -274,8 +272,8 @@ finger up - - + + @@ -297,8 +295,8 @@ release - - + + @@ -306,8 +304,8 @@ finger down - - + + @@ -315,10 +313,10 @@ threshold - - - - + + + + @@ -331,10 +329,10 @@ finger up - - - - + + + + @@ -342,12 +340,12 @@ finger down - - - - - - + + + + + + @@ -360,8 +358,8 @@ finger up - - + + @@ -369,11 +367,11 @@ finger up - - - + + + - + @@ -382,19 +380,19 @@ finger down - - - - - - + + + + + + TOUCH_3_HOLD - - + + @@ -407,12 +405,12 @@ DEAD - - - - - - + + + + + + @@ -430,13 +428,13 @@ any finger up - - - - + + + + - - + + yes @@ -444,14 +442,14 @@ any finger up - - - - - - - - + + + + + + + + @@ -464,12 +462,12 @@ count == 0 - - - - - - + + + + + + @@ -482,10 +480,10 @@ DRAGGING_2 - - - - + + + + @@ -493,12 +491,12 @@ finger up - - - - - - + + + + + + @@ -506,12 +504,12 @@ finger down - - - - - - + + + + + + @@ -519,8 +517,8 @@ finger down - - + + @@ -528,8 +526,8 @@ release - - + + @@ -539,18 +537,18 @@ press - - - - - - - - - + + + + + + + + + - - + + @@ -560,8 +558,8 @@ press - - + + @@ -569,41 +567,41 @@ release - - - - - - - - - - - + + + + + + + + + + + - + DRAGGING_WAIT - + - + timeout - - - - - - - + + + + + + + - + first - + finger down - - + + @@ -614,31 +612,31 @@ TOUCH_IDLE - - - - - - - - + + + + + + + + TOUCH_DEAD - - - - - - - - + + + + + + + + - + yes @@ -647,56 +645,56 @@ TOUCH_DEAD - - - - - - + + + + + + TOUCH_IDLE - - + + TOUCH_TOUCH - - - - + + + + TOUCH_IDLE - - + + TOUCH_IDLE - - + + TOUCH_IDLE - - + + TOUCH_TOUCH - - + + @@ -704,19 +702,19 @@ TOUCH_IDLE - - + + TOUCH_DEAD - - - - - - + + + + + + @@ -724,13 +722,13 @@ TOUCH_IDLE - - - - + + + + - - + + no @@ -738,8 +736,8 @@ TOUCH_TOUCH - - + + @@ -750,24 +748,24 @@ TOUCH_TOUCH - - + + TOUCH_DEAD - - - - + + + + TOUCH_IDLE - - + + @@ -778,43 +776,43 @@ TOUCH_TOUCH - - + + TOUCH_IDLE - - + + TOUCH_IDLE - - + + TOUCH_TOUCH - - + + TOUCH_IDLE - - + + TOUCH_TOUCH - - + + @@ -822,8 +820,8 @@ TOUCH_IDLE - - + + @@ -846,22 +844,22 @@ TOUCH_DEAD - - + + TOUCH_DEAD - - + + TOUCH_DEAD - - + + @@ -876,11 +874,11 @@ TOUCH_TOUCH - - + + - - + + no @@ -888,8 +886,8 @@ TOUCH_DEAD - - + + @@ -912,30 +910,30 @@ MULTITAP - - - - + + + + timeout - - - - + + + + IDLE - - - - - - + + + + + + @@ -948,10 +946,10 @@ press - - - - + + + + @@ -959,8 +957,8 @@ finger up - - + + @@ -968,8 +966,8 @@ release - - + + @@ -989,12 +987,12 @@ threshold - - - - - - + + + + + + @@ -1009,12 +1007,12 @@ press - - - - - - + + + + + + @@ -1029,12 +1027,12 @@ press - - - - - - + + + + + + @@ -1049,28 +1047,28 @@ press - - - - - - - - + + + + + + + + TOUCH_TOUCH - - + + TOUCH_IDLE - - + + @@ -1080,12 +1078,12 @@ press - - - - - - + + + + + + @@ -1098,17 +1096,17 @@ finger up - - + + timeout - - - - + + + + @@ -1116,26 +1114,70 @@ threshold - - - - - - - - - - + + + + + + + + + + TOUCH_IDLE - - - - - - + + + + + + + + + + +
+
+ drag lock
+ enabled?
+
+
+
+ + [Not supported by viewer] +
+
+ + + + + +
+
+ no
+
+
+ + [Not supported by viewer] +
+
+ + + + + +
+
+ yes
+
+
+
+ + [Not supported by viewer] +
+
diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 5d986ca8..40d431aa 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -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), diff --git a/src/evdev-mt-touchpad.h b/src/evdev-mt-touchpad.h index 9357969c..36260c68 100644 --- a/src/evdev-mt-touchpad.h +++ b/src/evdev-mt-touchpad.h @@ -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 { diff --git a/test/touchpad-tap.c b/test/touchpad-tap.c index 423f89bb..9bc02a0d 100644 --- a/test/touchpad-tap.c +++ b/test/touchpad-tap.c @@ -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); + } From 16107e18626ff9bc526a879845888c14bfef1a16 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 22 Jun 2015 11:07:31 +1000 Subject: [PATCH 07/26] tools: hook up drag lock config Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- tools/event-debug.c | 7 ++++++- tools/shared.c | 16 ++++++++++++++++ tools/shared.h | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/event-debug.c b/tools/event-debug.c index 7aeac067..becde168 100644 --- a/tools/event-debug.c +++ b/tools/event-debug.c @@ -157,8 +157,13 @@ print_device_notify(struct libinput_event *ev) if (libinput_device_get_size(dev, &w, &h) == 0) printf("\tsize %.2f/%.2fmm", w, h); - if (libinput_device_config_tap_get_finger_count(dev)) + if (libinput_device_config_tap_get_finger_count(dev)) { printf(" tap"); + if (libinput_device_config_tap_get_drag_lock_enabled(dev)) + printf("(dl on)"); + else + printf("(dl off)"); + } if (libinput_device_config_left_handed_is_available(dev)) printf(" left"); if (libinput_device_config_scroll_has_natural_scroll(dev)) diff --git a/tools/shared.c b/tools/shared.c index 1858c93f..0c2f9c42 100644 --- a/tools/shared.c +++ b/tools/shared.c @@ -43,6 +43,8 @@ enum options { OPT_VERBOSE, OPT_TAP_ENABLE, OPT_TAP_DISABLE, + OPT_DRAG_LOCK_ENABLE, + OPT_DRAG_LOCK_DISABLE, OPT_NATURAL_SCROLL_ENABLE, OPT_NATURAL_SCROLL_DISABLE, OPT_LEFT_HANDED_ENABLE, @@ -75,6 +77,8 @@ tools_usage() "Features:\n" "--enable-tap\n" "--disable-tap.... enable/disable tapping\n" + "--enable-drag-lock\n" + "--disable-drag-lock.... enable/disable tapping drag lock\n" "--enable-natural-scrolling\n" "--disable-natural-scrolling.... enable/disable natural scrolling\n" "--enable-left-handed\n" @@ -100,6 +104,7 @@ tools_init_options(struct tools_options *options) { memset(options, 0, sizeof(*options)); options->tapping = -1; + options->drag_lock = -1; options->natural_scroll = -1; options->left_handed = -1; options->middlebutton = -1; @@ -124,6 +129,8 @@ tools_parse_args(int argc, char **argv, struct tools_options *options) { "verbose", 0, 0, OPT_VERBOSE }, { "enable-tap", 0, 0, OPT_TAP_ENABLE }, { "disable-tap", 0, 0, OPT_TAP_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 }, { "disable-natural-scrolling", 0, 0, OPT_NATURAL_SCROLL_DISABLE }, { "enable-left-handed", 0, 0, OPT_LEFT_HANDED_ENABLE }, @@ -168,6 +175,12 @@ tools_parse_args(int argc, char **argv, struct tools_options *options) case OPT_TAP_DISABLE: options->tapping = 0; break; + case OPT_DRAG_LOCK_ENABLE: + options->drag_lock = 1; + break; + case OPT_DRAG_LOCK_DISABLE: + options->drag_lock = 0; + break; case OPT_NATURAL_SCROLL_ENABLE: options->natural_scroll = 1; break; @@ -354,6 +367,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_lock != -1) + libinput_device_config_tap_set_drag_lock_enabled(device, + options->drag_lock); if (options->natural_scroll != -1) libinput_device_config_scroll_set_natural_scroll_enabled(device, options->natural_scroll); diff --git a/tools/shared.h b/tools/shared.h index 3ce2e1ca..da752d59 100644 --- a/tools/shared.h +++ b/tools/shared.h @@ -38,6 +38,7 @@ struct tools_options { int verbose; int tapping; + int drag_lock; int natural_scroll; int left_handed; int middlebutton; From 3195b95d1d814cdb35289fc5e3cfad97f00971bf Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 17 Jun 2015 10:59:21 +1000 Subject: [PATCH 08/26] test: add non-draglock test and rename draglock-dependent tests Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- test/touchpad-tap.c | 57 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 6 deletions(-) diff --git a/test/touchpad-tap.c b/test/touchpad-tap.c index 9bc02a0d..d04feb45 100644 --- a/test/touchpad-tap.c +++ b/test/touchpad-tap.c @@ -614,6 +614,50 @@ START_TEST(touchpad_1fg_multitap_n_drag_tap_click) END_TEST START_TEST(touchpad_1fg_tap_n_drag) +{ + struct litest_device *dev = litest_current_device(); + struct libinput *li = dev->libinput; + struct libinput_event *event; + struct libinput_event_pointer *ptrev __attribute__((unused)); + + litest_enable_tap(dev->libinput_device); + disable_drag_lock(dev->libinput_device); + + litest_drain_events(li); + + litest_touch_down(dev, 0, 50, 50); + litest_touch_up(dev, 0); + litest_touch_down(dev, 0, 50, 50); + litest_touch_move_to(dev, 0, 50, 50, 80, 80, 5, 40); + + libinput_dispatch(li); + + litest_assert_button_event(li, BTN_LEFT, + LIBINPUT_BUTTON_STATE_PRESSED); + + libinput_dispatch(li); + + litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); + + litest_touch_up(dev, 0); + + /* don't use helper functions here, we expect the event be available + * immediately, not after a timeout that the helper functions may + * trigger. + */ + libinput_dispatch(li); + event = libinput_get_event(li); + ck_assert_notnull(event); + ptrev = litest_is_button_event(event, + BTN_LEFT, + LIBINPUT_BUTTON_STATE_RELEASED); + libinput_event_destroy(event); + + litest_assert_empty_queue(li); +} +END_TEST + +START_TEST(touchpad_1fg_tap_n_drag_draglock) { struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; @@ -654,7 +698,7 @@ START_TEST(touchpad_1fg_tap_n_drag) } END_TEST -START_TEST(touchpad_1fg_tap_n_drag_tap) +START_TEST(touchpad_1fg_tap_n_drag_draglock_tap) { struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; @@ -696,7 +740,7 @@ START_TEST(touchpad_1fg_tap_n_drag_tap) } END_TEST -START_TEST(touchpad_1fg_tap_n_drag_tap_click) +START_TEST(touchpad_1fg_tap_n_drag_draglock_tap_click) { struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; @@ -741,7 +785,7 @@ START_TEST(touchpad_1fg_tap_n_drag_tap_click) } END_TEST -START_TEST(touchpad_1fg_tap_n_drag_timeout) +START_TEST(touchpad_1fg_tap_n_drag_draglock_timeout) { struct litest_device *dev = litest_current_device(); struct libinput *li = dev->libinput; @@ -1723,8 +1767,9 @@ litest_setup_tests(void) litest_add_ranged("touchpad:tap", touchpad_1fg_multitap_n_drag_2fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, &multitap_range); litest_add_ranged("touchpad:tap", touchpad_1fg_multitap_n_drag_click, LITEST_CLICKPAD, LITEST_ANY, &multitap_range); litest_add("touchpad:tap", touchpad_1fg_tap_n_drag, LITEST_TOUCHPAD, LITEST_ANY); - litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_tap, LITEST_TOUCHPAD, LITEST_ANY); - litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_timeout, LITEST_TOUCHPAD, LITEST_ANY); + litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_draglock, LITEST_TOUCHPAD, LITEST_ANY); + litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_draglock_tap, LITEST_TOUCHPAD, LITEST_ANY); + litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_draglock_timeout, LITEST_TOUCHPAD, LITEST_ANY); litest_add("touchpad:tap", touchpad_2fg_tap_n_drag, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH); litest_add("touchpad:tap", touchpad_2fg_tap_n_drag_3fg_btntool, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_APPLE_CLICKPAD); litest_add("touchpad:tap", touchpad_2fg_tap_n_drag_3fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH); @@ -1753,7 +1798,7 @@ litest_setup_tests(void) litest_add("touchpad:tap", touchpad_1fg_double_tap_click, LITEST_CLICKPAD, LITEST_ANY); litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_click, LITEST_CLICKPAD, LITEST_ANY); litest_add_ranged("touchpad:tap", touchpad_1fg_multitap_n_drag_tap_click, LITEST_CLICKPAD, LITEST_ANY, &multitap_range); - litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_tap_click, LITEST_CLICKPAD, LITEST_ANY); + litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_draglock_tap_click, LITEST_CLICKPAD, LITEST_ANY); litest_add("touchpad:tap", touchpad_tap_default_disabled, LITEST_TOUCHPAD|LITEST_BUTTON, LITEST_ANY); litest_add("touchpad:tap", touchpad_tap_default_enabled, LITEST_TOUCHPAD, LITEST_BUTTON); From f783dae0a70e660f8fc0175b4a702bd3f9953d7d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 19 Jun 2015 09:21:58 +1000 Subject: [PATCH 09/26] touchpad: only send most recent edge delta when triggering threshold When edge scrolling is triggered by exceeding the motion threshold (5mm) we sent the whole delta as the first scroll event, causing a big jump. Instead, send only the current delta. This effectively introduces a 5mm dead zone when edge scrolling, still better than the jump. https://bugs.freedesktop.org/show_bug.cgi?id=90990 Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/evdev-mt-touchpad-edge-scroll.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c index 56f1e8a0..992a1693 100644 --- a/src/evdev-mt-touchpad-edge-scroll.c +++ b/src/evdev-mt-touchpad-edge-scroll.c @@ -353,7 +353,7 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time) struct tp_touch *t; enum libinput_pointer_axis axis; double *delta; - struct normalized_coords normalized; + struct normalized_coords normalized, tmp; const struct normalized_coords zero = { 0.0, 0.0 }; const struct discrete_coords zero_discrete = { 0.0, 0.0 }; @@ -402,11 +402,14 @@ tp_edge_scroll_post_events(struct tp_dispatch *tp, uint64_t time) t->scroll.edge_state); break; case EDGE_SCROLL_TOUCH_STATE_EDGE_NEW: + tmp = normalized; normalized = tp_normalize_delta(tp, device_delta(t->point, t->scroll.initial)); if (fabs(*delta) < DEFAULT_SCROLL_THRESHOLD) normalized = zero; + else + normalized = tmp; break; case EDGE_SCROLL_TOUCH_STATE_EDGE: break; From abc8c0d6c29ce60275ff8a35fc7bdbbf6407969b Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 19 Jun 2015 10:11:13 +1000 Subject: [PATCH 10/26] touchpad: reduce edge scroll motion threshold to 3mm Reduce the dead zone/initial jump https://bugs.freedesktop.org/show_bug.cgi?id=90990 Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/evdev-mt-touchpad-edge-scroll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c index 992a1693..6bfef904 100644 --- a/src/evdev-mt-touchpad-edge-scroll.c +++ b/src/evdev-mt-touchpad-edge-scroll.c @@ -39,7 +39,7 @@ avoid accidentally locking in scrolling mode when trying to use the entire touchpad to move the pointer. The user can wait for the timeout to trigger to do a small scroll. */ -#define DEFAULT_SCROLL_THRESHOLD TP_MM_TO_DPI_NORMALIZED(5) +#define DEFAULT_SCROLL_THRESHOLD TP_MM_TO_DPI_NORMALIZED(3) enum scroll_event { SCROLL_EVENT_TOUCH, From 8baf05ebddefcc9becda2d19831b472fcd7e5098 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 24 Jun 2015 11:00:52 +1000 Subject: [PATCH 11/26] Fix an indentation issue Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 356f9b9e..9e60f466 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -524,7 +524,7 @@ tp_palm_detect(struct tp_dispatch *tp, struct tp_touch *t, uint64_t time) int dirs; if (tp_palm_detect_dwt(tp, t, time)) - goto out; + goto out; /* If labelled a touch as palm, we unlabel as palm when we move out of the palm edge zone within the timeout, provided From 6b2afee368f622091a0195252903daf7f23b5333 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 24 Jun 2015 14:46:53 +1000 Subject: [PATCH 12/26] tools: remove obsolete comments With the OPT_foo enums, these comments aren't necessary anymore Signed-off-by: Peter Hutterer --- tools/shared.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/shared.c b/tools/shared.c index 0c2f9c42..a0ff779c 100644 --- a/tools/shared.c +++ b/tools/shared.c @@ -149,11 +149,11 @@ tools_parse_args(int argc, char **argv, struct tools_options *options) break; switch(c) { - case 'h': /* --help */ + case 'h': case OPT_HELP: tools_usage(); exit(0); - case OPT_DEVICE: /* --device */ + case OPT_DEVICE: options->backend = BACKEND_DEVICE; if (!optarg) { tools_usage(); @@ -161,12 +161,12 @@ tools_parse_args(int argc, char **argv, struct tools_options *options) } options->device = optarg; break; - case OPT_UDEV: /* --udev */ + case OPT_UDEV: options->backend = BACKEND_UDEV; if (optarg) options->seat = optarg; break; - case OPT_VERBOSE: /* --verbose */ + case OPT_VERBOSE: options->verbose = 1; break; case OPT_TAP_ENABLE: From 41ad79f8d80d6b919cb17099751bac5a0cbca0ca Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 24 Jun 2015 14:52:48 +1000 Subject: [PATCH 13/26] tools: move the interface into the shared code No need to duplicate this atm Signed-off-by: Peter Hutterer --- tools/event-debug.c | 20 +------------------- tools/event-gui.c | 20 +------------------- tools/libinput-list-devices.c | 24 +----------------------- tools/shared.c | 29 +++++++++++++++++++++++++---- tools/shared.h | 3 +-- 5 files changed, 29 insertions(+), 67 deletions(-) diff --git a/tools/event-debug.c b/tools/event-debug.c index becde168..77133851 100644 --- a/tools/event-debug.c +++ b/tools/event-debug.c @@ -45,24 +45,6 @@ static const uint32_t screen_height = 100; struct tools_options options; static unsigned int stop = 0; -static int -open_restricted(const char *path, int flags, void *user_data) -{ - int fd = open(path, flags); - return fd < 0 ? -errno : fd; -} - -static void -close_restricted(int fd, void *user_data) -{ - close(fd); -} - -static const struct libinput_interface interface = { - .open_restricted = open_restricted, - .close_restricted = close_restricted, -}; - static void print_event_header(struct libinput_event *ev) { @@ -403,7 +385,7 @@ main(int argc, char **argv) if (tools_parse_args(argc, argv, &options)) return 1; - li = tools_open_backend(&options, NULL, &interface); + li = tools_open_backend(&options, NULL); if (!li) return 1; diff --git a/tools/event-gui.c b/tools/event-gui.c index 9d291956..7af2a303 100644 --- a/tools/event-gui.c +++ b/tools/event-gui.c @@ -489,24 +489,6 @@ sockets_init(struct libinput *li) g_io_add_watch(c, G_IO_IN, handle_event_libinput, li); } -static int -open_restricted(const char *path, int flags, void *user_data) -{ - int fd = open(path, flags); - return fd < 0 ? -errno : fd; -} - -static void -close_restricted(int fd, void *user_data) -{ - close(fd); -} - -static const struct libinput_interface interface = { - .open_restricted = open_restricted, - .close_restricted = close_restricted, -}; - int main(int argc, char *argv[]) { @@ -525,7 +507,7 @@ main(int argc, char *argv[]) if (!udev) error("Failed to initialize udev\n"); - li = tools_open_backend(&options, &w, &interface); + li = tools_open_backend(&options, &w); if (!li) return 1; diff --git a/tools/libinput-list-devices.c b/tools/libinput-list-devices.c index b3f7e2f9..e66aa3c9 100644 --- a/tools/libinput-list-devices.c +++ b/tools/libinput-list-devices.c @@ -23,7 +23,6 @@ #define _GNU_SOURCE #include -#include #include #include #include @@ -36,27 +35,6 @@ #include "shared.h" -static int -open_restricted(const char *path, int flags, void *user_data) -{ - int fd = open(path, flags); - if (fd < 0) - fprintf(stderr, "Failed to open %s (%s)\n", - path, strerror(errno)); - return fd < 0 ? -errno : fd; -} - -static void -close_restricted(int fd, void *user_data) -{ - close(fd); -} - -static const struct libinput_interface interface = { - .open_restricted = open_restricted, - .close_restricted = close_restricted, -}; - static inline const char* bool_to_str(bool b) { @@ -308,7 +286,7 @@ main(int argc, char **argv) tools_init_options(&options); - li = tools_open_backend(&options, NULL, &interface); + li = tools_open_backend(&options, NULL); if (!li) return 1; diff --git a/tools/shared.c b/tools/shared.c index a0ff779c..7b032080 100644 --- a/tools/shared.c +++ b/tools/shared.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -344,17 +345,37 @@ open_device(const struct libinput_interface *interface, return li; } +static int +open_restricted(const char *path, int flags, void *user_data) +{ + int fd = open(path, flags); + if (fd < 0) + fprintf(stderr, "Failed to open %s (%s)\n", + path, strerror(errno)); + return fd < 0 ? -errno : fd; +} + +static void +close_restricted(int fd, void *user_data) +{ + close(fd); +} + +static const struct libinput_interface interface = { + .open_restricted = open_restricted, + .close_restricted = close_restricted, +}; + struct libinput * tools_open_backend(struct tools_options *options, - void *userdata, - const struct libinput_interface *interface) + void *userdata) { struct libinput *li = NULL; if (options->backend == BACKEND_UDEV) { - li = open_udev(interface, userdata, options->seat, options->verbose); + li = open_udev(&interface, userdata, options->seat, options->verbose); } else if (options->backend == BACKEND_DEVICE) { - li = open_device(interface, userdata, options->device, options->verbose); + li = open_device(&interface, userdata, options->device, options->verbose); } else abort(); diff --git a/tools/shared.h b/tools/shared.h index da752d59..dad33a16 100644 --- a/tools/shared.h +++ b/tools/shared.h @@ -51,8 +51,7 @@ struct tools_options { void tools_init_options(struct tools_options *options); int tools_parse_args(int argc, char **argv, struct tools_options *options); struct libinput* tools_open_backend(struct tools_options *options, - void *userdata, - const struct libinput_interface *interface); + void *userdata); void tools_device_apply_config(struct libinput_device *device, struct tools_options *options); void tools_usage(); From b7c414558d4d9520b3d935be9e6ad3c7f045639e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 24 Jun 2015 15:07:53 +1000 Subject: [PATCH 14/26] tools: pass a context around as userdata We need the options during open_restricted(), so instead of the caller just passing in a custom userdata, let them wrap it into a tools_context. Signed-off-by: Peter Hutterer --- tools/event-debug.c | 10 +++++----- tools/event-gui.c | 22 +++++++++++++--------- tools/libinput-list-devices.c | 6 +++--- tools/shared.c | 14 +++++++++----- tools/shared.h | 12 ++++++++---- 5 files changed, 38 insertions(+), 26 deletions(-) diff --git a/tools/event-debug.c b/tools/event-debug.c index 77133851..7f6c54ab 100644 --- a/tools/event-debug.c +++ b/tools/event-debug.c @@ -42,7 +42,7 @@ uint32_t start_time; static const uint32_t screen_width = 100; static const uint32_t screen_height = 100; -struct tools_options options; +struct tools_context context; static unsigned int stop = 0; static void @@ -298,7 +298,7 @@ handle_and_print_events(struct libinput *li) case LIBINPUT_EVENT_DEVICE_REMOVED: print_device_notify(ev); tools_device_apply_config(libinput_event_get_device(ev), - &options); + &context.options); break; case LIBINPUT_EVENT_KEYBOARD_KEY: print_key_event(ev); @@ -380,12 +380,12 @@ main(int argc, char **argv) struct libinput *li; struct timespec tp; - tools_init_options(&options); + tools_init_context(&context); - if (tools_parse_args(argc, argv, &options)) + if (tools_parse_args(argc, argv, &context)) return 1; - li = tools_open_backend(&options, NULL); + li = tools_open_backend(&context); if (!li) return 1; diff --git a/tools/event-gui.c b/tools/event-gui.c index 7af2a303..5736e979 100644 --- a/tools/event-gui.c +++ b/tools/event-gui.c @@ -44,7 +44,7 @@ #define clip(val_, min_, max_) min((max_), max((min_), (val_))) -struct tools_options options; +struct tools_context context; struct touch { int active; @@ -264,6 +264,7 @@ change_ptraccel(struct window *w, double amount) static void handle_event_device_notify(struct libinput_event *ev) { + struct tools_context *context; struct libinput_device *dev = libinput_event_get_device(ev); struct libinput *li; struct window *w; @@ -280,11 +281,12 @@ handle_event_device_notify(struct libinput_event *ev) libinput_device_get_name(dev), type); - tools_device_apply_config(libinput_event_get_device(ev), - &options); - li = libinput_event_get_context(ev); - w = libinput_get_user_data(li); + context = libinput_get_user_data(li); + w = context->user_data; + + tools_device_apply_config(libinput_event_get_device(ev), + &context->options); if (libinput_event_get_type(ev) == LIBINPUT_EVENT_DEVICE_ADDED) { for (i = 0; i < ARRAY_LENGTH(w->devices); i++) { @@ -430,7 +432,8 @@ static gboolean handle_event_libinput(GIOChannel *source, GIOCondition condition, gpointer data) { struct libinput *li = data; - struct window *w = libinput_get_user_data(li); + struct tools_context *context = libinput_get_user_data(li); + struct window *w = context->user_data; struct libinput_event *ev; libinput_dispatch(li); @@ -498,16 +501,17 @@ main(int argc, char *argv[]) gtk_init(&argc, &argv); - tools_init_options(&options); + tools_init_context(&context); - if (tools_parse_args(argc, argv, &options) != 0) + if (tools_parse_args(argc, argv, &context) != 0) return 1; udev = udev_new(); if (!udev) error("Failed to initialize udev\n"); - li = tools_open_backend(&options, &w); + context.user_data = &w; + li = tools_open_backend(&context); if (!li) return 1; diff --git a/tools/libinput-list-devices.c b/tools/libinput-list-devices.c index e66aa3c9..6d162e2f 100644 --- a/tools/libinput-list-devices.c +++ b/tools/libinput-list-devices.c @@ -268,7 +268,7 @@ int main(int argc, char **argv) { struct libinput *li; - struct tools_options options; + struct tools_context context; struct libinput_event *ev; if (argc > 1) { @@ -284,9 +284,9 @@ main(int argc, char **argv) } } - tools_init_options(&options); + tools_init_context(&context); - li = tools_open_backend(&options, NULL); + li = tools_open_backend(&context); if (!li) return 1; diff --git a/tools/shared.c b/tools/shared.c index 7b032080..0bb03b1b 100644 --- a/tools/shared.c +++ b/tools/shared.c @@ -101,8 +101,12 @@ tools_usage() } void -tools_init_options(struct tools_options *options) +tools_init_context(struct tools_context *context) { + struct tools_options *options = &context->options; + + context->user_data = NULL; + memset(options, 0, sizeof(*options)); options->tapping = -1; options->drag_lock = -1; @@ -367,15 +371,15 @@ static const struct libinput_interface interface = { }; struct libinput * -tools_open_backend(struct tools_options *options, - void *userdata) +tools_open_backend(struct tools_context *context) { struct libinput *li = NULL; + struct tools_options *options = &context->options; if (options->backend == BACKEND_UDEV) { - li = open_udev(&interface, userdata, options->seat, options->verbose); + li = open_udev(&interface, context, options->seat, options->verbose); } else if (options->backend == BACKEND_DEVICE) { - li = open_device(&interface, userdata, options->device, options->verbose); + li = open_device(&interface, context, options->device, options->verbose); } else abort(); diff --git a/tools/shared.h b/tools/shared.h index dad33a16..442d7cd3 100644 --- a/tools/shared.h +++ b/tools/shared.h @@ -48,10 +48,14 @@ struct tools_options { double speed; }; -void tools_init_options(struct tools_options *options); -int tools_parse_args(int argc, char **argv, struct tools_options *options); -struct libinput* tools_open_backend(struct tools_options *options, - void *userdata); +struct tools_context { + struct tools_options options; + void *user_data; +}; + +void tools_init_context(struct tools_context *context); +int tools_parse_args(int argc, char **argv, struct tools_context *context); +struct libinput* tools_open_backend(struct tools_context *context); void tools_device_apply_config(struct libinput_device *device, struct tools_options *options); void tools_usage(); From f74769e77e2e51b568cf2061e7703eec1405f06d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 24 Jun 2015 15:12:54 +1000 Subject: [PATCH 15/26] tools: add --grab option Issues an EVIOCGRAB on the openend devices, providing exclusive access. Makes it easier for debugging, so moving the pointer doesn't accidentally trigger other stuff. Signed-off-by: Peter Hutterer --- tools/shared.c | 17 ++++++++++++++++- tools/shared.h | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/shared.c b/tools/shared.c index 0bb03b1b..64544c5c 100644 --- a/tools/shared.c +++ b/tools/shared.c @@ -40,6 +40,7 @@ enum options { OPT_DEVICE, OPT_UDEV, + OPT_GRAB, OPT_HELP, OPT_VERBOSE, OPT_TAP_ENABLE, @@ -95,6 +96,7 @@ tools_usage() "is not explicitly specified it is left at each device's default.\n" "\n" "Other options:\n" + "--grab .......... Exclusively grab all openend devices\n" "--verbose ....... Print debugging output.\n" "--help .......... Print this help.\n", program_invocation_short_name); @@ -122,14 +124,17 @@ tools_init_context(struct tools_context *context) } int -tools_parse_args(int argc, char **argv, struct tools_options *options) +tools_parse_args(int argc, char **argv, struct tools_context *context) { + struct tools_options *options = &context->options; + while (1) { int c; int option_index = 0; static struct option opts[] = { { "device", 1, 0, OPT_DEVICE }, { "udev", 0, 0, OPT_UDEV }, + { "grab", 0, 0, OPT_GRAB }, { "help", 0, 0, OPT_HELP }, { "verbose", 0, 0, OPT_VERBOSE }, { "enable-tap", 0, 0, OPT_TAP_ENABLE }, @@ -171,6 +176,9 @@ tools_parse_args(int argc, char **argv, struct tools_options *options) if (optarg) options->seat = optarg; break; + case OPT_GRAB: + options->grab = 1; + break; case OPT_VERBOSE: options->verbose = 1; break; @@ -352,10 +360,17 @@ open_device(const struct libinput_interface *interface, static int open_restricted(const char *path, int flags, void *user_data) { + const struct tools_context *context = user_data; int fd = open(path, flags); + if (fd < 0) fprintf(stderr, "Failed to open %s (%s)\n", path, strerror(errno)); + else if (context->options.grab && + ioctl(fd, EVIOCGRAB, (void*)1) == -1) + fprintf(stderr, "Grab requested, but failed for %s (%s)\n", + path, strerror(errno)); + return fd < 0 ? -errno : fd; } diff --git a/tools/shared.h b/tools/shared.h index 442d7cd3..a848e2d1 100644 --- a/tools/shared.h +++ b/tools/shared.h @@ -35,6 +35,7 @@ struct tools_options { enum tools_backend backend; const char *device; /* if backend is BACKEND_DEVICE */ const char *seat; /* if backend is BACKEND_UDEV */ + int grab; /* EVIOCGRAB */ int verbose; int tapping; From 56264a6ff624afc39935a744d5fd40f0ae969a52 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 25 Jun 2015 12:20:04 +1000 Subject: [PATCH 16/26] touchpad: fix stuck finger after a click On a touchpad without resolution, the pinned finger was stuck. The motion distance scale factor ended up as 0 and the finger never reached the threshold of 3mm. int was not the best choice of datatype for a value of 0.007... Fix the data types for xdist/ydist at the same time, clamping to int may cause erroneous (un)pinning. Introduced in 8025b374d564f4a30b089e5cf6fd65e0c6af8da2 https://bugs.freedesktop.org/show_bug.cgi?id=91070 Signed-off-by: Peter Hutterer --- src/evdev-mt-touchpad-buttons.c | 2 +- src/evdev-mt-touchpad.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index 8d4e278e..6abf9d5f 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -741,7 +741,7 @@ tp_init_buttons(struct tp_dispatch *tp, /* pinned-finger motion threshold, see tp_unpin_finger. The MAGIC for resolution-less touchpads ends up as 2% of the diagonal */ if (device->abs.fake_resolution) { - const int BUTTON_MOTION_MAGIC = 0.007; + const double BUTTON_MOTION_MAGIC = 0.007; width = abs(absinfo_x->maximum - absinfo_x->minimum); height = abs(absinfo_y->maximum - absinfo_y->minimum); diagonal = sqrt(width*width + height*height); diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 9e60f466..4666870b 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -426,7 +426,7 @@ tp_process_key(struct tp_dispatch *tp, static void tp_unpin_finger(struct tp_dispatch *tp, struct tp_touch *t) { - unsigned int xdist, ydist; + double xdist, ydist; if (!t->pinned.is_pinned) return; From 38d59cefff831bc1a80f145159f17783402a95b0 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 24 Jun 2015 15:30:59 +1000 Subject: [PATCH 17/26] Add a debug_trace() macro for easier debugging Disabled by default, define DEBUG_TRACE when needed Signed-off-by: Peter Hutterer --- src/libinput-util.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libinput-util.h b/src/libinput-util.h index 4f73ad41..0c56b765 100644 --- a/src/libinput-util.h +++ b/src/libinput-util.h @@ -93,6 +93,15 @@ int list_empty(const struct list *list); #define streq(s1, s2) (strcmp((s1), (s2)) == 0) #define strneq(s1, s2, n) (strncmp((s1), (s2), (n)) == 0) +#ifdef DEBUG_TRACE +#define debug_trace(...) \ + do { \ + printf("%s:%d %s() - ", __FILE__, __LINE__, __func__); \ + printf(__VA_ARGS__); \ + } while (0) +#else +#define debug_trace(...) { } +#endif #define LIBINPUT_EXPORT __attribute__ ((visibility("default"))) static inline void * From 387b8057b14ffcf2f953cbd9a86f0992efabef8c Mon Sep 17 00:00:00 2001 From: Gilles Dartiguelongue Date: Tue, 23 Jun 2015 11:31:56 +0200 Subject: [PATCH 18/26] Add missing includes for *stat Signed-off-by: Gilles Dartiguelongue Signed-off-by: Peter Hutterer --- src/evdev.c | 1 + src/path.c | 1 + 2 files changed, 2 insertions(+) diff --git a/src/evdev.c b/src/evdev.c index 7e1e5c80..cfcdc349 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "linux/input.h" #include #include diff --git a/src/path.c b/src/path.c index 92535cda..ab4d0655 100644 --- a/src/path.c +++ b/src/path.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "path.h" From 0d2c25e123a72c6b0dfa9e3b82689140fa4c1bd3 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 25 Jun 2015 14:10:38 +1000 Subject: [PATCH 19/26] evdev: store the device dimensions We use width/height often enough that storing it once is better than calculating it on each event. Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/evdev-mt-touchpad-buttons.c | 18 ++++++++---------- src/evdev-mt-touchpad-edge-scroll.c | 4 ++-- src/evdev-mt-touchpad.c | 12 ++++-------- src/evdev.c | 8 ++++++++ src/evdev.h | 2 ++ 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/evdev-mt-touchpad-buttons.c b/src/evdev-mt-touchpad-buttons.c index 6abf9d5f..9c1c096c 100644 --- a/src/evdev-mt-touchpad-buttons.c +++ b/src/evdev-mt-touchpad-buttons.c @@ -527,8 +527,8 @@ tp_init_softbuttons(struct tp_dispatch *tp, xoffset = absinfo_x->minimum, yoffset = absinfo_y->minimum; yres = absinfo_y->resolution; - width = abs(absinfo_x->maximum - absinfo_x->minimum); - height = abs(absinfo_y->maximum - absinfo_y->minimum); + width = device->abs.dimensions.x; + height = device->abs.dimensions.y; /* button height: 10mm or 15% of the touchpad height, whichever is smaller */ @@ -558,8 +558,8 @@ tp_init_top_softbuttons(struct tp_dispatch *tp, xoffset = absinfo_x->minimum, yoffset = absinfo_y->minimum; yres = absinfo_y->resolution; - width = abs(absinfo_x->maximum - absinfo_x->minimum); - height = abs(absinfo_y->maximum - absinfo_y->minimum); + width = device->abs.dimensions.x; + height = device->abs.dimensions.y; if (tp->buttons.has_topbuttons) { /* T440s has the top button line 5mm from the top, event @@ -742,8 +742,8 @@ tp_init_buttons(struct tp_dispatch *tp, The MAGIC for resolution-less touchpads ends up as 2% of the diagonal */ if (device->abs.fake_resolution) { const double BUTTON_MOTION_MAGIC = 0.007; - width = abs(absinfo_x->maximum - absinfo_x->minimum); - height = abs(absinfo_y->maximum - absinfo_y->minimum); + width = device->abs.dimensions.x; + height = device->abs.dimensions.y; diagonal = sqrt(width*width + height*height); tp->buttons.motion_dist.x_scale_coeff = diagonal * BUTTON_MOTION_MAGIC; tp->buttons.motion_dist.y_scale_coeff = diagonal * BUTTON_MOTION_MAGIC; @@ -838,10 +838,8 @@ tp_check_clickfinger_distance(struct tp_dispatch *tp, /* Use a maximum of 30% of the touchpad width or height if * we dont' have resolution. */ - w = tp->device->abs.absinfo_x->maximum - - tp->device->abs.absinfo_x->minimum; - h = tp->device->abs.absinfo_y->maximum - - tp->device->abs.absinfo_y->minimum; + w = tp->device->abs.dimensions.x; + h = tp->device->abs.dimensions.y; return (x < w * 0.3 && y < h * 0.3) ? 1 : 0; } else { diff --git a/src/evdev-mt-touchpad-edge-scroll.c b/src/evdev-mt-touchpad-edge-scroll.c index 6bfef904..9a9d3b84 100644 --- a/src/evdev-mt-touchpad-edge-scroll.c +++ b/src/evdev-mt-touchpad-edge-scroll.c @@ -275,8 +275,8 @@ tp_edge_scroll_init(struct tp_dispatch *tp, struct evdev_device *device) int width, height; int edge_width, edge_height; - width = device->abs.absinfo_x->maximum - device->abs.absinfo_x->minimum; - height = device->abs.absinfo_y->maximum - device->abs.absinfo_y->minimum; + width = device->abs.dimensions.x; + height = device->abs.dimensions.y; switch (tp->model) { case MODEL_ALPS: diff --git a/src/evdev-mt-touchpad.c b/src/evdev-mt-touchpad.c index 4666870b..c70d28e6 100644 --- a/src/evdev-mt-touchpad.c +++ b/src/evdev-mt-touchpad.c @@ -1402,10 +1402,8 @@ tp_init_palmdetect(struct tp_dispatch *tp, tp->palm.left_edge = INT_MIN; tp->palm.vert_center = INT_MIN; - width = abs(device->abs.absinfo_x->maximum - - device->abs.absinfo_x->minimum); - height = abs(device->abs.absinfo_y->maximum - - device->abs.absinfo_y->minimum); + width = device->abs.dimensions.x; + height = device->abs.dimensions.y; /* Wacom doesn't have internal touchpads, * Apple touchpads are always big enough to warrant palm detection */ @@ -1484,10 +1482,8 @@ tp_init(struct tp_dispatch *tp, if (tp_init_slots(tp, device) != 0) return -1; - width = abs(device->abs.absinfo_x->maximum - - device->abs.absinfo_x->minimum); - height = abs(device->abs.absinfo_y->maximum - - device->abs.absinfo_y->minimum); + width = device->abs.dimensions.x; + height = device->abs.dimensions.y; diagonal = sqrt(width*width + height*height); tp->reports_distance = libevdev_has_event_code(device->evdev, diff --git a/src/evdev.c b/src/evdev.c index cfcdc349..627e185b 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1762,6 +1762,10 @@ evdev_configure_mt_device(struct evdev_device *device) device->abs.absinfo_x = libevdev_get_abs_info(evdev, ABS_MT_POSITION_X); device->abs.absinfo_y = libevdev_get_abs_info(evdev, ABS_MT_POSITION_Y); + device->abs.dimensions.x = abs(device->abs.absinfo_x->maximum - + device->abs.absinfo_x->minimum); + device->abs.dimensions.y = abs(device->abs.absinfo_y->maximum - + device->abs.absinfo_y->minimum); device->is_mt = 1; /* We only handle the slotted Protocol B in libinput. @@ -1874,6 +1878,10 @@ evdev_configure_device(struct evdev_device *device) device->abs.absinfo_y = libevdev_get_abs_info(evdev, ABS_Y); device->abs.point.x = device->abs.absinfo_x->value; device->abs.point.y = device->abs.absinfo_y->value; + device->abs.dimensions.x = abs(device->abs.absinfo_x->maximum - + device->abs.absinfo_x->minimum); + device->abs.dimensions.y = abs(device->abs.absinfo_y->maximum - + device->abs.absinfo_y->minimum); if (evdev_is_fake_mt_device(device)) { udev_tags &= ~EVDEV_UDEV_TAG_TOUCHSCREEN; diff --git a/src/evdev.h b/src/evdev.h index 566b0a44..0485894d 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -137,6 +137,8 @@ struct evdev_device { struct matrix calibration; struct matrix default_calibration; /* from LIBINPUT_CALIBRATION_MATRIX */ struct matrix usermatrix; /* as supplied by the caller */ + + struct device_coords dimensions; } abs; struct { From 83028604513641e9bd7c8ad7c864d52c8f313d62 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 19 Jun 2015 16:01:34 +1000 Subject: [PATCH 20/26] evdev: read dpi before evdev_configure_device So we can use to set up accel during evdev_configure_device. Signed-off-by: Peter Hutterer --- src/evdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index 627e185b..22df6223 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -2092,6 +2092,8 @@ evdev_device_create(struct libinput_seat *seat, device->scroll.wheel_click_angle = evdev_read_wheel_click_prop(device); device->model = evdev_read_model(device); + device->dpi = evdev_read_dpi_prop(device); + /* at most 5 SYN_DROPPED log-messages per 30s */ ratelimit_init(&device->syn_drop_limit, 30ULL * 1000, 5); @@ -2102,8 +2104,6 @@ evdev_device_create(struct libinput_seat *seat, if (evdev_configure_device(device) == -1) goto err; - device->dpi = evdev_read_dpi_prop(device); - if (device->seat_caps == 0) { unhandled_device = 1; goto err; From ffaf1f3b725cd7aa27a8dc05fdc9a9f3b60c6f77 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 23 Jun 2015 12:41:57 +1000 Subject: [PATCH 21/26] evdev: log device's DPI setting if any Makes debugging things easier. Signed-off-by: Peter Hutterer --- src/evdev.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/evdev.c b/src/evdev.c index 22df6223..9e2909c3 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -1497,6 +1497,10 @@ evdev_read_dpi_prop(struct evdev_device *device) DEFAULT_MOUSE_DPI); dpi = DEFAULT_MOUSE_DPI; } + log_info(libinput, + "Device '%s' set to %d DPI\n", + device->devname, + dpi); } return dpi; From 7ebb718ee9dfe84b02e4e8cecb6854b620808822 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 26 Jun 2015 09:27:20 +1000 Subject: [PATCH 22/26] evdev: move posting a trackpoint scroll event into a helper Signed-off-by: Peter Hutterer --- src/evdev.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index 9e2909c3..63d2ca8e 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -254,6 +254,23 @@ normalize_delta(struct evdev_device *device, normalized->y = delta->y * DEFAULT_MOUSE_DPI / (double)device->dpi; } +static inline bool +evdev_post_trackpoint_scroll(struct evdev_device *device, + struct normalized_coords unaccel, + uint64_t time) +{ + if (device->scroll.method != LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN || + !hw_is_key_down(device, device->scroll.button)) + return false; + + if (device->scroll.button_scroll_active) + evdev_post_scroll(device, time, + LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS, + &unaccel); + + return true; +} + static void evdev_flush_pending_event(struct evdev_device *device, uint64_t time) { @@ -276,14 +293,8 @@ evdev_flush_pending_event(struct evdev_device *device, uint64_t time) device->rel.y = 0; /* Use unaccelerated deltas for pointing stick scroll */ - if (device->scroll.method == LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN && - hw_is_key_down(device, device->scroll.button)) { - if (device->scroll.button_scroll_active) - evdev_post_scroll(device, time, - LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS, - &unaccel); - break; - } + if (evdev_post_trackpoint_scroll(device, unaccel, time)) + break; /* Apply pointer acceleration. */ accel = filter_dispatch(device->pointer.filter, From c902b37a8d1efe4f0d48eee828427be9659f606b Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 26 Jun 2015 10:00:24 +1000 Subject: [PATCH 23/26] tools: don't drop the accelerated deltas in ptraccel-debug Leftover from the initial (out-of-tree) implementation where we updated motion in place. That hasn't been true since libinput switched to type-safe coordinates. Signed-off-by: Peter Hutterer --- tools/ptraccel-debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/ptraccel-debug.c b/tools/ptraccel-debug.c index 1d895983..c774e3bf 100644 --- a/tools/ptraccel-debug.c +++ b/tools/ptraccel-debug.c @@ -95,7 +95,7 @@ print_ptraccel_movement(struct motion_filter *filter, motion.y = 0; time += 12; /* pretend 80Hz data */ - filter_dispatch(filter, &motion, NULL, time); + motion = filter_dispatch(filter, &motion, NULL, time); printf("%d %.3f %.3f\n", i, motion.x, dx); @@ -129,7 +129,7 @@ print_ptraccel_sequence(struct motion_filter *filter, motion.y = 0; time += 12; /* pretend 80Hz data */ - filter_dispatch(filter, &motion, NULL, time); + motion = filter_dispatch(filter, &motion, NULL, time); printf("%d %.3f %.3f\n", i, motion.x, *dx); } From 68f94c6ba4bdfedb62c7e92e1cc025993ebecdf1 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Tue, 23 Jun 2015 12:45:55 +1000 Subject: [PATCH 24/26] filter: use a tmp variable for the accel factor No real effect, just makes the diff for debugging printfs smaller. Signed-off-by: Peter Hutterer --- src/filter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/filter.c b/src/filter.c index a4142e98..b37ca766 100644 --- a/src/filter.c +++ b/src/filter.c @@ -385,11 +385,14 @@ pointer_accel_profile_linear(struct motion_filter *filter, const double max_accel = accel_filter->accel; /* unitless factor */ const double threshold = accel_filter->threshold; /* units/ms */ const double incline = accel_filter->incline; + double factor; s1 = min(1, 0.3 + speed_in * 4); s2 = 1 + (speed_in - threshold) * incline; - return min(max_accel, s2 > 1 ? s2 : s1); + factor = min(max_accel, s2 > 1 ? s2 : s1); + + return factor; } double From 0f623c75b3796c5d55148f7711cbdf0277aadc5d Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 25 Jun 2015 11:03:09 +1000 Subject: [PATCH 25/26] Add missing @ingroup tag to the logging priority enum Signed-off-by: Peter Hutterer --- src/libinput.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libinput.h b/src/libinput.h index 240900b6..7d907f16 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -38,6 +38,8 @@ extern "C" { #define LIBINPUT_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated)) /** + * @ingroup base + * * Log priority for internal logging messages. */ enum libinput_log_priority { From b344e3e56646ecea29f3930d88b57babea358db2 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 26 Jun 2015 16:18:29 +1000 Subject: [PATCH 26/26] touchpad: disable tap drag lock by default Similar to tapping, it's a feature that is useful but confusing if a user doesn't know it exists. It makes the touchpad appear laggy and slow to react in the best case, or appear like a stuck button in the worst case. Signed-off-by: Peter Hutterer Reviewed-by: Hans de Goede --- src/evdev-mt-touchpad-tap.c | 2 +- test/touchpad-tap.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/evdev-mt-touchpad-tap.c b/src/evdev-mt-touchpad-tap.c index 40d431aa..7f241de5 100644 --- a/src/evdev-mt-touchpad-tap.c +++ b/src/evdev-mt-touchpad-tap.c @@ -880,7 +880,7 @@ tp_tap_config_get_draglock_enabled(struct libinput_device *device) static inline enum libinput_config_drag_lock_state tp_drag_lock_default(struct evdev_device *device) { - return LIBINPUT_CONFIG_DRAG_LOCK_ENABLED; + return LIBINPUT_CONFIG_DRAG_LOCK_DISABLED; } static enum libinput_config_drag_lock_state diff --git a/test/touchpad-tap.c b/test/touchpad-tap.c index d04feb45..c021f1dc 100644 --- a/test/touchpad-tap.c +++ b/test/touchpad-tap.c @@ -1699,16 +1699,16 @@ START_TEST(touchpad_tap_invalid) } END_TEST -START_TEST(touchpad_drag_lock_default_enabled) +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_ENABLED); + LIBINPUT_CONFIG_DRAG_LOCK_DISABLED); ck_assert_int_eq(libinput_device_config_tap_get_default_drag_lock_enabled(device), - LIBINPUT_CONFIG_DRAG_LOCK_ENABLED); + LIBINPUT_CONFIG_DRAG_LOCK_DISABLED); status = libinput_device_config_tap_set_drag_lock_enabled(device, LIBINPUT_CONFIG_DRAG_LOCK_ENABLED); @@ -1728,7 +1728,7 @@ START_TEST(touchpad_drag_lock_default_enabled) } END_TEST -START_TEST(touchpad_drag_lock_default_disabled) +START_TEST(touchpad_drag_lock_default_unavailable) { struct litest_device *dev = litest_current_device(); struct libinput_device *device = dev->libinput_device; @@ -1809,7 +1809,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); + litest_add("touchpad:tap", touchpad_drag_lock_default_disabled, LITEST_TOUCHPAD, LITEST_ANY); + litest_add("touchpad:tap", touchpad_drag_lock_default_unavailable, LITEST_ANY, LITEST_TOUCHPAD); }