Merge pull request #862 from mitchellh/mrn/macos-menubar-non-native

macOS: only unhide menu in non-native FS if focus lost to Ghostty
This commit is contained in:
Mitchell Hashimoto
2023-11-11 09:48:13 -08:00
committed by GitHub

View File

@ -83,7 +83,7 @@ class FullScreenHandler {
object: window) object: window)
NotificationCenter.default.addObserver( NotificationCenter.default.addObserver(
self, self,
selector: #selector(FullScreenHandler.unHideMenu), selector: #selector(FullScreenHandler.onDidResignMain),
name: NSWindow.didResignMainNotification, name: NSWindow.didResignMainNotification,
object: window) object: window)
} }
@ -105,8 +105,16 @@ class FullScreenHandler {
NSApp.presentationOptions.insert(.autoHideMenuBar) NSApp.presentationOptions.insert(.autoHideMenuBar)
} }
@objc func unHideMenu() { @objc func onDidResignMain(_ notification: Notification) {
NSApp.presentationOptions.remove(.autoHideMenuBar) guard let resigningWindow = notification.object as? NSWindow else { return }
guard let mainWindow = NSApplication.shared.mainWindow else { return }
// We're only unhiding the menu bar, if the focus shifted within our application.
// In that case, `mainWindow` is the window of our application the focus shifted
// to.
if !resigningWindow.isEqual(mainWindow) {
NSApp.presentationOptions.remove(.autoHideMenuBar)
}
} }
@objc func hideDock() { @objc func hideDock() {