mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
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:
@ -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,9 +105,17 @@ class FullScreenHandler {
|
|||||||
NSApp.presentationOptions.insert(.autoHideMenuBar)
|
NSApp.presentationOptions.insert(.autoHideMenuBar)
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc func unHideMenu() {
|
@objc func onDidResignMain(_ notification: Notification) {
|
||||||
|
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)
|
NSApp.presentationOptions.remove(.autoHideMenuBar)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@objc func hideDock() {
|
@objc func hideDock() {
|
||||||
NSApp.presentationOptions.insert(.autoHideDock)
|
NSApp.presentationOptions.insert(.autoHideDock)
|
||||||
|
Reference in New Issue
Block a user