GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat(domain): allow `ReplaceContainerCommand` to take a list of containers as replacement
Lars Berger84b70225b4c9
diff --git a/LarsWM.Domain/Containers/CommandHandlers/ReplaceContainerHandler.cs b/LarsWM.Domain/Containers/CommandHandlers/ReplaceContainerHandler.csindex efb53862..19fd2cb4 100644--- a/LarsWM.Domain/Containers/CommandHandlers/ReplaceContainerHandler.cs+++ b/LarsWM.Domain/Containers/CommandHandlers/ReplaceContainerHandler.cs@@ -16,22 +16,31 @@ namespace LarsWM.Domain.Containers.CommandHandlerspublic CommandResponse Handle(ReplaceContainerCommand command){var parentContainer = command.ParentContainer;- var replacementContainer = command.ReplacementContainer;+ var replacementContainers = command.ReplacementContainers;var childIndex = command.ChildIndex;// TODO: Consider detaching `ReplacementContainer` if it already has a parent.- // Replace the container at the given index.var containerToReplace = parentContainer.Children[childIndex];- parentContainer.Children.Replace(containerToReplace, replacementContainer);- replacementContainer.Parent = parentContainer;- replacementContainer.SizePercentage = containerToReplace.SizePercentage;++ foreach (var replacementContainer in replacementContainers)+ {+ replacementContainer.Parent = parentContainer;+ replacementContainer.SizePercentage =+ containerToReplace.SizePercentage * replacementContainer.SizePercentage;+ }++ // Replace the container at the given index.+ var index = parentContainer.Children.IndexOf(containerToReplace);+ parentContainer.Children.InsertRange(index, replacementContainers);+ parentContainer.RemoveChild(containerToReplace);// Correct any focus order references to the replaced container.- parentContainer.ChildFocusOrder.Replace(containerToReplace, replacementContainer);+ parentContainer.ChildFocusOrder.Replace(+ containerToReplace, containerToReplace.LastFocusedChild ?? replacementContainers[0]+ );_containerService.SplitContainersToRedraw.Add(parentContainer as SplitContainer);- _containerService.SplitContainersToRedraw.Add(replacementContainer.Parent as SplitContainer);return CommandResponse.Ok;}diff --git a/LarsWM.Domain/Containers/Commands/ReplaceContainerCommand.cs b/LarsWM.Domain/Containers/Commands/ReplaceContainerCommand.csindex 81e42b28..4040bfe9 100644--- a/LarsWM.Domain/Containers/Commands/ReplaceContainerCommand.cs+++ b/LarsWM.Domain/Containers/Commands/ReplaceContainerCommand.cs@@ -1,4 +1,5 @@-using LarsWM.Infrastructure.Bussing;+using System.Collections.Generic;+using LarsWM.Infrastructure.Bussing;namespace LarsWM.Domain.Containers.Commands{@@ -6,13 +7,13 @@ namespace LarsWM.Domain.Containers.Commands{public Container ParentContainer { get; }public int ChildIndex { get; }- public Container ReplacementContainer { get; }+ public List<Container> ReplacementContainers { get; }- public ReplaceContainerCommand(Container parentContainer, int childIndex, Container replacementContainer)+ public ReplaceContainerCommand(Container parentContainer, int childIndex, List<Container> replacementContainers){ParentContainer = parentContainer;ChildIndex = childIndex;- ReplacementContainer = replacementContainer;+ ReplacementContainers = replacementContainers;}}}