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

@ -16,6 +16,14 @@ class FocusedSurfaceWrapper {
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(
contentRect: NSRect(x: 0, y: 0, width: 800, height: 600),
@ -53,12 +61,4 @@ class PrimaryWindow: NSWindow {
return mask
}
override var canBecomeKey: Bool {
return true
}
override var canBecomeMain: Bool {
return true
}
}

View File

@ -82,6 +82,15 @@ extension Ghostty {
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 {