diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2025-09-26 12:35:35 +0300 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2025-10-02 09:33:08 +0300 |
| commit | 7fc544b9d67229008bd4b6f85f110a7a9361aa08 (patch) | |
| tree | c6d558bed435be6eafee6d8f232693bd141beba7 /src/layout | |
| parent | 36dc5c6e8e82028d7a1a2cbf6bf411c1a030eea2 (diff) | |
| download | niri-7fc544b9d67229008bd4b6f85f110a7a9361aa08.tar.gz niri-7fc544b9d67229008bd4b6f85f110a7a9361aa08.tar.bz2 niri-7fc544b9d67229008bd4b6f85f110a7a9361aa08.zip | |
layout: Extract Monitor::into_workspaces()
Diffstat (limited to 'src/layout')
| -rw-r--r-- | src/layout/mod.rs | 9 | ||||
| -rw-r--r-- | src/layout/monitor.rs | 10 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/layout/mod.rs b/src/layout/mod.rs index 597d036d..e771a450 100644 --- a/src/layout/mod.rs +++ b/src/layout/mod.rs @@ -814,14 +814,7 @@ impl<W: LayoutElement> Layout<W> { monitor.workspaces[monitor.active_workspace_idx].id(), ); - let mut workspaces = monitor.workspaces; - - for ws in &mut workspaces { - ws.set_output(None); - } - - // Get rid of empty workspaces. - workspaces.retain(|ws| ws.has_windows_or_name()); + let mut workspaces = monitor.into_workspaces(); if monitors.is_empty() { // Removed the last monitor. diff --git a/src/layout/monitor.rs b/src/layout/monitor.rs index 45118a22..6433688a 100644 --- a/src/layout/monitor.rs +++ b/src/layout/monitor.rs @@ -303,6 +303,16 @@ impl<W: LayoutElement> Monitor<W> { } } + pub fn into_workspaces(mut self) -> Vec<Workspace<W>> { + self.workspaces.retain(|ws| ws.has_windows_or_name()); + + for ws in &mut self.workspaces { + ws.set_output(None); + } + + self.workspaces + } + pub fn output(&self) -> &Output { &self.output } |
