From 9de0ec308917262f8380e5a0c6d6110464f64314 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Mon, 30 Mar 2026 17:13:57 +0200 Subject: [PATCH] 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. --- types/wlr_keyboard.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/types/wlr_keyboard.c b/types/wlr_keyboard.c index a24335b3a..adc705db5 100644 --- a/types/wlr_keyboard.c +++ b/types/wlr_keyboard.c @@ -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,