macos: use Ghostty.AppState as @EnvironmentObject

This is a small cleanup change. This provides the Ghostty.AppState
object to any view that needs it within the TerminalSplit view hierarchy
without needing to explicitly define EnvironmentKeys.
This commit is contained in:
Gregory Anders
2023-11-05 20:09:38 -06:00
parent 9b14398153
commit 582df33083
3 changed files with 4 additions and 38 deletions

View File

@@ -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
}