forge
Explore
Log in

Don't you dare go Hollow

Add live-reload to libinput settings

Browse files at this commit

4656332d0781515f601e3a81690dfc1ee5bcc5c3Ivan MolodetskikhParent: 954f711
README.mdmodified+1 -3
@@ -163,9 +163,7 @@ Niri will load configuration from `$XDG_CONFIG_HOME/.config/niri/config.kdl` or
163 If this fails, it will load [the default configuration file](resources/default-config.kdl).163 If this fails, it will load [the default configuration file](resources/default-config.kdl).
164 Please use the default configuration file as the starting point for your custom configuration.164 Please use the default configuration file as the starting point for your custom configuration.
165 165
166-Niri will live-reload many of the configuration settings, like key binds or gaps, as you change the config file.166+Niri will live-reload most of the configuration settings, like key binds or gaps or output modes, as you change the config file.
167-Though, some settings are still missing live-reload support.
168-Notably, input device libinput settings will only apply when the input device is reconnected.
169 167
170 [PaperWM]: https://github.com/paperwm/PaperWM168 [PaperWM]: https://github.com/paperwm/PaperWM
171 [mako]: https://github.com/emersion/mako169 [mako]: https://github.com/emersion/mako
src/input.rsmodified+2 -0
@@ -89,6 +89,7 @@ impl State {
89 89
90 match event {90 match event {
91 InputEvent::DeviceAdded { device } => {91 InputEvent::DeviceAdded { device } => {
92+ self.niri.devices.insert(device.clone());
92 93
93 if device.has_capability(input::DeviceCapability::TabletTool) {94 if device.has_capability(input::DeviceCapability::TabletTool) {
94 match device.size() {95 match device.size() {
@@ -107,6 +108,7 @@ impl State {
107 }108 }
108 InputEvent::DeviceRemoved { device } => {109 InputEvent::DeviceRemoved { device } => {
109 self.niri.tablets.remove(device);110 self.niri.tablets.remove(device);
111+ self.niri.devices.remove(device);
110 }112 }
111 _ => (),113 _ => (),
112 }114 }
src/niri.rsmodified+17 -2
@@ -96,7 +96,7 @@ use crate::dbus::gnome_shell_screenshot::{NiriToScreenshot, ScreenshotToNiri};
96 use crate::dbus::mutter_screen_cast::{self, ScreenCastToNiri};96 use crate::dbus::mutter_screen_cast::{self, ScreenCastToNiri};
97 use crate::frame_clock::FrameClock;97 use crate::frame_clock::FrameClock;
98 use crate::handlers::configure_lock_surface;98 use crate::handlers::configure_lock_surface;
99-use crate::input::TabletData;99+use crate::input::{apply_libinput_settings, TabletData};
100 use crate::layout::{Layout, MonitorRenderElement};100 use crate::layout::{Layout, MonitorRenderElement};
101 use crate::pw_utils::{Cast, PipeWire};101 use crate::pw_utils::{Cast, PipeWire};
102 use crate::render_helpers::{NiriRenderer, PrimaryGpuTextureRenderElement};102 use crate::render_helpers::{NiriRenderer, PrimaryGpuTextureRenderElement};
@@ -135,6 +135,7 @@ pub struct Niri {
135 // When false, we're idling with monitors powered off.135 // When false, we're idling with monitors powered off.
136 pub monitors_active: bool,136 pub monitors_active: bool,
137 137
138+ pub devices: HashSet<input::Device>,
138 pub tablets: HashMap<input::Device, TabletData>,139 pub tablets: HashMap<input::Device, TabletData>,
139 140
140 // Smithay state.141 // Smithay state.
@@ -542,6 +543,7 @@ impl State {
542 animation::ANIMATION_SLOWDOWN.store(config.debug.animation_slowdown, Ordering::Relaxed);543 animation::ANIMATION_SLOWDOWN.store(config.debug.animation_slowdown, Ordering::Relaxed);
543 544
544 let mut reload_xkb = None;545 let mut reload_xkb = None;
546+ let mut libinput_config_changed = false;
545 let mut output_config_changed = false;547 let mut output_config_changed = false;
546 let mut old_config = self.niri.config.borrow_mut();548 let mut old_config = self.niri.config.borrow_mut();
547 549
@@ -569,6 +571,12 @@ impl State {
569 );571 );
570 }572 }
571 573
574+ if config.input.touchpad != old_config.input.touchpad
575+ || config.input.mouse != old_config.input.mouse
576+ {
577+ libinput_config_changed = true;
578+ }
579+
572 if config.outputs != old_config.outputs {580 if config.outputs != old_config.outputs {
573 output_config_changed = true;581 output_config_changed = true;
574 }582 }
@@ -586,6 +594,13 @@ impl State {
586 }594 }
587 }595 }
588 596
597+ if libinput_config_changed {
598+ let config = self.niri.config.borrow();
599+ for mut device in self.niri.devices.iter().cloned() {
600+ apply_libinput_settings(&config.input, &mut device);
601+ }
602+ }
603+
589 if output_config_changed {604 if output_config_changed {
590 let mut resized_outputs = vec![];605 let mut resized_outputs = vec![];
591 for output in self.niri.global_space.outputs() {606 for output in self.niri.global_space.outputs() {
@@ -620,7 +635,6 @@ impl State {
620 }635 }
621 636
622 self.niri.queue_redraw_all();637 self.niri.queue_redraw_all();
623- // FIXME: apply libinput device settings.
624 // FIXME: apply xdg decoration settings.638 // FIXME: apply xdg decoration settings.
625 }639 }
626 640
@@ -878,6 +892,7 @@ impl Niri {
878 unmapped_windows: HashMap::new(),892 unmapped_windows: HashMap::new(),
879 monitors_active: true,893 monitors_active: true,
880 894
895+ devices: HashSet::new(),
881 tablets: HashMap::new(),896 tablets: HashMap::new(),
882 897
883 compositor_state,898 compositor_state,