keyboard: fix modifiers event when no keymap set

Actually send the modifiers event when there is no keymap set.

Compositors may need lower-level "raw" access to the key/modifiers
events from the backend. Currently it is impossible for a compositor
to get modifier events from the backend without them being filtered
through an xkb_state controlled by wlroots.

I need this feature for river in order to fix some keyboard state
synchronization bugs.

Note that setting a keymap resets the modifiers so I don't think setting
wlr_keyboard->modifiers directly here is a concern.
This commit is contained in:
Isaac Freund 2026-03-30 17:13:57 +02:00 committed by Simon Ser
parent c66a910753
commit 9de0ec3089

View file

@ -84,6 +84,16 @@ void wlr_keyboard_notify_modifiers(struct wlr_keyboard *keyboard,
uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked,
uint32_t group) {
if (keyboard->xkb_state == NULL) {
if (keyboard->modifiers.depressed != mods_depressed ||
keyboard->modifiers.latched != mods_latched ||
keyboard->modifiers.locked != mods_locked ||
keyboard->modifiers.group != group) {
keyboard->modifiers.depressed = mods_depressed;
keyboard->modifiers.latched = mods_latched;
keyboard->modifiers.locked = mods_locked;
keyboard->modifiers.group = group;
wl_signal_emit_mutable(&keyboard->events.modifiers, keyboard);
}
return;
}
xkb_state_update_mask(keyboard->xkb_state, mods_depressed, mods_latched,