Agent-only release. The relay and Pi pump are unchanged from v1.0.2 — the .exes and installer scripts are re-attached here so this release is a complete install on its own.
The bug
The mouse bridge would refuse to activate even though the Moonlight window was plainly focused. Alt-tabbing away and back fixed it every time.
The culprit turned out to be Explorer, not Moonlight. Every alt-tab or taskbar click pushes 3–4 invisible, titleless explorer.exe windows (the task switcher) through the foreground for a frame. The agent read each one as "focus left the stream window", gated off — and then no event ever arrived to turn it back on, because focus never actually moved. The stream stayed dead until the next real window switch.
Log signature, in the same second:
Focus GAINED -> streaming to ...
Focus LOST -> stream stopped (1 packets, 0 send errors, 0.0min session)
Running two Moonlight instances doubles the hidden helper windows and makes it frequent.
A second defect surfaced during the fix: the foreground event for the real destination window is sometimes never delivered at all, which can strand the gate in either state.
The fix
- Invisible windows — and titleless windows belonging to the stream window's own process — can no longer move the gate. Both are logged with hwnd + pid.
- 200 ms foreground reconciliation riding the existing keepalive timer: the gate is re-checked against the real foreground window and self-heals any disagreement, whatever caused it. Worst case is 200 ms of dead mouse instead of a dead session.
- The gate latches the stream window's hwnd/pid, so only the foreground window drives it. A duplicate window with the same title logs a
[WARN]naming the extra pid instead of fighting over the gate. - 64-bit correctness:
argtypesforGetWindowText*/GetWindowThreadProcessId/IsWindowVisibleso HWNDs aren't truncated to 32 bits.
Upgrading
Replace mousebridge-agent.exe in %USERPROFILE%\MouseBridge and restart it — kill the start-agent.cmd wrapper loop first, or it will respawn onto the locked file. Config and the relay need no changes.