Skip to content

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

feat(domain): ignore non-tiling containers in `GetDescendantInDirection`

Lars Bergerbd5f1cf5f00a
diff --git a/GlazeWM.Domain/Containers/ContainerService.cs b/GlazeWM.Domain/Containers/ContainerService.cs
index 06b79e0d..2d2a1df4 100644
--- a/GlazeWM.Domain/Containers/ContainerService.cs
+++ b/GlazeWM.Domain/Containers/ContainerService.cs
@@ -144,7 +144,7 @@ namespace GlazeWM.Domain.Containers
/// <summary>
/// Traverse down a container in search of a descendant in the given direction. For example, get
/// the rightmost container for `Direction.RIGHT`. Returns the `originContainer` if no suitable
- /// descendants are found.
+ /// descendants are found. Any non-tiling containers are ignored.
/// </summary>
public Container GetDescendantInDirection(Container originContainer, Direction direction)
{
@@ -154,12 +154,22 @@ namespace GlazeWM.Domain.Containers
var layout = (originContainer as SplitContainer).Layout;
if (layout != direction.GetCorrespondingLayout())
- return GetDescendantInDirection(originContainer.LastFocusedChild, direction);
+ return GetDescendantInDirection(
+ originContainer.LastFocusedChildOfType(typeof(IResizable)),
+ direction
+ );
if (direction == Direction.UP || direction == Direction.LEFT)
- return GetDescendantInDirection(originContainer.Children.First(), direction);
+ return GetDescendantInDirection(
+ originContainer.ChildrenOfType(typeof(IResizable)).First(),
+ direction
+ );
+
else
- return GetDescendantInDirection(originContainer.Children.Last(), direction);
+ return GetDescendantInDirection(
+ originContainer.ChildrenOfType(typeof(IResizable)).Last(),
+ direction
+ );
}
/// <summary>