forge
Explore
Log in

Don't you dare go Hollow

input: Update keyboard LEDs on config reloads

Browse files at this commit

12de51d6a60baad8896366920278a24f17921f52AeysolParent: 45739bc
On a keymap reset, niri restores Num Lock through `set_modifier_state()`
but does not restore the keyboard LEDs. On config reloads, an active Num
Lock modifier is not visible to the user and pressing Num Lock again to
supposedly turn it on will turn it off instead.
src/handlers/mod.rsmodified+1 -10
@@ -113,16 +113,7 @@ impl SeatHandler for State {
113113 }
114114
115115 fn led_state_changed(&mut self, _seat: &Seat<Self>, led_state: keyboard::LedState) {
116- let keyboards = self
117- .niri
118- .devices
119- .iter()
120- .filter(|device| device.has_capability(input::DeviceCapability::Keyboard))
121- .cloned();
122-
123- for mut keyboard in keyboards {
124- keyboard.led_update(led_state.into());
125- }
116+ self.update_keyboard_leds(led_state);
126117 }
127118
128119 fn click_grab(
src/niri.rsmodified+16 -1
@@ -46,7 +46,7 @@ use smithay::desktop::{
4646 find_popup_root_surface, layer_map_for_output, LayerMap, LayerSurface, PopupGrab, PopupManager,
4747 PopupUngrabStrategy, Space, Window, WindowSurfaceType,
4848 };
49-use smithay::input::keyboard::{Layout as KeyboardLayout, XkbConfig};
49+use smithay::input::keyboard::{Layout as KeyboardLayout, LedState, XkbConfig};
5050 use smithay::input::pointer::{
5151 CursorIcon, CursorImageStatus, CursorImageSurfaceData, Focus,
5252 GrabStartData as PointerGrabStartData, MotionEvent,
@@ -1620,6 +1620,8 @@ impl State {
16201620 }
16211621 if mods_changed {
16221622 keyboard.set_modifier_state(mods);
1623+ // set_modifier_state() doesn't update the LED state of physical keyboards.
1624+ self.update_keyboard_leds(keyboard.led_state());
16231625 // set_modifier_state() doesn't tell the focused client on its own.
16241626 keyboard.advertise_modifier_state(self);
16251627 }
@@ -1638,6 +1640,19 @@ impl State {
16381640 }
16391641 }
16401642
1643+ pub fn update_keyboard_leds(&mut self, led_state: LedState) {
1644+ let keyboards = self
1645+ .niri
1646+ .devices
1647+ .iter()
1648+ .filter(|device| device.has_capability(input::DeviceCapability::Keyboard))
1649+ .cloned();
1650+
1651+ for mut keyboard in keyboards {
1652+ keyboard.led_update(led_state.into());
1653+ }
1654+ }
1655+
16411656 /// Loads the configured keymap (xkb file, xkb config, or locale1's) onto the seat, replacing a
16421657 /// virtual keyboard's if there is one.
16431658 pub fn load_configured_keymap(&mut self) {