Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

feat(domain): flatten any top-level split containers that have the same layout as the workspace

Lars Berger5fcc252c5308
diff --git a/LarsWM.Domain/Containers/CommandHandlers/ChangeContainerLayoutHandler.cs b/LarsWM.Domain/Containers/CommandHandlers/ChangeContainerLayoutHandler.cs
index 6954b8bb..e4fb3c1b 100644
--- a/LarsWM.Domain/Containers/CommandHandlers/ChangeContainerLayoutHandler.cs
+++ b/LarsWM.Domain/Containers/CommandHandlers/ChangeContainerLayoutHandler.cs
@@ -1,3 +1,4 @@
+using System.Collections.Generic;
using System.Linq;
using LarsWM.Domain.Common.Enums;
using LarsWM.Domain.Containers.Commands;
@@ -81,9 +82,19 @@ namespace LarsWM.Domain.Containers.CommandHandlers
workspace.Layout = newLayout;
- // TODO: Flatten any top-level split containers with the changed layout of the workspace.
+ // Flatten any top-level split containers with the same layout as the workspace. Clone
+ // the list since the number of workspace children changes when split containers are flattened.
+ foreach (var child in workspace.Children.ToList())
+ {
+ var childSplitContainer = child as SplitContainer;
+
+ if (childSplitContainer == null || childSplitContainer.Layout != newLayout)
+ continue;
+
+ _bus.Invoke(new ReplaceContainerCommand(workspace, child.Index, child.Children));
+ }
- _bus.Invoke(new RedrawContainersCommand());
+ _containerService.SplitContainersToRedraw.Add(workspace);
}
}
}