macos: fix various iOS build errors

This commit is contained in:
Mitchell Hashimoto
2025-12-27 14:42:27 -08:00
parent 485b861342
commit d92fe44d0d
3 changed files with 20 additions and 2 deletions

View File

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

View File

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

View File

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