input: Update keyboard LEDs on config reloads
Browse files at this commit12de51d6a60baad8896366920278a24f17921f52Parent: 45739bc2 changed files +17 -11
- src/handlers/mod.rs +1 -10
- src/niri.rs +16 -1
src/handlers/mod.rsmodified+1 -10
| @@ -113,16 +113,7 @@ impl SeatHandler for State { | ||
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | 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); | |
| 126 | 117 | } |
| 127 | 118 | |
| 128 | 119 | fn click_grab( |
src/niri.rsmodified+16 -1
| @@ -46,7 +46,7 @@ use smithay::desktop::{ | ||
| 46 | 46 | find_popup_root_surface, layer_map_for_output, LayerMap, LayerSurface, PopupGrab, PopupManager, |
| 47 | 47 | PopupUngrabStrategy, Space, Window, WindowSurfaceType, |
| 48 | 48 | }; |
| 49 | -use smithay::input::keyboard::{Layout as KeyboardLayout, XkbConfig}; | |
| 49 | +use smithay::input::keyboard::{Layout as KeyboardLayout, LedState, XkbConfig}; | |
| 50 | 50 | use smithay::input::pointer::{ |
| 51 | 51 | CursorIcon, CursorImageStatus, CursorImageSurfaceData, Focus, |
| 52 | 52 | GrabStartData as PointerGrabStartData, MotionEvent, |
| @@ -1620,6 +1620,8 @@ impl State { | ||
| 1620 | 1620 | } |
| 1621 | 1621 | if mods_changed { |
| 1622 | 1622 | 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()); | |
| 1623 | 1625 | // set_modifier_state() doesn't tell the focused client on its own. |
| 1624 | 1626 | keyboard.advertise_modifier_state(self); |
| 1625 | 1627 | } |
| @@ -1638,6 +1640,19 @@ impl State { | ||
| 1638 | 1640 | } |
| 1639 | 1641 | } |
| 1640 | 1642 | |
| 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 | + | |
| 1641 | 1656 | /// Loads the configured keymap (xkb file, xkb config, or locale1's) onto the seat, replacing a |
| 1642 | 1657 | /// virtual keyboard's if there is one. |
| 1643 | 1658 | pub fn load_configured_keymap(&mut self) { |