From d30a5c1f6c8ffcbba0d41e85e58bcd641cd95dc3 Mon Sep 17 00:00:00 2001 From: Nikita Bobko Date: Fri, 15 Sep 2023 00:40:57 +0200 Subject: [PATCH] Move lastActiveWindow cleanup to unbindIfPossible --- src/model/TreeNode.swift | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/model/TreeNode.swift b/src/model/TreeNode.swift index e17fc07c..4a61a965 100644 --- a/src/model/TreeNode.swift +++ b/src/model/TreeNode.swift @@ -49,8 +49,7 @@ class TreeNode: Equatable { if newParent is MacWindow { error("Windows can't have children") } - let prevParent: TreeNode? = _parent - if prevParent === newParent { + if _parent === newParent { error("Binding to the same parent doesn't make sense") } let result = unbindIfPossible() @@ -59,9 +58,6 @@ class TreeNode: Equatable { return result } if let window = self as? MacWindow { - if prevParent?.workspace.lastActiveWindow == window { - prevParent?.workspace.lastActiveWindow = nil - } let newParentWorkspace = newParent.workspace newParentWorkspace.lastActiveWindow = window newParentWorkspace.assignedMonitor = window.getTopLeftCorner()?.monitorApproximation @@ -85,6 +81,9 @@ class TreeNode: Equatable { currentEmptyWorkspace = workspace currentEmptyWorkspace.assignedMonitor = nil } + if let window = self as? MacWindow, parent.workspace.lastActiveWindow == window { + parent.workspace.lastActiveWindow = nil + } return PreviousBindingData(adaptiveWeight: adaptiveWeight, index: index) } -- 2.51.2