From 3e1810e3e94f34d26cd74588df9f2aef2e8c5916 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Fri, 30 Oct 2026 21:17:56 -0700 Subject: [PATCH] refactor(protocol): use the seven common payload enums from komorebi-protocol in KDE Delete the seven enums from komorebi-for-kde core/mod.rs (text identical to the crate's) and re-export them from core, so existing paths stay valid. Verified: cargo check --workspace --all-targets in komorebi-for-kde: 0 errors, no warnings; cargo test -p komorebi --lib --test schemas --test animation: passed (counts in the stage log). --- komorebi-for-kde/komorebi/src/core/mod.rs | 133 ++-------------------- 1 file changed, 7 insertions(+), 126 deletions(-) diff --git a/komorebi-for-kde/komorebi/src/core/mod.rs b/komorebi-for-kde/komorebi/src/core/mod.rs index 954b8b45..09366806 100644 --- a/komorebi-for-kde/komorebi/src/core/mod.rs +++ b/komorebi-for-kde/komorebi/src/core/mod.rs @@ -54,19 +54,13 @@ pub mod animation; pub mod asc; pub mod config_generation; pub use komorebi_protocol::pathext; - -#[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, -} +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; #[derive(Clone, Copy, Debug, Default, Serialize, Deserialize, PartialEq)] pub struct WindowManagementBehaviour { @@ -394,21 +388,6 @@ pub enum PlacementMatchingRules { Many(Vec), } -#[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, )] @@ -422,104 +401,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, -} - /// A message to the daemon, as it is written on its socket: JSON, with the variant's name in /// `type` and its arguments, if it has any, in `content`. ///