GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
refactor(domain): change `MoveContainerWithinTreeCommand` to take a target parent + index
Lars Berger80e4216fb28e
diff --git a/GlazeWM.Domain/Containers/CommandHandlers/MoveContainerWithinTreeHandler.cs b/GlazeWM.Domain/Containers/CommandHandlers/MoveContainerWithinTreeHandler.csindex 536d7cec..d3acb302 100644--- a/GlazeWM.Domain/Containers/CommandHandlers/MoveContainerWithinTreeHandler.cs+++ b/GlazeWM.Domain/Containers/CommandHandlers/MoveContainerWithinTreeHandler.cs@@ -21,10 +21,15 @@ namespace GlazeWM.Domain.Containers.CommandHandlerspublic CommandResponse Handle(MoveContainerWithinTreeCommand command){var container = command.Container;- var target = command.Target;+ var targetParent = command.TargetParent;+ var targetIndex = command.TargetIndex;var insertionPosition = command.InsertionPosition;+ // TODO: Handle case where target parent doesn't have children.+ // TODO: Throw error if `target` is null.+// Get lowest common ancestor (LCA) between `container` and `target`.+ var target = targetParent.Children[targetIndex];var lowestCommonAncestor = _containerService.GetLowestCommonAncestor(container, target);// Get ancestors of `container` and `target` that are direct children of the LCA. This coulddiff --git a/GlazeWM.Domain/Containers/Commands/MoveContainerWithinTreeCommand.cs b/GlazeWM.Domain/Containers/Commands/MoveContainerWithinTreeCommand.csindex f3056b95..c3af53bf 100644--- a/GlazeWM.Domain/Containers/Commands/MoveContainerWithinTreeCommand.cs+++ b/GlazeWM.Domain/Containers/Commands/MoveContainerWithinTreeCommand.cs@@ -6,13 +6,15 @@ namespace GlazeWM.Domain.Containers.Commandspublic class MoveContainerWithinTreeCommand : Command{public Container Container { get; }- public Container Target { get; }+ public Container TargetParent { get; }+ public int TargetIndex { get; }public InsertionPosition InsertionPosition { get; }- public MoveContainerWithinTreeCommand(Container container, Container target, InsertionPosition insertionPosition)+ public MoveContainerWithinTreeCommand(Container container, Container targetParent, int targetIndex, InsertionPosition insertionPosition){Container = container;- Target = target;+ TargetParent = targetParent;+ TargetIndex = targetIndex;InsertionPosition = insertionPosition;}}diff --git a/GlazeWM.Domain/Windows/CommandHandlers/ToggleFloatingHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/ToggleFloatingHandler.csindex 5fae10eb..6538c728 100644--- a/GlazeWM.Domain/Windows/CommandHandlers/ToggleFloatingHandler.cs+++ b/GlazeWM.Domain/Windows/CommandHandlers/ToggleFloatingHandler.cs@@ -79,7 +79,14 @@ namespace GlazeWM.Domain.Windows.CommandHandlersif (insertionTarget == null)_bus.Invoke(new AttachContainerCommand(workspace, tilingWindow));else- _bus.Invoke(new MoveContainerWithinTreeCommand(tilingWindow, insertionTarget, InsertionPosition.AFTER));+ _bus.Invoke(+ new MoveContainerWithinTreeCommand(+ tilingWindow,+ insertionTarget.Parent,+ insertionTarget.Index,+ InsertionPosition.AFTER+ )+ );_bus.Invoke(new RedrawContainersCommand());}