diff --git a/src/input/actions.rs b/src/input/actions.rs index 218dded9..7a693dd5 100644 --- a/src/input/actions.rs +++ b/src/input/actions.rs @@ -669,8 +669,41 @@ impl State { }; if let Some(next_output) = next_output { - self.common - .migrate_workspace(&active_output, &next_output, &active); + let mut shell = self.common.shell.write(); + let mut workspace_state = self.common.workspace_state.update(); + shell.workspaces.migrate_workspace( + &active_output, + &next_output, + &active, + &mut workspace_state, + ); + // Activate workspace on new set, and set that output as active + if let Some(new_idx) = shell + .workspaces + .sets + .get(&next_output) + .and_then(|set| set.workspaces.iter().position(|w| w.handle == active)) + { + let res = shell.activate( + &next_output, + new_idx, + WorkspaceDelta::new_shortcut(), + &mut workspace_state, + ); + drop(workspace_state); + drop(shell); + if res.is_ok() { + self.handle_shortcut_action( + Action::SwitchOutput(direction), + seat, + serial, + time, + pattern, + Some(direction), + true, + ) + } + } } } diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 227dfec0..6ddd844f 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -878,14 +878,14 @@ impl Workspaces { } // Move workspace from one output to another, explicitly by the user - fn migrate_workspace( + pub fn migrate_workspace( &mut self, from: &Output, to: &Output, handle: &WorkspaceHandle, workspace_state: &mut WorkspaceUpdateGuard<'_, State>, ) { - if !self.sets.contains_key(to) { + if !self.sets.contains_key(to) || from == to { return; } @@ -1354,19 +1354,6 @@ impl Common { self.refresh(); // cleans up excess of workspaces and empty workspaces } - pub fn migrate_workspace(&mut self, from: &Output, to: &Output, handle: &WorkspaceHandle) { - if from == to { - return; - } - - let mut shell = self.shell.write(); - shell - .workspaces - .migrate_workspace(from, to, handle, &mut self.workspace_state.update()); - - std::mem::drop(shell); - } - pub fn update_config(&mut self) { let mut shell = self.shell.write(); let shell_ref = &mut *shell;