From 2ee0bbc0c721211950038c5716681288f42d05aa Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Mon, 31 Mar 2025 18:02:46 -0700 Subject: [PATCH] refactor(themes): move colour.rs to komorebi-themes --- Cargo.lock | 2 +- komorebi-client/src/lib.rs | 4 ++-- komorebi-themes/Cargo.toml | 7 ++++++- {komorebi => komorebi-themes}/src/colour.rs | 2 +- komorebi-themes/src/lib.rs | 2 ++ komorebi/Cargo.toml | 1 - komorebi/src/border_manager/mod.rs | 4 ++-- komorebi/src/lib.rs | 3 +-- komorebi/src/process_command.rs | 21 ++++++++++----------- komorebi/src/static_config.rs | 2 +- komorebi/src/theme_manager.rs | 2 +- 11 files changed, 27 insertions(+), 23 deletions(-) rename {komorebi => komorebi-themes}/src/colour.rs (99%) diff --git a/Cargo.lock b/Cargo.lock index 217f7bd7..b27277ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2676,7 +2676,6 @@ dependencies = [ "dirs", "dunce", "getset", - "hex_color", "hotwatch", "komorebi-themes", "lazy_static", @@ -2778,6 +2777,7 @@ dependencies = [ "base16-egui-themes", "catppuccin-egui", "eframe", + "hex_color", "schemars", "serde", "serde_variant", diff --git a/komorebi-client/src/lib.rs b/komorebi-client/src/lib.rs index e82e4e79..1f3eb65c 100644 --- a/komorebi-client/src/lib.rs +++ b/komorebi-client/src/lib.rs @@ -5,8 +5,6 @@ pub use komorebi::animation::prefix::AnimationPrefix; pub use komorebi::animation::PerAnimationPrefixConfig; pub use komorebi::asc::ApplicationSpecificConfiguration; pub use komorebi::border_manager::BorderInfo; -pub use komorebi::colour::Colour; -pub use komorebi::colour::Rgb; pub use komorebi::config_generation::ApplicationConfiguration; pub use komorebi::config_generation::IdWithIdentifier; pub use komorebi::config_generation::IdWithIdentifierAndComment; @@ -57,6 +55,7 @@ pub use komorebi::AnimationsConfig; pub use komorebi::AppSpecificConfigurationPath; pub use komorebi::AspectRatio; pub use komorebi::BorderColours; +pub use komorebi::Colour; pub use komorebi::CrossBoundaryBehaviour; pub use komorebi::GlobalState; pub use komorebi::KomorebiTheme; @@ -64,6 +63,7 @@ pub use komorebi::MonitorConfig; pub use komorebi::Notification; pub use komorebi::NotificationEvent; pub use komorebi::PredefinedAspectRatio; +pub use komorebi::Rgb; pub use komorebi::RuleDebug; pub use komorebi::StackbarConfig; pub use komorebi::State; diff --git a/komorebi-themes/Cargo.toml b/komorebi-themes/Cargo.toml index 07441d44..4db37ea7 100644 --- a/komorebi-themes/Cargo.toml +++ b/komorebi-themes/Cargo.toml @@ -8,7 +8,12 @@ base16-egui-themes = { git = "https://github.com/LGUG2Z/base16-egui-themes", rev catppuccin-egui = { git = "https://github.com/LGUG2Z/catppuccin-egui", rev = "bdaff30959512c4f7ee7304117076a48633d777f", default-features = false, features = ["egui31"] } #catppuccin-egui = { version = "5", default-features = false, features = ["egui30"] } eframe = { workspace = true } -schemars = { workspace = true } +schemars = { workspace = true, optional = true } serde = { workspace = true } serde_variant = "0.1" strum = { workspace = true } +hex_color = { version = "3", features = ["serde"] } + +[features] +default = ["schemars"] +schemars = ["dep:schemars"] diff --git a/komorebi/src/colour.rs b/komorebi-themes/src/colour.rs similarity index 99% rename from komorebi/src/colour.rs rename to komorebi-themes/src/colour.rs index 385a1f52..d51433bb 100644 --- a/komorebi/src/colour.rs +++ b/komorebi-themes/src/colour.rs @@ -1,5 +1,4 @@ use hex_color::HexColor; -use komorebi_themes::Color32; #[cfg(feature = "schemars")] use schemars::gen::SchemaGenerator; #[cfg(feature = "schemars")] @@ -9,6 +8,7 @@ use schemars::schema::Schema; #[cfg(feature = "schemars")] use schemars::schema::SchemaObject; +use crate::Color32; use serde::Deserialize; use serde::Serialize; diff --git a/komorebi-themes/src/lib.rs b/komorebi-themes/src/lib.rs index 1aaeaac2..7183ea09 100644 --- a/komorebi-themes/src/lib.rs +++ b/komorebi-themes/src/lib.rs @@ -1,6 +1,8 @@ #![warn(clippy::all)] #![allow(clippy::missing_errors_doc)] +pub mod colour; + use schemars::JsonSchema; use serde::Deserialize; use serde::Serialize; diff --git a/komorebi/Cargo.toml b/komorebi/Cargo.toml index e00ade0e..e9489ebd 100644 --- a/komorebi/Cargo.toml +++ b/komorebi/Cargo.toml @@ -19,7 +19,6 @@ ctrlc = { version = "3", features = ["termination"] } dirs = { workspace = true } dunce = { workspace = true } getset = "0.1" -hex_color = { version = "3", features = ["serde"] } hotwatch = { workspace = true } lazy_static = { workspace = true } miow = "0.6" diff --git a/komorebi/src/border_manager/mod.rs b/komorebi/src/border_manager/mod.rs index 869ae090..9c15e785 100644 --- a/komorebi/src/border_manager/mod.rs +++ b/komorebi/src/border_manager/mod.rs @@ -7,8 +7,6 @@ use crate::core::WindowKind; use crate::ring::Ring; use crate::windows_api; use crate::workspace::WorkspaceLayer; -use crate::Colour; -use crate::Rgb; use crate::WindowManager; use crate::WindowsApi; use border::border_hwnds; @@ -17,6 +15,8 @@ use crossbeam_channel::Receiver; use crossbeam_channel::Sender; use crossbeam_utils::atomic::AtomicCell; use crossbeam_utils::atomic::AtomicConsume; +use komorebi_themes::colour::Colour; +use komorebi_themes::colour::Rgb; use lazy_static::lazy_static; use parking_lot::Mutex; use serde::Deserialize; diff --git a/komorebi/src/lib.rs b/komorebi/src/lib.rs index 59c1fb38..34d2a744 100644 --- a/komorebi/src/lib.rs +++ b/komorebi/src/lib.rs @@ -5,7 +5,6 @@ pub mod border_manager; pub mod com; #[macro_use] pub mod ring; -pub mod colour; pub mod container; pub mod core; pub mod focus_manager; @@ -47,8 +46,8 @@ use std::sync::atomic::AtomicU64; use std::sync::atomic::Ordering; use std::sync::Arc; -pub use colour::*; pub use core::*; +pub use komorebi_themes::colour::*; pub use process_command::*; pub use process_event::*; pub use static_config::*; diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 311b8475..9a4fc560 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1,6 +1,7 @@ use color_eyre::eyre::anyhow; use color_eyre::eyre::OptionExt; use color_eyre::Result; +use komorebi_themes::colour::Rgb; use miow::pipe::connect; use net2::TcpStreamExt; use parking_lot::Mutex; @@ -19,9 +20,18 @@ use std::sync::Arc; use std::time::Duration; use uds_windows::UnixStream; +use crate::animation::ANIMATION_DURATION_GLOBAL; use crate::animation::ANIMATION_DURATION_PER_ANIMATION; +use crate::animation::ANIMATION_ENABLED_GLOBAL; use crate::animation::ANIMATION_ENABLED_PER_ANIMATION; +use crate::animation::ANIMATION_FPS; +use crate::animation::ANIMATION_STYLE_GLOBAL; use crate::animation::ANIMATION_STYLE_PER_ANIMATION; +use crate::border_manager; +use crate::border_manager::IMPLEMENTATION; +use crate::border_manager::STYLE; +use crate::build; +use crate::config_generation::WorkspaceMatchingRule; use crate::core::config_generation::IdWithIdentifier; use crate::core::config_generation::MatchingRule; use crate::core::config_generation::MatchingStrategy; @@ -38,17 +48,6 @@ use crate::core::SocketMessage; use crate::core::StateQuery; use crate::core::WindowContainerBehaviour; use crate::core::WindowKind; - -use crate::animation::ANIMATION_DURATION_GLOBAL; -use crate::animation::ANIMATION_ENABLED_GLOBAL; -use crate::animation::ANIMATION_FPS; -use crate::animation::ANIMATION_STYLE_GLOBAL; -use crate::border_manager; -use crate::border_manager::IMPLEMENTATION; -use crate::border_manager::STYLE; -use crate::build; -use crate::colour::Rgb; -use crate::config_generation::WorkspaceMatchingRule; use crate::current_virtual_desktop; use crate::monitor::MonitorInformation; use crate::notify_subscribers; diff --git a/komorebi/src/static_config.rs b/komorebi/src/static_config.rs index 2d2e4723..23b2ab4f 100644 --- a/komorebi/src/static_config.rs +++ b/komorebi/src/static_config.rs @@ -13,7 +13,6 @@ use crate::border_manager; use crate::border_manager::ZOrder; use crate::border_manager::IMPLEMENTATION; use crate::border_manager::STYLE; -use crate::colour::Colour; use crate::config_generation::WorkspaceMatchingRule; use crate::core::config_generation::ApplicationConfiguration; use crate::core::config_generation::ApplicationConfigurationGenerator; @@ -87,6 +86,7 @@ use color_eyre::Result; use crossbeam_channel::Receiver; use hotwatch::EventKind; use hotwatch::Hotwatch; +use komorebi_themes::colour::Colour; use parking_lot::Mutex; use regex::Regex; use serde::Deserialize; diff --git a/komorebi/src/theme_manager.rs b/komorebi/src/theme_manager.rs index be70a715..a3ac87e3 100644 --- a/komorebi/src/theme_manager.rs +++ b/komorebi/src/theme_manager.rs @@ -5,11 +5,11 @@ use crate::stackbar_manager; use crate::stackbar_manager::STACKBAR_FOCUSED_TEXT_COLOUR; use crate::stackbar_manager::STACKBAR_TAB_BACKGROUND_COLOUR; use crate::stackbar_manager::STACKBAR_UNFOCUSED_TEXT_COLOUR; -use crate::Colour; use crate::KomorebiTheme; use crossbeam_channel::Receiver; use crossbeam_channel::Sender; use crossbeam_utils::atomic::AtomicCell; +use komorebi_themes::colour::Colour; use std::ops::Deref; use std::sync::atomic::Ordering; use std::sync::OnceLock;