Skip to content

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

feat(domain): swap focused window with sibling when moving within same parent container

Lars Bergerdea6baa71d78
diff --git a/LarsWM.Domain/Windows/CommandHandlers/MoveFocusedWindowHandler.cs b/LarsWM.Domain/Windows/CommandHandlers/MoveFocusedWindowHandler.cs
index 155982f7..6b581703 100644
--- a/LarsWM.Domain/Windows/CommandHandlers/MoveFocusedWindowHandler.cs
+++ b/LarsWM.Domain/Windows/CommandHandlers/MoveFocusedWindowHandler.cs
@@ -47,6 +47,21 @@ namespace LarsWM.Domain.Windows.CommandHandlers
return CommandResponse.Ok;
}
+ // Swap the focused window with sibling in given direction.
+ if (ancestorWithLayout == focusedWindow.Parent)
+ {
+ var index = focusedWindow.SelfAndSiblings.IndexOf(focusedWindow);
+
+ if (direction == Direction.UP || direction == Direction.LEFT)
+ _bus.Invoke(new SwapContainersCommand(focusedWindow, focusedWindow.Parent.Children[index - 1]));
+ else
+ _bus.Invoke(new SwapContainersCommand(focusedWindow, focusedWindow.Parent.Children[index + 1]));
+
+ _bus.Invoke(new RedrawContainersCommand());
+
+ return CommandResponse.Ok;
+ }
+
return CommandResponse.Ok;
}
}