layout: Do not update original output for named workspaces upon adding windows

The way named workspaces are generally used makes them more "attached" to their
original output.

For example, you have a two-monitor setup with named workspaces on both. When
you disconnect the monitor to go somewhere and work for a while, then return,
you probably want your named workspaces to return to where they were on your
second monitor.

This is in contrast to unnamed workspaces which are more transient and should
more easily follow you wherever you're working.
This commit is contained in:
Ivan Molodetskikh
2025-01-29 13:45:29 +03:00
parent 1c749f578c
commit 1d3820a064
3 changed files with 43 additions and 3 deletions
+30
View File
@@ -6073,6 +6073,36 @@ mod tests {
check_ops(&ops);
}
#[test]
fn named_workspaces_dont_update_original_output_on_adding_window() {
let ops = [
Op::AddOutput(1),
Op::SetWorkspaceName {
new_ws_name: 1,
ws_name: None,
},
Op::AddOutput(2),
Op::RemoveOutput(1),
Op::FocusWorkspaceUp,
// Adding a window updates the original output for unnamed workspaces.
Op::AddWindow {
params: TestWindowParams::new(1),
},
// Connecting the previous output should move the named workspace back since its
// original output wasn't updated.
Op::AddOutput(1),
];
let layout = check_ops(&ops);
let (mon, _, ws) = layout
.workspaces()
.find(|(_, _, ws)| ws.name().is_some())
.unwrap();
assert!(ws.name().is_some()); // Sanity check.
let mon = mon.unwrap();
assert_eq!(mon.output_name(), "output1");
}
#[test]
fn workspaces_update_original_output_on_moving_to_same_output() {
let ops = [