From a754fe8c304675ade2496ddb0e253f5c15c7a4bd Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 7 Mar 2023 22:09:39 -0800 Subject: [PATCH] macos: little tweaks --- macos/Sources/Ghostty/SurfaceView.swift | 15 +++++++++++++++ macos/Sources/GhosttyApp.swift | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) 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 {