mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-12-31 18:52:12 +00:00
surfaceview as transferable
This commit is contained in:
@@ -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")
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user