From 75aab6e2829d63a905bfc366a136bdbace8ba05c Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Wed, 26 Mar 2025 12:08:46 -0700 Subject: [PATCH] shell/workspace: Clear output stack when moved user moves workspace If the user explicitly moves a workspace to an output, assume that is where the user wants it, so it shouldn't be moved back to a different output in the future. For persistent workspaces, the explicitly set workspace is the one that will be stored, instead of trying to track an unbounded list of outputs persistently. --- src/shell/mod.rs | 13 +++++++------ src/shell/workspace.rs | 11 +++++++++-- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/shell/mod.rs b/src/shell/mod.rs index 69099c69..d64182ca 100644 --- a/src/shell/mod.rs +++ b/src/shell/mod.rs @@ -518,14 +518,14 @@ impl WorkspaceSet { } } - fn set_output(&mut self, new_output: &Output) { + fn set_output(&mut self, new_output: &Output, explicit: bool) { self.sticky_layer.set_output(new_output); for window in self.sticky_layer.windows() { toplevel_leave_output(&window, &self.output); toplevel_enter_output(&window, &new_output); } for workspace in &mut self.workspaces { - workspace.set_output(new_output); + workspace.set_output(new_output, explicit); } self.output = new_output.clone(); } @@ -711,7 +711,7 @@ impl Workspaces { .backup_set .take() .map(|mut set| { - set.set_output(output); + set.set_output(output, false); set }) .unwrap_or_else(|| { @@ -738,7 +738,7 @@ impl Workspaces { } set.update_workspace_idxs(workspace_state); for (i, workspace) in set.workspaces.iter_mut().enumerate() { - workspace.set_output(output); + workspace.set_output(output, false); workspace.refresh(); if i == set.active { workspace_state.add_workspace_state(&workspace.handle, WState::Active); @@ -790,7 +790,7 @@ impl Workspaces { move_workspace_to_group(&mut workspace, &workspace_group, workspace_state); // update mapping - workspace.set_output(&new_output); + workspace.set_output(&new_output, false); workspace.refresh(); new_set.workspaces.push(workspace); @@ -840,6 +840,7 @@ impl Workspaces { } } + // Move workspace from one output to another, explicitly by the user fn migrate_workspace( &mut self, from: &Output, @@ -858,7 +859,7 @@ impl Workspaces { { let new_set = self.sets.get_mut(to).unwrap(); move_workspace_to_group(&mut workspace, &new_set.group, workspace_state); - workspace.set_output(to); + workspace.set_output(to, true); workspace.refresh(); new_set.workspaces.insert(new_set.active + 1, workspace); new_set.update_workspace_idxs(workspace_state); diff --git a/src/shell/workspace.rs b/src/shell/workspace.rs index bfbd672a..b6d09f99 100644 --- a/src/shell/workspace.rs +++ b/src/shell/workspace.rs @@ -85,7 +85,7 @@ pub struct Workspace { pub handle: WorkspaceHandle, pub focus_stack: FocusStacks, pub screencopy: ScreencopySessions, - pub output_stack: VecDeque, + output_stack: VecDeque, pub(super) backdrop_id: Id, pub dirty: AtomicBool, } @@ -361,7 +361,11 @@ impl Workspace { &self.output } - pub fn set_output(&mut self, output: &Output) { + // Set output the workspace is on + // + // If `explicit` is `true`, the user has explicitly moved the workspace + // to this output, so previous outputs it was on can be forgotten. + pub fn set_output(&mut self, output: &Output, explicit: bool) { self.tiling_layer.set_output(output); self.floating_layer.set_output(output); for mapped in self.mapped() { @@ -376,6 +380,9 @@ impl Workspace { toplevel_enter_output(&surface, output); } } + if explicit { + self.output_stack.clear(); + } let output_name = output.name(); if let Some(pos) = self .output_stack