Skip to content

Commit

Permalink
3/n restoreClosedWindowsCache if newly detected window is in the cache
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabobko committed Nov 27, 2024
1 parent 46bf611 commit 668bbb5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Sources/AppBundle/tree/MacWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ final class MacWindow: Window, CustomStringConvertible {
{
allWindowsMap[id] = window
debugWindowsIfRecording(window)
tryOnWindowDetected(window, startup: startup)
if !restoreClosedWindowsCacheIfNeeded(newlyDetectedWindow: window) {
tryOnWindowDetected(window, startup: startup)
}
return window
} else {
window.garbageCollect(skipClosedWindowsCache: true)
Expand Down
6 changes: 5 additions & 1 deletion Sources/AppBundle/tree/frozen/FrozenTree.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ func cacheClosedWindowIfNeeded(window: Window) {
)
}

func restoreWindowsFromClosedWindowsCache() {
func restoreClosedWindowsCacheIfNeeded(newlyDetectedWindow: Window) -> Bool {
if !closedWindowsCache.windowIds.contains(newlyDetectedWindow.windowId) {
return false
}
let monitors = monitors
let topLeftCornerToMonitor = monitors.grouped { $0.rect.topLeftCorner }

Expand Down Expand Up @@ -117,6 +120,7 @@ func restoreWindowsFromClosedWindowsCache() {
.singleOrNil()?
.setActiveWorkspace(Workspace.get(byName: monitor.visibleWorkspace))
}
return true
}

private func restoreTreeRecursive(frozenContainer: FrozenContainer, parent: NonLeafTreeNodeObject, index: Int) {
Expand Down

0 comments on commit 668bbb5

Please sign in to comment.