macos: background-opacity getter

This commit is contained in:
Mitchell Hashimoto
2023-09-20 22:05:23 -07:00
parent 3ad39dd5e4
commit 960edee559
2 changed files with 18 additions and 9 deletions

View File

@ -15,6 +15,14 @@ class FocusedSurfaceWrapper {
// such as non-native fullscreen.
class PrimaryWindow: NSWindow {
var focusedSurfaceWrapper: FocusedSurfaceWrapper = FocusedSurfaceWrapper()
override var canBecomeKey: Bool {
return true
}
override var canBecomeMain: Bool {
return true
}
static func create(ghostty: Ghostty.AppState, appDelegate: AppDelegate, baseConfig: ghostty_surface_config_s? = nil) -> PrimaryWindow {
let window = PrimaryWindow(
@ -53,12 +61,4 @@ class PrimaryWindow: NSWindow {
return mask
}
override var canBecomeKey: Bool {
return true
}
override var canBecomeMain: Bool {
return true
}
}

View File

@ -81,7 +81,16 @@ extension Ghostty {
guard let ptr = v else { return nil }
return String(cString: ptr)
}
/// The background opacity.
var backgroundOpacity: Double {
guard let config = self.config else { return 1 }
var v: Double = 1
let key = "background-opacity"
_ = ghostty_config_get(config, &v, key, UInt(key.count))
return v;
}
init() {
// Initialize ghostty global state. This happens once per process.
guard ghostty_init() == GHOSTTY_SUCCESS else {