Consolidate workspace slide cleanup
This commit is contained in:
1 parent
74634b8cd0
commit
362bf79012
1 file changed
+47
-48
+47
-48
@@ -1536,21 +1536,46 @@ impl Ferese {
|
|||||||
self.relayout();
|
self.relayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn relayout(&mut self) {
|
fn visible_workspace_ids(&self) -> HashSet<WorkspaceId> {
|
||||||
let mut protected = self
|
let mut visible = self
|
||||||
.output_workspaces
|
.output_workspaces
|
||||||
.connected_outputs()
|
.connected_outputs()
|
||||||
.filter_map(|output| self.output_workspaces.active_workspace(output))
|
.filter_map(|output| self.output_workspaces.active_workspace(output))
|
||||||
.collect::<HashSet<_>>();
|
.collect::<HashSet<_>>();
|
||||||
protected.extend(
|
visible.extend(
|
||||||
self.workspace_slides
|
self.workspace_slides
|
||||||
.values()
|
.values()
|
||||||
.flat_map(|slide| slide.items.iter().map(|item| item.workspace)),
|
.flat_map(|slide| slide.items.iter().map(|item| item.workspace)),
|
||||||
);
|
);
|
||||||
for workspace in self.workspaces.prune_empty(&protected) {
|
visible
|
||||||
|
}
|
||||||
|
|
||||||
|
fn prune_empty_workspaces(&mut self, visible: &HashSet<WorkspaceId>) {
|
||||||
|
for workspace in self.workspaces.prune_empty(visible) {
|
||||||
self.output_workspaces.forget_workspace(workspace);
|
self.output_workspaces.forget_workspace(workspace);
|
||||||
self.viewport_animations.remove(&workspace);
|
self.viewport_animations.remove(&workspace);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn unmap_invisible_windows(&mut self, visible: &HashSet<WindowId>) -> bool {
|
||||||
|
let mut changed = false;
|
||||||
|
for (window, id) in &self.window_ids {
|
||||||
|
if visible.contains(id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
let was_mapped = self.space.element_location(window).is_some();
|
||||||
|
changed |= was_mapped;
|
||||||
|
if was_mapped && let Some(geometry) = self.window_geometry.get_mut(id) {
|
||||||
|
geometry.settle_presentation();
|
||||||
|
}
|
||||||
|
self.space.unmap_elem(window);
|
||||||
|
}
|
||||||
|
changed
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn relayout(&mut self) {
|
||||||
|
let visible_workspaces = self.visible_workspace_ids();
|
||||||
|
self.prune_empty_workspaces(&visible_workspaces);
|
||||||
if self.session_lock.active {
|
if self.session_lock.active {
|
||||||
self.configure_lock_surfaces();
|
self.configure_lock_surfaces();
|
||||||
}
|
}
|
||||||
@@ -1564,7 +1589,7 @@ impl Ferese {
|
|||||||
let constraints = self.window_constraints();
|
let constraints = self.window_constraints();
|
||||||
let mut visible = HashSet::new();
|
let mut visible = HashSet::new();
|
||||||
let mut placements = Vec::new();
|
let mut placements = Vec::new();
|
||||||
let mut output_workspaces = Vec::new();
|
let mut visible_workspace_pairs = Vec::new();
|
||||||
|
|
||||||
for output in outputs {
|
for output in outputs {
|
||||||
let Some(output_id) = self.output_ids.get(&output).copied() else {
|
let Some(output_id) = self.output_ids.get(&output).copied() else {
|
||||||
@@ -1573,17 +1598,17 @@ impl Ferese {
|
|||||||
let Some(active_workspace) = self.output_workspaces.active_workspace(output_id) else {
|
let Some(active_workspace) = self.output_workspaces.active_workspace(output_id) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
output_workspaces.push((output.clone(), active_workspace));
|
visible_workspace_pairs.push((output.clone(), active_workspace));
|
||||||
if let Some(slide) = self.workspace_slides.get(&output_id) {
|
if let Some(slide) = self.workspace_slides.get(&output_id) {
|
||||||
for item in &slide.items {
|
for item in &slide.items {
|
||||||
if item.workspace != active_workspace {
|
if item.workspace != active_workspace {
|
||||||
output_workspaces.push((output.clone(), item.workspace));
|
visible_workspace_pairs.push((output.clone(), item.workspace));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (output, workspace_id) in output_workspaces {
|
for (output, workspace_id) in visible_workspace_pairs {
|
||||||
let Some(bounds) = self.output_bounds_for(&output) else {
|
let Some(bounds) = self.output_bounds_for(&output) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
@@ -1709,20 +1734,7 @@ impl Ferese {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut space = std::mem::take(&mut self.space);
|
let mut layout_changed = self.unmap_invisible_windows(&visible);
|
||||||
let mut layout_changed = false;
|
|
||||||
for (window, id) in &self.window_ids {
|
|
||||||
if visible.contains(id) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
let was_mapped = space.element_location(window).is_some();
|
|
||||||
layout_changed |= was_mapped;
|
|
||||||
if was_mapped && let Some(geometry) = self.window_geometry.get_mut(id) {
|
|
||||||
geometry.settle_presentation();
|
|
||||||
}
|
|
||||||
space.unmap_elem(window);
|
|
||||||
}
|
|
||||||
self.space = space;
|
|
||||||
|
|
||||||
let now = self.start_time.elapsed();
|
let now = self.start_time.elapsed();
|
||||||
|
|
||||||
@@ -2165,34 +2177,21 @@ impl Ferese {
|
|||||||
for output in completed_slides {
|
for output in completed_slides {
|
||||||
self.workspace_slides.remove(&output);
|
self.workspace_slides.remove(&output);
|
||||||
}
|
}
|
||||||
let mut visible = visible_workspaces;
|
let visible = self.visible_workspace_ids();
|
||||||
visible.extend(
|
let visible_windows = self
|
||||||
self.workspace_slides
|
.window_ids
|
||||||
.values()
|
.values()
|
||||||
.flat_map(|slide| slide.items.iter().map(|item| item.workspace)),
|
.copied()
|
||||||
);
|
.filter(|id| {
|
||||||
let mapped = self
|
self.workspaces
|
||||||
.space
|
.workspace_for_window(*id)
|
||||||
.elements()
|
.is_none_or(|workspace| visible.contains(&workspace))
|
||||||
.filter_map(|window| self.window_ids.get(window).map(|id| (window.clone(), *id)))
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<HashSet<_>>();
|
||||||
for (window, id) in mapped {
|
self.unmap_invisible_windows(&visible_windows);
|
||||||
if self
|
self.prune_empty_workspaces(&visible);
|
||||||
.workspaces
|
|
||||||
.workspace_for_window(id)
|
|
||||||
.is_some_and(|workspace| !visible.contains(&workspace))
|
|
||||||
{
|
|
||||||
self.space.unmap_elem(&window);
|
|
||||||
if let Some(geometry) = self.window_geometry.get_mut(&id) {
|
|
||||||
geometry.settle_presentation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for workspace in self.workspaces.prune_empty(&visible) {
|
|
||||||
self.output_workspaces.forget_workspace(workspace);
|
|
||||||
self.viewport_animations.remove(&workspace);
|
|
||||||
}
|
|
||||||
self.send_shell_snapshots();
|
self.send_shell_snapshots();
|
||||||
|
active_animation = true;
|
||||||
}
|
}
|
||||||
active_animation |=
|
active_animation |=
|
||||||
self.overview
|
self.overview
|
||||||
|
|||||||
Reference in new issue
Block a user