Give up focus when opening a tray menu

Closing the panel was not enough: SimpleTopBar stayed frontmost, so
Spotlight's search field never appeared. Deactivate the app when a tray
item is selected so transient panels can take focus, and allow a little
more time before the bar re-hides.

💘 Generated with Crush

Assisted-by: Crush:deepseek-v4.1-flash
This commit is contained in:
2026-09-27 10:30:20 +08:00
parent e465acba12
commit 8d795d0a28
4 changed files with 13 additions and 8 deletions
+7 -2
View File
@@ -133,11 +133,16 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
)
self.popover = popover
// Selecting a tray item must dismiss our panel, otherwise it stays on
// top of the menu that opens (and can strand menus behind it).
// Selecting a tray item must dismiss our panel and give up focus,
// otherwise the panel stays on top of the menu and our app stays
// frontmost, which stops transient items (Spotlight's search field)
// from appearing at all.
Task { @MainActor [weak self] in
MenuBarItemManager.shared.onWillPress = {
self?.popover?.performClose(nil)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
NSApp.deactivate()
}
}
}
}