mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-07-05 12:41:47 +02: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,
|
UnstackWindow,
|
||||||
CycleStack(CycleDirection),
|
CycleStack(CycleDirection),
|
||||||
MoveContainerToMonitorNumber(usize),
|
MoveContainerToMonitorNumber(usize),
|
||||||
|
CycleMoveContainerToMonitor(CycleDirection),
|
||||||
MoveContainerToWorkspaceNumber(usize),
|
MoveContainerToWorkspaceNumber(usize),
|
||||||
MoveContainerToNamedWorkspace(String),
|
MoveContainerToNamedWorkspace(String),
|
||||||
CycleMoveContainerToWorkspace(CycleDirection),
|
CycleMoveContainerToWorkspace(CycleDirection),
|
||||||
SendContainerToMonitorNumber(usize),
|
SendContainerToMonitorNumber(usize),
|
||||||
|
CycleSendContainerToMonitor(CycleDirection),
|
||||||
SendContainerToWorkspaceNumber(usize),
|
SendContainerToWorkspaceNumber(usize),
|
||||||
CycleSendContainerToWorkspace(CycleDirection),
|
CycleSendContainerToWorkspace(CycleDirection),
|
||||||
SendContainerToMonitorWorkspaceNumber(usize, usize),
|
SendContainerToMonitorWorkspaceNumber(usize, usize),
|
||||||
|
|||||||
@@ -321,6 +321,15 @@ impl WindowManager {
|
|||||||
SocketMessage::MoveContainerToMonitorNumber(monitor_idx) => {
|
SocketMessage::MoveContainerToMonitorNumber(monitor_idx) => {
|
||||||
self.move_container_to_monitor(monitor_idx, None, true)?;
|
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) => {
|
SocketMessage::SendContainerToWorkspaceNumber(workspace_idx) => {
|
||||||
self.move_container_to_workspace(workspace_idx, false)?;
|
self.move_container_to_workspace(workspace_idx, false)?;
|
||||||
}
|
}
|
||||||
@@ -343,6 +352,15 @@ impl WindowManager {
|
|||||||
SocketMessage::SendContainerToMonitorNumber(monitor_idx) => {
|
SocketMessage::SendContainerToMonitorNumber(monitor_idx) => {
|
||||||
self.move_container_to_monitor(monitor_idx, None, false)?;
|
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) => {
|
SocketMessage::SendContainerToMonitorWorkspaceNumber(monitor_idx, workspace_idx) => {
|
||||||
self.move_container_to_monitor(monitor_idx, Option::from(workspace_idx), false)?;
|
self.move_container_to_monitor(monitor_idx, Option::from(workspace_idx), false)?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -113,6 +113,8 @@ gen_enum_subcommand_args! {
|
|||||||
CycleMove: CycleDirection,
|
CycleMove: CycleDirection,
|
||||||
CycleMoveToWorkspace: CycleDirection,
|
CycleMoveToWorkspace: CycleDirection,
|
||||||
CycleSendToWorkspace: CycleDirection,
|
CycleSendToWorkspace: CycleDirection,
|
||||||
|
CycleSendToMonitor: CycleDirection,
|
||||||
|
CycleMoveToMonitor: CycleDirection,
|
||||||
CycleMonitor: CycleDirection,
|
CycleMonitor: CycleDirection,
|
||||||
CycleWorkspace: CycleDirection,
|
CycleWorkspace: CycleDirection,
|
||||||
Stack: OperationDirection,
|
Stack: OperationDirection,
|
||||||
@@ -722,6 +724,9 @@ enum SubCommand {
|
|||||||
/// Move the focused window to the specified monitor
|
/// Move the focused window to the specified monitor
|
||||||
#[clap(arg_required_else_help = true)]
|
#[clap(arg_required_else_help = true)]
|
||||||
MoveToMonitor(MoveToMonitor),
|
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
|
/// Move the focused window to the specified workspace
|
||||||
#[clap(arg_required_else_help = true)]
|
#[clap(arg_required_else_help = true)]
|
||||||
MoveToWorkspace(MoveToWorkspace),
|
MoveToWorkspace(MoveToWorkspace),
|
||||||
@@ -734,6 +739,9 @@ enum SubCommand {
|
|||||||
/// Send the focused window to the specified monitor
|
/// Send the focused window to the specified monitor
|
||||||
#[clap(arg_required_else_help = true)]
|
#[clap(arg_required_else_help = true)]
|
||||||
SendToMonitor(SendToMonitor),
|
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
|
/// Send the focused window to the specified workspace
|
||||||
#[clap(arg_required_else_help = true)]
|
#[clap(arg_required_else_help = true)]
|
||||||
SendToWorkspace(SendToWorkspace),
|
SendToWorkspace(SendToWorkspace),
|
||||||
@@ -1054,6 +1062,11 @@ fn main() -> Result<()> {
|
|||||||
SubCommand::MoveToMonitor(arg) => {
|
SubCommand::MoveToMonitor(arg) => {
|
||||||
send_message(&SocketMessage::MoveContainerToMonitorNumber(arg.target).as_bytes()?)?;
|
send_message(&SocketMessage::MoveContainerToMonitorNumber(arg.target).as_bytes()?)?;
|
||||||
}
|
}
|
||||||
|
SubCommand::CycleMoveToMonitor(arg) => {
|
||||||
|
send_message(
|
||||||
|
&SocketMessage::CycleMoveContainerToMonitor(arg.cycle_direction).as_bytes()?,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
SubCommand::MoveToWorkspace(arg) => {
|
SubCommand::MoveToWorkspace(arg) => {
|
||||||
send_message(&SocketMessage::MoveContainerToWorkspaceNumber(arg.target).as_bytes()?)?;
|
send_message(&SocketMessage::MoveContainerToWorkspaceNumber(arg.target).as_bytes()?)?;
|
||||||
}
|
}
|
||||||
@@ -1068,6 +1081,11 @@ fn main() -> Result<()> {
|
|||||||
SubCommand::SendToMonitor(arg) => {
|
SubCommand::SendToMonitor(arg) => {
|
||||||
send_message(&SocketMessage::SendContainerToMonitorNumber(arg.target).as_bytes()?)?;
|
send_message(&SocketMessage::SendContainerToMonitorNumber(arg.target).as_bytes()?)?;
|
||||||
}
|
}
|
||||||
|
SubCommand::CycleSendToMonitor(arg) => {
|
||||||
|
send_message(
|
||||||
|
&SocketMessage::CycleSendContainerToMonitor(arg.cycle_direction).as_bytes()?,
|
||||||
|
)?;
|
||||||
|
}
|
||||||
SubCommand::SendToWorkspace(arg) => {
|
SubCommand::SendToWorkspace(arg) => {
|
||||||
send_message(&SocketMessage::SendContainerToWorkspaceNumber(arg.target).as_bytes()?)?;
|
send_message(&SocketMessage::SendContainerToWorkspaceNumber(arg.target).as_bytes()?)?;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user