session-matrix: parkCursor carries the HideMouseCursor gate

QA finding 3. HideMouseCursor moves the real cursor only when
(desMachineID != MachineID && desMachineID != ID.ALL) || byHideMouseMessage
(Common.cs:1488), and SwitchToMachine calls it after setting DesMachineID
(MachineStuff.cs:1025) — so control coming home parks nothing. The action
is now .parkCursor(destinationIsRemote:byHideMouseMessage:), both halves
of that gate pre-evaluated by Switcher (new .destinationIsRemote), so
input-inject can implement it without reading the Windows source. Spelled
out as a consumer rule in the README's Handshakes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
lucioandClaude Opus 5 committed 2026-09-16 00:59:29 -07:00
1 parent e0638de0b9
commit 9252158bbc
2 files changed
+42 -7

No files matched your search

+13 -1
View File
@@ -268,7 +268,7 @@ public struct Jump: Sendable, Equatable {
}
public enum SwitchAction: Sendable, Equatable {
case send(Packet) // already addressed
case parkCursor(byHideMouseMessage: Bool)
case parkCursor(destinationIsRemote: Bool, byHideMouseMessage: Bool)
case moveCursor(UniversalPoint) // pixel-tagged means pixels
case releaseAllKeys
case desMachineChanged(id: UInt32, name: String?)
@@ -287,6 +287,7 @@ public final class Switcher { // not Sendable: app-wide
public private(set) var desMachineName: String?
public private(set) var newDesMachineID: UInt32
public var isBroadcasting: Bool { get }
public var destinationIsRemote: Bool { get } // the HideMouseCursor gate
public func isConnected(to id: UInt32) -> Bool
public func crossing(at point: CGPoint, now: TimeInterval) -> Jump?
public func prepareToSwitch(to:landing:now:) -> [SwitchAction]
@@ -317,6 +318,17 @@ Rules the consuming lanes must honour:
**not** `Session.send(_:)` — one broadcast must keep one `Id` across a
peer's two connections or the receiver's replay ring will not collapse
the duplicate.
- **`.parkCursor` records a position; it moves the OS cursor only when
`destinationIsRemote || byHideMouseMessage`.** `Switcher` pre-evaluates
both halves of the `HideMouseCursor` gate (`Common.cs:1488`) so no
consumer needs `desMachineID`, and `destinationIsRemote` is computed
*after* the switch, as `SwitchToMachine` does (`MachineStuff.cs:1025`).
The hidden position (primary screen, horizontal centre, `y = 4` with
`HideMouse` on, else vertical centre) is remembered as `LastPos` every
time, because that is what the cursor is restored to. An injector that
moves unconditionally will jerk the local cursor to the top of the
screen every time control comes home — on every `ByeBye` and every peer
disconnect (`Common.cs:622-625`).
- **`Matrix.live(connectedNames:)` must be given the local machine's own
name**, because the Windows `IsConnectedTo` answers yes for it without a
socket. `Switcher.crossing` adds it; a direct caller must too.