diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2023-12-08 07:58:03 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2023-12-08 07:58:03 +0400 |
| commit | 243519598eb334d74dad440bacb9f73ce947c4ba (patch) | |
| tree | 7ab3e0f2713188cb25c1e456c9f20fd517850e8b | |
| parent | 0b5f232bc22a324341b809da63d167e468540853 (diff) | |
| download | niri-243519598eb334d74dad440bacb9f73ce947c4ba.tar.gz niri-243519598eb334d74dad440bacb9f73ce947c4ba.tar.bz2 niri-243519598eb334d74dad440bacb9f73ce947c4ba.zip | |
Live-reload keyboard config
This needed the Smithay bump for a deadlock fix.
| -rw-r--r-- | src/config.rs | 2 | ||||
| -rw-r--r-- | src/niri.rs | 27 |
2 files changed, 27 insertions, 2 deletions
diff --git a/src/config.rs b/src/config.rs index 966fd85b..a9b60dc9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -66,7 +66,7 @@ pub struct Keyboard { pub track_layout: TrackLayout, } -#[derive(knuffel::Decode, Debug, Default, PartialEq, Eq)] +#[derive(knuffel::Decode, Debug, Default, PartialEq, Eq, Clone)] pub struct Xkb { #[knuffel(child, unwrap(argument), default)] pub rules: String, diff --git a/src/niri.rs b/src/niri.rs index 45b1d4f4..8221ba6c 100644 --- a/src/niri.rs +++ b/src/niri.rs @@ -468,8 +468,10 @@ impl State { self.niri.layout.update_config(&config); animation::ANIMATION_SLOWDOWN.store(config.debug.animation_slowdown, Ordering::Relaxed); + let mut reload_xkb = None; let mut old_config = self.niri.config.borrow_mut(); + // Reload the cursor. if config.cursor != old_config.cursor { self.niri .cursor_manager @@ -477,15 +479,38 @@ impl State { self.niri.cursor_texture_cache.clear(); } + // We need &mut self to reload the xkb config, so just store it here. + if config.input.keyboard.xkb != old_config.input.keyboard.xkb { + reload_xkb = Some(config.input.keyboard.xkb.clone()); + } + + // Reload the repeat info. + if config.input.keyboard.repeat_rate != old_config.input.keyboard.repeat_rate + || config.input.keyboard.repeat_delay != old_config.input.keyboard.repeat_delay + { + let keyboard = self.niri.seat.get_keyboard().unwrap(); + keyboard.change_repeat_info( + config.input.keyboard.repeat_rate.into(), + config.input.keyboard.repeat_delay.into(), + ); + } + *old_config = config; // Release the borrow. drop(old_config); + // Now with a &mut self we can reload the xkb config. + if let Some(xkb) = reload_xkb { + let keyboard = self.niri.seat.get_keyboard().unwrap(); + if let Err(err) = keyboard.set_xkb_config(self, xkb.to_xkb_config()) { + warn!("error updating xkb config: {err:?}"); + } + } + self.niri.queue_redraw_all(); // FIXME: apply output scale and whatnot. // FIXME: apply libinput device settings. - // FIXME: apply xkb settings. // FIXME: apply xdg decoration settings. } |
