# extras ## Goal The remaining PowerToys behaviours that are neither input routing nor clipboard: keeping the *other* machines' screens awake while the user is active here (`BlockScreenSaverOnOtherMachines`), not switching away by edge while a fullscreen app has the foreground (`DisableEasyMouseWhenForegroundWindowIsFullscreen` + excluded apps), drawing a cursor on a controlled Mac so the user can see where the remote pointer is (`DrawMouseCursor`/`DrawMouseEx`), plus finishing two paths that exist but were never verified end-to-end (`BlockMouseAtScreenCorners`, `MoveMouseRelatively` with `NextMachine`) and the clipboard-transfer notifications app-ui still owes. This lane ends at **CP3**, after which the app is feature-complete against the 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 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`. ### Promised (to polish) ```swift public final class DisplayAwake { func renew(seconds: TimeInterval); func release() } // MWBMac/Awake.swift public enum Fullscreen { static func frontmostIsFullscreen(excluding: Set) -> Bool } @MainActor public final class CursorOverlay { func show(at: CGPoint); func move(to: CGPoint); func hide() } ``` ## 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; `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. - [ ] **Checkpoint CP3** is the lead's after merge. ## Work log ## QA log ## Review