diff --git a/Sources/MWBMac/KeyState.swift b/Sources/MWBMac/KeyState.swift index 2a8558e..77b1254 100644 --- a/Sources/MWBMac/KeyState.swift +++ b/Sources/MWBMac/KeyState.swift @@ -162,6 +162,12 @@ public struct KeyState: Sendable { // through the switch. Both paths lock, so the duplication is harmless. private mutating func processDown(vk: Int32, lockMachine: Hotkey) -> KeyDecision { var decision = KeyDecision.inject + // No equivalent of Windows' `if (!Common.RunOnLogonDesktop && + // !Common.RunOnScrSaverDesktop)` (`InputSimulation.cs:408-409`): those + // flags are set only for the copy the MWB service runs on a secure + // desktop (`Program.cs:150-167`), which macOS has no analogue of and + // which is out of scope anyway (README D6, docs/protocol.md §10.5 + // note 8). The gate is unconditionally open here, deliberately. if lockMachine.matches(vk: vk, modifiers: chord) { resetChord(keeping: lockMachine) // ResetModifiersState, :364-370 decision = KeyDecision(eatKey: true, releaseAllKeys: true, lockMachine: true) diff --git a/docs/features/input-inject/README.md b/docs/features/input-inject/README.md index 31dc5cc..08e9474 100644 --- a/docs/features/input-inject/README.md +++ b/docs/features/input-inject/README.md @@ -86,6 +86,28 @@ work log. *this* Mac's setting, which is how the lock hotkey actually reaches a peer (§10.5 note 2). `InjectorConfig.lockMachine` carries it. Ctrl+Alt+End is not eaten by Windows, so the key still posts here. + ***(amended)*** The chord booleans and the lock-hotkey test are fed the + **raw** VK off the wire, never `KeyState.normalise(vk:)`'s output: + `InputProcessKeyEx`'s two switches are side-specific only + (`InputSimulation.cs:372-403` up, `:418-438` down) and `HotkeyMatched` + (`:406`) gets the raw `vkCode`, so a side-less `VK_SHIFT`/`VK_CONTROL`/ + `VK_MENU` — which the lock-chord replay sends — moves nothing + (docs/protocol.md §10.5 note 3). `normalise(vk:)` is the posting path alone. +- **Windows' desktop gate on the lock hotkey is considered and + inapplicable, so the hotkey is always eaten and always locks.** + `InputSimulation.cs:408-409` skips the `HotKeyLockMachine` branch when + `Common.RunOnLogonDesktop` or `Common.RunOnScrSaverDesktop` is set. + Those flags are set only where the MWB **service** launches a second + copy of the process onto the `Winlogon` or `Screen-saver` secure + desktop (`Program.cs:150-167`, `Common.cs:176-186`). macOS has no + secure-desktop session split — one process per login session, no copy + of us running behind `loginwindow` or the screen saver, and a + user-space `CGEventTap` neither receives nor posts once the screen is + locked — and the Windows service is out of scope anyway (README D6). + `KeyState.processDown` therefore has no guard: a decision, not an + omission. Recorded as docs/protocol.md §10.5 note 8. (The hardcoded Win+L + branch `:450-460` is ungated on Windows too, so it was never in + question.) - **`releaseAll()`** posts key-up for every key and button the injector believes is down — a superset of Windows' fixed modifier list (`InitAndCleanup.cs:214-243`) because a lost key-up for a letter is as diff --git a/docs/protocol.md b/docs/protocol.md index 07f4506..8a6294e 100644 --- a/docs/protocol.md +++ b/docs/protocol.md @@ -852,3 +852,21 @@ sees them. One subsection per lane, appended, never rewritten. mouse's wheel is also a CP1 question; we post `.line` units with the sign the capture side reads, so the two halves agree with each other whatever the answer (see §10.4 note 10 for the still-unverified horizontal sign). +8. **The lock hotkey's desktop gate has no macOS equivalent, so the receiver + always eats it and always locks.** On Windows the `HotKeyLockMachine` match is + wrapped in `if (!Common.RunOnLogonDesktop && !Common.RunOnScrSaverDesktop)` + (`InputSimulation.cs:408-409`): on those two desktops `HotkeyMatched` can be + true while `eatKey` stays `false`, so the key is passed through and nothing + locks. Both flags are set only in `Program.Main` when the MWB **service** + launches a second copy of the process onto the `Winlogon` or `Screen-saver` + desktop (`Program.cs:150-167`, from `Common.RunOnScrSaverDesktop`/ + `RunOnLogonDesktop`, `Common.cs:176-186`) — Win32 secure desktops, one process + instance per desktop, each with its own hook. macOS has no such split: there + is one process per login session, `loginwindow` and the screen saver are not + desktops that host a copy of us, and once the screen is actually locked the + system stops delivering to and posting from a user-space event tap anyway. The + condition is therefore unconditionally true for a Mac receiver, which is why + `KeyState.processDown` has no guard. The Windows service that creates those + desktops is out of scope in the first place (README D6). Note that the + hardcoded Win+L branch (`:450-460`) carries no such gate on Windows either, so + only the configurable hotkey was ever gated.