extras: protocol §10.8, feature README, TODO §9
§10.8 records seven findings with citations: the Awake receiver honours the sender's setting and pokes itself with a mouse jiggle; the fullscreen rule is asked once, only by the pointer's owner; the excluded-apps list matches two spellings of the image name; DrawMouseCursor only draws when the real cursor is suppressed; BlockMouseAtCorners is a 100 px square around every monitor corner; relative mode moves edge detection to the controlled machine and gates NextMachine on IsSwitchingByMouseEnabled; both edge paths set HasSwitchedMachineSinceLastCopy. README: Assumptions confirmed, Handshakes updated to the shipped API with four deviations, two open requests (input-capture's easyMouseKeyDown, clipboard's HasSwitchedMachineSinceLastCopy) and the three provisional lines taken in ClipboardBridge.swift, Status ticked, Work log with the corners/relative-mode reading trace. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
21c886165e
commit
39df560fcd
3 files changed
+449
-78
No files matched your search
@@ -189,19 +189,35 @@ concurrency, shared constants, checkpoints) is fixed in `docs/contracts.md`.
|
||||
|
||||
## 9. extras (mac + core) — `Sources/MWBMac/Awake.swift`, `Sources/MWBMac/Fullscreen.swift`, `Sources/MWBMac/FakeCursor.swift`
|
||||
|
||||
- [ ] `BlockScreenSaverOnOtherMachines`: hold an `IOPMAssertion`
|
||||
- [x] `BlockScreenSaverOnOtherMachines`: hold an `IOPMAssertion`
|
||||
(`PreventUserIdleDisplaySleep`) while `Awake` packets arrive within
|
||||
the heartbeat window; release on `Heartbeat`/timeout (§3.3).
|
||||
- [ ] `DisableEasyMouseWhenForegroundWindowIsFullscreen` +
|
||||
Shipped as a 90 s `kIOPMAssertionTimeoutKey` renewed per `Awake`,
|
||||
so the assertion lapses by itself rather than needing a
|
||||
`Heartbeat` to clear it (protocol §10.8 note 1).
|
||||
- [x] `DisableEasyMouseWhenForegroundWindowIsFullscreen` +
|
||||
`EasyMouseFullscreenSwitchBlockExcludedApps`: frontmost app via
|
||||
`NSWorkspace`, fullscreen via the Accessibility API; excluded-apps
|
||||
editor in the settings window.
|
||||
- [ ] `Settings.drawMouseCursor` accessor + the Behaviour-pane toggle
|
||||
editor in the settings window. Shipped via `CGWindowListCopy
|
||||
WindowInfo` bounds rather than the Accessibility API — no extra
|
||||
TCC grant, and it is the test `SHQueryUserNotificationState` is
|
||||
approximating (protocol §10.8 note 3). The editor was already in
|
||||
the Behaviour pane from app-ui.
|
||||
- [x] `Settings.drawMouseCursor` accessor + the Behaviour-pane toggle
|
||||
(app-ui's open request), then `DrawMouseCursor` / `DrawMouseEx`: a borderless transparent overlay
|
||||
window drawing a cursor image where the remote pointer is, so the
|
||||
user sees where the pointer went (Windows `CustomCursor.cs`).
|
||||
- [ ] `BlockMouseAtScreenCorners` end-to-end; `MoveMouseRelatively`
|
||||
end-to-end with `NextMachine` §4.4.
|
||||
`DrawMouseEx` accepted and ignored. Known deviation for CP3: the
|
||||
Windows "only when the real cursor is suppressed" gate has no
|
||||
macOS equivalent (protocol §10.8 note 4).
|
||||
- [x] `BlockMouseAtScreenCorners` end-to-end; `MoveMouseRelatively`
|
||||
end-to-end with `NextMachine` §4.4. Verified by reading against
|
||||
`MachineStuff.cs:203-283`, `Receiver.cs:145-172`,
|
||||
`Common.cs:516-539` and `InputHook.cs:311-312`; corners needed no
|
||||
change. Two gaps recorded in the extras README Handshakes:
|
||||
`NextMachine` ignores the held Ctrl/Shift Easy-Mouse key
|
||||
(input-capture does not publish it), and nothing sets an
|
||||
equivalent of `HasSwitchedMachineSinceLastCopy` (clipboard).
|
||||
- [ ] **Checkpoint CP3** (C5).
|
||||
|
||||
## 10. polish — driven by the user's testing
|
||||
|
||||
+322
-72
@@ -17,97 +17,347 @@ PowerToys module minus README D6.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- **Awake** (`Receiver.cs:245-248` → `Common.HumanBeingDetected`,
|
||||
`Common.cs` — read it: on Windows it nudges the system idle timer /
|
||||
`SetThreadExecutionState`). On a Mac that is being controlled, each
|
||||
`Awake (21)` packet renews an `IOPMAssertionCreateWithName(
|
||||
kIOPMAssertionTypePreventUserIdleDisplaySleep, …)` with a 90 s
|
||||
timeout (`IOPMAssertionTimeoutKey`) so the display stays on while the
|
||||
remote user is active and the assertion lapses on its own when the
|
||||
`Awake`s stop (60 s cadence, §3.3). A plain `Heartbeat` does not renew.
|
||||
`IOKit` is imported only in `MWBMac/Awake.swift`. Nothing is asserted
|
||||
when `BlockScreenSaverOnOtherMachines` is off on the *receiving*
|
||||
side? — No: Windows applies the *sender's* setting (it decides whether
|
||||
to send `Awake`); the receiver always honours it. Port that.
|
||||
- **Fullscreen rule** (`Common.cs` `IsForegroundWindowFullscreen` — find
|
||||
it and the excluded-apps check, cite): before an *edge* switch (not a
|
||||
hotkey switch) the Engine asks `Fullscreen.frontmostIsFullscreen()`,
|
||||
which takes `NSWorkspace.shared.frontmostApplication`, skips it if
|
||||
its bundle identifier or localized name is in
|
||||
`EasyMouseFullscreenSwitchBlockExcludedApps` (case-insensitive, as
|
||||
`StringComparer.OrdinalIgnoreCase`), and otherwise checks whether
|
||||
that app has an on-screen window whose bounds equal a display's
|
||||
bounds, via `CGWindowListCopyWindowInfo(.optionOnScreenOnly)` filtered
|
||||
by `kCGWindowOwnerPID` — bounds are available without Screen
|
||||
Recording permission; window names are not read. Cached for 250 ms
|
||||
so an edge storm does not query per event. When true, the edge
|
||||
candidate is ignored (`Switcher.crossing` is not called).
|
||||
- **Drawn cursor** (`Class/CustomCursor.cs`, `Common.cs` `DrawMouse…`,
|
||||
`Form/frmScreen.cs` — read which machine draws and when; cite): on the
|
||||
Mac being controlled, when `DrawMouseCursor` is on, a borderless,
|
||||
transparent, click-through `NSWindow` (`level = .screenSaver`,
|
||||
`ignoresMouseEvents`, `collectionBehavior = [.canJoinAllSpaces,
|
||||
.stationary]`) shows a standard arrow image at the last injected
|
||||
position and hides when control leaves. `DrawMouseEx` on Windows
|
||||
selects the richer drawing path; here it is accepted and ignored
|
||||
(say so). The overlay is driven from `Injector`'s posted moves via a
|
||||
callback the Engine wires; never from the tap.
|
||||
- **`Settings.drawMouseCursor`** accessor added to `MWBCore/Settings.swift`
|
||||
(authorised; app-ui's open request) and the toggle added to
|
||||
`BehaviourPane.swift` (authorised) in the position PowerToys shows it.
|
||||
- **Corners and relative mode**: read `Engine.considerCrossing`,
|
||||
`Engine.reportEdgeToController`, the `.nextMachine` dispatch case,
|
||||
`Edge`, `Coordinates` and the tap's relative-move encoding, and
|
||||
confirm against `MachineStuff.cs:203-283`, `Receiver.cs:145-172`,
|
||||
`Common.cs:516-539`, `InputHook.cs:311-312` that both settings work
|
||||
end-to-end; fix gaps with cited, minimal edits (authorised in
|
||||
`Engine.swift`/`EngineActions.swift` for those paths only) and record
|
||||
what was verified by reading in the Work log.
|
||||
- **Transfer notifications** (clipboard's open request): when
|
||||
`ShowClipboardAndNetworkStatusMessages` is on, `UIBridge` posts
|
||||
`Notifier` messages for clipboard received/sent/failed using the text
|
||||
`ClipboardAction.note` already carries (authorised edit of
|
||||
`UIBridge.swift`, that path only).
|
||||
- **Permissions**: none of this needs a new TCC grant. IOKit
|
||||
Confirmed against the Windows source while porting; anything that turned
|
||||
out differently is in the Work log and in `docs/protocol.md` §10.8.
|
||||
|
||||
- **Awake** (`Receiver.cs:244-249` → `Common.HumanBeingDetected`,
|
||||
`Common.cs:561-572`, which runs `PokeMyself`, `:574-591`). On Windows
|
||||
the receiver jiggles its own mouse ±9 px ten times to reset the idle
|
||||
timer. The port cannot: CLAUDE.md invariant 5 forbids posting input.
|
||||
Each `Awake (21)` instead renews an
|
||||
`IOPMAssertionTypePreventUserIdleDisplaySleep` assertion with a 90 s
|
||||
`kIOPMAssertionTimeoutKey` and `kIOPMAssertionTimeoutActionRelease`, so
|
||||
the display stays on while the remote user is active and the assertion
|
||||
lapses on its own when the beats stop (60 s cadence, §3.3). A plain
|
||||
`Heartbeat` does not renew it. **Confirmed**: Windows applies the
|
||||
*sender's* `BlockScreenSaver` (it decides whether `Awake` is sent at
|
||||
all, `Common.cs:547`); the receiver checks no setting, and neither do
|
||||
we. `IOKit` is imported only in `MWBMac/Awake.swift`.
|
||||
- **Fullscreen rule** (`Common.IsEasyMouseSwitchAllowed`,
|
||||
`Common.cs:1638-1650`, called only from `Event.cs:79`). Before an
|
||||
*edge* switch — never a hotkey switch, never the relative-mode
|
||||
`NextMachine` path — the Engine asks
|
||||
`Fullscreen.frontmostIsFullscreen(excluding:displays:)`, but only when
|
||||
`DisableEasyMouseWhenForegroundWindowIsFullscreen` is on **and** this
|
||||
Mac currently holds the pointer (`Common.cs:1646`). The check takes
|
||||
`NSWorkspace.shared.frontmostApplication`, skips it when its bundle
|
||||
identifier, localized name or bundle file name (with or without
|
||||
`.app`) is in `EasyMouseFullscreenSwitchBlockExcludedApps`
|
||||
case-insensitively — the two spellings `Common.cs:1597-1599` accepts —
|
||||
and otherwise asks whether that app owns an on-screen
|
||||
`kCGWindowLayer == 0` window whose bounds equal a display's, via
|
||||
`CGWindowListCopyWindowInfo(.optionOnScreenOnly)` filtered by
|
||||
`kCGWindowOwnerPID`. Bounds need no Screen Recording grant; window
|
||||
names are never read. Cached 250 ms, keyed on the excluded set, so an
|
||||
edge storm costs one query.
|
||||
- **Drawn cursor** (`CustomCursor.cs:71-146`, fed from
|
||||
`Receiver.cs:186-188`). On the Mac being controlled, with
|
||||
`DrawMouseCursor` on, a borderless, transparent, click-through
|
||||
`NSWindow` (`level = .screenSaver`, `ignoresMouseEvents`,
|
||||
`collectionBehavior = [.canJoinAllSpaces, .stationary, .ignoresCycle]`)
|
||||
shows `NSCursor.arrow.image` at (x+1, y+1) of the position read back
|
||||
after each injected move, and hides on a park, on local input and at
|
||||
shutdown. **Deviation**: Windows draws only while the real cursor is
|
||||
hidden or suppressed (`GetCursorInfo`, `ci.flags != 1`,
|
||||
`CustomCursor.cs:79`); macOS has no read-only equivalent and the
|
||||
injected moves keep the real pointer visible, so the overlay is a
|
||||
second marker rather than a replacement (protocol §10.8 note 4).
|
||||
`DrawMouseEx` is accepted and ignored.
|
||||
- **`Settings.drawMouseCursor`** accessor added to
|
||||
`MWBCore/Settings.swift` (authorised; app-ui's open request) and the
|
||||
toggle added to `BehaviourPane.swift` after "Hide mouse at the screen
|
||||
edge", the position `MouseWithoutBordersPage.xaml:246-251` shows it in.
|
||||
- **Corners and relative mode**: verified by reading, not by running —
|
||||
see the Work log for the trace. Two gaps found, one fixed with a
|
||||
comment and a Handshake request (`NextMachine` is gated on
|
||||
`EasyMouse == Enable` alone, where Windows also accepts the held
|
||||
Ctrl/Shift Easy-Mouse key), one recorded as the clipboard lane's
|
||||
(`HasSwitchedMachineSinceLastCopy`).
|
||||
- **Transfer notifications** (clipboard's open request): the Engine only
|
||||
logged `ClipboardAction.note`. `UIBridge.TransferNotices` is the wire
|
||||
from there to `Notifier`, which already carries the
|
||||
`ShowClipboardAndNetworkStatusMessages` gate.
|
||||
- **Permissions**: confirmed — none of this needs a new TCC grant. IOKit
|
||||
assertions, `CGWindowList` bounds and overlay windows need nothing.
|
||||
|
||||
## Handshakes
|
||||
|
||||
### Consumed
|
||||
|
||||
- `app-engine`: `Engine` dispatch for `.awake`, the edge path, the
|
||||
injector callback; `Settings` accessors.
|
||||
- `input-inject`: a `Injector.onPointerMoved` hook if one exists — if
|
||||
not, the Engine already knows every injected position and forwards it
|
||||
to the overlay (prefer that; no Injector edit).
|
||||
- `app-ui`: `Notifier`, `BehaviourPane`.
|
||||
- `app-engine`: `Engine.dispatch`, `Engine.pointerPosition()`,
|
||||
`EngineActions.perform(_:)`/`applyConfiguration()`, `Settings`
|
||||
accessors, `Log`, `EventTap.now()`.
|
||||
- `input-capture`: `ScreenLayout.displays`, `Screens.layout`,
|
||||
`EventTap.now()`, `RoutingSnapshot`'s easy-mouse gate on
|
||||
`.edgeCandidate` (nothing changed).
|
||||
- `input-inject`: nothing. The Engine already knows every injected
|
||||
position, so `FakeCursor` is driven from `Engine.dispatch` and
|
||||
`Injector` was not touched.
|
||||
- `app-ui`: `Notifier.post(title:body:)`, `SettingsToggle`,
|
||||
`SettingsViewModel.binding(_:)`.
|
||||
- `clipboard`: `ClipboardAction.note`.
|
||||
|
||||
### Promised (to polish)
|
||||
|
||||
As shipped 2026-09-16.
|
||||
|
||||
```swift
|
||||
public final class DisplayAwake { func renew(seconds: TimeInterval); func release() } // MWBMac/Awake.swift
|
||||
public enum Fullscreen { static func frontmostIsFullscreen(excluding: Set<String>) -> Bool }
|
||||
@MainActor public final class CursorOverlay { func show(at: CGPoint); func move(to: CGPoint); func hide() }
|
||||
// MWBMac/Awake.swift — IOKit lives here and nowhere else
|
||||
public final class DisplayAwake: Sendable {
|
||||
public static let timeout: TimeInterval // 90
|
||||
public init()
|
||||
public var isAsserted: Bool { get }
|
||||
public func renew(seconds: TimeInterval = DisplayAwake.timeout)
|
||||
public func release()
|
||||
}
|
||||
|
||||
// MWBMac/Fullscreen.swift
|
||||
public enum Fullscreen {
|
||||
public static let cacheInterval: TimeInterval // 0.25
|
||||
public static func frontmostIsFullscreen(excluding: Set<String>, displays: [CGRect]) -> Bool
|
||||
public static func invalidate()
|
||||
}
|
||||
|
||||
// MWBMac/FakeCursor.swift
|
||||
public final class FakeCursor: Sendable { // the Engine's door
|
||||
public init()
|
||||
public func setEnabled(_ isOn: Bool)
|
||||
public func show(at point: CGPoint) // CG coordinates
|
||||
public func hide()
|
||||
}
|
||||
@MainActor public final class CursorOverlay { // the window itself
|
||||
public init()
|
||||
public func show(at point: CGPoint)
|
||||
public func hide()
|
||||
}
|
||||
|
||||
// MWBCore/Settings.swift
|
||||
public var drawMouseCursor: Bool { get set } // "DrawMouseCursor"
|
||||
|
||||
// mwb/UIBridge.swift
|
||||
@MainActor enum TransferNotices {
|
||||
static func install(_ notifier: Notifier?)
|
||||
static func post(_ text: String)
|
||||
}
|
||||
```
|
||||
|
||||
Four deviations from the shape this section sketched at planning time:
|
||||
|
||||
- **`Fullscreen.frontmostIsFullscreen` takes `displays:`.** The sketch had
|
||||
it read the display list itself; passing `ScreenLayout.displays` in
|
||||
means nothing here queries CoreGraphics for geometry the Engine already
|
||||
holds, and it keeps the 250 ms cache honest.
|
||||
- **`CursorOverlay` has no `move(to:)`, and is fronted by `FakeCursor`.**
|
||||
Windows has one call, `ShowFakeMouseCursor(x, y)`, with `int.MinValue`
|
||||
meaning hide, so `show(at:)` + `hide()` is the whole surface. The
|
||||
overlay stays `@MainActor` as the brief requires; `FakeCursor` is the
|
||||
nonisolated, `Sendable` door the Engine actor calls, and it coalesces —
|
||||
the latest wanted state under a lock, at most one main-thread hop
|
||||
scheduled — because a controlled Mac takes up to a hundred mouse
|
||||
packets a second and one `Task` each would both allocate and arrive out
|
||||
of order.
|
||||
- **`DisplayAwake.renew()` re-creates the assertion rather than extending
|
||||
one.** Once a minute, and it means the assertion's own timeout is the
|
||||
only lifetime rule; an assertion we somehow fail to release cannot
|
||||
outlive 90 s.
|
||||
- **`TransferNotices` is a `@MainActor` static rendezvous**, not a
|
||||
property on the Engine: the Engine is an actor, `Notifier` is
|
||||
`@MainActor`, and there is exactly one of each per process.
|
||||
|
||||
### Requested of input-capture (open)
|
||||
|
||||
1. **`EventTap.easyMouseKeyDown` is not published, so relative mode
|
||||
ignores `NextMachine` when Easy Mouse is set to Ctrl or Shift.**
|
||||
Windows gates the `NextMachine` handler on
|
||||
`Event.IsSwitchingByMouseEnabled()` (`Receiver.cs:198`), which is
|
||||
`EasyMouse == Enable` **or** the Easy-Mouse modifier being held
|
||||
(`Event.cs:152-155`). The tap owns that second half
|
||||
(`EventTap.swift:93, 349-353`) and already applies it to
|
||||
`.edgeCandidate`, but the Engine cannot read it, so
|
||||
`Engine.dispatch`'s `.nextMachine` case tests the setting alone. A
|
||||
`var easyMouseKeyDown: Bool { get }` on `EventTap`, or the flag in
|
||||
`RoutingSnapshot`, closes it. Commented at the call site; not worked
|
||||
around.
|
||||
|
||||
### Requested of clipboard / app-engine (taken provisionally — the lead rules at review)
|
||||
|
||||
The brief authorised `UIBridge.swift` for the transfer notifications, but
|
||||
the note never leaves the Engine: `ClipboardAction.note` is consumed in
|
||||
`Sources/mwb/ClipboardBridge.swift`, which belongs to the clipboard lane.
|
||||
Three one-line additions were made there rather than silently widening
|
||||
the scope; revert them and the notifications are inert but nothing else
|
||||
changes.
|
||||
|
||||
1. `perform(_ actions: [ClipboardAction])`, `case .note`: also
|
||||
`Task { @MainActor in TransferNotices.post(text) }`.
|
||||
2. `clipboardFailed(_:)`: the same, for the bulk channel's failures
|
||||
(`Clipboard.cs:916`).
|
||||
3. `commitReceivedFile(staged:name:)`, on success: the same, with
|
||||
"Received <name>." (`Clipboard.cs:869-881`).
|
||||
|
||||
There is no `.note` for a *send*, and none was invented: Windows' only
|
||||
send-side balloon is "Connecting to <machine>" (`Clipboard.cs:451`),
|
||||
which our `Notifier.connected(to:)` already covers from the control
|
||||
channel.
|
||||
|
||||
### Requested of clipboard (open)
|
||||
|
||||
1. **`HasSwitchedMachineSinceLastCopy` has no equivalent.** Windows sets
|
||||
it on both edge paths (`Event.cs:81`, `Receiver.cs:160`), on
|
||||
`HideMouse` (`Receiver.cs:384`) and in `Helper.cs:320`, and it
|
||||
suppresses the "same content as last time" short-circuit exactly once
|
||||
(`Clipboard.cs:130-139, 206-215`). Without it, copying the same text
|
||||
again after a machine switch can be dropped where Windows resends it.
|
||||
`ClipboardBridge.swift` is the clipboard lane's file; recorded in
|
||||
protocol §10.8 note 7.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [ ] `Sources/MWBMac/Awake.swift` + Engine `.awake` hook
|
||||
(`Receiver.cs:245-248`, `Common.cs` HumanBeingDetected).
|
||||
- [ ] `Sources/MWBMac/Fullscreen.swift` + edge-path hook + excluded apps
|
||||
(`Common.cs` IsForegroundWindowFullscreen and callers).
|
||||
- [ ] `Sources/MWBCore/Settings.swift` `drawMouseCursor` accessor;
|
||||
- [x] `Sources/MWBMac/Awake.swift` + Engine `.awake` hook
|
||||
(`Receiver.cs:244-249`, `Common.cs:561-591`).
|
||||
- [x] `Sources/MWBMac/Fullscreen.swift` + edge-path hook + excluded apps
|
||||
(`Common.cs:1562-1650`, called from `Event.cs:79`).
|
||||
- [x] `Sources/MWBCore/Settings.swift` `drawMouseCursor` accessor;
|
||||
`Sources/MWBMac/SettingsWindow/BehaviourPane.swift` toggle.
|
||||
- [ ] `Sources/MWBMac/FakeCursor.swift` + Engine wiring
|
||||
(`CustomCursor.cs`, `frmScreen.cs` drawing path).
|
||||
- [ ] Corners + relative mode verified end-to-end by reading; gaps fixed
|
||||
(`Sources/mwb/Engine.swift`, `EngineActions.swift`, authorised).
|
||||
- [ ] `Sources/mwb/UIBridge.swift`: clipboard transfer notifications.
|
||||
- [ ] `docs/protocol.md`: append §10.8 with anything learned, cited.
|
||||
- [x] `Sources/MWBMac/FakeCursor.swift` + Engine wiring
|
||||
(`CustomCursor.cs:71-146`, `Receiver.cs:186-188`).
|
||||
- [x] Corners + relative mode verified end-to-end by reading; one gap
|
||||
fixed by citation and a Handshake request, one recorded as the
|
||||
clipboard lane's (see the Work log).
|
||||
- [x] `Sources/mwb/UIBridge.swift`: clipboard transfer notifications
|
||||
(three provisional lines in `ClipboardBridge.swift`, flagged above).
|
||||
- [x] `docs/protocol.md`: §10.8 appended, seven notes, all cited.
|
||||
- [ ] **Checkpoint CP3** is the lead's after merge.
|
||||
|
||||
## Work log
|
||||
|
||||
### 2026-09-16 (dev)
|
||||
|
||||
**Read first**: `CLAUDE.md`, `README.md`, `docs/protocol.md` §3.3,
|
||||
§4.3-§4.4, §10.1-§10.7, `docs/contracts.md`, `docs/topo.md`, and the
|
||||
Handshakes and Review sections of app-engine, app-ui, input-inject,
|
||||
input-capture, clipboard and session-matrix.
|
||||
|
||||
**Awake.** `DisplayAwake` holds one `IOPMAssertionCreateWithProperties`
|
||||
assertion with `kIOPMAssertionTimeoutKey: 90` and
|
||||
`kIOPMAssertionTimeoutActionRelease`; `renew()` creates the new one
|
||||
before releasing the old so the display is never momentarily unasserted,
|
||||
and `Engine.stop()` releases. Hooked by splitting `.awake` out of the
|
||||
`.heartbeat, .heartbeatEx, .awake, .hello` case in `Engine.dispatch`, so
|
||||
it still learns the sender (`switcher.learn`) and then renews, in
|
||||
`Receiver.cs:244-249` order. **Decision**: the Windows `PokeMyself`
|
||||
jiggle is not ported, at all — invariant 5. **Decision**: no gate on our
|
||||
own `BlockScreenSaverOnOtherMachines`; that setting is the sender's, and
|
||||
`Common.HumanBeingDetected` checks nothing (protocol §10.8 note 1).
|
||||
Autolinking picks `IOKit` up from `import IOKit.pwr_mgt`; `Package.swift`
|
||||
needed no change.
|
||||
|
||||
**Fullscreen.** `Fullscreen.frontmostIsFullscreen(excluding:displays:)`
|
||||
with a 250 ms cache keyed on the excluded set, called from
|
||||
`Engine.easyMouseSwitchAllowed()`, which reproduces
|
||||
`IsEasyMouseSwitchAllowed`'s two early outs. Placed in
|
||||
`considerCrossing` *after* `switcher.crossing`, because `Event.cs:79`
|
||||
asks in that order and `crossing` is what updates `LastX`/`LastY`.
|
||||
Finder is treated as the Windows shell/desktop early-out
|
||||
(`Common.cs:1607-1612`). **Deviation**: `SHQueryUserNotificationState`
|
||||
has no macOS twin, so the test is "the frontmost app owns an on-screen
|
||||
layer-0 window whose bounds equal a display's" — a zoomed window stops
|
||||
below the menu bar, a native full-screen one does not, which is the
|
||||
discrimination the Windows call is making. 1-point tolerance.
|
||||
|
||||
**Drawn cursor.** `FakeCursor` (nonisolated, coalescing) +
|
||||
`CursorOverlay` (`@MainActor`, the window). Shown from `Engine.dispatch`
|
||||
after injecting a `.mouse` packet, at `pointerPosition()` — the port of
|
||||
`Receiver.cs:186-188`'s inject → `GetCursorPos` → draw. Hidden from
|
||||
`SwitchAction.parkCursor` (`Common.cs:1495`), from `drainCapture` when
|
||||
real local input arrives and the destination is not remote
|
||||
(`InputHook.cs:256-264`, where `local` means `NewDesMachineID` is us or
|
||||
`ALL`), and in `Engine.stop()`. `applyConfiguration()` follows the
|
||||
setting, which is `Setting.cs:97-101`'s behaviour of hiding the moment
|
||||
the box is unticked. **Deviation, flagged for CP3**: the Windows
|
||||
`ci.flags != 1` gate cannot be ported (protocol §10.8 note 4), so with
|
||||
`DrawMouseCursor` at its PowerToys default of `true` a controlled Mac
|
||||
shows the overlay *beside* its own real pointer. The default is kept
|
||||
(README D3 says the schema matches PowerToys); if the second arrow reads
|
||||
as a bug at CP3, the fix is a macOS-specific default of `false`, not a
|
||||
change here.
|
||||
|
||||
**Behaviour pane.** The toggle went in after "Block mouse at screen
|
||||
corners", matching `MouseWithoutBordersPage.xaml:240-251`. The two
|
||||
`NotYetActive` footnotes were replaced by one: the first said clipboard
|
||||
sharing, file transfer and screen-saver blocking were inert, which
|
||||
stopped being true with the clipboard lane and this one, and the second
|
||||
said the drawn cursor was not shown here, which this change undoes.
|
||||
Leaving either in place would have been a false statement in the UI.
|
||||
|
||||
**Corners and relative mode, verified by reading.** No code change was
|
||||
needed for the corner path and none was made.
|
||||
|
||||
- Corners. `Settings.blockMouseAtScreenCorners` →
|
||||
`EngineActions.applyConfiguration()` →
|
||||
`ScreenLayout.edgeConfig(blockCorners:moveRelatively:)` →
|
||||
`Switcher.edge.config`, re-applied on every settings change and every
|
||||
display change (`Engine.handle(.screensChanged)`). `ScreenLayout.
|
||||
current()` builds `corners` as the four corners of every active
|
||||
display in `WinAPI.cs:106-109` order, and `CGDisplayBounds`'
|
||||
`maxX`/`maxY` are exclusive exactly as `rcMonitor.Right`/`Bottom` are.
|
||||
`Edge.isNearCorner` is `abs(dx) < 100 && abs(dy) < 100` over that list
|
||||
— the Chebyshev square of `MachineStuff.cs:228`, not a radius — and it
|
||||
sits between the debounce and the edge comparisons, as at
|
||||
`MachineStuff.cs:217-234`, so a blocked switch still records
|
||||
`lastX`/`lastY`. Because the check is inside `Edge.crossing`, it
|
||||
applies on both callers: the controller's edge path and the controlled
|
||||
machine's relative-mode path, which is also true of the one Windows
|
||||
function.
|
||||
- Relative mode, controller → wire. `EventTap.remotePosition` tags every
|
||||
delta with `Coordinates.tagRelative` when `moveMouseRelatively`,
|
||||
including a zero delta, which is `InputHook.cs:311-312`; that is why
|
||||
`Event.cs:105`'s `|dx| >= MOVE_MOUSE_RELATIVE && |dy| >= …` test always
|
||||
takes the relative branch in this mode, and why
|
||||
`Coordinates.isRelative` tests **both** axes (`Receiver.cs:147`).
|
||||
`EventTap.offerEdgeCandidate` refuses to propose an edge while the
|
||||
destination is remote and the mode is on, which is `Event.cs:73`'s
|
||||
`(DesMachineID == MachineID || !MoveMouseRelatively)`.
|
||||
- Relative mode, controlled machine. `Engine.dispatch`'s `.mouse` case
|
||||
runs `takeControlBack()` (`Receiver.cs:122-125`), injects — and
|
||||
`Injector.injectMouse` reads the tag, adds the delta to the current
|
||||
pointer for a move and re-reads the pointer for a button or wheel,
|
||||
which is `Receiver.cs:151-153` and `:170-176` — then
|
||||
`reportEdgeToController`, which requires `WM_MOUSEMOVE` and a relative
|
||||
tag, reads `pointerPosition()` (`GetCursorPos`, `Receiver.cs:154`) and
|
||||
calls `switcher.crossing`. `Switcher.crossing` computes
|
||||
`cursorIsLocal = desMachineID == localID`, which is true here because
|
||||
`takeControlBack` has just made it so — the same thing Windows gets by
|
||||
passing `Common.MachineID` explicitly at `Receiver.cs:156`. The reply
|
||||
is `Switcher.nextMachinePacket`, rate-limited to one per 100 ms
|
||||
(`Common.cs:516-524`), `Des` = the controller, `Md.X/Y` = the landing
|
||||
point, `Md.WheelDelta` = the target id (§4.4). Note that the
|
||||
`lastJump` debounce inside `Edge.crossing` is dead on this side, in our
|
||||
port and in Windows alike, because only `prepareToSwitch` /
|
||||
`PrepareToSwitchToMachine` writes it and the controlled machine never
|
||||
calls either (protocol §10.8 note 6).
|
||||
- Relative mode, back on the controller. `.nextMachine` →
|
||||
`switcher.prepareToSwitch(to: UInt32(bitPattern: wheelDelta), landing:
|
||||
(x, y))`, which is `Receiver.cs:195-201`. **Gap found**: the guard is
|
||||
`settings.easyMouse == .enable`, where Windows also accepts the held
|
||||
Ctrl/Shift Easy-Mouse key (`Event.cs:152-155`). The flag lives in the
|
||||
tap and is not published, so the gap is cited at the call site and
|
||||
filed as a Handshake request to input-capture rather than worked
|
||||
around. **Second gap, not ours**: neither edge path sets anything like
|
||||
`Clipboard.HasSwitchedMachineSinceLastCopy`; filed to the clipboard
|
||||
lane and recorded in protocol §10.8 note 7.
|
||||
|
||||
**Transfer notifications.** `TransferNotices` in `UIBridge.swift`, with
|
||||
the notifier installed in `UIBridge.start()` and dropped in `stop()`.
|
||||
Feeding it needed three one-line additions in the clipboard lane's
|
||||
`ClipboardBridge.swift`; they are listed in Handshakes above rather than
|
||||
made silently.
|
||||
|
||||
**Verification**: build-only, as the brief requires. Nothing here was
|
||||
executed: no app launched, no tap created, no event posted, no overlay
|
||||
window made, no IOKit assertion taken and no notification posted.
|
||||
`tools/gates.sh` green under `tools/guard.sh`.
|
||||
|
||||
## QA log
|
||||
|
||||
## Review
|
||||
@@ -1068,3 +1068,108 @@ sees them. One subsection per lane, appended, never rewritten.
|
||||
**not** exempt from the replay ring, so exactly one terminator arrives; a
|
||||
copy that arrives wholly after the terminator starts a reassembly that can
|
||||
never finish and is dropped by the idle timeout.
|
||||
|
||||
### 10.8 extras (2026-09-16)
|
||||
|
||||
1. **The `Awake (21)` receiver has no setting of its own; it pokes the
|
||||
*machine*, not the network.** `Receiver.cs:244-249` answers `Awake` with
|
||||
`AddToMachinePool` plus `Common.HumanBeingDetected()`, and that method
|
||||
(`Common.cs:561-572`) consults nothing but `lastInputEventCount`,
|
||||
`RunOnLogonDesktop`, `RunOnScrSaverDesktop` and `IsMyDesktopActive()` — never
|
||||
`BlockScreenSaver`. The setting is the *sender's*
|
||||
(`SendAwakeBeat`, `Common.cs:545-559`, which needs it to send `Awake` at all
|
||||
rather than `Heartbeat`), so a receiver honours a peer's wish
|
||||
unconditionally. What the receiver then does is `PokeMyself()`
|
||||
(`Common.cs:574-591`): ten ±9-pixel *relative mouse moves*, 50 ms apart,
|
||||
abandoned early if the local user moves — a jiggle, because resetting the
|
||||
Windows idle timer from user mode means faking input. Two consequences for
|
||||
the port: the counter `lastInputEventCount` is shared with `SendAwakeBeat`
|
||||
(`Common.cs:542-543, 557-559`), so a machine whose own user is busy never
|
||||
pokes itself; and the mac port cannot copy the mechanism at all — CLAUDE.md
|
||||
invariant 5 forbids posting input — so it renews an
|
||||
`IOPMAssertionTypePreventUserIdleDisplaySleep` assertion with a 90 s
|
||||
`kIOPMAssertionTimeoutKey` instead, which is the effect Windows is reaching
|
||||
for and lapses by itself when the 60 s beats stop (§3.3).
|
||||
|
||||
2. **The fullscreen rule is asked in exactly one place, and only by the machine
|
||||
that owns the pointer.** `Common.IsEasyMouseSwitchAllowed`
|
||||
(`Common.cs:1638-1650`) has two early outs — the setting being off, and
|
||||
`DesMachineID != MachineID` ("never prevent a switch if we are not moving out
|
||||
of the host machine") — and its only caller is `Event.cs:79`, on the
|
||||
controller's edge path, *after* `MoveToMyNeighbourIfNeeded` has already said a
|
||||
switch would happen. The relative-mode path on the controlled machine
|
||||
(`Receiver.cs:156-170`) never consults it, and neither does the `NextMachine`
|
||||
handler (`:195-201`). So a full-screen app on a machine that is *being
|
||||
controlled* blocks nothing, and a blocked switch still updates
|
||||
`Common.LastX`/`LastY` (`MachineStuff.cs:207-215`) because the geometry ran
|
||||
first.
|
||||
|
||||
3. **The excluded-apps list is matched twice, against two spellings of the
|
||||
process image.** `IsAppIgnoredByEasyMouseFullscreenCheck`
|
||||
(`Common.cs:1567-1600`) resolves the foreground window's process to a full
|
||||
image path with `QueryFullProcessImageName` and then tests the set for both
|
||||
`Path.GetFileNameWithoutExtension(name)` and `Path.GetFileName(name)` with
|
||||
`StringComparer.OrdinalIgnoreCase` — so `msedge` and `msedge.exe` both work,
|
||||
in any case. The mac port keeps that shape by testing the frontmost app's
|
||||
bundle identifier, its localized name, and its bundle's file name with and
|
||||
without the `.app` extension. The fullscreen question itself is
|
||||
`SHQueryUserNotificationState` on Windows (BUSY, RUNNING_D3D_FULL_SCREEN or
|
||||
PRESENTATION_MODE, `Common.cs:1618-1624`); macOS has no such call, so the port
|
||||
asks whether the frontmost app has an on-screen `kCGWindowLayer == 0` window
|
||||
whose bounds equal a display's — a zoomed window stops below the menu bar and
|
||||
a native full-screen one does not.
|
||||
|
||||
4. **`DrawMouseCursor` only draws when the real cursor is already gone.**
|
||||
`CustomCursor.ShowFakeMouseCursor` (`CustomCursor.cs:71-146`) checks
|
||||
`Setting.Values.DrawMouse` *and* `GetCursorInfo(out ci)` with `ci.flags != 1`
|
||||
— "the cursor is hidden or suppressed" — and when the real cursor is visible
|
||||
it closes and disposes the form instead. The feature exists for Windows 10+
|
||||
machines with no physical mouse attached, where the injected `SendInput` moves
|
||||
do not light the cursor up. `int.MinValue` in either coordinate means hide,
|
||||
via a three-call latch (`hiding = 3`, decremented per call, `:88-96`), and the
|
||||
form is a 32×32 top-most window placed at `(x + 1, y + 1)` (`:100-103`). It is
|
||||
fed from `Receiver.cs:186-188` — inject, `GetCursorPos` into
|
||||
`Common.LastX/LastY`, draw — and cleared from `Common.HideMouseCursor`
|
||||
(`Common.cs:1495`), the three `Helper` form routines (`Helper.cs:192, 224,
|
||||
244`) and the mouse hook when the local user moves (`InputHook.cs:256-264`,
|
||||
where `local` means `NewDesMachineID` is us or `ALL`). On a Mac the injected
|
||||
`CGEvent` moves *do* move the visible pointer, so the port has no equivalent
|
||||
of the `ci.flags` gate and the overlay is a second marker rather than a
|
||||
replacement; `DrawMouseEx`, which paints pixels straight onto the desktop DC
|
||||
(`frmMouseCursor.cs:32-52`), is accepted and ignored.
|
||||
|
||||
5. **`BlockMouseAtCorners` is a 100-pixel square, not a radius, around all four
|
||||
corners of every monitor.** The test is
|
||||
`Math.Abs(p.X - x) < 100 && Math.Abs(p.Y - y) < 100` over `WinAPI.
|
||||
SensitivePoints` (`MachineStuff.cs:222-234`), and that list is rebuilt by
|
||||
`GetScreenConfig`'s monitor enumeration as
|
||||
`(Left,Top) (Right,Top) (Right,Bottom) (Left,Bottom)` per monitor
|
||||
(`WinAPI.cs:104-109`) — exclusive right and bottom, like `CGDisplayBounds`.
|
||||
The check sits between the debounce and the edge comparisons, so it suppresses
|
||||
the switch without suppressing the `LastX`/`LastY` bookkeeping.
|
||||
|
||||
6. **In relative mode the controller does not look at edges at all, and the
|
||||
`NextMachine` it gets back is gated on Easy Mouse.** `Event.cs:73` runs
|
||||
`MoveToMyNeighbourIfNeeded` only when
|
||||
`DesMachineID == MachineID || !MoveMouseRelatively`, so while a remote machine
|
||||
is being driven relatively the controller's own hook never proposes a switch;
|
||||
the controlled machine does it (`Receiver.cs:154-170`) and replies with
|
||||
`NextMachine (121)`. The controller's acceptance test for that packet is
|
||||
`Event.IsSwitchingByMouseEnabled()` (`Receiver.cs:198`), which is
|
||||
`EasyMouse == Enable` **or** `InputHook.EasyMouseKeyDown`
|
||||
(`Event.cs:152-155`) — the Ctrl/Shift Easy-Mouse key being held — not the
|
||||
setting alone. Note also that the two 100 ms debounces are different clocks:
|
||||
`MoveToMyNeighbourIfNeeded`'s is `lastJump` (`MachineStuff.cs:217`), written
|
||||
only by `PrepareToSwitchToMachine` (`Event.cs:190`), which the controlled
|
||||
machine never calls — so on that side the debounce that actually applies is
|
||||
`SendNextMachine`'s own `lastSendNextMachine` (`Common.cs:516-524`).
|
||||
|
||||
7. **Both edge paths set `Clipboard.HasSwitchedMachineSinceLastCopy`.** The
|
||||
controller at `Event.cs:81` and the controlled machine at `Receiver.cs:160`,
|
||||
as well as `Receiver.cs:384` (`HideMouse`) and `Helper.cs:320`. The flag
|
||||
suppresses the "same content as last time" short-circuit exactly once
|
||||
(`Clipboard.cs:130-139` for text, `:206-215` for the byte path), so copying
|
||||
the same text again after a machine switch still re-sends it. Our
|
||||
`ClipboardBridge` has no equivalent, which means a second copy of identical
|
||||
content after a switch may be dropped where Windows would resend it — recorded
|
||||
here rather than fixed, since it is the clipboard lane's state.
|
||||
Reference in new issue
Block a user