From e5263bbad80baf0aba0ecc7cdacf57d87736ac61 Mon Sep 17 00:00:00 2001 From: Paul Daniel Faria Date: Wed, 1 Jan 2025 08:48:32 -0800 Subject: [PATCH] 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. --- src/input/mod.rs | 3 ++- src/shell/seats.rs | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/input/mod.rs b/src/input/mod.rs index 8b40908e..68af65b2 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -171,7 +171,8 @@ impl State { InputEvent::DeviceAdded { device } => { let shell = self.common.shell.read().unwrap(); let seat = shell.seats.last_active(); - seat.devices().add_device(&device); + let led_state = seat.get_keyboard().unwrap().led_state(); + seat.devices().add_device(&device, led_state); if device.has_capability(DeviceCapability::TabletTool) { seat.tablet_seat().add_tablet::( &self.common.display_handle, diff --git a/src/shell/seats.rs b/src/shell/seats.rs index 8fa33069..ceb9cde4 100644 --- a/src/shell/seats.rs +++ b/src/shell/seats.rs @@ -83,7 +83,11 @@ impl Seats { } impl Devices { - pub fn add_device(&self, device: &D) -> Vec { + pub fn add_device( + &self, + device: &D, + led_state: LedState, + ) -> Vec { 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) = ::downcast_ref::(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); } }