From 855bb4980409247dd684818d111894e3c8db0c62 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sun, 12 May 2024 12:32:34 -0700 Subject: [PATCH] feat(wm): add noop cross-monitor-move-behaviour This commit adds a new "NoOp" MoveBehaviour for users who don't want any moves to happen across monitor boundaries. The toggle-cross-monitor-move-behaviour will only toggle between Swap and Insert, and will do nothing if NoOp is the selected MoveBehaviour. resolve #667 --- komorebi-core/src/lib.rs | 2 ++ komorebi/src/process_command.rs | 1 + komorebi/src/window_manager.rs | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/komorebi-core/src/lib.rs b/komorebi-core/src/lib.rs index 743d714e..38e6203b 100644 --- a/komorebi-core/src/lib.rs +++ b/komorebi-core/src/lib.rs @@ -283,6 +283,8 @@ pub enum MoveBehaviour { Swap, /// Insert the window container into the focused workspace on the adjacent monitor Insert, + /// Do nothing if trying to move a window container in the direction of an adjacent monitor + NoOp, } #[derive( diff --git a/komorebi/src/process_command.rs b/komorebi/src/process_command.rs index 57d54600..f1b1bdcc 100644 --- a/komorebi/src/process_command.rs +++ b/komorebi/src/process_command.rs @@ -1187,6 +1187,7 @@ impl WindowManager { MoveBehaviour::Insert => { self.cross_monitor_move_behaviour = MoveBehaviour::Swap; } + _ => {} } } SocketMessage::CrossMonitorMoveBehaviour(behaviour) => { diff --git a/komorebi/src/window_manager.rs b/komorebi/src/window_manager.rs index c5540153..c45293bf 100644 --- a/komorebi/src/window_manager.rs +++ b/komorebi/src/window_manager.rs @@ -1333,6 +1333,11 @@ impl WindowManager { // If there is nowhere to move on the current workspace, try to move it onto the monitor // in that direction if there is one None => { + // Don't do anything if the user has set the MoveBehaviour to NoOp + if matches!(self.cross_monitor_move_behaviour, MoveBehaviour::NoOp) { + return Ok(()); + } + let target_monitor_idx = self .monitor_idx_in_direction(direction) .ok_or_else(|| anyhow!("there is no container or monitor in this direction"))?;