diff --git a/src/config/mod.rs b/src/config/mod.rs index 888e5291..4e38600d 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -851,6 +851,10 @@ pub enum Action { MoveToNextWorkspace, MoveToPreviousWorkspace, MoveToLastWorkspace, + SendToWorkspace(u8), + SendToNextWorkspace, + SendToPreviousWorkspace, + SendToLastWorkspace, NextOutput, PreviousOutput, diff --git a/src/input/mod.rs b/src/input/mod.rs index 20af5ac5..4a246d95 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -617,20 +617,23 @@ impl State { .saturating_sub(1); let _ = self.common.shell.activate(¤t_output, workspace); } - Action::MoveToWorkspace(key_num) => { + x @ Action::MoveToWorkspace(_) | x @ Action::SendToWorkspace(_) => { let current_output = seat.active_output(); - let workspace = match key_num { - 0 => 9, - x => x - 1, + let follow = matches!(x, Action::MoveToWorkspace(_)); + let workspace = match x { + Action::MoveToWorkspace(0) | Action::SendToWorkspace(0) => 9, + Action::MoveToWorkspace(x) | Action::SendToWorkspace(x) => x - 1, + _ => unreachable!(), }; Shell::move_current_window( self, seat, ¤t_output, (¤t_output, Some(workspace as usize)), + follow, ); } - Action::MoveToNextWorkspace => { + x @ Action::MoveToNextWorkspace | x @ Action::SendToNextWorkspace => { let current_output = seat.active_output(); let workspace = self .common @@ -644,9 +647,10 @@ impl State { seat, ¤t_output, (¤t_output, Some(workspace as usize)), + matches!(x, Action::MoveToNextWorkspace), ); } - Action::MoveToPreviousWorkspace => { + x @ Action::MoveToPreviousWorkspace | x @ Action::SendToPreviousWorkspace => { let current_output = seat.active_output(); let workspace = self .common @@ -660,9 +664,10 @@ impl State { seat, ¤t_output, (¤t_output, Some(workspace as usize)), + matches!(x, Action::MoveToPreviousWorkspace), ); } - Action::MoveToLastWorkspace => { + x @ Action::MoveToLastWorkspace | x @ Action::SendToLastWorkspace => { let current_output = seat.active_output(); let workspace = self .common @@ -675,6 +680,7 @@ impl State { seat, ¤t_output, (¤t_output, Some(workspace as usize)), + matches!(x, Action::MoveToLastWorkspace), ); } Action::NextOutput => { @@ -753,6 +759,7 @@ impl State { seat, ¤t_output, (&next_output, None), + true, ) { if let Some(ptr) = seat.get_pointer() { ptr.motion( @@ -786,6 +793,7 @@ impl State { seat, ¤t_output, (&prev_output, None), + true, ) { if let Some(ptr) = seat.get_pointer() { ptr.motion( diff --git a/src/shell/mod.rs b/src/shell/mod.rs index bbe2470e..f1d6835e 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -1120,6 +1120,7 @@ impl Shell { seat: &Seat, from_output: &Output, to: (&Output, Option), + follow: bool, ) -> Option> { let (to_output, to_idx) = to; let to_idx = to_idx.unwrap_or(state.common.shell.workspaces.active_num(to_output)); @@ -1157,9 +1158,12 @@ impl Shell { for mapped in elements.into_iter() { state.common.shell.update_reactive_popups(&mapped); } - - seat.set_active_output(&to_output); - let new_pos = state.common.shell.activate(to_output, to_idx); + let new_pos = if follow { + seat.set_active_output(&to_output); + state.common.shell.activate(to_output, to_idx) + } else { + None + }; let to_workspace = state .common @@ -1191,7 +1195,9 @@ impl Shell { state.common.shell.update_reactive_popups(&mapped); } - Common::set_focus(state, Some(&KeyboardFocusTarget::from(mapped)), &seat, None); + if follow { + Common::set_focus(state, Some(&KeyboardFocusTarget::from(mapped)), &seat, None); + } new_pos }