Skip to content

Commit 75aab6e

Browse files
ids1024Drakulix
authored andcommitted
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.
1 parent e74eafc commit 75aab6e

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/shell/mod.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,14 +518,14 @@ impl WorkspaceSet {
518518
}
519519
}
520520

521-
fn set_output(&mut self, new_output: &Output) {
521+
fn set_output(&mut self, new_output: &Output, explicit: bool) {
522522
self.sticky_layer.set_output(new_output);
523523
for window in self.sticky_layer.windows() {
524524
toplevel_leave_output(&window, &self.output);
525525
toplevel_enter_output(&window, &new_output);
526526
}
527527
for workspace in &mut self.workspaces {
528-
workspace.set_output(new_output);
528+
workspace.set_output(new_output, explicit);
529529
}
530530
self.output = new_output.clone();
531531
}
@@ -711,7 +711,7 @@ impl Workspaces {
711711
.backup_set
712712
.take()
713713
.map(|mut set| {
714-
set.set_output(output);
714+
set.set_output(output, false);
715715
set
716716
})
717717
.unwrap_or_else(|| {
@@ -738,7 +738,7 @@ impl Workspaces {
738738
}
739739
set.update_workspace_idxs(workspace_state);
740740
for (i, workspace) in set.workspaces.iter_mut().enumerate() {
741-
workspace.set_output(output);
741+
workspace.set_output(output, false);
742742
workspace.refresh();
743743
if i == set.active {
744744
workspace_state.add_workspace_state(&workspace.handle, WState::Active);
@@ -790,7 +790,7 @@ impl Workspaces {
790790
move_workspace_to_group(&mut workspace, &workspace_group, workspace_state);
791791

792792
// update mapping
793-
workspace.set_output(&new_output);
793+
workspace.set_output(&new_output, false);
794794
workspace.refresh();
795795
new_set.workspaces.push(workspace);
796796

@@ -840,6 +840,7 @@ impl Workspaces {
840840
}
841841
}
842842

843+
// Move workspace from one output to another, explicitly by the user
843844
fn migrate_workspace(
844845
&mut self,
845846
from: &Output,
@@ -858,7 +859,7 @@ impl Workspaces {
858859
{
859860
let new_set = self.sets.get_mut(to).unwrap();
860861
move_workspace_to_group(&mut workspace, &new_set.group, workspace_state);
861-
workspace.set_output(to);
862+
workspace.set_output(to, true);
862863
workspace.refresh();
863864
new_set.workspaces.insert(new_set.active + 1, workspace);
864865
new_set.update_workspace_idxs(workspace_state);

src/shell/workspace.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub struct Workspace {
8585
pub handle: WorkspaceHandle,
8686
pub focus_stack: FocusStacks,
8787
pub screencopy: ScreencopySessions,
88-
pub output_stack: VecDeque<String>,
88+
output_stack: VecDeque<String>,
8989
pub(super) backdrop_id: Id,
9090
pub dirty: AtomicBool,
9191
}
@@ -361,7 +361,11 @@ impl Workspace {
361361
&self.output
362362
}
363363

364-
pub fn set_output(&mut self, output: &Output) {
364+
// Set output the workspace is on
365+
//
366+
// If `explicit` is `true`, the user has explicitly moved the workspace
367+
// to this output, so previous outputs it was on can be forgotten.
368+
pub fn set_output(&mut self, output: &Output, explicit: bool) {
365369
self.tiling_layer.set_output(output);
366370
self.floating_layer.set_output(output);
367371
for mapped in self.mapped() {
@@ -376,6 +380,9 @@ impl Workspace {
376380
toplevel_enter_output(&surface, output);
377381
}
378382
}
383+
if explicit {
384+
self.output_stack.clear();
385+
}
379386
let output_name = output.name();
380387
if let Some(pos) = self
381388
.output_stack

0 commit comments

Comments
 (0)