diff --git a/src/backend/udev.rs b/src/backend/udev.rs index 166ec87..d0e8829 100644 --- a/src/backend/udev.rs +++ b/src/backend/udev.rs @@ -949,7 +949,7 @@ impl State { .as_ref() .expect("Stream doesn't exist"); let mut stream = stream.lock().expect("Couldn't lock stream"); - for callback_id in dt.state.output_callback_ids.iter() { + for callback_id in dt.state.config.output_callback_ids.iter() { crate::config::api::send_to_client( &mut stream, &OutgoingMsg::CallCallback { diff --git a/src/config.rs b/src/config.rs index 21b5aa1..3a5cb8b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -114,8 +114,8 @@ pub enum Key { #[derive(Default, Debug)] pub struct Config { - window_rules: Vec<(WindowRuleCondition, WindowRule)>, - output_callback_ids: Vec, + pub window_rules: Vec<(WindowRuleCondition, WindowRule)>, + pub output_callback_ids: Vec, } fn parse(config_dir: &Path) -> anyhow::Result { @@ -243,7 +243,7 @@ impl State { tracing::debug!("Clearing mouse and keybinds"); self.input_state.keybinds.clear(); self.input_state.mousebinds.clear(); - self.window_rules.clear(); + self.config.window_rules.clear(); tracing::debug!("Killing old config"); if let Err(err) = self.api_state.config_process.kill() { diff --git a/src/config/api.rs b/src/config/api.rs index 9a45394..238448a 100644 --- a/src/config/api.rs +++ b/src/config/api.rs @@ -121,10 +121,8 @@ impl PinnacleSocketSource { if multiple_instances { if let Ok(exists) = socket_path.try_exists() { if exists { - std::fs::remove_file(&socket_path).context(format!( - "Failed to remove old socket at {}", - socket_path.to_string_lossy() - ))?; + std::fs::remove_file(&socket_path) + .context(format!("Failed to remove old socket at {socket_path:?}",))?; } } } else { @@ -133,14 +131,9 @@ impl PinnacleSocketSource { .filter_map(|entry| entry.ok()) .filter(|entry| entry.file_name().to_string_lossy().starts_with(SOCKET_NAME)) { - tracing::debug!( - "trying to remove socket at {}", - file.path().to_string_lossy() - ); - std::fs::remove_file(file.path()).context(format!( - "Failed to remove old socket at {}", - file.path().to_string_lossy() - ))?; + tracing::debug!("Removing socket at {:?}", file.path()); + std::fs::remove_file(file.path()) + .context(format!("Failed to remove old socket at {:?}", file.path()))?; } } diff --git a/src/state.rs b/src/state.rs index 80107c0..7dafc70 100644 --- a/src/state.rs +++ b/src/state.rs @@ -11,13 +11,7 @@ use std::{ use crate::{ backend::{udev::Udev, winit::Winit, BackendData}, - config::{ - api::msg::{ - window_rules::{WindowRule, WindowRuleCondition}, - CallbackId, Msg, - }, - ConfigReturn, - }, + config::{api::msg::Msg, Config, ConfigReturn}, cursor::Cursor, focus::FocusState, grab::resize_grab::ResizeSurfaceState, @@ -125,14 +119,11 @@ pub struct State { pub dnd_icon: Option, pub windows: Vec, - pub window_rules: Vec<(WindowRuleCondition, WindowRule)>, + + pub config: Config, pub async_scheduler: Scheduler<()>, - // TODO: move into own struct - // | basically just clean this mess up - pub output_callback_ids: Vec, - pub xwayland: XWayland, pub xwm: Option, pub xdisplay: Option, @@ -320,6 +311,8 @@ impl State { }, focus_state: FocusState::new(), + config: Config::default(), + seat, dnd_icon: None, @@ -331,8 +324,6 @@ impl State { async_scheduler: sched, windows: vec![], - window_rules: vec![], - output_callback_ids: vec![], xwayland, xwm: None, diff --git a/src/state/api_handlers.rs b/src/state/api_handlers.rs index b8840b6..e90dcc2 100644 --- a/src/state/api_handlers.rs +++ b/src/state/api_handlers.rs @@ -30,7 +30,10 @@ impl State { callback_id, } => { let key = match key { - KeyIntOrString::Int(num) => num, + KeyIntOrString::Int(num) => { + tracing::info!("set keybind: {:?}, raw {}", modifiers, num); + num + } KeyIntOrString::String(s) => { if s.chars().count() == 1 { let Some(ch) = s.chars().next() else { unreachable!() }; @@ -156,7 +159,7 @@ impl State { self.update_windows(&output); } Msg::AddWindowRule { cond, rule } => { - self.window_rules.push((cond, rule)); + self.config.window_rules.push((cond, rule)); } Msg::WindowMoveGrab { button } => { // TODO: in the future, there may be movable layer surfaces @@ -324,7 +327,7 @@ impl State { ) .expect("Send to client failed"); } - self.output_callback_ids.push(callback_id); + self.config.output_callback_ids.push(callback_id); } Msg::SetOutputLocation { output_name, x, y } => { let Some(output) = output_name.output(self) else { return }; diff --git a/src/window.rs b/src/window.rs index 30fd3ae..8d1c765 100644 --- a/src/window.rs +++ b/src/window.rs @@ -595,7 +595,7 @@ impl Blocker for WindowBlocker { impl State { pub fn apply_window_rules(&mut self, window: &WindowElement) { tracing::debug!("Applying window rules"); - for (cond, rule) in self.window_rules.iter() { + for (cond, rule) in self.config.window_rules.iter() { if cond.is_met(self, window) { let WindowRule { output,