From a541e2312082a80e054d0482ef672efe4c97f06e Mon Sep 17 00:00:00 2001 From: Lukas <134181853+bo2themax@users.noreply.github.com> Date: Sun, 12 Apr 2026 12:17:33 +0200 Subject: [PATCH] macOS: move `surface` to `OSSurfaceView` --- macos/Sources/Ghostty/Surface View/OSSurfaceView.swift | 4 ++++ .../Sources/Ghostty/Surface View/SurfaceView_AppKit.swift | 2 +- .../Sources/Ghostty/Surface View/SurfaceView_UIKit.swift | 8 ++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/macos/Sources/Ghostty/Surface View/OSSurfaceView.swift b/macos/Sources/Ghostty/Surface View/OSSurfaceView.swift index db712ca3d..e9f49a769 100644 --- a/macos/Sources/Ghostty/Surface View/OSSurfaceView.swift +++ b/macos/Sources/Ghostty/Surface View/OSSurfaceView.swift @@ -48,6 +48,10 @@ extension Ghostty { /// True when the surface should show a highlight effect (e.g., when presented via goto_split). @Published private(set) var highlighted: Bool = false + var surface: ghostty_surface_t? { + nil + } + init(id: UUID?, frame: CGRect) { self.id = id ?? UUID() super.init(frame: frame) diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift b/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift index 75356ceed..726892e18 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView_AppKit.swift @@ -164,7 +164,7 @@ extension Ghostty { private(set) var surfaceModel: Ghostty.Surface? /// Returns the underlying C value for the surface. See "note" on surfaceModel. - var surface: ghostty_surface_t? { + override var surface: ghostty_surface_t? { surfaceModel?.unsafeCValue } /// Current scrollbar state, cached here for persistence across rebuilds diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView_UIKit.swift b/macos/Sources/Ghostty/Surface View/SurfaceView_UIKit.swift index 81981f7fb..3b5034a0e 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView_UIKit.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView_UIKit.swift @@ -14,7 +14,11 @@ extension Ghostty { // The current search state. When non-nil, the search overlay should be shown. @Published var searchState: SearchState? - private(set) var surface: ghostty_surface_t? + private(set) var _surface: ghostty_surface_t? + + override var surface: ghostty_surface_t? { + _surface + } init(_ app: ghostty_app_t, baseConfig: SurfaceConfiguration? = nil, uuid: UUID? = nil) { @@ -32,7 +36,7 @@ extension Ghostty { // TODO return } - self.surface = surface + self._surface = surface } required init?(coder: NSCoder) {