mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-02-03 18:10:28 +01:00
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 <peter.hutterer@who-t.net>
This commit is contained in:
parent
7735f3aa4e
commit
6d8a256bd4
2 changed files with 26 additions and 3 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue