mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-17 06:11:21 +01:00
refactor(windows): use AspectRatio and PerAnimationPrefixConfig of komorebi-config
window re-exports AspectRatio and PredefinedAspectRatio and animation re-exports PerAnimationPrefixConfig from komorebi-config; the local definitions are removed (87 lines) with the imports they needed, so no call site changes. cargo fmt also drops two stray blank lines left by the previous revision in border_manager and core. Verified: Windows cargo clippy --workspace --locked --all-targets -D warnings: clean (tier 2). schema.json untouched.
This commit is contained in:
1 parent
44e0b32459
commit
96b706b61c
4 files changed
+4
-86
No files matched your search
@@ -13,6 +13,7 @@ use std::time::Duration;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
pub use engine::AnimationEngine;
|
||||
pub use komorebi_config::animation::PerAnimationPrefixConfig;
|
||||
pub mod animation_manager;
|
||||
pub mod engine;
|
||||
pub mod ghost;
|
||||
@@ -25,42 +26,6 @@ pub use render_dispatcher::RenderDispatcher;
|
||||
pub mod style;
|
||||
pub mod 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;
|
||||
pub const DEFAULT_ANIMATION_DURATION: u64 = 250;
|
||||
|
||||
@@ -11,12 +11,12 @@ use crate::windows_api;
|
||||
use crate::workspace::Workspace;
|
||||
use crate::workspace::WorkspaceLayer;
|
||||
pub use border::Border;
|
||||
pub use komorebi_config::behaviour::ZOrder;
|
||||
use border::border_hwnds;
|
||||
use crossbeam_channel::Receiver;
|
||||
use crossbeam_channel::Sender;
|
||||
use crossbeam_utils::atomic::AtomicCell;
|
||||
use crossbeam_utils::atomic::AtomicConsume;
|
||||
pub use komorebi_config::behaviour::ZOrder;
|
||||
use komorebi_themes::colour::Colour;
|
||||
use komorebi_themes::colour::Rgb;
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
#![allow(clippy::missing_errors_doc, clippy::use_self, clippy::doc_markdown)]
|
||||
#![allow(deprecated)] // allow deprecated variants like HidingBehaviour::Hide to be used in derive macros
|
||||
|
||||
|
||||
use clap::ValueEnum;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use strum::Display;
|
||||
use strum::EnumString;
|
||||
|
||||
|
||||
// Re-export everything from komorebi-layouts
|
||||
pub use komorebi_layouts::Arrangement;
|
||||
pub use komorebi_layouts::Axis;
|
||||
|
||||
+2
-47
@@ -44,6 +44,8 @@ use crate::windows_api;
|
||||
use crate::windows_api::WindowsApi;
|
||||
use color_eyre::eyre;
|
||||
use crossbeam_utils::atomic::AtomicConsume;
|
||||
pub use komorebi_config::aspect_ratio::AspectRatio;
|
||||
pub use komorebi_config::aspect_ratio::PredefinedAspectRatio;
|
||||
use regex::Regex;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
@@ -58,8 +60,6 @@ use std::sync::atomic::AtomicI32;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use strum::Display;
|
||||
use strum::EnumString;
|
||||
use windows::Win32::Foundation::HWND;
|
||||
|
||||
pub static MINIMUM_WIDTH: AtomicI32 = AtomicI32::new(0);
|
||||
@@ -227,51 +227,6 @@ impl RenderDispatcher for TransparencyRenderDispatcher {
|
||||
}
|
||||
}
|
||||
|
||||
#[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),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Window {
|
||||
pub const fn hwnd(self) -> HWND {
|
||||
HWND(windows_api::as_ptr!(self.hwnd))
|
||||
|
||||
Reference in new issue
Block a user