mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-04-20 00:18:53 +03:00

macOS 12 is officially EOL by Apple and the project only supports officially supported versions of macOS. Once publicly released, users on older macOS versions will have to use older released builds.
38 lines
1.6 KiB
Swift
38 lines
1.6 KiB
Swift
import Cocoa
|
|
|
|
extension NSScreen {
|
|
/// The unique CoreGraphics display ID for this screen.
|
|
var displayID: UInt32? {
|
|
deviceDescription[NSDeviceDescriptionKey("NSScreenNumber")] as? UInt32
|
|
}
|
|
|
|
// Returns true if the given screen has a visible dock. This isn't
|
|
// point-in-time visible, this is true if the dock is always visible
|
|
// AND present on this screen.
|
|
var hasDock: Bool {
|
|
// If the dock autohides then we don't have a dock ever.
|
|
if let dockAutohide = UserDefaults.standard.persistentDomain(forName: "com.apple.dock")?["autohide"] as? Bool {
|
|
if (dockAutohide) { return false }
|
|
}
|
|
|
|
// There is no public API to directly ask about dock visibility, so we have to figure it out
|
|
// by comparing the sizes of visibleFrame (the currently usable area of the screen) and
|
|
// frame (the full screen size). We also need to account for the menubar, any inset caused
|
|
// by the notch on macbooks, and a little extra padding to compensate for the boundary area
|
|
// which triggers showing the dock.
|
|
|
|
// If our visible width is less than the frame we assume its the dock.
|
|
if (visibleFrame.width < frame.width) {
|
|
return true
|
|
}
|
|
|
|
// We need to see if our visible frame height is less than the full
|
|
// screen height minus the menu and notch and such.
|
|
let menuHeight = NSApp.mainMenu?.menuBarHeight ?? 0
|
|
let notchInset: CGFloat = safeAreaInsets.top
|
|
let boundaryAreaPadding = 5.0
|
|
|
|
return visibleFrame.height < (frame.height - max(menuHeight, notchInset) - boundaryAreaPadding)
|
|
}
|
|
}
|