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) }