diff --git a/komorebi-for-mac/komorebi/src/core/mod.rs b/komorebi-for-mac/komorebi/src/core/mod.rs index 661c557d..b97aeb17 100644 --- a/komorebi-for-mac/komorebi/src/core/mod.rs +++ b/komorebi-for-mac/komorebi/src/core/mod.rs @@ -1,14 +1,6 @@ -use crate::animation::AnimationPrefix; -use crate::core::animation::AnimationStyle; -use crate::core::pathext::ResolvedPathBuf; use clap::ValueEnum; -use color_eyre::eyre; -use komorebi_themes::KomorebiTheme; use serde::Deserialize; use serde::Serialize; -use std::num::NonZeroUsize; -use std::path::PathBuf; -use std::str::FromStr; use strum::Display; use strum::EnumString; @@ -167,234 +159,7 @@ pub enum CrossBoundaryBehaviour { Monitor, } -// serde_as must be before derive -#[serde_with::serde_as] -#[derive(Clone, Debug, Serialize, Deserialize, Display)] -#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] -#[serde(tag = "type", content = "content")] -pub enum SocketMessage { - // Window / Container Commands - FocusWindow(OperationDirection), - MoveWindow(OperationDirection), - PreselectDirection(OperationDirection), - CancelPreselect, - CycleFocusWindow(CycleDirection), - CycleMoveWindow(CycleDirection), - StackWindow(OperationDirection), - UnstackWindow, - CycleStack(CycleDirection), - CycleStackIndex(CycleDirection), - FocusStackWindow(usize), - StackAll, - UnstackAll, - ResizeWindowEdge(OperationDirection, Sizing), - ResizeWindowAxis(Axis, Sizing), - MoveContainerToLastWorkspace, - SendContainerToLastWorkspace, - MoveContainerToMonitorNumber(usize), - CycleMoveContainerToMonitor(CycleDirection), - MoveContainerToWorkspaceNumber(usize), - MoveContainerToNamedWorkspace(String), - CycleMoveContainerToWorkspace(CycleDirection), - SendContainerToMonitorNumber(usize), - CycleSendContainerToMonitor(CycleDirection), - SendContainerToWorkspaceNumber(usize), - CycleSendContainerToWorkspace(CycleDirection), - SendContainerToMonitorWorkspaceNumber(usize, usize), - MoveContainerToMonitorWorkspaceNumber(usize, usize), - SendContainerToNamedWorkspace(String), - CycleMoveWorkspaceToMonitor(CycleDirection), - MoveWorkspaceToMonitorNumber(usize), - SwapWorkspacesToMonitorNumber(usize), - // ForceFocus, - Close, - Minimize, - Promote, - PromoteSwap, - PromoteFocus, - PromoteWindow(OperationDirection), - EagerFocus(String), - LockMonitorWorkspaceContainer(usize, usize, usize), - UnlockMonitorWorkspaceContainer(usize, usize, usize), - ToggleLock, - ToggleFloat, - ToggleMonocle, - // ToggleMaximize, - ToggleWindowContainerBehaviour, - ToggleFloatOverride, - // WindowHidingBehaviour(HidingBehaviour), - ToggleCrossMonitorMoveBehaviour, - CrossMonitorMoveBehaviour(MoveBehaviour), - ToggleMonocleFocusBehaviour, - MonocleFocusBehaviour(MonocleFocusBehaviour), - UnmanagedWindowOperationBehaviour(OperationBehaviour), - // Current Workspace Commands - ManageFocusedWindow, - UnmanageFocusedWindow, - AdjustContainerPadding(Sizing, i32), - AdjustWorkspacePadding(Sizing, i32), - ChangeLayout(DefaultLayout), - CycleLayout(CycleDirection), - ScrollingLayoutColumns(NonZeroUsize), - ScrollingLayoutFullWidth, - CenterFocus, - Expand, - Pan(PanDirection), - PanGesture(PanGesture), - Consume(OperationDirection), - Expel, - ToggleColumnStack, - LayoutRatios(Option>, Option>), - // ChangeLayoutCustom(#[serde_as(as = "ResolvedPathBuf")] PathBuf), - FlipLayout(Axis), - ToggleWorkspaceWindowContainerBehaviour, - ToggleWorkspaceFloatOverride, - // Monitor and Workspace Commands - // MonitorIndexPreference(usize, i32, i32, i32, i32), - DisplayIndexPreference(usize, String), - EnsureWorkspaces(usize, usize), - EnsureNamedWorkspaces(usize, Vec), - NewWorkspace, - ToggleTiling, - Stop, - StopIgnoreRestore, - TogglePause, - Retile, - RetileWithResizeDimensions, - QuickSave, - QuickLoad, - Save(#[serde_as(as = "ResolvedPathBuf")] PathBuf), - Load(#[serde_as(as = "ResolvedPathBuf")] PathBuf), - CycleFocusMonitor(CycleDirection), - CycleFocusWorkspace(CycleDirection), - CycleFocusEmptyWorkspace(CycleDirection), - FocusMonitorNumber(usize), - FocusMonitorAtCursor, - FocusLastWorkspace, - CloseWorkspace, - FocusWorkspaceNumber(usize), - FocusWorkspaceNumbers(usize), - FocusMonitorWorkspaceNumber(usize, usize), - FocusNamedWorkspace(String), - ContainerPadding(usize, usize, i32), - NamedWorkspaceContainerPadding(String, i32), - FocusedWorkspaceContainerPadding(i32), - WorkspacePadding(usize, usize, i32), - NamedWorkspacePadding(String, i32), - FocusedWorkspacePadding(i32), - WorkspaceTiling(usize, usize, bool), - NamedWorkspaceTiling(String, bool), - WorkspaceName(usize, usize, String), - WorkspaceLayout(usize, usize, DefaultLayout), - NamedWorkspaceLayout(String, DefaultLayout), - // WorkspaceLayoutCustom(usize, usize, #[serde_as(as = "ResolvedPathBuf")] PathBuf), - // NamedWorkspaceLayoutCustom(String, #[serde_as(as = "ResolvedPathBuf")] PathBuf), - WorkspaceLayoutRule(usize, usize, usize, DefaultLayout), - NamedWorkspaceLayoutRule(String, usize, DefaultLayout), - // WorkspaceLayoutCustomRule( - // usize, - // usize, - // usize, - // #[serde_as(as = "ResolvedPathBuf")] PathBuf, - // ), - // NamedWorkspaceLayoutCustomRule(String, usize, #[serde_as(as = "ResolvedPathBuf")] PathBuf), - ClearWorkspaceLayoutRules(usize, usize), - ClearNamedWorkspaceLayoutRules(String), - ToggleWorkspaceLayer, - // Configuration - // ReloadConfiguration, - ReplaceConfiguration(#[serde_as(as = "ResolvedPathBuf")] PathBuf), - ReloadStaticConfiguration(#[serde_as(as = "ResolvedPathBuf")] PathBuf), - // WatchConfiguration(bool), - // CompleteConfiguration, - // AltFocusHack(bool), - Theme(Box), - Animation(bool, Option), - AnimationDuration(u64, Option), - AnimationFps(u64), - AnimationStyle(AnimationStyle, Option), - #[serde(alias = "ActiveWindowBorder")] - Border(bool), - #[serde(alias = "ActiveWindowBorderColour")] - BorderColour(WindowKind, u32, u32, u32), - // #[serde(alias = "ActiveWindowBorderStyle")] - // BorderStyle(BorderStyle), - BorderWidth(i32), - BorderOffset(i32), - // BorderImplementation(BorderImplementation), - // Transparency(bool), - // ToggleTransparency, - // TransparencyAlpha(u8), - // InvisibleBorders(Rect), - // StackbarMode(StackbarMode), - // StackbarLabel(StackbarLabel), - // StackbarFocusedTextColour(u32, u32, u32), - // StackbarUnfocusedTextColour(u32, u32, u32), - // StackbarBackgroundColour(u32, u32, u32), - // StackbarHeight(i32), - // StackbarTabWidth(i32), - // StackbarFontSize(i32), - // StackbarFontFamily(Option), - WorkAreaOffset(Rect), - MonitorWorkAreaOffset(usize, Rect), - WorkspaceWorkAreaOffset(usize, usize, Rect), - ToggleWindowBasedWorkAreaOffset, - ResizeDelta(i32), - InitialWorkspaceRule(ApplicationIdentifier, String, usize, usize), - InitialNamedWorkspaceRule(ApplicationIdentifier, String, String), - WorkspaceRule(ApplicationIdentifier, String, usize, usize), - NamedWorkspaceRule(ApplicationIdentifier, String, String), - ClearWorkspaceRules(usize, usize), - ClearNamedWorkspaceRules(String), - ClearAllWorkspaceRules, - EnforceWorkspaceRules, - SessionFloatRule, - SessionFloatRules, - ClearSessionFloatRules, - #[serde(alias = "FloatRule")] - IgnoreRule(ApplicationIdentifier, String), - ManageRule(ApplicationIdentifier, String), - // IdentifyObjectNameChangeApplication(ApplicationIdentifier, String), - // IdentifyTrayApplication(ApplicationIdentifier, String), - // IdentifyLayeredApplication(ApplicationIdentifier, String), - // IdentifyBorderOverflowApplication(ApplicationIdentifier, String), - State, - GlobalState, - VisibleWindows, - MonitorInformation, - Query(StateQuery), - // FocusFollowsMouse(FocusFollowsMouseImplementation, bool), - // ToggleFocusFollowsMouse(FocusFollowsMouseImplementation), - MouseFollowsFocus(bool), - ToggleMouseFollowsFocus, - // RemoveTitleBar(ApplicationIdentifier, String), - // ToggleTitleBars, - AddSubscriberSocket(String), - AddSubscriberSocketWithOptions(String, SubscribeOptions), - RemoveSubscriberSocket(String), - // AddSubscriberPipe(String), - // RemoveSubscriberPipe(String), - ApplicationSpecificConfigurationSchema, - NotificationSchema, - SocketSchema, - StaticConfigSchema, - GenerateStaticConfig, - DebugWindow(i64), -} - -impl SocketMessage { - pub fn as_bytes(&self) -> eyre::Result> { - Ok(serde_json::to_string(self)?.as_bytes().to_vec()) - } -} - -impl FromStr for SocketMessage { - type Err = serde_json::Error; - - fn from_str(s: &str) -> Result { - serde_json::from_str(s) - } -} +pub use komorebi_protocol::message::SocketMessage; #[cfg(test)] mod tests { diff --git a/komorebi-for-mac/komorebi/src/process_command.rs b/komorebi-for-mac/komorebi/src/process_command.rs index 5d3605c9..6e8cb5db 100644 --- a/komorebi-for-mac/komorebi/src/process_command.rs +++ b/komorebi-for-mac/komorebi/src/process_command.rs @@ -1843,6 +1843,52 @@ impl WindowManager { ANIMATION_STYLE_PER_ANIMATION.lock().clear(); } }, + // Messages of other platforms: answered, and nothing else happens + SocketMessage::AddSubscriberPipe(..) + | SocketMessage::AltFocusHack(..) + | SocketMessage::ApplyState(..) + | SocketMessage::BorderImplementation(..) + | SocketMessage::BorderStyle(..) + | SocketMessage::ChangeLayoutCustom(..) + | SocketMessage::CompleteConfiguration + | SocketMessage::FocusFollowsMouse(..) + | SocketMessage::ForceFocus + | SocketMessage::HotkeysState + | SocketMessage::IdentifyBorderOverflowApplication(..) + | SocketMessage::IdentifyLayeredApplication(..) + | SocketMessage::IdentifyObjectNameChangeApplication(..) + | SocketMessage::IdentifyTrayApplication(..) + | SocketMessage::InvisibleBorders(..) + | SocketMessage::MonitorIndexPreference(..) + | SocketMessage::NamedWorkspaceLayoutCustom(..) + | SocketMessage::NamedWorkspaceLayoutCustomRule(..) + | SocketMessage::ReloadConfiguration + | SocketMessage::ReloadHotkeys + | SocketMessage::RemoveSubscriberPipe(..) + | SocketMessage::RemoveTitleBar(..) + | SocketMessage::StackbarBackgroundColour(..) + | SocketMessage::StackbarFocusedTextColour(..) + | SocketMessage::StackbarFontFamily(..) + | SocketMessage::StackbarFontSize(..) + | SocketMessage::StackbarHeight(..) + | SocketMessage::StackbarLabel(..) + | SocketMessage::StackbarMode(..) + | SocketMessage::StackbarTabWidth(..) + | SocketMessage::StackbarUnfocusedTextColour(..) + | SocketMessage::ToggleFocusFollowsMouse(..) + | SocketMessage::ToggleMaximize + | SocketMessage::ToggleTitleBars + | SocketMessage::ToggleTransparency + | SocketMessage::Transparency(..) + | SocketMessage::TransparencyAlpha(..) + | SocketMessage::WatchConfiguration(..) + | SocketMessage::WindowHidingBehaviour(..) + | SocketMessage::WorkspaceLayoutCustom(..) + | SocketMessage::WorkspaceLayoutCustomRule(..) + => { + reply.write_all(message.not_supported_reply().as_bytes())?; + return Ok(()); + } } self.update_known_window_ids();