diff --git a/macos/Sources/Ghostty/SurfaceView.swift b/macos/Sources/Ghostty/SurfaceView.swift index aad9f2a75..4c3def0c2 100644 --- a/macos/Sources/Ghostty/SurfaceView.swift +++ b/macos/Sources/Ghostty/SurfaceView.swift @@ -46,6 +46,7 @@ extension Ghostty { GeometryReader { geo in Surface(view: surfaceView, hasFocus: hasFocus, size: geo.size) .focused($surfaceFocus) + .focusedValue(\.ghosttySurfaceView, surfaceView) .navigationTitle(surfaceView.title) } .ghosttySurfaceView(surfaceView) @@ -511,3 +512,17 @@ extension View { environment(\.ghosttySurfaceView, surfaceView) } } + +// MARK: Surface Focus Keys + +extension FocusedValues { + var ghosttySurfaceView: Ghostty.SurfaceView? { + get { self[FocusedGhosttySurface.self] } + set { self[FocusedGhosttySurface.self] = newValue } + } + + struct FocusedGhosttySurface: FocusedValueKey { + typealias Value = Ghostty.SurfaceView + } +} + diff --git a/macos/Sources/GhosttyApp.swift b/macos/Sources/GhosttyApp.swift index 2eb459623..76fe6a1d5 100644 --- a/macos/Sources/GhosttyApp.swift +++ b/macos/Sources/GhosttyApp.swift @@ -11,7 +11,7 @@ struct GhosttyApp: App { /// The ghostty global state. Only one per process. @StateObject private var ghostty = Ghostty.AppState() - @NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate; + @NSApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate var body: some Scene { WindowGroup {