From 998be47ac18123c2243c8d56546270acb4de0477 Mon Sep 17 00:00:00 2001 From: Bruno Filipe Date: Thu, 18 Jul 2024 06:56:18 +0000 Subject: [PATCH] backends/libinput: Ignore redundant events for pointer buttons and keyboard keys when pressed/released on multiple devices BUG: 486034 --- src/backends/libinput/connection.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/backends/libinput/connection.cpp b/src/backends/libinput/connection.cpp index e161212164..be67a7ecc8 100644 --- a/src/backends/libinput/connection.cpp +++ b/src/backends/libinput/connection.cpp @@ -302,6 +302,12 @@ void Connection::processEvents() } case LIBINPUT_EVENT_KEYBOARD_KEY: { KeyEvent *ke = static_cast(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(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;