From 221e4ea545c383e0094bf04a34b698c0c8be7a46 Mon Sep 17 00:00:00 2001 From: alex-ds13 <145657253+alex-ds13@users.noreply.github.com> Date: Thu, 10 Oct 2024 12:06:19 +0100 Subject: [PATCH] feat(cli): add commands for workspace new window behaviour and float_override This commit adds the commands to toggle the `window_container_behaviour` and `float_override` of the currently focused workspace. --- komorebi/src/core/mod.rs | 2 ++ komorebi/src/process_command.rs | 24 ++++++++++++++++++++++++ komorebic/src/main.rs | 14 ++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index 2b8fb68ea..7cbe78363 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -91,6 +91,8 @@ pub enum SocketMessage { CycleLayout(CycleDirection), ChangeLayoutCustom(PathBuf), FlipLayout(Axis), + ToggleWorkspaceWindowContainerBehaviour, + ToggleWorkspaceFloatOverride, // Monitor and Workspace Commands MonitorIndexPreference(usize, i32, i32, i32, i32), DisplayIndexPreference(usize, String), diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 21dbd83dd..ac0aa2425 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1358,6 +1358,30 @@ impl WindowManager { SocketMessage::ToggleFloatOverride => { self.window_management_behaviour.float_override = !self.window_management_behaviour.float_override; } + SocketMessage::ToggleWorkspaceWindowContainerBehaviour => { + let current_global_behaviour = self.window_management_behaviour.current_behaviour; + if let Some(behaviour) = self.focused_workspace_mut()?.window_container_behaviour_mut() { + match behaviour { + WindowContainerBehaviour::Create => *behaviour = WindowContainerBehaviour::Append, + WindowContainerBehaviour::Append => *behaviour = WindowContainerBehaviour::Create, + } + } else { + self.focused_workspace_mut()?.set_window_container_behaviour( + Some(match current_global_behaviour { + WindowContainerBehaviour::Create => WindowContainerBehaviour::Append, + WindowContainerBehaviour::Append => WindowContainerBehaviour::Create, + }) + ); + }; + } + SocketMessage::ToggleWorkspaceFloatOverride => { + let current_global_override = self.window_management_behaviour.float_override; + if let Some(float_override) = self.focused_workspace_mut()?.float_override_mut() { + *float_override = !*float_override; + } else { + self.focused_workspace_mut()?.set_float_override(Some(!current_global_override)); + }; + } SocketMessage::WindowHidingBehaviour(behaviour) => { let mut hiding_behaviour = HIDING_BEHAVIOUR.lock(); *hiding_behaviour = behaviour; diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index ca94b46f2..f805de6d2 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1169,6 +1169,14 @@ enum SubCommand { ToggleWindowContainerBehaviour, /// Enable or disable float override, which makes it so every new window opens in floating mode ToggleFloatOverride, + /// Toggle the behaviour for new windows (stacking or dynamic tiling) for currently focused + /// workspace. If there was no behaviour set for the workspace previously it takes the opposite + /// of the global value. + ToggleWorkspaceWindowContainerBehaviour, + /// Enable or disable float override, which makes it so every new window opens in floating + /// mode, for the currently focused workspace. If there was no override value set for the + /// workspace previously it takes the opposite of the global value. + ToggleWorkspaceFloatOverride, /// Toggle window tiling on the focused workspace TogglePause, /// Toggle window tiling on the focused workspace @@ -2475,6 +2483,12 @@ Stop-Process -Name:komorebi -ErrorAction SilentlyContinue SubCommand::ToggleFloatOverride => { send_message(&SocketMessage::ToggleFloatOverride)?; } + SubCommand::ToggleWorkspaceWindowContainerBehaviour => { + send_message(&SocketMessage::ToggleWorkspaceWindowContainerBehaviour)?; + } + SubCommand::ToggleWorkspaceFloatOverride => { + send_message(&SocketMessage::ToggleWorkspaceFloatOverride)?; + } SubCommand::WindowHidingBehaviour(arg) => { send_message(&SocketMessage::WindowHidingBehaviour(arg.hiding_behaviour))?; }