app-engine: release held keys on every switch that lands control here
QA finding 2. `Helper.HelperThread` releases once `NewDesMachineID == MachineID` (`Helper.cs:120-123`) and its event is set by both `SwitchToMachine` (`MachineStuff.cs:1024`) and `PrepareToSwitchToMachine` (`Event.cs:203`), so Windows releases on the `ByeBye`, edge-crossing and `NextMachine` paths too — we only did on the hotkey, the broadcast toggle and `recoverLocal`. The tail of `perform(_ actions:)` now covers all of them, gated on the destination actually moving so that a switch which leaves control local (a matrix edit while a peer drives this Mac) cannot drop that peer's held modifiers. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
f76eb8fabc
commit
ccbeff2e0a
1 file changed
+23
@@ -24,11 +24,34 @@ extension Engine {
|
||||
/// what tells the tap to start or stop swallowing, what arms the 30 s stall
|
||||
/// rule (control-channel request 2) and what hands the pointer back.
|
||||
func perform(_ actions: [SwitchAction]) {
|
||||
let wasDes = switcher.desMachineID
|
||||
let wasBroadcasting = switcher.isBroadcasting
|
||||
for action in actions { perform(action) }
|
||||
releaseKeysIfControlCameHome(wasDes: wasDes, wasBroadcasting: wasBroadcasting)
|
||||
syncRouting()
|
||||
publish()
|
||||
}
|
||||
|
||||
/// `Helper.HelperThread` releases every held key as soon as
|
||||
/// `NewDesMachineID == MachineID` (`Helper.cs:120-123`), and the event it
|
||||
/// waits on is set by *every* switch — `SwitchToMachine`
|
||||
/// (`MachineStuff.cs:1024`) and `PrepareToSwitchToMachine` (`Event.cs:203`)
|
||||
/// alike. So a received `ByeBye`, an edge crossing and a `NextMachine`
|
||||
/// packet that land control back on this Mac release too, not only the
|
||||
/// hotkey and the broadcast toggle, which carry their own
|
||||
/// `.releaseAllKeys`. Calling it twice is harmless: `releaseAll()` is
|
||||
/// idempotent.
|
||||
///
|
||||
/// Only on an actual change of target, though. While a peer is driving
|
||||
/// *this* Mac our own destination is local the whole time, and releasing on
|
||||
/// a switch that did not move it — a matrix edit, say — would drop the
|
||||
/// modifiers that peer is holding down, mid-keystroke.
|
||||
private func releaseKeysIfControlCameHome(wasDes: UInt32, wasBroadcasting: Bool) {
|
||||
let moved = switcher.desMachineID != wasDes || switcher.isBroadcasting != wasBroadcasting
|
||||
guard moved, !switcher.destinationIsRemote, !switcher.isBroadcasting else { return }
|
||||
injector.releaseAll()
|
||||
}
|
||||
|
||||
private func perform(_ action: SwitchAction) {
|
||||
switch action {
|
||||
case .send(let packet):
|
||||
|
||||
Reference in new issue
Block a user