Fix reversed hands scroll in Virtualization framework VM windows

This commit is contained in:
Ian Gulliver
2026-10-22 21:30:06 -07:00
parent f70ee02af4
commit 73291f7c35
+7 -1
View File
@@ -159,9 +159,15 @@ func drag(_ from: CGPoint, _ to: CGPoint) async throws {
}
}
// Marks the deltas as inverted from the device, as natural scrolling does: VM windows undo that to recover the device's
// direction and the guest applies its own natural scrolling, so without it a scroll lands reversed there.
let scrollDirectionInverted = CGEventField(rawValue: 137)!
func scroll(_ p: CGPoint, dx: Int32, dy: Int32) {
post(CGEvent(mouseEventSource: nil, mouseType: .mouseMoved, mouseCursorPosition: p, mouseButton: .left))
post(CGEvent(scrollWheelEvent2Source: nil, units: .line, wheelCount: 2, wheel1: dy, wheel2: dx, wheel3: 0))
let e = CGEvent(scrollWheelEvent2Source: nil, units: .line, wheelCount: 2, wheel1: dy, wheel2: dx, wheel3: 0)
e?.setIntegerValueField(scrollDirectionInverted, value: 1)
post(e)
}
func type(_ s: String) async throws {