refactor(kde): use AspectRatio and PerAnimationPrefixConfig of komorebi-config

window and animation re-export the three types from komorebi-config; the local definitions (82 lines) and their imports are removed, so no call site changes.

Verified: KDE cargo check --workspace --all-targets: no warnings; cargo test -p komorebi --lib: 289 passed, 0 failed; --test schemas: 5 passed; komorebic regeneration: schema.json and schema.asc.json byte-identical to the checked-in files.
This commit is contained in:
LGUG2Z committed 2026-10-31 01:37:54 -07:00
1 parent 96b706b61c
commit 4095f45fd3
2 files changed
+3 -82

No files matched your search

+1 -35
View File
@@ -12,6 +12,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;
@@ -20,41 +21,6 @@ use std::sync::atomic::AtomicU64;
pub mod prefix;
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<T> {
/// Animation configuration prefixed for a specific animation kind
Prefix(HashMap<AnimationPrefix, T>),
/// Animation configuration for all animation kinds
Global(T),
}
pub const DEFAULT_ANIMATION_ENABLED: bool = false;
pub const DEFAULT_ANIMATION_STYLE: AnimationStyle = AnimationStyle::Linear;
+2 -47
View File
@@ -27,6 +27,8 @@ use crate::REGEX_IDENTIFIERS;
use crate::backend::backend;
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::config_generation::IdWithIdentifier;
use crate::core::config_generation::MatchingRule;
use crate::core::config_generation::MatchingStrategy;
@@ -43,8 +45,6 @@ use std::fmt::Display;
use std::fmt::Formatter;
use std::fmt::Write;
use std::path::PathBuf;
use strum::Display;
use strum::EnumString;
/// The windows the user is resizing by dragging an edge of: komorebi does not move them while they
/// are (the other tiles follow the drag, and the window is put in its tile when they let go)
@@ -431,51 +431,6 @@ impl Window {
}
}
#[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),
}
}
}
/// Why [`Window::should_manage`] decided as it did: what it read of the window, and the rule of
/// each kind that matched it
#[derive(Debug, Default, Serialize, Deserialize)]