GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
refactor(domain): use `MoveContainerWithinTreeCommand` to insert window after focused descendant on minimize end
Lars Berger41ab1d22c00e
diff --git a/GlazeWM.Domain/Windows/EventHandlers/WindowMinimizeEndedHandler.cs b/GlazeWM.Domain/Windows/EventHandlers/WindowMinimizeEndedHandler.csindex 334d6dd1..aca964d1 100644--- a/GlazeWM.Domain/Windows/EventHandlers/WindowMinimizeEndedHandler.cs+++ b/GlazeWM.Domain/Windows/EventHandlers/WindowMinimizeEndedHandler.cs@@ -1,4 +1,3 @@-using System.Diagnostics;using System.Linq;using GlazeWM.Domain.Containers;using GlazeWM.Domain.Containers.Commands;@@ -32,32 +31,27 @@ namespace GlazeWM.Domain.Windows.EventHandlersreturn;var tilingWindow = new TilingWindow(window.Hwnd, window.OriginalWidth, window.OriginalHeight);+ _bus.Invoke(new ReplaceContainerCommand(window.Parent, window.Index, tilingWindow));- // Keep reference to the window's ancestor workspace and focus order index prior to detaching.+ // Keep reference to the window's ancestor workspace prior to detaching.var workspace = _workspaceService.GetWorkspaceFromChildContainer(window);- _bus.Invoke(new DetachContainerCommand(window));- AttachChildWindow(window);+ var insertionTarget = workspace.LastFocusedDescendantOfType(typeof(IResizable));++ // Insert the created tiling window after the last focused descendant of the workspace.+ if (insertionTarget == null)+ _bus.Invoke(new MoveContainerWithinTreeCommand(tilingWindow, workspace, 0));+ else+ _bus.Invoke(+ new MoveContainerWithinTreeCommand(+ tilingWindow,+ insertionTarget.Parent,+ insertionTarget.Index + 1+ )+ );_containerService.ContainersToRedraw.Add(workspace);_bus.Invoke(new RedrawContainersCommand());}-- private void AttachChildWindow(Window window)- {- var focusedContainer = _containerService.FocusedContainer;-- // If the focused container is a workspace, attach the window as a child of the workspace.- if (focusedContainer is Workspace)- {- _bus.Invoke(new AttachContainerCommand(focusedContainer as Workspace, window));- return;- }-- // Attach the window as a sibling next to the focused window.- _bus.Invoke(new AttachContainerCommand(- focusedContainer.Parent as SplitContainer, window, focusedContainer.Index + 1- ));- }}}