input-capture: handleMouse reads the screen layout only when remote
QA finding 2: `screens.layout` (a locked read) was taken before the destination branch, but only the remote branch uses it. The local branch is what runs for essentially every mouse event while this Mac keeps its own pointer, so it was paying for a lock acquisition it discarded (invariant 4: minimum work on the local path). Moved inside the `isRemote` branch, matching `handleScroll`, which already checked the destination before reading the layout. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
8af26751a8
commit
ece6bbf8fd
1 file changed
+5
-1
@@ -359,10 +359,14 @@ public final class EventTap: @unchecked Sendable {
|
||||
guard let message = EventTap.windowsMessage(for: type, event: event) else {
|
||||
return Unmanaged.passUnretained(event)
|
||||
}
|
||||
let layout = screens.layout
|
||||
let isMove = message.flags == WindowsMessage.mouseMove
|
||||
|
||||
if snapshot.destination.isRemote {
|
||||
// The layout is only read here, on the branch that needs it, so the
|
||||
// local path — every mouse event on a Mac that is not controlling a
|
||||
// peer — pays for no lock it throws away (invariant 4), exactly as
|
||||
// `handleScroll` does.
|
||||
let layout = screens.layout
|
||||
let dx = Double(event.getIntegerValueField(.mouseEventDeltaX))
|
||||
let dy = Double(event.getIntegerValueField(.mouseEventDeltaY))
|
||||
let virtual = routing.advanceVirtualCursor(dx: dx, dy: dy, clampedTo: layout.primary)
|
||||
|
||||
Reference in new issue
Block a user