Skip to content

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

feat(domain): removed logic of setting container coordinates in DetachContainerHandler

Larsc047b721aa31
diff --git a/LarsWM.Domain/Containers/CommandHandlers/DetachContainerHandler.cs b/LarsWM.Domain/Containers/CommandHandlers/DetachContainerHandler.cs
index 959d2b2e..34d9aa34 100644
--- a/LarsWM.Domain/Containers/CommandHandlers/DetachContainerHandler.cs
+++ b/LarsWM.Domain/Containers/CommandHandlers/DetachContainerHandler.cs
@@ -23,47 +23,18 @@ namespace LarsWM.Domain.Containers.CommandHandlers
{
var parent = command.Parent;
var childToRemove = command.ChildToRemove;
- var currentChildren = command.Parent.Children;
+ var children = command.Parent.Children;
- var innerGap = _userConfigService.UserConfig.InnerGap;
+ parent.RemoveChild(childToRemove);
- if (parent.Layout == Layout.Horizontal)
- {
- // Available parent width is the width of the parent minus all inner gaps.
- var currentAvailableParentWidth = parent.Width - (innerGap * (currentChildren.Count - 1));
- var newAvailableParentWidth = parent.Width - (innerGap * (currentChildren.Count - 2));
+ double defaultPercent = 1 / children.Count;
- // Adjust widths of current child containers.
- foreach (var currentChild in currentChildren)
- {
- // TODO: Width percentage is incorrect.
- // Eg. if 33%/33%/33% -> 50%/50% or 50%/25%/25% -> 62.5%/37.5%
- // Get the percentage of the child to remove and distribute it evenly amongst new children.
- var widthPercentage = (double)currentChild.Width / currentAvailableParentWidth;
- currentChild.Width = (int)(widthPercentage * (newAvailableParentWidth + childToRemove.Width));
- }
+ // TODO: Adjust SizePercentage of children based on their previous SizePercentage.
- parent.RemoveChild(childToRemove);
+ foreach (var child in children)
+ child.SizePercentage = defaultPercent;
- // Adjust x-coordinate of child containers.
- Container previousChild = null;
- foreach (var child in parent.Children)
- {
- if (previousChild == null)
- child.X = parent.X;
-
- else
- child.X = previousChild.X + previousChild.Width + innerGap;
-
- previousChild = child;
- }
- }
-
- if (parent.Layout == Layout.Vertical)
- {
- }
-
- _containerService.PendingContainersToRedraw.Add(parent);
+ _containerService.SplitContainersToRedraw.Add(parent);
return CommandResponse.Ok;
}