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.
This commit is contained in:
Ian Douglas Scott 2025-03-26 12:08:46 -07:00 committed by Victoria Brekenfeld
parent e74eafce2c
commit 75aab6e282
2 changed files with 16 additions and 8 deletions

View file

@ -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);

View file

@ -85,7 +85,7 @@ pub struct Workspace {
pub handle: WorkspaceHandle,
pub focus_stack: FocusStacks,
pub screencopy: ScreencopySessions,
pub output_stack: VecDeque<String>,
output_stack: VecDeque<String>,
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