mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 08:16:13 +03:00

Fixes #7114 Supercedes #7271 This fixes a crash that could occur with non-native fullscreen and `fullscreen = true` set at once. The "windowNumber" can be `<= 0` if the window "doesn't have a window device." I don't fully know all the scenarios this is true but it is true when the window is not visible, at least.
13 lines
464 B
Swift
13 lines
464 B
Swift
import AppKit
|
||
|
||
extension NSWindow {
|
||
/// Get the CGWindowID type for the window (used for low level CoreGraphics APIs).
|
||
var cgWindowId: CGWindowID? {
|
||
// "If the window doesn’t have a window device, the value of this
|
||
// property is equal to or less than 0." - Docs. In practice I've
|
||
// found this is true if a window is not visible.
|
||
guard windowNumber > 0 else { return nil }
|
||
return CGWindowID(windowNumber)
|
||
}
|
||
}
|