backends/libinput: Ignore redundant events for pointer buttons and keyboard keys when pressed/released on multiple devices

BUG: 486034
This commit is contained in:
Bruno Filipe 2024-07-18 06:56:18 +00:00 committed by Vlad Zahorodnii
parent ea4b2c2b20
commit 998be47ac1

View file

@ -302,6 +302,12 @@ void Connection::processEvents()
}
case LIBINPUT_EVENT_KEYBOARD_KEY: {
KeyEvent *ke = static_cast<KeyEvent *>(event.get());
const int seatKeyCount = libinput_event_keyboard_get_seat_key_count(*ke);
const int keyState = libinput_event_keyboard_get_key_state(*ke);
if ((keyState == LIBINPUT_KEY_STATE_PRESSED && seatKeyCount != 1) ||
(keyState == LIBINPUT_KEY_STATE_RELEASED && seatKeyCount != 0)) {
break;
}
Q_EMIT ke->device()->keyChanged(ke->key(), ke->state(), ke->time(), ke->device());
break;
}
@ -349,6 +355,12 @@ void Connection::processEvents()
}
case LIBINPUT_EVENT_POINTER_BUTTON: {
PointerEvent *pe = static_cast<PointerEvent *>(event.get());
const int seatButtonCount = libinput_event_pointer_get_seat_button_count(*pe);
const int buttonState = libinput_event_pointer_get_button_state(*pe);
if ((buttonState == LIBINPUT_BUTTON_STATE_PRESSED && seatButtonCount != 1) ||
(buttonState == LIBINPUT_BUTTON_STATE_RELEASED && seatButtonCount != 0)) {
break;
}
Q_EMIT pe->device()->pointerButtonChanged(pe->button(), pe->buttonState(), pe->time(), pe->device());
Q_EMIT pe->device()->pointerFrame(pe->device());
break;