mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-03-19 07:54:04 +01:00
feat(wm): add cycle move/send to monitor cmds
This commit introduces cyclical commands for moving (with focus) or sending (without focus) windows between adjacent monitors. resolve #363
This commit is contained in:
@@ -46,10 +46,12 @@ pub enum SocketMessage {
|
||||
UnstackWindow,
|
||||
CycleStack(CycleDirection),
|
||||
MoveContainerToMonitorNumber(usize),
|
||||
CycleMoveContainerToMonitor(CycleDirection),
|
||||
MoveContainerToWorkspaceNumber(usize),
|
||||
MoveContainerToNamedWorkspace(String),
|
||||
CycleMoveContainerToWorkspace(CycleDirection),
|
||||
SendContainerToMonitorNumber(usize),
|
||||
CycleSendContainerToMonitor(CycleDirection),
|
||||
SendContainerToWorkspaceNumber(usize),
|
||||
CycleSendContainerToWorkspace(CycleDirection),
|
||||
SendContainerToMonitorWorkspaceNumber(usize, usize),
|
||||
|
||||
@@ -321,6 +321,15 @@ impl WindowManager {
|
||||
SocketMessage::MoveContainerToMonitorNumber(monitor_idx) => {
|
||||
self.move_container_to_monitor(monitor_idx, None, true)?;
|
||||
}
|
||||
SocketMessage::CycleMoveContainerToMonitor(direction) => {
|
||||
let monitor_idx = direction.next_idx(
|
||||
self.focused_monitor_idx(),
|
||||
NonZeroUsize::new(self.monitors().len())
|
||||
.ok_or_else(|| anyhow!("there must be at least one monitor"))?,
|
||||
);
|
||||
|
||||
self.move_container_to_monitor(monitor_idx, None, true)?;
|
||||
}
|
||||
SocketMessage::SendContainerToWorkspaceNumber(workspace_idx) => {
|
||||
self.move_container_to_workspace(workspace_idx, false)?;
|
||||
}
|
||||
@@ -343,6 +352,15 @@ impl WindowManager {
|
||||
SocketMessage::SendContainerToMonitorNumber(monitor_idx) => {
|
||||
self.move_container_to_monitor(monitor_idx, None, false)?;
|
||||
}
|
||||
SocketMessage::CycleSendContainerToMonitor(direction) => {
|
||||
let monitor_idx = direction.next_idx(
|
||||
self.focused_monitor_idx(),
|
||||
NonZeroUsize::new(self.monitors().len())
|
||||
.ok_or_else(|| anyhow!("there must be at least one monitor"))?,
|
||||
);
|
||||
|
||||
self.move_container_to_monitor(monitor_idx, None, false)?;
|
||||
}
|
||||
SocketMessage::SendContainerToMonitorWorkspaceNumber(monitor_idx, workspace_idx) => {
|
||||
self.move_container_to_monitor(monitor_idx, Option::from(workspace_idx), false)?;
|
||||
}
|
||||
|
||||
@@ -113,6 +113,8 @@ gen_enum_subcommand_args! {
|
||||
CycleMove: CycleDirection,
|
||||
CycleMoveToWorkspace: CycleDirection,
|
||||
CycleSendToWorkspace: CycleDirection,
|
||||
CycleSendToMonitor: CycleDirection,
|
||||
CycleMoveToMonitor: CycleDirection,
|
||||
CycleMonitor: CycleDirection,
|
||||
CycleWorkspace: CycleDirection,
|
||||
Stack: OperationDirection,
|
||||
@@ -722,6 +724,9 @@ enum SubCommand {
|
||||
/// Move the focused window to the specified monitor
|
||||
#[clap(arg_required_else_help = true)]
|
||||
MoveToMonitor(MoveToMonitor),
|
||||
/// Move the focused window to the monitor in the given cycle direction
|
||||
#[clap(arg_required_else_help = true)]
|
||||
CycleMoveToMonitor(CycleMoveToMonitor),
|
||||
/// Move the focused window to the specified workspace
|
||||
#[clap(arg_required_else_help = true)]
|
||||
MoveToWorkspace(MoveToWorkspace),
|
||||
@@ -734,6 +739,9 @@ enum SubCommand {
|
||||
/// Send the focused window to the specified monitor
|
||||
#[clap(arg_required_else_help = true)]
|
||||
SendToMonitor(SendToMonitor),
|
||||
/// Send the focused window to the monitor in the given cycle direction
|
||||
#[clap(arg_required_else_help = true)]
|
||||
CycleSendToMonitor(CycleSendToMonitor),
|
||||
/// Send the focused window to the specified workspace
|
||||
#[clap(arg_required_else_help = true)]
|
||||
SendToWorkspace(SendToWorkspace),
|
||||
@@ -1054,6 +1062,11 @@ fn main() -> Result<()> {
|
||||
SubCommand::MoveToMonitor(arg) => {
|
||||
send_message(&SocketMessage::MoveContainerToMonitorNumber(arg.target).as_bytes()?)?;
|
||||
}
|
||||
SubCommand::CycleMoveToMonitor(arg) => {
|
||||
send_message(
|
||||
&SocketMessage::CycleMoveContainerToMonitor(arg.cycle_direction).as_bytes()?,
|
||||
)?;
|
||||
}
|
||||
SubCommand::MoveToWorkspace(arg) => {
|
||||
send_message(&SocketMessage::MoveContainerToWorkspaceNumber(arg.target).as_bytes()?)?;
|
||||
}
|
||||
@@ -1068,6 +1081,11 @@ fn main() -> Result<()> {
|
||||
SubCommand::SendToMonitor(arg) => {
|
||||
send_message(&SocketMessage::SendContainerToMonitorNumber(arg.target).as_bytes()?)?;
|
||||
}
|
||||
SubCommand::CycleSendToMonitor(arg) => {
|
||||
send_message(
|
||||
&SocketMessage::CycleSendContainerToMonitor(arg.cycle_direction).as_bytes()?,
|
||||
)?;
|
||||
}
|
||||
SubCommand::SendToWorkspace(arg) => {
|
||||
send_message(&SocketMessage::SendContainerToWorkspaceNumber(arg.target).as_bytes()?)?;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user