feat(core+host+driver+client): mid-stream cursor-render flip — host composites in the capture model

The cursor channel excluded the host pointer from the video for the
whole session, but the client only draws it under the DESKTOP mouse
model — flipping ⌃⌥⇧M to capture mid-stream left the session
pointer-blind (user-found). The fix makes render ownership LIVE state:

- wire: CursorRenderMode 0x51 (client→host, control stream) —
  client_draws: true = desktop model (host excludes + forwards),
  false = capture model / released (host composites, full fidelity —
  DWM on Windows incl. real XOR inversion, encoder blend on Linux).
  Sessions start client_draws=true (the pre-message behavior).
- host: control task stores the flag; the encode loop edge-detects it —
  forwarding + frame.cursor strip while the client draws, quiet
  forwarder + overlay-into-blend while composited. SessionPlan now
  grants blend CAPABILITY wherever the capture has a pointer (dropping
  the !cursor_forward gate) so the composite side needs no encoder
  rebuild; per-tick frame.cursor decides what is drawn.
- Windows: Capturer::set_cursor_forward → retained
  IOCTL_SET_CURSOR_FORWARD sender (proto v6) → driver (un)declares the
  IddCx hardware cursor on the LIVE monitor. Un-declare re-issues the
  setup with EMPTY caps (candidate mechanism — the DDI has no
  documented un-setup); resetup-on-commit is skipped while off, so a
  mode commit's software-cursor default is the fallback path. Failure
  against a pre-v6 driver logs and keeps declared-at-ADD behavior.
- SDL client: one edge-detected reconciler at the cursor pump site —
  desktop-active = client draws; capture model or released = host
  composites. Covers the chord, the M3 auto-flip, and engage/release.
- C ABI v12: punktfunk_connection_set_cursor_render (additive; wire
  version unchanged — pre-§8 hosts ignore the unknown message type).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-22 23:43:23 +02:00
co-authored by Claude Opus 4.8
parent 0420be9fa5
commit 92761813a9
16 changed files with 361 additions and 23 deletions
+23 -1
View File
@@ -45,7 +45,11 @@
// v10: added `punktfunk_connection_clock_offset_now_ns` — the LIVE (mid-stream re-synced)
// clock offset ongoing latency math must use; the connect-time getter stays frozen by
// contract. Additive, client-local — no wire change, so [`WIRE_VERSION`] is unchanged.
#define ABI_VERSION 11
// v12: added `punktfunk_connection_set_cursor_render` — the mid-stream cursor-render flip
// (design/remote-desktop-sweep.md §8): the client's mouse-model chord tells the host who
// renders the pointer. Additive; rides the existing control stream (a new message TYPE, which
// pre-§8 hosts ignore), so [`WIRE_VERSION`] is unchanged.
#define ABI_VERSION 12
// The punktfunk/1 **wire** version — what `Hello`/`Welcome` carry and hosts equality-check.
// Deliberately its own constant: [`ABI_VERSION`] tracks the embeddable **C surface**
@@ -793,6 +797,11 @@
#define MSG_CURSOR_SHAPE 80
#endif
#if defined(PUNKTFUNK_FEATURE_QUIC)
// Type byte of [`CursorRenderMode`] (client → host): who renders the pointer right now.
#define MSG_CURSOR_RENDER 81
#endif
#if defined(PUNKTFUNK_FEATURE_QUIC)
// Per-side pixel cap for a forwarded cursor bitmap. The control-stream frame is length-prefixed
// with a `u16`, so a whole message must fit 65535 bytes — 128×128 RGBA (65536 B) already
@@ -2168,6 +2177,19 @@ PunktfunkStatus punktfunk_connection_next_cursor_state(PunktfunkConnection *c,
uint32_t timeout_ms);
#endif
#if defined(PUNKTFUNK_FEATURE_QUIC)
// Tell the host who renders the pointer (design/remote-desktop-sweep.md §8 — the mid-stream
// mouse-model flip): `client_draws = true` = this client draws it locally (the desktop mouse
// model; the host excludes the pointer from the video and forwards shape/state), `false` =
// the host composites it into the video (the capture model — full fidelity, the pre-channel
// look). Idempotent, latest-wins; harmless against hosts without the cursor cap (an unknown
// control message type, ignored). ABI v12.
//
// # Safety
// `c` is a valid connection handle.
PunktfunkStatus punktfunk_connection_set_cursor_render(PunktfunkConnection *c, bool client_draws);
#endif
#if defined(PUNKTFUNK_FEATURE_QUIC)
// Pull the next per-AU host timing (0xCF) into `*out`: the host's capture→sent duration for one
// access unit, correlated to the AU by `pts_ns` (see [`PunktfunkHostTiming`]).