GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat(domain): throw error when attempting to attach an already attached container
Lars Berger84b7a0cf9877
diff --git a/GlazeWM.Domain/Containers/CommandHandlers/AttachContainerHandler.cs b/GlazeWM.Domain/Containers/CommandHandlers/AttachContainerHandler.csindex 19e7587a..d642cfbc 100644--- a/GlazeWM.Domain/Containers/CommandHandlers/AttachContainerHandler.cs+++ b/GlazeWM.Domain/Containers/CommandHandlers/AttachContainerHandler.cs@@ -1,3 +1,4 @@+using System;using GlazeWM.Domain.Containers.Commands;using GlazeWM.Infrastructure.Bussing;@@ -19,20 +20,15 @@ namespace GlazeWM.Domain.Containers.CommandHandlersvar parent = command.Parent;var childToAdd = command.ChildToAdd;- // Get whether the container has focus prior to making any state changes.- var isFocusedContainer = _containerService.FocusedContainer == childToAdd;-if (childToAdd.Parent != null)- _bus.Invoke(new DetachContainerCommand(childToAdd));+ throw new Exception("Attempting to attach an already attached container. This is a bug.");+ // TODO: Insert at end of parent's `ChildFocusOrder`.parent.Children.Insert(command.InsertPosition, childToAdd);childToAdd.Parent = parent;_containerService.ContainersToRedraw.Add(parent);- // Adjust focus order of ancestors if the attached container is focused.- if (isFocusedContainer)- _bus.Invoke(new SetFocusedDescendantCommand(childToAdd));return CommandResponse.Ok;}