mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-03 16:36:32 +00:00
Merge pull request #585 from mikdusan/fullscreen
macos: adjust fullscreen frame height for notch
This commit is contained in:
@@ -93,7 +93,7 @@ class FullScreenHandler { var previousTabGroup: NSWindowTabGroup?
|
|||||||
window.styleMask.remove(.titled)
|
window.styleMask.remove(.titled)
|
||||||
|
|
||||||
// Set frame to screen size, accounting for the menu bar if needed
|
// 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)
|
window.setFrame(frame, display: true)
|
||||||
|
|
||||||
// Focus window
|
// Focus window
|
||||||
@@ -116,12 +116,26 @@ class FullScreenHandler { var previousTabGroup: NSWindowTabGroup?
|
|||||||
NSApp.presentationOptions.remove(.autoHideDock)
|
NSApp.presentationOptions.remove(.autoHideDock)
|
||||||
}
|
}
|
||||||
|
|
||||||
func calculateFullscreenFrame(screenFrame: NSRect, subtractMenu: Bool)->NSRect {
|
func calculateFullscreenFrame(screen: NSScreen, subtractMenu: Bool)->NSRect {
|
||||||
if (subtractMenu) {
|
if (subtractMenu) {
|
||||||
let menuHeight = NSApp.mainMenu?.menuBarHeight ?? 0
|
if let menuHeight = NSApp.mainMenu?.menuBarHeight {
|
||||||
return NSMakeRect(screenFrame.minX, screenFrame.minY, screenFrame.width, screenFrame.height - menuHeight)
|
var padding: CGFloat = 0
|
||||||
|
|
||||||
|
// Detect the notch. If there is a safe area on top it includes the
|
||||||
|
// menu height as a safe area so we also subtract that from it.
|
||||||
|
if (screen.safeAreaInsets.top > 0) {
|
||||||
|
padding = screen.safeAreaInsets.top - menuHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
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) {
|
func leaveFullscreen(window: NSWindow) {
|
||||||
|
Reference in New Issue
Block a user