Update leds when devices are added

This fixes #1104

LEDs on keyboard will now update to match the
compositor state when they're plugged in.
This commit is contained in:
Paul Daniel Faria 2025-01-01 08:48:32 -08:00 committed by Victoria Brekenfeld
parent 68b6156aa8
commit e5263bbad8
2 changed files with 10 additions and 3 deletions

View file

@ -83,7 +83,11 @@ impl Seats {
}
impl Devices {
pub fn add_device<D: Device + 'static>(&self, device: &D) -> Vec<DeviceCapability> {
pub fn add_device<D: Device + 'static>(
&self,
device: &D,
led_state: LedState,
) -> Vec<DeviceCapability> {
let id = device.id();
let mut map = self.capabilities.borrow_mut();
let caps = [
@ -104,7 +108,9 @@ impl Devices {
if device.has_capability(DeviceCapability::Keyboard) {
if let Some(device) = <dyn Any>::downcast_ref::<InputDevice>(device) {
self.keyboards.borrow_mut().push(device.clone());
let mut device = device.clone();
device.led_update(led_state.into());
self.keyboards.borrow_mut().push(device);
}
}