backend/libinput: guard against new enum entries

When libinput introduces new enum entries, we'd abort or send bogus
events to the compositor. Instead, log a message and ignore the
event.

Keep all enums without a default case so that the compiler warns
when we're missing a case.
This commit is contained in:
Simon Ser 2026-02-12 22:37:41 +01:00 committed by Simon Zeni
parent 25f94c5965
commit 884d29e5f3
7 changed files with 179 additions and 89 deletions

View file

@ -148,13 +148,9 @@ void handle_tablet_pad_button(struct libinput_event *event,
.group = libinput_tablet_pad_mode_group_get_index(
libinput_event_tablet_pad_get_mode_group(pevent)),
};
switch (libinput_event_tablet_pad_get_button_state(pevent)) {
case LIBINPUT_BUTTON_STATE_PRESSED:
wlr_event.state = WLR_BUTTON_PRESSED;
break;
case LIBINPUT_BUTTON_STATE_RELEASED:
wlr_event.state = WLR_BUTTON_RELEASED;
break;
if (!button_state_from_libinput(libinput_event_tablet_pad_get_button_state(pevent), &wlr_event.state)) {
wlr_log(WLR_DEBUG, "Unhandled libinput button state");
return;
}
wl_signal_emit_mutable(&tablet_pad->events.button, &wlr_event);
}
@ -168,6 +164,7 @@ void handle_tablet_pad_ring(struct libinput_event *event,
.ring = libinput_event_tablet_pad_get_ring_number(pevent),
.position = libinput_event_tablet_pad_get_ring_position(pevent),
.mode = libinput_event_tablet_pad_get_mode(pevent),
.source = WLR_TABLET_PAD_RING_SOURCE_UNKNOWN,
};
switch (libinput_event_tablet_pad_get_ring_source(pevent)) {
case LIBINPUT_TABLET_PAD_RING_SOURCE_UNKNOWN:
@ -189,6 +186,7 @@ void handle_tablet_pad_strip(struct libinput_event *event,
.strip = libinput_event_tablet_pad_get_strip_number(pevent),
.position = libinput_event_tablet_pad_get_strip_position(pevent),
.mode = libinput_event_tablet_pad_get_mode(pevent),
.source = WLR_TABLET_PAD_STRIP_SOURCE_UNKNOWN,
};
switch (libinput_event_tablet_pad_get_strip_source(pevent)) {
case LIBINPUT_TABLET_PAD_STRIP_SOURCE_UNKNOWN: