Skip to content

Commit

Permalink
Move lastActiveWindow cleanup to unbindIfPossible
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabobko committed Sep 15, 2023
1 parent a6f5ce6 commit d30a5c1
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/model/TreeNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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)
}

Expand Down

0 comments on commit d30a5c1

Please sign in to comment.