Skip to content

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

fix(domain): iterate in correct order in `LastFocusedDescendantOfType`

Lars Bergere8126b2db34e
diff --git a/GlazeWM.Domain/Containers/Container.cs b/GlazeWM.Domain/Containers/Container.cs
index e8f6c4ec..debdec18 100644
--- a/GlazeWM.Domain/Containers/Container.cs
+++ b/GlazeWM.Domain/Containers/Container.cs
@@ -160,7 +160,7 @@ namespace GlazeWM.Domain.Containers
var stack = new Stack<Container>();
stack.Push(this);
- // Depth-first search using `ChildFocusOrder` list.
+ // Do a depth-first search using child focus order.
while (stack.Any())
{
var current = stack.Pop();
@@ -170,7 +170,8 @@ namespace GlazeWM.Domain.Containers
if (isMatch)
return current;
- foreach (var focusChild in current.ChildFocusOrder)
+ // Reverse the child focus order so that the first element is pushed last/popped first.
+ foreach (var focusChild in current.ChildFocusOrder.AsEnumerable().Reverse())
stack.Push(focusChild);
}