Fixes #8409 https://github.com/user-attachments/assets/c9e7ad9b-c1eb-451b-a537-90f380f5f5f3pull/9589/head
commit
05b42919d5
|
|
@ -133,6 +133,12 @@ class SurfaceScrollView: NSView {
|
|||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
surfaceView.$pointerStyle
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] newStyle in
|
||||
self?.scrollView.documentCursor = newStyle.cursor
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@ extension Ghostty {
|
|||
.focusedValue(\.ghosttySurfaceView, surfaceView)
|
||||
.focusedValue(\.ghosttySurfaceCellSize, surfaceView.cellSize)
|
||||
#if canImport(AppKit)
|
||||
.backport.pointerStyle(surfaceView.pointerStyle)
|
||||
.onReceive(pubBecomeKey) { notification in
|
||||
guard let window = notification.object as? NSWindow else { return }
|
||||
guard let surfaceWindow = surfaceView.window else { return }
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ extension Ghostty {
|
|||
@Published var surfaceSize: ghostty_surface_size_s? = nil
|
||||
|
||||
// Whether the pointer should be visible or not
|
||||
@Published private(set) var pointerStyle: BackportPointerStyle = .default
|
||||
@Published private(set) var pointerStyle: CursorStyle = .horizontalText
|
||||
|
||||
/// The configuration derived from the Ghostty config so we don't need to rely on references.
|
||||
@Published private(set) var derivedConfig: DerivedConfig
|
||||
|
|
@ -477,16 +477,16 @@ extension Ghostty {
|
|||
pointerStyle = .resizeLeftRight
|
||||
|
||||
case GHOSTTY_MOUSE_SHAPE_VERTICAL_TEXT:
|
||||
pointerStyle = .default
|
||||
pointerStyle = .verticalText
|
||||
|
||||
// These are not yet supported. We should support them by constructing a
|
||||
// PointerStyle from an NSCursor.
|
||||
case GHOSTTY_MOUSE_SHAPE_CONTEXT_MENU:
|
||||
fallthrough
|
||||
pointerStyle = .contextMenu
|
||||
|
||||
case GHOSTTY_MOUSE_SHAPE_CROSSHAIR:
|
||||
fallthrough
|
||||
pointerStyle = .crosshair
|
||||
|
||||
case GHOSTTY_MOUSE_SHAPE_NOT_ALLOWED:
|
||||
pointerStyle = .default
|
||||
pointerStyle = .operationNotAllowed
|
||||
|
||||
default:
|
||||
// We ignore unknown shapes.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import Cocoa
|
||||
import SwiftUI
|
||||
|
||||
/// This helps manage the stateful nature of NSCursor hiding and unhiding.
|
||||
class Cursor {
|
||||
|
|
@ -19,7 +20,7 @@ class Cursor {
|
|||
// won't go negative.
|
||||
NSCursor.unhide()
|
||||
|
||||
if (counter > 0) {
|
||||
if counter > 0 {
|
||||
counter -= 1
|
||||
return true
|
||||
}
|
||||
|
|
@ -36,3 +37,82 @@ class Cursor {
|
|||
return counter
|
||||
}
|
||||
}
|
||||
|
||||
enum CursorStyle {
|
||||
case `default`
|
||||
case grabIdle
|
||||
case grabActive
|
||||
case horizontalText
|
||||
case verticalText
|
||||
case link
|
||||
case resizeLeft
|
||||
case resizeRight
|
||||
case resizeUp
|
||||
case resizeDown
|
||||
case resizeUpDown
|
||||
case resizeLeftRight
|
||||
case contextMenu
|
||||
case crosshair
|
||||
case operationNotAllowed
|
||||
}
|
||||
|
||||
extension CursorStyle {
|
||||
var cursor: NSCursor {
|
||||
switch self {
|
||||
case .default:
|
||||
return .arrow
|
||||
case .grabIdle:
|
||||
return .openHand
|
||||
case .grabActive:
|
||||
return .closedHand
|
||||
case .horizontalText:
|
||||
return .iBeam
|
||||
case .verticalText:
|
||||
return .iBeamCursorForVerticalLayout
|
||||
case .link:
|
||||
return .pointingHand
|
||||
case .resizeLeft:
|
||||
if #available(macOS 15.0, *) {
|
||||
return .columnResize(directions: .left)
|
||||
} else {
|
||||
return .resizeLeft
|
||||
}
|
||||
case .resizeRight:
|
||||
if #available(macOS 15.0, *) {
|
||||
return .columnResize(directions: .right)
|
||||
} else {
|
||||
return .resizeRight
|
||||
}
|
||||
case .resizeUp:
|
||||
if #available(macOS 15.0, *) {
|
||||
return .rowResize(directions: .up)
|
||||
} else {
|
||||
return .resizeUp
|
||||
}
|
||||
case .resizeDown:
|
||||
if #available(macOS 15.0, *) {
|
||||
return .rowResize(directions: .down)
|
||||
} else {
|
||||
return .resizeDown
|
||||
}
|
||||
case .resizeUpDown:
|
||||
if #available(macOS 15.0, *) {
|
||||
return .rowResize
|
||||
} else {
|
||||
return .resizeUpDown
|
||||
}
|
||||
case .resizeLeftRight:
|
||||
if #available(macOS 15.0, *) {
|
||||
return .columnResize
|
||||
} else {
|
||||
return .resizeLeftRight
|
||||
}
|
||||
case .contextMenu:
|
||||
return .contextualMenu
|
||||
case .crosshair:
|
||||
return .crosshair
|
||||
case .operationNotAllowed:
|
||||
return .operationNotAllowed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue