diff --git a/macos/Sources/Ghostty/Surface View/SurfaceGrabHandle.swift b/macos/Sources/Ghostty/Surface View/SurfaceGrabHandle.swift index d35045315..8f4347644 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceGrabHandle.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceGrabHandle.swift @@ -53,6 +53,7 @@ extension Ghostty { // make sure on new drags the screenshot is updated. TimelineView(.periodic(from: .now, by: 1.0 / 30.0)) { _ in if let snapshot = surfaceView.asImage { + #if canImport(AppKit) Image(nsImage: snapshot) .resizable() .aspectRatio(contentMode: .fit) @@ -62,6 +63,17 @@ extension Ghostty { ) .clipShape(RoundedRectangle(cornerRadius: 8)) .shadow(radius: 10) + #elseif canImport(UIKit) + Image(uiImage: snapshot) + .resizable() + .aspectRatio(contentMode: .fit) + .frame( + width: snapshot.size.width * scale, + height: snapshot.size.height * scale + ) + .clipShape(RoundedRectangle(cornerRadius: 8)) + .shadow(radius: 10) + #endif } } } diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView+Transferable.swift b/macos/Sources/Ghostty/Surface View/SurfaceView+Transferable.swift index da4b420d5..da3050eae 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView+Transferable.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView+Transferable.swift @@ -1,4 +1,6 @@ +#if canImport(AppKit) import AppKit +#endif import CoreTransferable import UniformTypeIdentifiers @@ -29,6 +31,7 @@ extension Ghostty.SurfaceView: Transferable { @MainActor static func find(uuid: UUID) -> Self? { + #if canImport(AppKit) for window in NSApp.windows { guard let controller = window.windowController as? BaseTerminalController else { continue @@ -39,6 +42,7 @@ extension Ghostty.SurfaceView: Transferable { } } } + #endif return nil } diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView_UIKit.swift b/macos/Sources/Ghostty/Surface View/SurfaceView_UIKit.swift index eb8a60fd9..f9baf56c9 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView_UIKit.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView_UIKit.swift @@ -4,8 +4,10 @@ import GhosttyKit extension Ghostty { /// The UIView implementation for a terminal surface. class SurfaceView: UIView, ObservableObject { + typealias ID = UUID + /// Unique ID per surface - let uuid: UUID + let id: UUID // The current title of the surface as defined by the pty. This can be // changed with escape codes. This is public because the callbacks go @@ -63,7 +65,7 @@ extension Ghostty { private(set) var surface: ghostty_surface_t? init(_ app: ghostty_app_t, baseConfig: SurfaceConfiguration? = nil, uuid: UUID? = nil) { - self.uuid = uuid ?? .init() + self.id = uuid ?? .init() // Initialize with some default frame size. The important thing is that this // is non-zero so that our layer bounds are non-zero so that our renderer