Skip to content

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

feat(domain): handle resizing from a focused window within a split container

Lars40f71e80c052
diff --git a/LarsWM.Domain/Windows/CommandHandlers/ResizeFocusedWindowHandler.cs b/LarsWM.Domain/Windows/CommandHandlers/ResizeFocusedWindowHandler.cs
index 47189048..48a699ce 100644
--- a/LarsWM.Domain/Windows/CommandHandlers/ResizeFocusedWindowHandler.cs
+++ b/LarsWM.Domain/Windows/CommandHandlers/ResizeFocusedWindowHandler.cs
@@ -1,5 +1,4 @@
-using System;
-using System.Linq;
+using System.Linq;
using LarsWM.Domain.Common.Enums;
using LarsWM.Domain.Containers;
using LarsWM.Domain.Containers.Commands;
@@ -43,23 +42,61 @@ namespace LarsWM.Domain.Windows.CommandHandlers
var resizePercentage = _userConfigService.UserConfig.ResizePercentage;
var resizeDirection = command.ResizeDirection;
- if (resizeDirection == ResizeDirection.GROW_WIDTH || resizeDirection == ResizeDirection.GROW_HEIGHT)
+ // TODO: Handle error where a horizontal workspace has 2 windows, and user attempts to grow the height of
+ // one of the containers.
+
+ if (
+ layout == Layout.Horizontal && resizeDirection == ResizeDirection.GROW_WIDTH
+ || layout == Layout.Vertical && resizeDirection == ResizeDirection.GROW_HEIGHT
+ )
{
focusedWindow.SizePercentage += resizePercentage;
foreach (var sibling in siblings)
sibling.SizePercentage -= resizePercentage / siblings.Count();
+
+ _containerService.SplitContainersToRedraw.Add(parent);
+ }
+
+ if (
+ layout == Layout.Vertical && resizeDirection == ResizeDirection.GROW_WIDTH
+ || layout == Layout.Horizontal && resizeDirection == ResizeDirection.GROW_HEIGHT
+ )
+ {
+ parent.SizePercentage += resizePercentage;
+
+ foreach (var sibling in parent.Siblings)
+ sibling.SizePercentage -= resizePercentage / siblings.Count();
+
+ _containerService.SplitContainersToRedraw.Add(parent.Parent as SplitContainer);
}
- if (resizeDirection == ResizeDirection.SHRINK_WIDTH || resizeDirection == ResizeDirection.SHRINK_HEIGHT)
+ if (
+ layout == Layout.Horizontal && resizeDirection == ResizeDirection.SHRINK_WIDTH
+ || layout == Layout.Vertical && resizeDirection == ResizeDirection.SHRINK_HEIGHT
+ )
{
focusedWindow.SizePercentage -= resizePercentage;
foreach (var sibling in siblings)
sibling.SizePercentage += resizePercentage / siblings.Count();
+
+ _containerService.SplitContainersToRedraw.Add(parent);
+ }
+
+ if (
+ layout == Layout.Vertical && resizeDirection == ResizeDirection.SHRINK_WIDTH
+ || layout == Layout.Horizontal && resizeDirection == ResizeDirection.SHRINK_HEIGHT
+ )
+ {
+ parent.SizePercentage -= resizePercentage;
+
+ foreach (var sibling in parent.Siblings)
+ sibling.SizePercentage += resizePercentage / siblings.Count();
+
+ _containerService.SplitContainersToRedraw.Add(parent.Parent as SplitContainer);
}
- _containerService.SplitContainersToRedraw.Add(parent);
_bus.Invoke(new RedrawContainersCommand());
return new CommandResponse(true, focusedWindow.Id);