aboutsummaryrefslogtreecommitdiff
path: root/backend/libinput/pointer.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-06-08 17:04:20 +0200
committerSimon Ser <contact@emersion.fr>2023-06-14 10:48:44 +0000
commite1c6801b652ff792e54ffee75b0804a185f1cc9d (patch)
tree324e5ccb93e38b730d5718468d39a06aecce145e /backend/libinput/pointer.c
parent670915eeeaa2faee95cb3c32c64199da4379adf8 (diff)
backend/libinput: ignore multiple events for same pointer button
If the same button is pressed on two devices on the same seat, ignore the second event. This is also what Mutter does. Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3665
Diffstat (limited to 'backend/libinput/pointer.c')
-rw-r--r--backend/libinput/pointer.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c
index a1d5ff9f..93f7ca32 100644
--- a/backend/libinput/pointer.c
+++ b/backend/libinput/pointer.c
@@ -63,12 +63,22 @@ void handle_pointer_button(struct libinput_event *event,
wlr_event.time_msec =
usec_to_msec(libinput_event_pointer_get_time_usec(pevent));
wlr_event.button = libinput_event_pointer_get_button(pevent);
+ // Ignore events which aren't a seat-wide state change. For instance, if
+ // the same button is pressed twice on the same seat, ignore the second
+ // press.
+ uint32_t seat_count = libinput_event_pointer_get_seat_button_count(pevent);
switch (libinput_event_pointer_get_button_state(pevent)) {
case LIBINPUT_BUTTON_STATE_PRESSED:
wlr_event.state = WLR_BUTTON_PRESSED;
+ if (seat_count != 1) {
+ return;
+ }
break;
case LIBINPUT_BUTTON_STATE_RELEASED:
wlr_event.state = WLR_BUTTON_RELEASED;
+ if (seat_count != 0) {
+ return;
+ }
break;
}
wl_signal_emit_mutable(&pointer->events.button, &wlr_event);