From dfd0d604aa78b9a32267c0ad1e3a29390c44c639 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 20 Apr 2024 14:58:55 -0700 Subject: [PATCH] feat(cli): add move-to-monitor-workspace command This commit adds a move-to-monitor-workspace command, which, following the existing convention, does the same action as send-to-monitor-workspace, but sets the focused monitor, workspace and container to the window container once it is inserted into the target monitor and workspace indices. --- komorebi-core/src/lib.rs | 1 + komorebi/src/process_command.rs | 5 +++++ komorebic/src/main.rs | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/komorebi-core/src/lib.rs b/komorebi-core/src/lib.rs index 5081f732..51315e3f 100644 --- a/komorebi-core/src/lib.rs +++ b/komorebi-core/src/lib.rs @@ -57,6 +57,7 @@ pub enum SocketMessage { SendContainerToWorkspaceNumber(usize), CycleSendContainerToWorkspace(CycleDirection), SendContainerToMonitorWorkspaceNumber(usize, usize), + MoveContainerToMonitorWorkspaceNumber(usize, usize), SendContainerToNamedWorkspace(String), MoveWorkspaceToMonitorNumber(usize), SwapWorkspacesToMonitorNumber(usize), diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 2e6f7d37..9ec5fdf2 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -465,6 +465,9 @@ impl WindowManager { SocketMessage::SendContainerToMonitorWorkspaceNumber(monitor_idx, workspace_idx) => { self.move_container_to_monitor(monitor_idx, Option::from(workspace_idx), false)?; } + SocketMessage::MoveContainerToMonitorWorkspaceNumber(monitor_idx, workspace_idx) => { + self.move_container_to_monitor(monitor_idx, Option::from(workspace_idx), true)?; + } SocketMessage::SendContainerToNamedWorkspace(ref workspace) => { if let Some((monitor_idx, workspace_idx)) = self.monitor_workspace_index_by_name(workspace) @@ -1411,6 +1414,8 @@ impl WindowManager { | SocketMessage::MoveWorkspaceToMonitorNumber(_) | SocketMessage::MoveContainerToMonitorNumber(_) | SocketMessage::MoveContainerToWorkspaceNumber(_) + | SocketMessage::MoveContainerToMonitorWorkspaceNumber(_, _) + | SocketMessage::MoveContainerToNamedWorkspace(_) | SocketMessage::ResizeWindowEdge(_, _) | SocketMessage::ResizeWindowAxis(_, _) | SocketMessage::ToggleFloat diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 95abb834..660d2f85 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -478,6 +478,14 @@ pub struct SendToMonitorWorkspace { target_workspace: usize, } +#[derive(Parser, AhkFunction)] +pub struct MoveToMonitorWorkspace { + /// Target monitor index (zero-indexed) + target_monitor: usize, + /// Workspace index on the target monitor (zero-indexed) + target_workspace: usize, +} + macro_rules! gen_focused_workspace_padding_subcommand_args { // SubCommand Pattern ( $( $name:ident ),+ $(,)? ) => { @@ -918,6 +926,9 @@ enum SubCommand { /// Send the focused window to the specified monitor workspace #[clap(arg_required_else_help = true)] SendToMonitorWorkspace(SendToMonitorWorkspace), + /// Move the focused window to the specified monitor workspace + #[clap(arg_required_else_help = true)] + MoveToMonitorWorkspace(MoveToMonitorWorkspace), /// Focus the specified monitor #[clap(arg_required_else_help = true)] FocusMonitor(FocusMonitor), @@ -1550,6 +1561,15 @@ fn main() -> Result<()> { .as_bytes()?, )?; } + SubCommand::MoveToMonitorWorkspace(arg) => { + send_message( + &SocketMessage::MoveContainerToMonitorWorkspaceNumber( + arg.target_monitor, + arg.target_workspace, + ) + .as_bytes()?, + )?; + } SubCommand::MoveWorkspaceToMonitor(arg) => { send_message(&SocketMessage::MoveWorkspaceToMonitorNumber(arg.target).as_bytes()?)?; }