mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
macos: use the configured unfocused split opacity
This commit is contained in:
@ -96,6 +96,7 @@ struct PrimaryView: View {
|
||||
|
||||
Ghostty.TerminalSplit(onClose: Self.closeWindow, baseConfig: self.baseConfig)
|
||||
.ghosttyApp(ghostty.app!)
|
||||
.ghosttyConfig(ghostty.config!)
|
||||
.background(WindowAccessor(window: $window))
|
||||
.onReceive(gotoTab) { onGotoTab(notification: $0) }
|
||||
.onReceive(toggleFullscreen) { onToggleFullscreen(notification: $0) }
|
||||
|
@ -350,15 +350,28 @@ private struct GhosttyAppKey: EnvironmentKey {
|
||||
static let defaultValue: ghostty_app_t? = nil
|
||||
}
|
||||
|
||||
private struct GhosttyConfigKey: EnvironmentKey {
|
||||
static let defaultValue: ghostty_config_t? = nil
|
||||
}
|
||||
|
||||
extension EnvironmentValues {
|
||||
var ghosttyApp: ghostty_app_t? {
|
||||
get { self[GhosttyAppKey.self] }
|
||||
set { self[GhosttyAppKey.self] = newValue }
|
||||
}
|
||||
|
||||
var ghosttyConfig: ghostty_config_t? {
|
||||
get { self[GhosttyConfigKey.self] }
|
||||
set { self[GhosttyConfigKey.self] = newValue }
|
||||
}
|
||||
}
|
||||
|
||||
extension View {
|
||||
func ghosttyApp(_ app: ghostty_app_t?) -> some View {
|
||||
environment(\.ghosttyApp, app)
|
||||
}
|
||||
|
||||
func ghosttyConfig(_ config: ghostty_config_t?) -> some View {
|
||||
environment(\.ghosttyConfig, config)
|
||||
}
|
||||
}
|
||||
|
@ -48,10 +48,20 @@ extension Ghostty {
|
||||
// Maintain whether our window has focus (is key) or not
|
||||
@State private var windowFocus: Bool = true
|
||||
|
||||
@Environment(\.ghosttyConfig) private var ghostty_config
|
||||
|
||||
// This is true if the terminal is considered "focused". The terminal is focused if
|
||||
// it is both individually focused and the containing window is key.
|
||||
private var hasFocus: Bool { surfaceFocus && windowFocus }
|
||||
|
||||
// The opacity of the rectangle when unfocused.
|
||||
private var unfocusedOpacity: Double {
|
||||
var opacity: Double = 0.85
|
||||
let key = "unfocused-split-opacity"
|
||||
_ = ghostty_config_get(ghostty_config, &opacity, key, UInt(key.count))
|
||||
return 1 - opacity
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
// We use a GeometryReader to get the frame bounds so that our metal surface
|
||||
@ -130,7 +140,7 @@ extension Ghostty {
|
||||
Rectangle()
|
||||
.fill(.white)
|
||||
.allowsHitTesting(false)
|
||||
.opacity(0.15)
|
||||
.opacity(unfocusedOpacity)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user