From 6ae2db838940062e724058e7ce86a27f61ed80fb Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 21:19:23 -0700 Subject: [PATCH] refactor(protocol): use the seven common payload enums from komorebi-protocol in macOS Delete the seven enums from komorebi-for-mac core/mod.rs (text identical to the crate's) and re-export them from core. Verified: fast-check macOS (fake CC) cargo check --workspace --all-targets: PASS (type-check only). --- komorebi-for-mac/komorebi/src/core/mod.rs | 133 ++-------------------- 1 file changed, 7 insertions(+), 126 deletions(-) diff --git a/komorebi-for-mac/komorebi/src/core/mod.rs b/komorebi-for-mac/komorebi/src/core/mod.rs index 56670e31..8aa5a961 100644 --- a/komorebi-for-mac/komorebi/src/core/mod.rs +++ b/komorebi-for-mac/komorebi/src/core/mod.rs @@ -41,21 +41,15 @@ pub mod animation; pub mod asc; pub mod config_generation; pub use komorebi_protocol::pathext; +pub use komorebi_protocol::types::ApplicationIdentifier; +pub use komorebi_protocol::types::MonocleFocusBehaviour; +pub use komorebi_protocol::types::MoveBehaviour; +pub use komorebi_protocol::types::OperationBehaviour; +pub use komorebi_protocol::types::StateQuery; +pub use komorebi_protocol::types::SubscribeOptions; +pub use komorebi_protocol::types::WindowKind; pub mod rect_ext; -#[derive( - Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum, -)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Operation behaviour for temporarily unmanaged and floating windows -pub enum OperationBehaviour { - /// Process commands on temporarily unmanaged/floated windows - #[default] - Op, - /// Ignore commands on temporarily unmanaged/floated windows - NoOp, -} - #[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, PartialEq)] pub struct WindowManagementBehaviour { /// The current WindowContainerBehaviour to be used @@ -160,21 +154,6 @@ impl Placement { } } -#[derive( - Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum, -)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Move behaviour when the operation works across a monitor boundary -pub enum MoveBehaviour { - /// Swap the window container with the window container at the edge of the adjacent monitor - #[default] - Swap, - /// Insert the window container into the focused workspace on the adjacent monitor - Insert, - /// Do nothing if trying to move a window container in the direction of an adjacent monitor - NoOp, -} - #[derive( Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, )] @@ -188,104 +167,6 @@ pub enum CrossBoundaryBehaviour { Monitor, } -#[derive( - Clone, Copy, Debug, Default, Serialize, Deserialize, Display, EnumString, ValueEnum, PartialEq, -)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Behaviour when focusing in a direction while a monocle container is active -pub enum MonocleFocusBehaviour { - /// Cycle the monocle container to the next/previous container in the workspace - Cycle, - /// Do nothing, allowing focus to fall through to cross-monitor logic - #[default] - NoOp, -} - -#[derive( - Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Display, EnumString, ValueEnum, -)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// Application identifier -pub enum ApplicationIdentifier { - /// Executable name - #[serde(alias = "exe")] - Exe, - // the description is part of the checked-in schemas, which differ per platform - #[cfg_attr(target_os = "windows", doc = " Class")] - #[cfg_attr(not(target_os = "windows"), doc = " Role or subrole")] - #[serde(alias = "class")] - Class, - #[serde(alias = "title")] - /// Window title - Title, - /// Executable path - #[serde(alias = "path")] - Path, -} - -#[derive( - Copy, - Clone, - Debug, - Default, - Serialize, - Deserialize, - Display, - EnumString, - ValueEnum, - PartialEq, - Eq, - Hash, -)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -/// What a window is to the layout, which decides the color of its border -pub enum WindowKind { - /// Single window - Single, - /// Stack container - Stack, - /// Monocle container - Monocle, - #[default] - /// Unfocused window - Unfocused, - /// Unfocused locked container - UnfocusedLocked, - /// Floating window - Floating, -} - -/// A question about the window manager that `SocketMessage::Query` asks, answered with one -/// value as text: an index, the name of a layout or of a container kind, or the version of the -/// daemon. -#[derive(Copy, Clone, Debug, Serialize, Deserialize, Display, EnumString, ValueEnum)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -pub enum StateQuery { - FocusedMonitorIndex, - FocusedWorkspaceIndex, - FocusedContainerIndex, - FocusedWindowIndex, - FocusedWorkspaceName, - FocusedWorkspaceLayout, - FocusedContainerKind, - Version, -} - -/// The options of a subscriber, which `SocketMessage::AddSubscriberSocketWithOptions` sets -/// -/// A subscriber added with `SocketMessage::AddSubscriberSocket` has the default options, and is -/// sent a notification for every event and message the window manager handles. With -/// `filter_state_changes`, it is sent one only when the event or the message changed the -/// state, and always when a window is shown, when a subscriber is added (so a new subscriber -/// receives the state as soon as it subscribes), when a theme is set (the colors of the borders -/// are not part of the state) and when the configuration is reloaded. -#[derive(Default, Debug, Copy, Clone, Eq, PartialEq, Serialize, Deserialize)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -pub struct SubscribeOptions { - /// Only emit notifications when the window manager state has changed - pub filter_state_changes: bool, -} - // serde_as must be before derive #[serde_with::serde_as] #[derive(Clone, Debug, Serialize, Deserialize, Display)]