Skip to content

Commit

Permalink
4/n Update comments about lines of defence against lock screen
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitabobko committed Nov 27, 2024
1 parent 668bbb5 commit 15ec7d0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Sources/AppBundle/GlobalObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
5 changes: 2 additions & 3 deletions Sources/AppBundle/layout/refresh.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Sources/AppBundle/tree/frozen/FrozenTree.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 15ec7d0

Please sign in to comment.