From 9d8d36ac8b8c4b805acb9bf9d589429837c17403 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 21:28:06 -0700 Subject: [PATCH] refactor(protocol): move the Windows-only payload enums and FocusFollowsMouseImplementation into komorebi-protocol (Windows) StackbarMode, StackbarLabel, BorderStyle, BorderImplementation, HidingBehaviour and FocusFollowsMouseImplementation move verbatim from core/mod.rs to the end of crates/komorebi-protocol/src/types.rs, because the unified SocketMessage (stage 2e) carries them; they keep their platform-only status in the support table. The crate allows the deprecated HidingBehaviour::Hide that the derives touch. core re-exports all six. Verified: Windows clippy --workspace --locked --all-targets -D warnings clean; native cargo test -p komorebi-protocol passes. --- crates/komorebi-protocol/src/lib.rs | 1 + crates/komorebi-protocol/src/types.rs | 86 +++++++++++++++++++++++++- komorebi/src/core/mod.rs | 87 ++------------------------- 3 files changed, 92 insertions(+), 82 deletions(-) diff --git a/crates/komorebi-protocol/src/lib.rs b/crates/komorebi-protocol/src/lib.rs index 4299c9ad..561b2c78 100644 --- a/crates/komorebi-protocol/src/lib.rs +++ b/crates/komorebi-protocol/src/lib.rs @@ -5,6 +5,7 @@ //! leaf modules (`animation`, `pathext`) those payloads depend on. The socket //! transport is not part of it. #![warn(clippy::all)] +#![allow(deprecated)] // HidingBehaviour::Hide is deprecated and still part of the wire format #![allow(clippy::missing_errors_doc, clippy::use_self, clippy::doc_markdown)] pub mod animation; diff --git a/crates/komorebi-protocol/src/types.rs b/crates/komorebi-protocol/src/types.rs index e86ff713..1b5e1dc0 100644 --- a/crates/komorebi-protocol/src/types.rs +++ b/crates/komorebi-protocol/src/types.rs @@ -1,4 +1,4 @@ -//! The payload types of `SocketMessage` that are the same on every platform. +//! The payload types of `SocketMessage`. use clap::ValueEnum; use serde::Deserialize; @@ -149,3 +149,87 @@ pub enum OperationBehaviour { /// Ignore commands on temporarily unmanaged/floated windows NoOp, } + +// Payloads of messages that not every platform handles (see `platforms`): borders, stackbars, +// window hiding and focus follows mouse are Windows features, the last one also exists on KDE. + +#[derive(Debug, Copy, Clone, Eq, PartialEq, Display, Serialize, Deserialize, ValueEnum)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +/// Stackbar mode +pub enum StackbarMode { + /// Always show + Always, + /// Never show + Never, + /// Show on stack + OnStack, +} + +#[derive(Debug, Copy, Default, Clone, Eq, PartialEq, Display, Serialize, Deserialize)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +/// Starbar label +pub enum StackbarLabel { + #[default] + /// Process name + Process, + /// Window title + Title, +} + +#[derive( + Default, Copy, Clone, Debug, Eq, PartialEq, Display, Serialize, Deserialize, ValueEnum, +)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +/// Border style +pub enum BorderStyle { + #[default] + /// Use the system border style + System, + /// Use the Windows 11-style rounded borders + Rounded, + /// Use the Windows 10-style square borders + Square, +} + +#[derive( + Default, Copy, Clone, Debug, Eq, PartialEq, Display, Serialize, Deserialize, ValueEnum, +)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +/// Border style +pub enum BorderImplementation { + #[default] + /// Use the adjustable komorebi border implementation + Komorebi, + /// Use the thin Windows accent border implementation + Windows, +} + +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +/// Focus follows mouse implementation +// KDE's compositor does the focusing: its description says so (it is part of the checked-in schema) +#[cfg_attr(target_os = "linux", doc = "")] +#[cfg_attr( + target_os = "linux", + doc = " The two exist on Windows. On KDE the compositor does it, so both ask KWin for its" +)] +#[cfg_attr(target_os = "linux", doc = " \"focus follows mouse\" focus policy.")] +pub enum FocusFollowsMouseImplementation { + /// Custom FFM implementation (slightly more CPU-intensive) + Komorebi, + /// Native (legacy) Windows FFM implementation + Windows, +} + +#[derive(Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq)] +#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] +/// Window hiding behaviour +pub enum HidingBehaviour { + /// END OF LIFE FEATURE: Use the `SW_HIDE` flag to hide windows when switching workspaces (has issues with Electron apps) + #[deprecated(note = "End of life feature")] + Hide, + /// Use the `SW_MINIMIZE` flag to hide windows when switching workspaces (has issues with frequent workspace switching) + Minimize, + /// Use the undocumented SetCloak Win32 function to hide windows when switching workspaces + Cloak, +} diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 8713850e..7a9a7542 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -49,9 +49,15 @@ pub use komorebi_layouts::validate_ratios; // Local modules and exports pub use animation::AnimationStyle; pub use komorebi_protocol::types::ApplicationIdentifier; +pub use komorebi_protocol::types::BorderImplementation; +pub use komorebi_protocol::types::BorderStyle; +pub use komorebi_protocol::types::FocusFollowsMouseImplementation; +pub use komorebi_protocol::types::HidingBehaviour; pub use komorebi_protocol::types::MonocleFocusBehaviour; pub use komorebi_protocol::types::MoveBehaviour; pub use komorebi_protocol::types::OperationBehaviour; +pub use komorebi_protocol::types::StackbarLabel; +pub use komorebi_protocol::types::StackbarMode; pub use komorebi_protocol::types::StateQuery; pub use komorebi_protocol::types::SubscribeOptions; pub use komorebi_protocol::types::WindowKind; @@ -296,74 +302,6 @@ impl FromStr for SocketMessage { } } -#[derive(Debug, Copy, Clone, Eq, PartialEq, Display, Serialize, Deserialize, ValueEnum)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Stackbar mode -pub enum StackbarMode { - /// Always show - Always, - /// Never show - Never, - /// Show on stack - OnStack, -} - -#[derive(Debug, Copy, Default, Clone, Eq, PartialEq, Display, Serialize, Deserialize)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Starbar label -pub enum StackbarLabel { - #[default] - /// Process name - Process, - /// Window title - Title, -} - -#[derive( - Default, Copy, Clone, Debug, Eq, PartialEq, Display, Serialize, Deserialize, ValueEnum, -)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Border style -pub enum BorderStyle { - #[default] - /// Use the system border style - System, - /// Use the Windows 11-style rounded borders - Rounded, - /// Use the Windows 10-style square borders - Square, -} - -#[derive( - Default, Copy, Clone, Debug, Eq, PartialEq, Display, Serialize, Deserialize, ValueEnum, -)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Border style -pub enum BorderImplementation { - #[default] - /// Use the adjustable komorebi border implementation - Komorebi, - /// Use the thin Windows accent border implementation - Windows, -} - -#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Focus follows mouse implementation -// KDE's compositor does the focusing: its description says so (it is part of the checked-in schema) -#[cfg_attr(target_os = "linux", doc = "")] -#[cfg_attr( - target_os = "linux", - doc = " The two exist on Windows. On KDE the compositor does it, so both ask KWin for its" -)] -#[cfg_attr(target_os = "linux", doc = " \"focus follows mouse\" focus policy.")] -pub enum FocusFollowsMouseImplementation { - /// Custom FFM implementation (slightly more CPU-intensive) - Komorebi, - /// Native (legacy) Windows FFM implementation - Windows, -} - #[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, PartialEq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] /// Window management behaviour @@ -696,19 +634,6 @@ pub enum CrossBoundaryBehaviour { Monitor, } -#[derive(Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Window hiding behaviour -pub enum HidingBehaviour { - /// END OF LIFE FEATURE: Use the `SW_HIDE` flag to hide windows when switching workspaces (has issues with Electron apps) - #[deprecated(note = "End of life feature")] - Hide, - /// Use the `SW_MINIMIZE` flag to hide windows when switching workspaces (has issues with frequent workspace switching) - Minimize, - /// Use the undocumented SetCloak Win32 function to hide windows when switching workspaces - Cloak, -} - #[derive( Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, )]