Add live-reload to libinput settings

This commit is contained in:
Ivan Molodetskikh
2024-01-16 20:28:46 +04:00
parent 954f711bf3
commit 4656332d07
3 changed files with 20 additions and 5 deletions
+1 -3
View File
@@ -163,9 +163,7 @@ Niri will load configuration from `$XDG_CONFIG_HOME/.config/niri/config.kdl` or
If this fails, it will load [the default configuration file](resources/default-config.kdl). If this fails, it will load [the default configuration file](resources/default-config.kdl).
Please use the default configuration file as the starting point for your custom configuration. Please use the default configuration file as the starting point for your custom configuration.
Niri will live-reload many of the configuration settings, like key binds or gaps, as you change the config file. Niri will live-reload most of the configuration settings, like key binds or gaps or output modes, as you change the config file.
Though, some settings are still missing live-reload support.
Notably, input device libinput settings will only apply when the input device is reconnected.
[PaperWM]: https://github.com/paperwm/PaperWM [PaperWM]: https://github.com/paperwm/PaperWM
[mako]: https://github.com/emersion/mako [mako]: https://github.com/emersion/mako
+2
View File
@@ -89,6 +89,7 @@ impl State {
match event { match event {
InputEvent::DeviceAdded { device } => { InputEvent::DeviceAdded { device } => {
self.niri.devices.insert(device.clone());
if device.has_capability(input::DeviceCapability::TabletTool) { if device.has_capability(input::DeviceCapability::TabletTool) {
match device.size() { match device.size() {
@@ -107,6 +108,7 @@ impl State {
} }
InputEvent::DeviceRemoved { device } => { InputEvent::DeviceRemoved { device } => {
self.niri.tablets.remove(device); self.niri.tablets.remove(device);
self.niri.devices.remove(device);
} }
_ => (), _ => (),
} }
+17 -2
View File
@@ -96,7 +96,7 @@ use crate::dbus::gnome_shell_screenshot::{NiriToScreenshot, ScreenshotToNiri};
use crate::dbus::mutter_screen_cast::{self, ScreenCastToNiri}; use crate::dbus::mutter_screen_cast::{self, ScreenCastToNiri};
use crate::frame_clock::FrameClock; use crate::frame_clock::FrameClock;
use crate::handlers::configure_lock_surface; use crate::handlers::configure_lock_surface;
use crate::input::TabletData; use crate::input::{apply_libinput_settings, TabletData};
use crate::layout::{Layout, MonitorRenderElement}; use crate::layout::{Layout, MonitorRenderElement};
use crate::pw_utils::{Cast, PipeWire}; use crate::pw_utils::{Cast, PipeWire};
use crate::render_helpers::{NiriRenderer, PrimaryGpuTextureRenderElement}; use crate::render_helpers::{NiriRenderer, PrimaryGpuTextureRenderElement};
@@ -135,6 +135,7 @@ pub struct Niri {
// When false, we're idling with monitors powered off. // When false, we're idling with monitors powered off.
pub monitors_active: bool, pub monitors_active: bool,
pub devices: HashSet<input::Device>,
pub tablets: HashMap<input::Device, TabletData>, pub tablets: HashMap<input::Device, TabletData>,
// Smithay state. // Smithay state.
@@ -542,6 +543,7 @@ impl State {
animation::ANIMATION_SLOWDOWN.store(config.debug.animation_slowdown, Ordering::Relaxed); animation::ANIMATION_SLOWDOWN.store(config.debug.animation_slowdown, Ordering::Relaxed);
let mut reload_xkb = None; let mut reload_xkb = None;
let mut libinput_config_changed = false;
let mut output_config_changed = false; let mut output_config_changed = false;
let mut old_config = self.niri.config.borrow_mut(); let mut old_config = self.niri.config.borrow_mut();
@@ -569,6 +571,12 @@ impl State {
); );
} }
if config.input.touchpad != old_config.input.touchpad
|| config.input.mouse != old_config.input.mouse
{
libinput_config_changed = true;
}
if config.outputs != old_config.outputs { if config.outputs != old_config.outputs {
output_config_changed = true; output_config_changed = true;
} }
@@ -586,6 +594,13 @@ impl State {
} }
} }
if libinput_config_changed {
let config = self.niri.config.borrow();
for mut device in self.niri.devices.iter().cloned() {
apply_libinput_settings(&config.input, &mut device);
}
}
if output_config_changed { if output_config_changed {
let mut resized_outputs = vec![]; let mut resized_outputs = vec![];
for output in self.niri.global_space.outputs() { for output in self.niri.global_space.outputs() {
@@ -620,7 +635,6 @@ impl State {
} }
self.niri.queue_redraw_all(); self.niri.queue_redraw_all();
// FIXME: apply libinput device settings.
// FIXME: apply xdg decoration settings. // FIXME: apply xdg decoration settings.
} }
@@ -878,6 +892,7 @@ impl Niri {
unmapped_windows: HashMap::new(), unmapped_windows: HashMap::new(),
monitors_active: true, monitors_active: true,
devices: HashSet::new(),
tablets: HashMap::new(), tablets: HashMap::new(),
compositor_state, compositor_state,