diff --git a/macos/Sources/Features/Terminal/TerminalView.swift b/macos/Sources/Features/Terminal/TerminalView.swift index 6da810690..7596c343a 100644 --- a/macos/Sources/Features/Terminal/TerminalView.swift +++ b/macos/Sources/Features/Terminal/TerminalView.swift @@ -85,8 +85,6 @@ struct TerminalView: View { Ghostty.TerminalSplit(node: $viewModel.surfaceTree) .environmentObject(ghostty) - .ghosttyApp(ghostty.app!) - .ghosttyConfig(ghostty.config!) .focused($focused) .onAppear { self.focused = true } .onChange(of: focusedSurface) { newValue in diff --git a/macos/Sources/Ghostty/AppState.swift b/macos/Sources/Ghostty/AppState.swift index d966d6900..c4e5cc2b7 100644 --- a/macos/Sources/Ghostty/AppState.swift +++ b/macos/Sources/Ghostty/AppState.swift @@ -582,35 +582,3 @@ extension Ghostty { } } } - -// MARK: AppState Environment Keys - -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) - } -} diff --git a/macos/Sources/Ghostty/SurfaceView.swift b/macos/Sources/Ghostty/SurfaceView.swift index 97a347aab..d14602c5d 100644 --- a/macos/Sources/Ghostty/SurfaceView.swift +++ b/macos/Sources/Ghostty/SurfaceView.swift @@ -4,11 +4,11 @@ import GhosttyKit extension Ghostty { /// Render a terminal for the active app in the environment. struct Terminal: View { - @Environment(\.ghosttyApp) private var app + @EnvironmentObject private var ghostty: Ghostty.AppState @FocusedValue(\.ghosttySurfaceTitle) private var surfaceTitle: String? var body: some View { - if let app = self.app { + if let app = self.ghostty.app { SurfaceForApp(app) { surfaceView in SurfaceWrapper(surfaceView: surfaceView) } @@ -48,7 +48,7 @@ extension Ghostty { // Maintain whether our window has focus (is key) or not @State private var windowFocus: Bool = true - @Environment(\.ghosttyConfig) private var ghostty_config + @EnvironmentObject private var ghostty: Ghostty.AppState // 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. @@ -58,7 +58,7 @@ extension Ghostty { private var unfocusedOpacity: Double { var opacity: Double = 0.85 let key = "unfocused-split-opacity" - _ = ghostty_config_get(ghostty_config, &opacity, key, UInt(key.count)) + _ = ghostty_config_get(ghostty.config, &opacity, key, UInt(key.count)) return 1 - opacity }