fix(wm): simplify stack-all command

This commit makes the `stack-all` command simpler, by simply making a
`VecDeque` with all the tiled windows of the workspace, then it creates
a new container with that `VecDeque` and changes the workspace
containers to be just this new container which has all the windows in
it.

Then and only then do we focus and show the previously focused window
and hide all the rest.

This way we don't have a bunch of `FocusChange`/`Cloak`/`Uncloak` events
coming up which might conflict with each other when the user has
transparency and animations enabled.

With this commit, there will only be one focus event for the focused
window and one cloak event for each of the other windows.
This commit is contained in:
alex-ds13
2025-10-30 17:48:31 +00:00
committed by LGUG2Z
parent 1a42c64620
commit 18ee667896

View File

@@ -2682,8 +2682,6 @@ impl WindowManager {
#[tracing::instrument(skip(self))]
pub fn stack_all(&mut self) -> eyre::Result<()> {
self.unstack_all(false)?;
self.handle_unmanaged_window_behaviour()?;
tracing::info!("stacking all windows on workspace");
@@ -2696,16 +2694,27 @@ impl WindowManager {
focused_hwnd = Some(window.hwnd);
}
workspace.focus_container(workspace.containers().len().saturating_sub(1));
while workspace.focused_container_idx() > 0 {
workspace.move_window_to_container(0)?;
workspace.focus_container(workspace.containers().len().saturating_sub(1));
}
let workspace_hwnds =
workspace
.containers()
.iter()
.fold(VecDeque::new(), |mut hwnds, c| {
hwnds.extend(c.windows().clone());
hwnds
});
if let Some(hwnd) = focused_hwnd {
workspace.focus_container_by_window(hwnd)?;
}
let mut container = Container::default();
*container.windows_mut() = workspace_hwnds;
*workspace.containers_mut() = VecDeque::from([container]);
workspace.focus_container(0);
if let Some(hwnd) = focused_hwnd
&& let Some(c) = workspace.focused_container_mut()
&& let Some(w_idx_to_focus) = c.idx_for_window(hwnd)
{
c.focus_window(w_idx_to_focus);
c.load_focused_window();
}
self.update_focused_workspace(self.mouse_follows_focus, true)
}