Files
punktfunk/crates
enricobuehler 537a1852ed feat(windows/cursor): give the pointer back after a desktop session — clear the declare between sessions
The start-up clean (5819cf05) cannot reach the case that actually bites: run a
desktop-mode session, disconnect, reconnect with mouse capture. Same host
process, so the adapter is still carrying the first session's hardware-cursor
declare — and because that declare is irrevocable and adapter-wide, the capture
session self-composites the pointer for its entire life. It pays a full-frame
copy for every frame with a visible pointer and draws our straight-alpha
approximation of an XOR cursor, when the OS would do it natively, for free, and
exactly right.

So clear it at the start of the session that does not want it. The host records
a declare when it delivers a cursor channel (`note_cursor_declared`), and the
next session whose Welcome carries no HOST_CAP_CURSOR restarts the device to
drop it. `pnputil /restart-device` recycles the WUDFHost process the driver's
DECLARED_TARGETS lives in — 0.07 s, measured on .173.

Placement is load-bearing: it runs in the handshake right after the Welcome is
sent and BEFORE the display prep is kicked. That is the one moment this
session's display does not exist yet, and the restart takes every monitor on
the adapter with it.

The guard is deliberately conservative. `manager::no_live_displays()` counts
KEEP-ALIVE slots as held, not just streaming ones: a kept monitor belongs to a
client that is expected back, and the cost of being wrong is that someone
else's session dies, against a skip costing only the old self-composited
behaviour. That does mean the clean will not fire while the previous session's
monitor is still kept — telling a kept slot apart from a live one needs
SlotState internals, and is the obvious follow-up.

Verified: `scripts/xcheck.sh windows` green; `cargo fmt --all` clean; full
`cargo build -p punktfunk-host --release --features nvenc` on .173. The
desktop -> disconnect -> capture sequence is NOT yet exercised on glass.
2026-08-08 18:29:18 +02:00
..