diff --git a/Sources/AppBundle/GlobalObserver.swift b/Sources/AppBundle/GlobalObserver.swift index 01fa7af6..8bc36ff8 100644 --- a/Sources/AppBundle/GlobalObserver.swift +++ b/Sources/AppBundle/GlobalObserver.swift @@ -2,7 +2,8 @@ import AppKit class GlobalObserver { private static func onNotif(_ notification: Notification) { - // Second line of defence against lock screen window. See: gcWindows + // Third line of defence against lock screen window. See: closedWindowsCache + // Second and third lines of defence are technically needed only to avoid potential flickering if (notification.userInfo?[NSWorkspace.applicationUserInfoKey] as? NSRunningApplication)?.bundleIdentifier == lockScreenAppBundleId { return } diff --git a/Sources/AppBundle/layout/refresh.swift b/Sources/AppBundle/layout/refresh.swift index 4e3fe8b6..34023bbb 100644 --- a/Sources/AppBundle/layout/refresh.swift +++ b/Sources/AppBundle/layout/refresh.swift @@ -58,9 +58,8 @@ private func gc() { } func gcWindows() { - // When lockscreen is active, all accessibility API becomes unobservable (all attributes become empty, window id - // becomes nil, etc.) which tricks AeroSpace into thinking that all windows were closed. - // The worst part is that windows don't becomes unobservable all together but window by window. + // Second line of defence against lock screen. See the first line of defence: closedWindowsCache + // Second and third lines of defence are technically needed only to avoid potential flickering if NSWorkspace.shared.frontmostApplication?.bundleIdentifier == lockScreenAppBundleId { return } let toKill = MacWindow.allWindowsMap.filter { $0.value.axWindow.containingWindowId() == nil } // If all windows are "unobservable", it's highly propable that loginwindow might be still active and we are still diff --git a/Sources/AppBundle/tree/frozen/FrozenTree.swift b/Sources/AppBundle/tree/frozen/FrozenTree.swift index dd3d8ca7..66dcf4e9 100644 --- a/Sources/AppBundle/tree/frozen/FrozenTree.swift +++ b/Sources/AppBundle/tree/frozen/FrozenTree.swift @@ -73,6 +73,8 @@ func getWeightOrNil(_ node: TreeNode) -> CGFloat? { ((node.parent as? TilingContainer)?.orientation).map { node.getWeight($0) } } +/// First line of defence against lock screen +/// /// When you lock the screen, all accessibility API becomes unobservable (all attributes become empty, window id /// becomes nil, etc.) which tricks AeroSpace into thinking that all windows were closed. /// That's why every time a window dies AeroSpace caches the "entire world" (unless window is already presented in the cache)