Skip to content

Commit b07284f

Browse files
committed
fix: raise Sparkle windows above the floating panel
Sparkle's update / progress / installed-version windows are plain NSWindows at .normal level, so the TerminalPanel (level .floating) and the NotchWindow (level .statusBar) both occluded them — users saw 'check for updates' do nothing visible. Watch NSWindow.didBecomeKeyNotification globally and, when the new key window belongs to Sparkle (class or delegate name prefix 'SU' / contains 'Sparkle'), promote it to .popUpMenu and add it to the active space. Also collapses the notch hover so the prompt is unobstructed.
1 parent 5544e6a commit b07284f

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Notchy/AppDelegate.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
4747
}
4848
setupHotkey()
4949
setupUpdater()
50+
observeUpdaterWindows()
5051
FullDiskAccessChecker.promptIfNeeded()
5152

5253
NotificationCenter.default.addObserver(
@@ -57,6 +58,37 @@ class AppDelegate: NSObject, NSApplicationDelegate {
5758
)
5859
}
5960

61+
/// Sparkle's update / progress / installed-version windows are plain
62+
/// NSWindows at .normal level, so our floating TerminalPanel obscures
63+
/// them. Watch every NSWindow that becomes key and, if it's owned by
64+
/// Sparkle, raise it to a level above the panel and the notch pill.
65+
private func observeUpdaterWindows() {
66+
NotificationCenter.default.addObserver(
67+
forName: NSWindow.didBecomeKeyNotification,
68+
object: nil,
69+
queue: .main
70+
) { [weak self] note in
71+
guard let window = note.object as? NSWindow,
72+
Self.isSparkleWindow(window) else { return }
73+
// .popUpMenu (101) is above .floating (3), .statusBar (25), and
74+
// .modalPanel (8) — guarantees the update prompt is reachable
75+
// even with the notch + panel both showing.
76+
window.level = .popUpMenu
77+
window.collectionBehavior.insert(.moveToActiveSpace)
78+
self?.notchWindow?.endHover()
79+
}
80+
}
81+
82+
private static func isSparkleWindow(_ window: NSWindow) -> Bool {
83+
let className = String(describing: type(of: window))
84+
if className.hasPrefix("SU") || className.contains("Sparkle") { return true }
85+
if let delegate = window.delegate {
86+
let delegateClass = String(describing: type(of: delegate))
87+
if delegateClass.hasPrefix("SU") || delegateClass.contains("Sparkle") { return true }
88+
}
89+
return false
90+
}
91+
6092
@objc private func handleCheckForUpdates() {
6193
updaterController?.checkForUpdates(nil)
6294
}

0 commit comments

Comments
 (0)