From be0e243d043583bad6a7f9764d73ef72fda46ce0 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 22:26:47 -0700 Subject: [PATCH] refactor(mac): use AspectRatio and PerAnimationPrefixConfig of komorebi-config window and animation re-export the three types from komorebi-config; the local definitions and their imports are removed, so no call site changes. Verified: macOS fake-CC cargo check --locked --target aarch64-apple-darwin --workspace --all-targets: finished, 0 errors, no warnings in komorebi (tier 2). Not verified: macOS unit tests. --- .../komorebi/src/animation/mod.rs | 36 +------------- komorebi-for-mac/komorebi/src/window.rs | 49 +------------------ 2 files changed, 3 insertions(+), 82 deletions(-) diff --git a/komorebi-for-mac/komorebi/src/animation/mod.rs b/komorebi-for-mac/komorebi/src/animation/mod.rs index 74f0b0b4..1213a6d6 100644 --- a/komorebi-for-mac/komorebi/src/animation/mod.rs +++ b/komorebi-for-mac/komorebi/src/animation/mod.rs @@ -2,6 +2,7 @@ use crate::core::animation::AnimationStyle; use parking_lot::Mutex; pub use prefix::AnimationPrefix; +pub use komorebi_config::animation::PerAnimationPrefixConfig; use std::collections::HashMap; use std::sync::Arc; use std::sync::LazyLock; @@ -25,41 +26,6 @@ pub mod tracks; pub mod transition; pub mod workspace_transition; -use serde::Deserialize; -use serde::Serialize; - -#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[serde(untagged)] -/// Animation configuration -/// -/// This can be either global: -/// ```json -/// { -/// "enabled": true, -/// "style": "EaseInSine", -/// "fps": 60, -/// "duration": 250 -/// } -/// ``` -/// -/// Or scoped by an animation kind prefix: -/// ```json -/// { -/// "movement": { -/// "enabled": true, -/// "style": "EaseInSine", -/// "fps": 60, -/// "duration": 250 -/// } -/// } -/// ``` -pub enum PerAnimationPrefixConfig { - /// Animation configuration prefixed for a specific animation kind - Prefix(HashMap), - /// Animation configuration for all animation kinds - Global(T), -} pub const DEFAULT_ANIMATION_ENABLED: bool = false; pub const DEFAULT_ANIMATION_STYLE: AnimationStyle = AnimationStyle::Linear; diff --git a/komorebi-for-mac/komorebi/src/window.rs b/komorebi-for-mac/komorebi/src/window.rs index 3edd9f82..90e80ad2 100644 --- a/komorebi-for-mac/komorebi/src/window.rs +++ b/komorebi-for-mac/komorebi/src/window.rs @@ -42,6 +42,8 @@ use crate::arrival; use crate::cf_dictionary_value; use crate::core::ApplicationIdentifier; use crate::core::Rect; +pub use komorebi_config::aspect_ratio::AspectRatio; +pub use komorebi_config::aspect_ratio::PredefinedAspectRatio; use crate::core::WindowHidingPosition; use crate::core::config_generation::IdWithIdentifier; use crate::core::config_generation::MatchingRule; @@ -98,8 +100,6 @@ use std::ptr::NonNull; use std::str::FromStr; use std::sync::atomic::AtomicU32; use std::sync::atomic::Ordering; -use strum::Display; -use strum::EnumString; use tracing::instrument; /// Where a window that has scrolled out of view was parked @@ -1592,51 +1592,6 @@ impl From<&CFDictionary> for WindowBounds { } } -#[derive(Copy, Clone, Debug, Display, EnumString, Serialize, Deserialize, PartialEq)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[serde(untagged)] -/// Aspect ratio for temporarily floating windows -pub enum AspectRatio { - /// Predefined aspect ratio - #[cfg_attr(feature = "schemars", schemars(title = "Predefined"))] - Predefined(PredefinedAspectRatio), - /// Custom W:H aspect ratio - #[cfg_attr(feature = "schemars", schemars(title = "Custom"))] - Custom(i32, i32), -} - -impl Default for AspectRatio { - fn default() -> Self { - AspectRatio::Predefined(PredefinedAspectRatio::default()) - } -} - -#[derive(Copy, Clone, Debug, Default, Display, EnumString, Serialize, Deserialize, PartialEq)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Predefined aspect ratio -pub enum PredefinedAspectRatio { - /// 21:9 - Ultrawide, - /// 16:9 - Widescreen, - /// 4:3 - #[default] - Standard, -} - -impl AspectRatio { - pub fn width_and_height(self) -> (i32, i32) { - match self { - AspectRatio::Predefined(predefined) => match predefined { - PredefinedAspectRatio::Ultrawide => (21, 9), - PredefinedAspectRatio::Widescreen => (16, 9), - PredefinedAspectRatio::Standard => (4, 3), - }, - AspectRatio::Custom(w, h) => (w, h), - } - } -} - #[derive(Debug, Default, Serialize, Deserialize)] pub struct RuleDebug { pub should_manage: bool,