diff options
| -rw-r--r-- | src/layout/mod.rs | 30 | ||||
| -rw-r--r-- | src/layout/monitor.rs | 12 | ||||
| -rw-r--r-- | wiki/Configuration:-Named-Workspaces.md | 4 |
3 files changed, 43 insertions, 3 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 17c97592..264bb298 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -6074,6 +6074,36 @@ mod tests { } #[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 = [ Op::AddOutput(1), diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index 3eaac97f..310121b5 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -259,7 +259,9 @@ impl<W: LayoutElement> Monitor<W> { workspace.add_column(column, activate); // After adding a new window, workspace becomes this output's own. - workspace.original_output = OutputId::new(&self.output); + if workspace.name().is_none() { + workspace.original_output = OutputId::new(&self.output); + } if workspace_idx == self.workspaces.len() - 1 { self.add_workspace_bottom(); @@ -311,7 +313,9 @@ impl<W: LayoutElement> Monitor<W> { workspace.add_tile(tile, target, activate, width, is_full_width, is_floating); // After adding a new window, workspace becomes this output's own. - workspace.original_output = OutputId::new(&self.output); + if workspace.name().is_none() { + workspace.original_output = OutputId::new(&self.output); + } if workspace_idx == self.workspaces.len() - 1 { // Insert a new empty workspace. @@ -341,7 +345,9 @@ impl<W: LayoutElement> Monitor<W> { workspace.add_tile_to_column(column_idx, tile_idx, tile, activate); // After adding a new window, workspace becomes this output's own. - workspace.original_output = OutputId::new(&self.output); + if workspace.name().is_none() { + workspace.original_output = OutputId::new(&self.output); + } // Since we're adding window to an existing column, the workspace isn't empty, and // therefore cannot be the last one, so we never need to insert a new empty workspace. diff --git a/wiki/Configuration:-Named-Workspaces.md b/wiki/Configuration:-Named-Workspaces.md index 3948f656..01f5cea2 100644 --- a/wiki/Configuration:-Named-Workspaces.md +++ b/wiki/Configuration:-Named-Workspaces.md @@ -41,3 +41,7 @@ There's no way to give a name to an already existing workspace, but you can simp Before, it could only use the connector name. <sup>Since: 25.01</sup> You can use `set-workspace-name` and `unset-workspace-name` actions to change workspace names dynamically. + +<sup>Since: next release</sup> Named workspaces no longer update/forget their original output when opening a new window on them (unnamed workspaces will keep doing that). +This means that named workspaces "stick" to their original output in more cases, reflecting their more permanent nature. +Explicitly moving a named workspace to a different monitor will still update its original output. |
