Skip to content

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

feat(domain): move getters for siblings of a specified type to `Container`

Lars Berger46b860bfb6c8
diff --git a/GlazeWM.Domain/Containers/Container.cs b/GlazeWM.Domain/Containers/Container.cs
index b435532d..7a154b8b 100644
--- a/GlazeWM.Domain/Containers/Container.cs
+++ b/GlazeWM.Domain/Containers/Container.cs
@@ -117,14 +117,6 @@ namespace GlazeWM.Domain.Containers
return Children.Remove(node);
}
- // Not sure if needed.
- public void Traverse(Action<Container> action)
- {
- action(this);
- foreach (var child in Children)
- child.Traverse(action);
- }
-
public bool HasChildren()
{
return Children.Count > 0;
@@ -134,5 +126,25 @@ namespace GlazeWM.Domain.Containers
{
return Siblings.Count() > 0;
}
+
+ public IEnumerable<Container> SelfAndSiblingsOfType(Type type)
+ {
+ return SelfAndSiblings.Where(container => type.IsAssignableFrom(container.GetType()));
+ }
+
+ public Container GetNextSiblingOfType(Type type)
+ {
+ return SelfAndSiblings
+ .Skip(Index)
+ .FirstOrDefault(container => type.IsAssignableFrom(container.GetType()));
+ }
+
+ public Container GetPreviousSiblingOfType(Type type)
+ {
+ return SelfAndSiblings
+ .Take(Index)
+ .Reverse()
+ .FirstOrDefault(container => type.IsAssignableFrom(container.GetType()));
+ }
}
}
diff --git a/GlazeWM.Domain/Windows/Window.cs b/GlazeWM.Domain/Windows/Window.cs
index 33fa2b0c..96a43567 100644
--- a/GlazeWM.Domain/Windows/Window.cs
+++ b/GlazeWM.Domain/Windows/Window.cs
@@ -67,22 +67,5 @@ namespace GlazeWM.Domain.Windows
{
return _windowService.HandleHasWindowExStyle(Hwnd, style);
}
-
- public IEnumerable<Container> SelfAndSiblingsOfType(Type type)
- {
- return SelfAndSiblings.Where(container => container.GetType().IsAssignableFrom(type));
- }
-
- public Container GetNextSiblingOfType(Type type)
- {
- return SelfAndSiblings
- .Skip(Index)
- .FirstOrDefault(container => container.GetType().IsAssignableFrom(type));
- }
-
- public Container GetPreviousSiblingOfType(Type type)
- {
- throw new NotImplementedException();
- }
}
}