From 4a5733eb1df335836cea1734a32ddd008633854c Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 20:46:42 -0700 Subject: [PATCH] refactor(collections): move ring.rs and lockable_sequence.rs into komorebi-collections Moves the identical ring.rs and lockable_sequence.rs out of komorebi/src into the crate (rename). Necessary edits: lib.rs with pub use Lockable and a hidden pastey re-export; #[macro_export] on impl_ring_elements! using $crate::pastey::paste!; the doc test now says komorebi_collections::ring::Ring. The Windows tree gets the path dependency, re-exports (pub use komorebi_collections::{ring, lockable_sequence, Lockable}, #[macro_use] extern crate), forwards its schemars feature, and drops pastey again. Windows is bundled here because it is the tree the files move out of. Verified: fast-check native, Windows clippy --all-targets -D warnings, KDE and macOS checks: PASS. --- Cargo.lock | 3 ++- Cargo.toml | 1 - crates/komorebi-collections/src/lib.rs | 11 +++++++++++ .../komorebi-collections}/src/lockable_sequence.rs | 0 {komorebi => crates/komorebi-collections}/src/ring.rs | 7 ++++--- komorebi/Cargo.toml | 4 ++-- komorebi/src/lib.rs | 10 ++++++---- 7 files changed, 25 insertions(+), 11 deletions(-) rename {komorebi => crates/komorebi-collections}/src/lockable_sequence.rs (100%) rename {komorebi => crates/komorebi-collections}/src/ring.rs (98%) diff --git a/Cargo.lock b/Cargo.lock index faf1ba74..6d4e8f03 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3337,6 +3337,7 @@ dependencies = [ "dirs 6.0.0", "ed25519-dalek", "hotwatch", + "komorebi-collections", "komorebi-layouts", "komorebi-scrolling", "komorebi-themes", @@ -3347,7 +3348,6 @@ dependencies = [ "os_info", "parking_lot", "paste", - "pastey 0.2.3", "powershell_script", "regex", "reqwest", @@ -3433,6 +3433,7 @@ name = "komorebi-collections" version = "0.1.42" dependencies = [ "pastey 0.2.3", + "schemars 1.2.3", "serde", "serde_json_lenient", ] diff --git a/Cargo.toml b/Cargo.toml index e65a07b7..0a6044e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,7 +40,6 @@ tracing-appender = "0.2" tracing-subscriber = { version = "0.3", features = ["env-filter"] } parking_lot = "0.12" paste = "1" -pastey = "0.2" sysinfo = "0.39" uds_windows = "1" win32-display-data = { git = "https://github.com/LGUG2Z/win32-display-data", rev = "8c42d8db257d30fe95bc98c2e5cd8f75da861021" } diff --git a/crates/komorebi-collections/src/lib.rs b/crates/komorebi-collections/src/lib.rs index e69de29b..ae06590d 100644 --- a/crates/komorebi-collections/src/lib.rs +++ b/crates/komorebi-collections/src/lib.rs @@ -0,0 +1,11 @@ +//! The collections that every komorebi keeps its monitors, workspaces, containers and windows in. + +pub mod lockable_sequence; +pub mod ring; + +pub use lockable_sequence::Lockable; + +// Re-exported so that `impl_ring_elements!` can name `pastey::paste!` from any crate that +// calls it, whether or not that crate depends on `pastey` itself. +#[doc(hidden)] +pub use pastey; diff --git a/komorebi/src/lockable_sequence.rs b/crates/komorebi-collections/src/lockable_sequence.rs similarity index 100% rename from komorebi/src/lockable_sequence.rs rename to crates/komorebi-collections/src/lockable_sequence.rs diff --git a/komorebi/src/ring.rs b/crates/komorebi-collections/src/ring.rs similarity index 98% rename from komorebi/src/ring.rs rename to crates/komorebi-collections/src/ring.rs index ae8b2f25..e6abae1f 100644 --- a/komorebi/src/ring.rs +++ b/crates/komorebi-collections/src/ring.rs @@ -18,7 +18,7 @@ use serde::Serialize; /// # Example /// /// ```rust -/// use komorebi::ring::Ring; +/// use komorebi_collections::ring::Ring; /// /// let mut ring = Ring::default(); /// ring.elements_mut().push_back("a"); @@ -83,9 +83,10 @@ impl Ring { /// `focused_container_idx()` and `focused_container_mut()`. The field is named after the element /// type in lower case with an `s` appended, and the methods after the field, so that "the focused /// container" is spelled the same way on every type that has one. +#[macro_export] macro_rules! impl_ring_elements { ($name:ty, $element:ident) => { - pastey::paste! { + $crate::pastey::paste! { impl $name { pub const fn [<$element:lower s>](&self) -> &std::collections::VecDeque<$element> { self.[<$element:lower s>].elements() @@ -116,7 +117,7 @@ macro_rules! impl_ring_elements { // ``` // Which allows using the `Window` element but name the functions as `floating_window` ($name:ty, $element:ident, $el_name:literal) => { - pastey::paste! { + $crate::pastey::paste! { impl $name { pub const fn [<$el_name:lower s>](&self) -> &std::collections::VecDeque<$element> { self.[<$el_name:lower s>].elements() diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index d2419d01..976413e4 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -8,6 +8,7 @@ edition = "2024" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +komorebi-collections = { path = "../crates/komorebi-collections" } komorebi-layouts = { path = "../komorebi-layouts", features = ["win32"] } komorebi-scrolling = { path = "../komorebi-scrolling" } komorebi-themes = { path = "../komorebi-themes" } @@ -30,7 +31,6 @@ net2 = "0.2" os_info = "3.10" parking_lot = { workspace = true } paste = { workspace = true } -pastey = { workspace = true } powershell_script = "1.0" regex = "1" reqwest = { version = "0.12", features = ["blocking"] } @@ -66,4 +66,4 @@ uuid = { version = "1", features = ["v4"] } [features] default = ["schemars"] deadlock_detection = ["parking_lot/deadlock_detection"] -schemars = ["dep:schemars", "komorebi-layouts/schemars"] +schemars = ["dep:schemars", "komorebi-collections/schemars", "komorebi-layouts/schemars"] diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index fd14e174..e5dac5c7 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -1,17 +1,19 @@ #![warn(clippy::all)] +#[macro_use] +extern crate komorebi_collections; + pub mod animation; pub mod border_manager; pub mod cloaked; pub mod com; -#[macro_use] -pub mod ring; +pub use komorebi_collections::ring; pub mod container; pub mod core; pub mod focus_manager; pub mod live_resize; -pub mod lockable_sequence; -pub use lockable_sequence::Lockable; +pub use komorebi_collections::lockable_sequence; +pub use komorebi_collections::Lockable; pub mod monitor; pub mod monitor_reconciliator; pub mod pan;