Skip to content

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

feat(domain): add `Container` getter for its last focused child of a given type

Lars Berger6260e9f15330
diff --git a/GlazeWM.Domain/Containers/Container.cs b/GlazeWM.Domain/Containers/Container.cs
index 8f57731d..482eccaa 100644
--- a/GlazeWM.Domain/Containers/Container.cs
+++ b/GlazeWM.Domain/Containers/Container.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
@@ -114,6 +114,16 @@ namespace GlazeWM.Domain.Containers
.FirstOrDefault(container => type.IsAssignableFrom(container.GetType()));
}
+ /// <summary>
+ /// Get the last focused child that matches the given type.
+ /// </summary>
+ public Container LastFocusedChildOfType(Type type)
+ {
+ return ChildFocusOrder.FirstOrDefault(
+ container => type.IsAssignableFrom(container.GetType())
+ );
+ }
+
/// <summary>
/// Get the last focused descendant that matches the given type.
/// </summary>