mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-15 21:32:26 +01:00
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.
This commit is contained in:
1 parent
4095f45fd3
commit
be0e243d04
2 files changed
+3
-82
No files matched your search
@@ -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<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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user