From a686b6191616f0a62114e634e32bc1fb5fb10931 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 22:51:56 -0700 Subject: [PATCH] refactor(komorebic-core): animation, animation-duration and animation-style join Messages The three animation subcommands were listed as differing in arguments between the trees because the possible values of --animation-type came from three different AnimationPrefix enums. Since step 2 there is one, and the pages of the three trees are now the same text (checked by comparing the rendered pages without fences and widths), so the Windows definitions move into Messages and the copies in WindowsCommands, MacosCommands and the KDE komorebic go, with their arms. The pages are byte-identical to the oracle: this is a move, not a docs change. Verified: oracle: windows 187, macos 158, kde 166 pages byte-identical; native cargo test -p komorebic-core: 31 + 3 passed; KDE cargo test -p komorebic --locked: 80 passed; macOS fake-CC cargo check --locked: 0 errors; Windows clippy --workspace --locked --all-targets -D warnings clean. --- crates/komorebic-core/src/args.rs | 30 +++++++++++++++ crates/komorebic-core/src/messages.rs | 18 +++++++++ crates/komorebic-core/src/platform/macos.rs | 38 ------------------- crates/komorebic-core/src/platform/windows.rs | 38 ------------------- komorebi-for-kde/komorebic/src/main.rs | 27 ------------- komorebi-for-mac/komorebic/src/main.rs | 18 --------- komorebic/src/main.rs | 18 --------- 7 files changed, 48 insertions(+), 139 deletions(-) diff --git a/crates/komorebic-core/src/args.rs b/crates/komorebic-core/src/args.rs index 126184e3..b11db7c9 100644 --- a/crates/komorebic-core/src/args.rs +++ b/crates/komorebic-core/src/args.rs @@ -22,6 +22,7 @@ use komorebi_layouts::CycleDirection; use komorebi_layouts::DefaultLayout; use komorebi_layouts::OperationDirection; use komorebi_layouts::Sizing; +use komorebi_protocol::animation::prefix::AnimationPrefix; use komorebi_protocol::pathext::replace_env_in_path; use komorebi_protocol::types::ApplicationIdentifier; use komorebi_protocol::types::HidingBehaviour; @@ -382,6 +383,35 @@ pub struct AnimationFps { /// Desired animation frames per second pub fps: u64, } + +#[derive(Args, Clone, Debug)] +pub struct Animation { + #[clap(value_enum)] + pub boolean_state: BooleanState, + /// Animation type to apply the state to. If not specified, sets global state + #[clap(value_enum, short, long)] + pub animation_type: Option, +} + +#[derive(Args, Clone, Debug)] +pub struct AnimationDuration { + /// Desired animation durations in ms + pub duration: u64, + /// Animation type to apply the duration to. If not specified, sets global duration + #[clap(value_enum, short, long)] + pub animation_type: Option, +} + +#[derive(Args, Clone, Debug)] +pub struct AnimationStyle { + /// Desired ease function for animation + #[clap(value_enum, short, long, default_value = "linear")] + pub style: komorebi_protocol::animation::AnimationStyle, + /// Animation type to apply the style to. If not specified, sets global style + #[clap(value_enum, short, long)] + pub animation_type: Option, +} + #[cfg(test)] mod tests { use super::*; diff --git a/crates/komorebic-core/src/messages.rs b/crates/komorebic-core/src/messages.rs index 935a895e..128c3943 100644 --- a/crates/komorebic-core/src/messages.rs +++ b/crates/komorebic-core/src/messages.rs @@ -354,6 +354,15 @@ pub enum Messages { /// Replace the configuration of a running instance of komorebi from a static configuration file #[clap(arg_required_else_help = true)] ReplaceConfiguration(ReplaceConfiguration), + /// Enable or disable movement animations + #[clap(arg_required_else_help = true)] + Animation(Animation), + /// Set the duration for movement animations in ms + #[clap(arg_required_else_help = true)] + AnimationDuration(AnimationDuration), + /// Set the ease function for movement animations + #[clap(arg_required_else_help = true)] + AnimationStyle(AnimationStyle), } impl Messages { @@ -644,6 +653,15 @@ impl From for SocketMessage { } Messages::ToggleMouseFollowsFocus => SocketMessage::ToggleMouseFollowsFocus, Messages::ReplaceConfiguration(args) => SocketMessage::ReplaceConfiguration(args.path), + Messages::Animation(args) => { + SocketMessage::Animation(args.boolean_state.into(), args.animation_type) + } + Messages::AnimationDuration(args) => { + SocketMessage::AnimationDuration(args.duration, args.animation_type) + } + Messages::AnimationStyle(args) => { + SocketMessage::AnimationStyle(args.style, args.animation_type) + } } } } diff --git a/crates/komorebic-core/src/platform/macos.rs b/crates/komorebic-core/src/platform/macos.rs index f6157902..858d0d04 100644 --- a/crates/komorebic-core/src/platform/macos.rs +++ b/crates/komorebic-core/src/platform/macos.rs @@ -4,7 +4,6 @@ use crate::args::*; use clap::Parser; use clap::Subcommand; use komorebi_layouts::*; -use komorebi_protocol::animation::prefix::AnimationPrefix; use komorebi_protocol::pathext::replace_env_in_path; use komorebi_protocol::types::*; use std::num::NonZeroUsize; @@ -113,34 +112,6 @@ pub struct BorderColour { pub b: u32, } -#[derive(Parser)] -pub struct Animation { - #[clap(value_enum)] - pub boolean_state: BooleanState, - /// Animation type to apply the state to. If not specified, sets global state - #[clap(value_enum, short, long)] - pub animation_type: Option, -} - -#[derive(Parser)] -pub struct AnimationDuration { - /// Desired animation durations in ms - pub duration: u64, - /// Animation type to apply the duration to. If not specified, sets global duration - #[clap(value_enum, short, long)] - pub animation_type: Option, -} - -#[derive(Parser)] -pub struct AnimationStyle { - /// Desired ease function for animation - #[clap(value_enum, short, long, default_value = "linear")] - pub style: komorebi_protocol::animation::AnimationStyle, - /// Animation type to apply the style to. If not specified, sets global style - #[clap(value_enum, short, long)] - pub animation_type: Option, -} - #[derive(Parser)] pub struct Docgen { /// Output directory for generated documentation files @@ -373,15 +344,6 @@ pub enum MacosCommands { // TransparencyAlpha(TransparencyAlpha), // /// Toggle transparency for unfocused windows // ToggleTransparency, - /// Enable or disable movement animations - #[clap(arg_required_else_help = true)] - Animation(Animation), - /// Set the duration for movement animations in ms - #[clap(arg_required_else_help = true)] - AnimationDuration(AnimationDuration), - /// Set the ease function for movement animations - #[clap(arg_required_else_help = true)] - AnimationStyle(AnimationStyle), // /// Enable or disable focus follows mouse for the operating system // #[clap(hide = true)] // #[clap(arg_required_else_help = true)] diff --git a/crates/komorebic-core/src/platform/windows.rs b/crates/komorebic-core/src/platform/windows.rs index d080e1e7..ec978d78 100644 --- a/crates/komorebic-core/src/platform/windows.rs +++ b/crates/komorebic-core/src/platform/windows.rs @@ -4,7 +4,6 @@ use crate::args::*; use clap::Parser; use clap::Subcommand; use komorebi_layouts::*; -use komorebi_protocol::animation::prefix::AnimationPrefix; use komorebi_protocol::pathext::replace_env_in_path; use komorebi_protocol::types::*; use std::num::NonZeroUsize; @@ -154,34 +153,6 @@ pub struct StackbarMode { pub mode: komorebi_protocol::types::StackbarMode, } -#[derive(Parser)] -pub struct Animation { - #[clap(value_enum)] - pub boolean_state: BooleanState, - /// Animation type to apply the state to. If not specified, sets global state - #[clap(value_enum, short, long)] - pub animation_type: Option, -} - -#[derive(Parser)] -pub struct AnimationDuration { - /// Desired animation durations in ms - pub duration: u64, - /// Animation type to apply the duration to. If not specified, sets global duration - #[clap(value_enum, short, long)] - pub animation_type: Option, -} - -#[derive(Parser)] -pub struct AnimationStyle { - /// Desired ease function for animation - #[clap(value_enum, short, long, default_value = "linear")] - pub style: komorebi_protocol::animation::AnimationStyle, - /// Animation type to apply the style to. If not specified, sets global style - #[clap(value_enum, short, long)] - pub animation_type: Option, -} - #[derive(Parser)] pub struct Docgen { /// Output directory for generated documentation files @@ -588,15 +559,6 @@ pub enum WindowsCommands { TransparencyAlpha(TransparencyAlpha), /// Toggle transparency for unfocused windows ToggleTransparency, - /// Enable or disable movement animations - #[clap(arg_required_else_help = true)] - Animation(Animation), - /// Set the duration for movement animations in ms - #[clap(arg_required_else_help = true)] - AnimationDuration(AnimationDuration), - /// Set the ease function for movement animations - #[clap(arg_required_else_help = true)] - AnimationStyle(AnimationStyle), /// Enable or disable focus follows mouse for the operating system #[clap(hide = true)] #[clap(arg_required_else_help = true)] diff --git a/komorebi-for-kde/komorebic/src/main.rs b/komorebi-for-kde/komorebic/src/main.rs index a1af69dc..da0e7c69 100644 --- a/komorebi-for-kde/komorebic/src/main.rs +++ b/komorebi-for-kde/komorebic/src/main.rs @@ -455,15 +455,6 @@ enum KdeCommands { TransparencyAlpha(TransparencyAlpha), /// Toggle transparency for unfocused windows ToggleTransparency, - /// Enable or disable movement animations - #[clap(arg_required_else_help = true)] - Animation(Animation), - /// Set the duration for movement animations in ms - #[clap(arg_required_else_help = true)] - AnimationDuration(AnimationDuration), - /// Set the ease function for movement animations - #[clap(arg_required_else_help = true)] - AnimationStyle(AnimationStyle), /// Enable or disable focus follows mouse (KWin's own focus policy) #[clap(arg_required_else_help = true)] FocusFollowsMouse(FocusFollowsMouse), @@ -886,24 +877,6 @@ fn main() -> eyre::Result<()> { KdeCommands::ToggleFocusFollowsMouse(args) => { send_message(&SocketMessage::ToggleFocusFollowsMouse(args.implementation))?; } - KdeCommands::Animation(args) => { - send_message(&SocketMessage::Animation( - args.boolean_state.into(), - args.animation_type, - ))?; - } - KdeCommands::AnimationDuration(args) => { - send_message(&SocketMessage::AnimationDuration( - args.duration, - args.animation_type, - ))?; - } - KdeCommands::AnimationStyle(args) => { - send_message(&SocketMessage::AnimationStyle( - args.style, - args.animation_type, - ))?; - } }, } diff --git a/komorebi-for-mac/komorebic/src/main.rs b/komorebi-for-mac/komorebic/src/main.rs index 41b00436..953fdbd0 100644 --- a/komorebi-for-mac/komorebic/src/main.rs +++ b/komorebi-for-mac/komorebic/src/main.rs @@ -851,24 +851,6 @@ exit 1 args.b, ))?; } - MacosCommands::Animation(args) => { - send_message(&SocketMessage::Animation( - args.boolean_state.into(), - args.animation_type, - ))?; - } - MacosCommands::AnimationDuration(args) => { - send_message(&SocketMessage::AnimationDuration( - args.duration, - args.animation_type, - ))?; - } - MacosCommands::AnimationStyle(args) => { - send_message(&SocketMessage::AnimationStyle( - args.style, - args.animation_type, - ))?; - } }, } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 246b357e..a10b5ad2 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1331,24 +1331,6 @@ if (Get-Command Get-CimInstance -ErrorAction SilentlyContinue) { WindowsCommands::ToggleTransparency => { send_message(&SocketMessage::ToggleTransparency)?; } - WindowsCommands::Animation(args) => { - send_message(&SocketMessage::Animation( - args.boolean_state.into(), - args.animation_type, - ))?; - } - WindowsCommands::AnimationDuration(args) => { - send_message(&SocketMessage::AnimationDuration( - args.duration, - args.animation_type, - ))?; - } - WindowsCommands::AnimationStyle(args) => { - send_message(&SocketMessage::AnimationStyle( - args.style, - args.animation_type, - ))?; - } WindowsCommands::ToggleWindowContainerBehaviour => { send_message(&SocketMessage::ToggleWindowContainerBehaviour)?;