GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
refactor(domain): remove `Container` methods for adding/removing children; move logic to attach/detach container commands
Lars Bergere417dceabdd9
diff --git a/GlazeWM.Domain/Containers/CommandHandlers/DetachContainerHandler.cs b/GlazeWM.Domain/Containers/CommandHandlers/DetachContainerHandler.csindex 3cc90591..13a951bb 100644--- a/GlazeWM.Domain/Containers/CommandHandlers/DetachContainerHandler.cs+++ b/GlazeWM.Domain/Containers/CommandHandlers/DetachContainerHandler.cs@@ -22,7 +22,8 @@ namespace GlazeWM.Domain.Containers.CommandHandlersvar childToRemove = command.ChildToRemove;var parent = childToRemove.Parent;- parent.RemoveChild(childToRemove);+ childToRemove.Parent = null;+ parent.Children.Remove(childToRemove);parent.ChildFocusOrder.Remove(childToRemove);if (childToRemove is TilingWindow || childToRemove is SplitContainer)diff --git a/GlazeWM.Domain/Containers/Container.cs b/GlazeWM.Domain/Containers/Container.csindex 54c604cb..e0fae7a0 100644--- a/GlazeWM.Domain/Containers/Container.cs+++ b/GlazeWM.Domain/Containers/Container.cs@@ -45,13 +45,7 @@ namespace GlazeWM.Domain.Containerspublic List<Container> SelfAndSiblings => Parent.Children;- public IEnumerable<Container> Siblings- {- get- {- return Parent.Children.Where(child => child != this);- }- }+ public IEnumerable<Container> Siblings => Parent.Children.Where(children => children != this);/// <summary>/// Index of this container amongst its siblings.@@ -87,7 +81,7 @@ namespace GlazeWM.Domain.Containers// TODO: Rename to SelfAndDescendants and change to getter.public IEnumerable<Container> Flatten(){- return new[] { this }.Concat(Children.SelectMany(x => x.Flatten()));+ return new[] { this }.Concat(Children.SelectMany(children => children.Flatten()));}public IEnumerable<Container> SelfAndAncestors => new[] { this }.Concat(Ancestors);@@ -106,33 +100,9 @@ namespace GlazeWM.Domain.Containers}}- public Container AddChild(Container container)- {- Children.Add(container);- container.Parent = this;- return container;- }-- public Container[] AddChildren(params Container[] containers)- {- return containers.Select(AddChild).ToArray();- }-- public bool RemoveChild(Container node)- {- node.Parent = null;- return Children.Remove(node);- }+ public bool HasChildren() => Children.Count > 0;- public bool HasChildren()- {- return Children.Count > 0;- }-- public bool HasSiblings()- {- return Siblings.Count() > 0;- }+ public bool HasSiblings() => Siblings.Count() > 0;public IEnumerable<Container> SelfAndSiblingsOfType(Type type){