From c06cb5b776d727be12f6020598d6a10201c25313 Mon Sep 17 00:00:00 2001 From: Ottatop Date: Wed, 20 Sep 2023 17:20:48 -0500 Subject: [PATCH] Remove WalkDir --- Cargo.toml | 1 - src/config.rs | 11 +++++++++++ src/config/api.rs | 19 +++++++++++-------- src/input.rs | 2 -- src/state.rs | 6 ++++-- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 528ad1f..b44c028 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,6 @@ clap = { version = "4.4.2", features = ["derive"] } xkbcommon = "0.6.0" xdg = "2.5.2" lazy_static = "1.4.0" -walkdir = "2.4.0" sysinfo = "0.29.10" diff --git a/src/config.rs b/src/config.rs index 49a2ec0..21b5aa1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -18,6 +18,11 @@ use crate::{ tag::TagId, }; +use self::api::msg::{ + window_rules::{WindowRule, WindowRuleCondition}, + CallbackId, +}; + #[derive(serde::Deserialize, Debug)] pub struct Metaconfig { pub command: String, @@ -107,6 +112,12 @@ pub enum Key { Escape = keysyms::KEY_Escape, } +#[derive(Default, Debug)] +pub struct Config { + window_rules: Vec<(WindowRuleCondition, WindowRule)>, + output_callback_ids: Vec, +} + fn parse(config_dir: &Path) -> anyhow::Result { let config_dir = config_dir.join("metaconfig.toml"); diff --git a/src/config/api.rs b/src/config/api.rs index 7eab360..9a45394 100644 --- a/src/config/api.rs +++ b/src/config/api.rs @@ -47,7 +47,6 @@ use smithay::reexports::calloop::{ self, channel::Sender, generic::Generic, EventSource, Interest, Mode, PostAction, }; use sysinfo::{ProcessRefreshKind, RefreshKind, SystemExt}; -use walkdir::WalkDir; use self::msg::{Msg, OutgoingMsg}; @@ -93,6 +92,8 @@ impl PinnacleSocketSource { /// Create a loop source that listens for connections to the provided socket_dir. /// This will also set PINNACLE_SOCKET for use in API implementations. pub fn new(sender: Sender, socket_dir: &Path) -> anyhow::Result { + tracing::debug!("Creating socket source for dir {socket_dir:?}"); + let system = sysinfo::System::new_with_specifics( RefreshKind::new().with_processes(ProcessRefreshKind::new()), ); @@ -128,15 +129,17 @@ impl PinnacleSocketSource { } } else { // If there are, remove them all - for entry in WalkDir::new(socket_dir) - .contents_first(true) - .into_iter() - .filter_entry(|entry| entry.file_name().to_string_lossy().starts_with(SOCKET_NAME)) - .filter_map(|e| e.ok()) + for file in std::fs::read_dir(socket_dir)? + .filter_map(|entry| entry.ok()) + .filter(|entry| entry.file_name().to_string_lossy().starts_with(SOCKET_NAME)) { - std::fs::remove_file(entry.path()).context(format!( + 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 {}", - entry.path().to_string_lossy() + file.path().to_string_lossy() ))?; } } diff --git a/src/input.rs b/src/input.rs index 635c674..89081f8 100644 --- a/src/input.rs +++ b/src/input.rs @@ -230,8 +230,6 @@ impl State { }, ); - self.move_mode = move_mode; - match action { Some(KeyAction::CallCallback(callback_id)) => { if let Some(stream) = self.api_state.stream.as_ref() { diff --git a/src/state.rs b/src/state.rs index 74312f9..80107c0 100644 --- a/src/state.rs +++ b/src/state.rs @@ -87,15 +87,18 @@ impl Backend { /// The main state of the application. pub struct State { + /// Which backend is currently running pub backend: Backend, + /// A loop signal used to stop the compositor pub loop_signal: LoopSignal, + /// A handle to the event loop pub loop_handle: LoopHandle<'static, CalloopData>, pub display_handle: DisplayHandle, pub clock: Clock, pub space: Space, - pub move_mode: bool, + /// The name of the Wayland socket pub socket_name: String, pub seat: Seat, @@ -321,7 +324,6 @@ impl State { dnd_icon: None, - move_mode: false, socket_name: socket_name.to_string_lossy().to_string(), popup_manager: PopupManager::default(),