layout: Extract Monitor::into_workspaces()

This commit is contained in:
Ivan Molodetskikh
2025-09-26 12:35:35 +03:00
parent 36dc5c6e8e
commit 7fc544b9d6
2 changed files with 11 additions and 8 deletions

View File

@@ -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.

View File

@@ -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
}