fixes cursor
This commit is contained in:
@@ -352,6 +352,10 @@ enum WorkspaceRegistry {
|
||||
if lastKey === model { lastKey = nil }
|
||||
}
|
||||
|
||||
static func model(for window: NSWindow) -> WorkspaceModel? {
|
||||
entries.first { $0.window === window }?.model
|
||||
}
|
||||
|
||||
static func becameKey(_ model: WorkspaceModel) {
|
||||
lastKey = model
|
||||
}
|
||||
|
||||
@@ -33,6 +33,9 @@ struct WorkspaceView: View {
|
||||
.overlay {
|
||||
if model.overlay.current == .launcher { RecentProjectsOverlay(model: model) }
|
||||
}
|
||||
.background(PointerRefresher(trigger: PointerRefresher.Trigger(
|
||||
overlay: model.overlay.current, activePath: model.editor?.activePath, visibility: model.layout.visibility,
|
||||
scale: model.layout.textScale)))
|
||||
.onAppear { model.layout.windowResized(width: proxy.size.width) }
|
||||
.onChange(of: proxy.size.width) { _, width in model.layout.windowResized(width: width) }
|
||||
}
|
||||
@@ -142,6 +145,37 @@ private struct HiddenPaneFocusGuard: NSViewRepresentable {
|
||||
}
|
||||
}
|
||||
|
||||
/// Re-reads the pointer when what lies under a still mouse changes: an overlay, the open file, a column shown or hidden.
|
||||
private struct PointerRefresher: NSViewRepresentable {
|
||||
struct Trigger: Equatable {
|
||||
var overlay: Overlay
|
||||
var activePath: String?
|
||||
var visibility: ColumnVisibility
|
||||
var scale: Double
|
||||
}
|
||||
|
||||
let trigger: Trigger
|
||||
|
||||
func makeNSView(context: Context) -> RefresherView {
|
||||
RefresherView()
|
||||
}
|
||||
|
||||
func updateNSView(_ view: RefresherView, context: Context) {
|
||||
view.trigger = trigger
|
||||
}
|
||||
|
||||
final class RefresherView: NSView {
|
||||
var trigger: Trigger? {
|
||||
didSet {
|
||||
guard let oldValue, oldValue != trigger else { return }
|
||||
PointerPolicy.setNeedsRefresh(in: window)
|
||||
}
|
||||
}
|
||||
|
||||
override func hitTest(_ point: NSPoint) -> NSView? { nil }
|
||||
}
|
||||
}
|
||||
|
||||
/// ⌘R lightens a column for a moment and lets it settle back; each new tick replays it.
|
||||
private struct RefreshFlash: ViewModifier {
|
||||
let tick: Int
|
||||
|
||||
Reference in New Issue
Block a user