Skip to content

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

feat(domain): allow window height to be resized in `ResizeFocusedWindowHandler`

Lars5bd3fc3eedec
diff --git a/LarsWM.Domain/Windows/CommandHandlers/ResizeFocusedWindowHandler.cs b/LarsWM.Domain/Windows/CommandHandlers/ResizeFocusedWindowHandler.cs
index 5650f9e1..47189048 100644
--- a/LarsWM.Domain/Windows/CommandHandlers/ResizeFocusedWindowHandler.cs
+++ b/LarsWM.Domain/Windows/CommandHandlers/ResizeFocusedWindowHandler.cs
@@ -32,13 +32,18 @@ namespace LarsWM.Domain.Windows.CommandHandlers
if (focusedWindow == null)
return CommandResponse.Ok;
- var parent = focusedWindow.Parent as SplitContainer;
- var siblings = parent.Children.Where(child => child != focusedWindow);
+ var siblings = focusedWindow.Siblings;
- var resizePercentage = _userConfigService.UserConfig.ResizePercentage;
+ // Ignore cases where focused window doesn't have any siblings.
+ if (siblings.Count() == 0)
+ return CommandResponse.Ok;
+
+ var parent = focusedWindow.Parent as SplitContainer;
var layout = parent.Layout;
+ var resizePercentage = _userConfigService.UserConfig.ResizePercentage;
+ var resizeDirection = command.ResizeDirection;
- if (layout == Layout.Horizontal && command.ResizeDirection == ResizeDirection.GROW_WIDTH)
+ if (resizeDirection == ResizeDirection.GROW_WIDTH || resizeDirection == ResizeDirection.GROW_HEIGHT)
{
focusedWindow.SizePercentage += resizePercentage;
@@ -46,7 +51,7 @@ namespace LarsWM.Domain.Windows.CommandHandlers
sibling.SizePercentage -= resizePercentage / siblings.Count();
}
- if (layout == Layout.Horizontal && command.ResizeDirection == ResizeDirection.SHRINK_WIDTH)
+ if (resizeDirection == ResizeDirection.SHRINK_WIDTH || resizeDirection == ResizeDirection.SHRINK_HEIGHT)
{
focusedWindow.SizePercentage -= resizePercentage;