fallback: don't double-map if any left-handed buttons are down

The key_count array for buttons records the logical button sent to the
client - for left-handed configurations that means a BTN_LEFT is
recorded as BTN_RIGHT.

When the device is suspended and we are releasing all keys we must thus
release the button code as-is without trying to map it again.

Fixes #881

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2023-03-29 10:56:41 +10:00
parent 41b16e6e4f
commit 01a02d4033
2 changed files with 39 additions and 1 deletions

View file

@ -1057,10 +1057,15 @@ release_pressed_keys(struct fallback_dispatch *dispatch,
LIBINPUT_KEY_STATE_RELEASED);
break;
case KEY_TYPE_BUTTON:
/* Note: the left-handed configuration is nonzero for
* the mapped button (not the physical button), in
* get_key_down_count(). We must not map this to left-handed
* again, see #881.
*/
evdev_pointer_notify_button(
device,
time,
evdev_to_left_handed(device, code),
code,
LIBINPUT_BUTTON_STATE_RELEASED);
break;
}

View file

@ -1304,6 +1304,38 @@ START_TEST(pointer_left_handed_during_click_multiple_buttons)
}
END_TEST
START_TEST(pointer_left_handed_disable_with_button_down)
{
struct libinput *li = litest_create_context();
struct litest_device *dev = litest_add_device(li, LITEST_MOUSE);
enum libinput_config_status status;
status = libinput_device_config_left_handed_set(dev->libinput_device, 1);
ck_assert_int_eq(status, LIBINPUT_CONFIG_STATUS_SUCCESS);
litest_drain_events(li);
litest_button_click_debounced(dev, li, BTN_LEFT, 1);
libinput_dispatch(li);
litest_assert_button_event(li,
BTN_RIGHT,
LIBINPUT_BUTTON_STATE_PRESSED);
litest_delete_device(dev);
libinput_dispatch(li);
litest_assert_button_event(li,
BTN_RIGHT,
LIBINPUT_BUTTON_STATE_RELEASED);
struct libinput_event *event = libinput_get_event(li);
litest_assert_event_type(event, LIBINPUT_EVENT_DEVICE_REMOVED);
litest_assert_empty_queue(li);
libinput_event_destroy(event);
litest_destroy_context(li);
}
END_TEST
START_TEST(pointer_scroll_button)
{
struct litest_device *dev = litest_current_device();
@ -3730,6 +3762,7 @@ TEST_COLLECTION(pointer)
litest_add(pointer_left_handed, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
litest_add(pointer_left_handed_during_click, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
litest_add(pointer_left_handed_during_click_multiple_buttons, LITEST_RELATIVE|LITEST_BUTTON, LITEST_ANY);
litest_add_no_device(pointer_left_handed_disable_with_button_down);
litest_add(pointer_accel_defaults, LITEST_RELATIVE, LITEST_ANY);
litest_add(pointer_accel_invalid, LITEST_RELATIVE, LITEST_ANY);