Skip to content

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

fix: crash when detaching monitor on display settings change (#519)

lars-berger0e9b289bc8de
diff --git a/GlazeWM.Domain/Containers/Container.cs b/GlazeWM.Domain/Containers/Container.cs
index c9fe480b..bf72b248 100644
--- a/GlazeWM.Domain/Containers/Container.cs
+++ b/GlazeWM.Domain/Containers/Container.cs
@@ -41,14 +41,18 @@ namespace GlazeWM.Domain.Containers
/// </summary>
public int FocusIndex => this is RootContainer ? 0 : Parent.ChildFocusOrder.IndexOf(this);
- public List<Container> SelfAndSiblings => Parent.Children;
+ public List<Container> SelfAndSiblings =>
+ this is RootContainer ? new List<Container>() { this } : Parent.Children;
- public IEnumerable<Container> Siblings => Parent.Children.Where(children => children != this);
+ public IEnumerable<Container> Siblings =>
+ this is RootContainer
+ ? Array.Empty<Container>()
+ : Parent.Children.Where(children => children != this);
/// <summary>
/// Index of this container amongst its siblings.
/// </summary>
- public int Index => Parent.Children.IndexOf(this);
+ public int Index => this is RootContainer ? 0 : Parent.Children.IndexOf(this);
/// <summary>
/// Get the last focused descendant by traversing downwards.