Skip to content

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

feat(domain): added ContainerTreeEnumeration method to ContainerService

Lars7ec953b5efa5
diff --git a/LarsWM.Domain/Containers/ContainerService.cs b/LarsWM.Domain/Containers/ContainerService.cs
index 6515ced5..96ec0cb1 100644
--- a/LarsWM.Domain/Containers/ContainerService.cs
+++ b/LarsWM.Domain/Containers/ContainerService.cs
@@ -5,7 +5,30 @@ namespace LarsWM.Domain.Containers
{
public class ContainerService
{
+ /// <summary>
+ /// List of trees consisting of containers. The root nodes are the monitors,
+ /// followed by workspaces, then split containers & windows.
+ /// </summary>
public List<Container> ContainerTree = new List<Container>();
+
+ // TODO: Consider renaming to PendingWindowsToRedraw and moving to WindowService.
public List<Container> PendingContainersToRedraw = new List<Container>();
+
+ /// <summary>
+ /// Breadth-first downward traversal from given root container.
+ /// </summary>
+ public IEnumerable<Container> ContainerTreeEnumeration(Container root)
+ {
+ var queue = new Queue<Container>();
+ queue.Enqueue(root);
+
+ while (queue.Count > 0)
+ {
+ var current = queue.Dequeue();
+ yield return current;
+ foreach (var child in root.Children)
+ queue.Enqueue(child);
+ }
+ }
}
}