From 6d8a256bd4ffdee5a65ff81720b7ed91fd640637 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 6 Feb 2017 11:23:18 +1000 Subject: [PATCH] Swap the return values for unsupported scroll button configs Usually we reply INVALID before we reply UNSUPPORTED but that's only for those values where the value is a programming error. But in this case it's a bit more complicated. INVALID is only for the cases where the button doesn't exist on the device, if we don't have button scrolling at all then we have UNSUPPORTED for all. Signed-off-by: Peter Hutterer --- src/libinput.c | 6 +++--- test/test-pointer.c | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/libinput.c b/src/libinput.c index 84e329de..514a6119 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -3954,13 +3954,13 @@ LIBINPUT_EXPORT enum libinput_config_status libinput_device_config_scroll_set_button(struct libinput_device *device, uint32_t button) { - if (button && !libinput_device_pointer_has_button(device, button)) - return LIBINPUT_CONFIG_STATUS_INVALID; - if ((libinput_device_config_scroll_get_methods(device) & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) == 0) return LIBINPUT_CONFIG_STATUS_UNSUPPORTED; + if (button && !libinput_device_pointer_has_button(device, button)) + return LIBINPUT_CONFIG_STATUS_INVALID; + return device->config.scroll_method->set_button(device, button); } diff --git a/test/test-pointer.c b/test/test-pointer.c index f28b5076..57e7fd14 100644 --- a/test/test-pointer.c +++ b/test/test-pointer.c @@ -1014,6 +1014,28 @@ START_TEST(pointer_scroll_button) } END_TEST +START_TEST(pointer_scroll_button_noscroll) +{ + struct litest_device *dev = litest_current_device(); + struct libinput_device *device = dev->libinput_device; + uint32_t methods, button; + enum libinput_config_status status; + + methods = libinput_device_config_scroll_get_method(device); + ck_assert_int_eq((methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN), 0); + button = libinput_device_config_scroll_get_button(device); + ck_assert_int_eq(button, 0); + button = libinput_device_config_scroll_get_default_button(device); + ck_assert_int_eq(button, 0); + + status = libinput_device_config_scroll_set_method(device, + LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN); + ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED); + status = libinput_device_config_scroll_set_button(device, BTN_LEFT); + ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_UNSUPPORTED); +} +END_TEST + START_TEST(pointer_scroll_button_no_event_before_timeout) { struct litest_device *device = litest_current_device(); @@ -1889,6 +1911,7 @@ litest_setup_tests_pointer(void) litest_add_for_device("pointer:button", pointer_button_has_no_button, LITEST_KEYBOARD); litest_add("pointer:scroll", pointer_scroll_wheel, LITEST_WHEEL, LITEST_TABLET); litest_add("pointer:scroll", pointer_scroll_button, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY); + litest_add("pointer:scroll", pointer_scroll_button_noscroll, LITEST_ANY, LITEST_RELATIVE|LITEST_BUTTON); litest_add("pointer:scroll", pointer_scroll_button_no_event_before_timeout, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY); litest_add("pointer:scroll", pointer_scroll_button_middle_emulation, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY); litest_add("pointer:scroll", pointer_scroll_nowheel_defaults, LITEST_RELATIVE|LITEST_BUTTON, LITEST_WHEEL);