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

+29 -6
View File
@@ -28,10 +28,20 @@ public struct Jump: Sendable, Equatable {
public enum SwitchAction: Sendable, Equatable {
/// Queue this packet on every connection (`Des` is already set).
case send(Packet)
/// Park the real cursor at the top centre of the primary screen
/// (`HideMouseCursor`, `Common.cs:1482-1496`). `byHideMouseMessage` is the
/// Windows flag: true when a peer asked with `HideMouse (50)`.
case parkCursor(byHideMouseMessage: Bool)
/// Park the cursor at the top centre of the primary screen — the "hidden"
/// position the app also remembers as `LastPos` (`HideMouseCursor`,
/// `Common.cs:1482-1496`).
///
/// **Record the position always; move the real OS cursor only when
/// `destinationIsRemote || byHideMouseMessage`.** That is the whole of the
/// `Common.cs:1488` gate, pre-evaluated here so no consumer has to re-derive
/// it from `desMachineID`: `destinationIsRemote` is
/// `desMachineID != localID && desMachineID != ID.ALL` *after* the switch,
/// and `byHideMouseMessage` is true only when a peer asked with
/// `HideMouse (50)`. Moving the cursor when both are false is a visible bug:
/// control coming home (a `ByeBye`, a disconnect, a hotkey back to this
/// machine) would jerk the user's own cursor to the top of the screen.
case parkCursor(destinationIsRemote: Bool, byHideMouseMessage: Bool)
/// Put the cursor at this switch location; pixel-tagged values mean pixels
/// (`Coordinates.isPixels`, `Helper.cs:100-115`).
case moveCursor(UniversalPoint)
@@ -107,6 +117,13 @@ public final class Switcher {
/// True while input goes to every machine at once (`ID.ALL`).
public var isBroadcasting: Bool { desMachineID == MachineID.all }
/// Whether the machine currently receiving input is a remote one — the
/// `desMachineID != MachineID && desMachineID != ID.ALL` half of the
/// `HideMouseCursor` gate (`Common.cs:1488`).
public var destinationIsRemote: Bool {
desMachineID != localID && desMachineID != MachineID.all
}
/// Whether a machine can be reached right now: itself always, others only
/// with a live socket (`Common.cs:852-855`).
public func isConnected(to id: UInt32) -> Bool {
@@ -197,7 +214,10 @@ public final class Switcher {
let centre = Coordinates.centre(of: edge.config.primary) // MachineStuff.cs:1021-1022
actions.append(.moveCursor(Coordinates.tagPixels(centre)))
actions.append(.parkCursor(byHideMouseMessage: false)) // MachineStuff.cs:1025
// HideMouseCursor(false) after DesMachineID is set (MachineStuff.cs:1025),
// so the gate reads the new destination, not the old one.
actions.append(
.parkCursor(destinationIsRemote: destinationIsRemote, byHideMouseMessage: false))
actions.append(.desMachineChanged(id: desMachineID, name: desMachineName))
return actions
}
@@ -298,7 +318,10 @@ public final class Switcher {
/// Handles `HideMouse (50)`: a peer took control, so park our cursor and let
/// go of every modifier (`Receiver.cs:383-388`).
public func handleHideMouse() -> [SwitchAction] {
[.parkCursor(byHideMouseMessage: true), .releaseAllKeys]
[
.parkCursor(destinationIsRemote: destinationIsRemote, byHideMouseMessage: true),
.releaseAllKeys,
]
}
/// A connection dropped: back-date the machine so it reads as dead, and take