diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView+Transferable.swift b/macos/Sources/Ghostty/Surface View/SurfaceView+Transferable.swift new file mode 100644 index 000000000..af20c9f37 --- /dev/null +++ b/macos/Sources/Ghostty/Surface View/SurfaceView+Transferable.swift @@ -0,0 +1,20 @@ +import CoreTransferable +import UniformTypeIdentifiers + +extension Ghostty.SurfaceView: Transferable { + static var transferRepresentation: some TransferRepresentation { + DataRepresentation(contentType: .ghosttySurfaceId) { surface in + withUnsafeBytes(of: surface.id.uuid) { Data($0) } + } importing: { data in + throw TransferError.importNotSupported + } + } + + enum TransferError: Error { + case importNotSupported + } +} + +extension UTType { + static let ghosttySurfaceId = UTType(exportedAs: "com.mitchellh.ghosttySurfaceId") +} diff --git a/macos/Sources/Ghostty/Surface View/SurfaceView.swift b/macos/Sources/Ghostty/Surface View/SurfaceView.swift index a5e677c54..140266ec5 100644 --- a/macos/Sources/Ghostty/Surface View/SurfaceView.swift +++ b/macos/Sources/Ghostty/Surface View/SurfaceView.swift @@ -227,7 +227,7 @@ extension Ghostty { // Grab handle for dragging the window. We want this to appear at the very // top Z-index os it isn't faded by the unfocused overlay. - SurfaceGrabHandle() + SurfaceGrabHandle(surfaceView: surfaceView) } } @@ -961,6 +961,8 @@ extension Ghostty { struct SurfaceGrabHandle: View { private let handleHeight: CGFloat = 10 + let surfaceView: SurfaceView + @State private var isHovering: Bool = false @State private var isDragging: Bool = false @@ -982,20 +984,12 @@ extension Ghostty { isHovering = hovering } } - .gesture( - DragGesture() - .onChanged { _ in - isDragging = true - } - .onEnded { _ in - isDragging = false - } - ) .backport.pointerStyle(isHovering ? .grabIdle : nil) Spacer() } .frame(maxWidth: .infinity, maxHeight: .infinity) + .draggable(surfaceView) } }