mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: adjust fullscreen frame height for notch
The macOS desktop menu-bar grows in total height by adding extra padding to deal with the physical notch found on various MacBook displays. When config `macos-non-native-fullscreen = visible-menu` we apply `safeAreaInsets.top` to reduce frame height.
This commit is contained in:

committed by
Mitchell Hashimoto

parent
7bbe669641
commit
1f30e4e2ed
@ -93,7 +93,7 @@ class FullScreenHandler { var previousTabGroup: NSWindowTabGroup?
|
||||
window.styleMask.remove(.titled)
|
||||
|
||||
// Set frame to screen size, accounting for the menu bar if needed
|
||||
let frame = calculateFullscreenFrame(screenFrame: screen.frame, subtractMenu: !hideMenu)
|
||||
let frame = calculateFullscreenFrame(screen: screen, subtractMenu: !hideMenu)
|
||||
window.setFrame(frame, display: true)
|
||||
|
||||
// Focus window
|
||||
@ -116,12 +116,23 @@ class FullScreenHandler { var previousTabGroup: NSWindowTabGroup?
|
||||
NSApp.presentationOptions.remove(.autoHideDock)
|
||||
}
|
||||
|
||||
func calculateFullscreenFrame(screenFrame: NSRect, subtractMenu: Bool)->NSRect {
|
||||
func calculateFullscreenFrame(screen: NSScreen, subtractMenu: Bool)->NSRect {
|
||||
if (subtractMenu) {
|
||||
let menuHeight = NSApp.mainMenu?.menuBarHeight ?? 0
|
||||
return NSMakeRect(screenFrame.minX, screenFrame.minY, screenFrame.width, screenFrame.height - menuHeight)
|
||||
if let menuHeight = NSApp.mainMenu?.menuBarHeight {
|
||||
var padding: CGFloat = 0
|
||||
if #available(macOS 12, *) {
|
||||
padding = screen.safeAreaInsets.top;
|
||||
}
|
||||
|
||||
return NSMakeRect(
|
||||
screen.frame.minX,
|
||||
screen.frame.minY,
|
||||
screen.frame.width,
|
||||
screen.frame.height - (menuHeight + padding)
|
||||
)
|
||||
}
|
||||
}
|
||||
return screenFrame
|
||||
return screen.frame
|
||||
}
|
||||
|
||||
func leaveFullscreen(window: NSWindow) {
|
||||
|
Reference in New Issue
Block a user