diff --git a/docs/cli/animation-style.md b/docs/cli/animation-style.md index e160298b..795cfcba 100644 --- a/docs/cli/animation-style.md +++ b/docs/cli/animation-style.md @@ -10,9 +10,9 @@ Options: Desired ease function for animation [default: linear] - [possible values: linear, ease-in-sine, ease-out-sine, ease-in-out-sine, ease-in-quad, ease-out-quad, ease-in-out-quad, ease-in-cubic, ease-in-out-cubic, ease-in-quart, - ease-out-quart, ease-in-out-quart, ease-in-quint, ease-out-quint, ease-in-out-quint, ease-in-expo, ease-out-expo, ease-in-out-expo, ease-in-circ, ease-out-circ, ease-in-out-circ, - ease-in-back, ease-out-back, ease-in-out-back, ease-in-elastic, ease-out-elastic, ease-in-out-elastic, ease-in-bounce, ease-out-bounce, ease-in-out-bounce] + [possible values: linear, ease-in-sine, ease-out-sine, ease-in-out-sine, ease-in-quad, ease-out-quad, ease-in-out-quad, ease-in-cubic, ease-in-out-cubic, ease-in-quart, ease-out-quart, + ease-in-out-quart, ease-in-quint, ease-out-quint, ease-in-out-quint, ease-in-expo, ease-out-expo, ease-in-out-expo, ease-in-circ, ease-out-circ, ease-in-out-circ, ease-in-back, ease-out-back, + ease-in-out-back, ease-in-elastic, ease-out-elastic, ease-in-out-elastic, ease-in-bounce, ease-out-bounce, ease-in-out-bounce] -a, --animation-type Animation type to apply the style to. If not specified, sets global style diff --git a/docs/cli/border-colour.md b/docs/cli/border-colour.md index 09a33ff4..55b84d34 100644 --- a/docs/cli/border-colour.md +++ b/docs/cli/border-colour.md @@ -18,7 +18,7 @@ Arguments: Options: -w, --window-kind [default: single] - [possible values: single, stack, monocle, unfocused, floating] + [possible values: single, stack, monocle, unfocused, unfocused-locked, floating] -h, --help Print help diff --git a/docs/cli/move-to-last-workspace.md b/docs/cli/move-to-last-workspace.md new file mode 100644 index 00000000..33e26777 --- /dev/null +++ b/docs/cli/move-to-last-workspace.md @@ -0,0 +1,12 @@ +# move-to-last-workspace + +``` +Move the focused window to the last focused monitor workspace + +Usage: komorebic.exe move-to-last-workspace + +Options: + -h, --help + Print help + +``` diff --git a/docs/cli/send-to-last-workspace.md b/docs/cli/send-to-last-workspace.md new file mode 100644 index 00000000..2ea1e443 --- /dev/null +++ b/docs/cli/send-to-last-workspace.md @@ -0,0 +1,12 @@ +# send-to-last-workspace + +``` +Send the focused window to the last focused monitor workspace + +Usage: komorebic.exe send-to-last-workspace + +Options: + -h, --help + Print help + +``` diff --git a/docs/cli/toggle-lock.md b/docs/cli/toggle-lock.md new file mode 100644 index 00000000..8ce9be8b --- /dev/null +++ b/docs/cli/toggle-lock.md @@ -0,0 +1,12 @@ +# toggle-lock + +``` +Toggle a lock for the focused container, ensuring it will not be displaced by any new windows + +Usage: komorebic.exe toggle-lock + +Options: + -h, --help + Print help + +``` diff --git a/docs/cli/toggle-workspace-float-override.md b/docs/cli/toggle-workspace-float-override.md index ba0641be..5bb8cf8f 100644 --- a/docs/cli/toggle-workspace-float-override.md +++ b/docs/cli/toggle-workspace-float-override.md @@ -1,8 +1,8 @@ # toggle-workspace-float-override ``` -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 +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 Usage: komorebic.exe toggle-workspace-float-override diff --git a/docs/cli/toggle-workspace-window-container-behaviour.md b/docs/cli/toggle-workspace-window-container-behaviour.md index f9725840..6653584e 100644 --- a/docs/cli/toggle-workspace-window-container-behaviour.md +++ b/docs/cli/toggle-workspace-window-container-behaviour.md @@ -1,8 +1,7 @@ # toggle-workspace-window-container-behaviour ``` -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 +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 Usage: komorebic.exe toggle-workspace-window-container-behaviour diff --git a/komorebi/src/core/mod.rs b/komorebi/src/core/mod.rs index d86e6435..9da94bcb 100644 --- a/komorebi/src/core/mod.rs +++ b/komorebi/src/core/mod.rs @@ -62,6 +62,8 @@ pub enum SocketMessage { UnstackAll, ResizeWindowEdge(OperationDirection, Sizing), ResizeWindowAxis(Axis, Sizing), + MoveContainerToLastWorkspace, + SendContainerToLastWorkspace, MoveContainerToMonitorNumber(usize), CycleMoveContainerToMonitor(CycleDirection), MoveContainerToWorkspaceNumber(usize), diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 868c7e68..ac872916 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -640,6 +640,67 @@ impl WindowManager { SocketMessage::AdjustWorkspacePadding(sizing, adjustment) => { self.adjust_workspace_padding(sizing, adjustment)?; } + SocketMessage::MoveContainerToLastWorkspace => { + // This is to ensure that even on an empty workspace on a secondary monitor, the + // secondary monitor where the cursor is focused will be used as the target for + // the workspace switch op + if let Some(monitor_idx) = self.monitor_idx_from_current_pos() { + if monitor_idx != self.focused_monitor_idx() { + if let Some(monitor) = self.monitors().get(monitor_idx) { + if let Some(workspace) = monitor.focused_workspace() { + if workspace.is_empty() { + self.focus_monitor(monitor_idx)?; + } + } + } + } + } + + let idx = self + .focused_monitor() + .ok_or_else(|| anyhow!("there is no monitor"))? + .focused_workspace_idx(); + + if let Some(monitor) = self.focused_monitor_mut() { + if let Some(last_focused_workspace) = monitor.last_focused_workspace() { + self.move_container_to_workspace(last_focused_workspace, true, None)?; + } + } + + self.focused_monitor_mut() + .ok_or_else(|| anyhow!("there is no monitor"))? + .set_last_focused_workspace(Option::from(idx)); + } + SocketMessage::SendContainerToLastWorkspace => { + // This is to ensure that even on an empty workspace on a secondary monitor, the + // secondary monitor where the cursor is focused will be used as the target for + // the workspace switch op + if let Some(monitor_idx) = self.monitor_idx_from_current_pos() { + if monitor_idx != self.focused_monitor_idx() { + if let Some(monitor) = self.monitors().get(monitor_idx) { + if let Some(workspace) = monitor.focused_workspace() { + if workspace.is_empty() { + self.focus_monitor(monitor_idx)?; + } + } + } + } + } + + let idx = self + .focused_monitor() + .ok_or_else(|| anyhow!("there is no monitor"))? + .focused_workspace_idx(); + + if let Some(monitor) = self.focused_monitor_mut() { + if let Some(last_focused_workspace) = monitor.last_focused_workspace() { + self.move_container_to_workspace(last_focused_workspace, false, None)?; + } + } + self.focused_monitor_mut() + .ok_or_else(|| anyhow!("there is no monitor"))? + .set_last_focused_workspace(Option::from(idx)); + } SocketMessage::MoveContainerToWorkspaceNumber(workspace_idx) => { self.move_container_to_workspace(workspace_idx, true, None)?; } diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 581703d2..772e272c 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1104,6 +1104,10 @@ enum SubCommand { /// Move the focused window to the specified monitor workspace #[clap(arg_required_else_help = true)] MoveToMonitorWorkspace(MoveToMonitorWorkspace), + /// Send the focused window to the last focused monitor workspace + SendToLastWorkspace, + /// Move the focused window to the last focused monitor workspace + MoveToLastWorkspace, /// Focus the specified monitor #[clap(arg_required_else_help = true)] FocusMonitor(FocusMonitor), @@ -1857,6 +1861,12 @@ fn main() -> Result<()> { arg.cycle_direction, ))?; } + SubCommand::MoveToLastWorkspace => { + send_message(&SocketMessage::MoveContainerToLastWorkspace)?; + } + SubCommand::SendToLastWorkspace => { + send_message(&SocketMessage::SendContainerToLastWorkspace)?; + } SubCommand::SwapWorkspacesWithMonitor(arg) => { send_message(&SocketMessage::SwapWorkspacesToMonitorNumber(arg.target))?; } diff --git a/mkdocs.yml b/mkdocs.yml index e87ad25a..8ebad2fe 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -133,6 +133,8 @@ nav: - cli/cycle-send-to-workspace.md - cli/send-to-monitor-workspace.md - cli/move-to-monitor-workspace.md + - cli/send-to-last-workspace.md + - cli/move-to-last-workspace.md - cli/focus-monitor.md - cli/focus-monitor-at-cursor.md - cli/focus-last-workspace.md @@ -191,6 +193,7 @@ nav: - cli/toggle-float.md - cli/toggle-monocle.md - cli/toggle-maximize.md + - cli/toggle-lock.md - cli/restore-windows.md - cli/manage.md - cli/unmanage.md