fix(windows/cursor-flip): flag + forced same-mode re-commit — the working un-declare

The empty-caps un-declare is REJECTED by IddCx (STATUS_INVALID_PARAMETER,
on-glass driver 9.9.0722.1407) — there is no un-declare DDI. The
composite flip now works with the only lever the OS gives us: every
mode COMMIT reverts the path to the software cursor, and the driver
skips its per-commit re-declare while cursor_forward_on is off. So:

- driver: disable stores the flag only (no DDI call); enable still
  declares immediately against the live worker's event.
- host capturer: after a successful disable flip, force a same-mode
  re-commit (win_display::force_mode_reenumeration) — DWM composites
  the pointer from the very next commit; the swap-chain flap is the
  class the driver's preserved-publisher machinery already rides out.
- state now survives re-arrivals end-to-end: the capturer caches the
  APPLIED state (cleared on every channel (re)delivery, which
  re-created driver entries need — their flag defaults to declared),
  and the stream loop re-applies every tick instead of edge-gating
  (steady-state cost: one Option compare).

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 79d30fde64
commit b50e4767de
4 changed files with 74 additions and 45 deletions
@@ -550,18 +550,25 @@ pub fn set_cursor_forward(target_id: u32, enable: bool) -> bool {
let Some((object, worker_ev)) = found else {
return false; // no hw-cursor monitor with this target at all
};
match (object, worker_ev) {
(Some(object), Some(ev)) => {
let st = if enable {
crate::cursor_worker::setup_hardware_cursor(object, ev)
} else {
crate::cursor_worker::unsetup_hardware_cursor(object, ev)
};
dbglog!("[pf-vd] cursor: forward flip enable={enable} -> {st:#x}");
match (enable, object, worker_ev) {
(true, Some(object), Some(ev)) => {
// Enable declares immediately against the live worker's event (works any time).
let st = crate::cursor_worker::setup_hardware_cursor(object, ev);
dbglog!("[pf-vd] cursor: forward flip enable=1 (declare) -> {st:#x}");
}
(false, _, _) => {
// There is NO un-declare DDI: re-issuing the setup with empty caps is rejected
// INVALID_PARAMETER (observed on-glass, 26100). The stored flag alone steers — the
// HOST forces a same-mode re-commit, whose software-cursor default then STICKS
// because [`resetup_cursor`] skips this monitor while the flag is off.
dbglog!(
"[pf-vd] cursor: forward flip enable=0 stored — awaiting the host's mode \
re-commit (software cursor from then on)"
);
}
_ => dbglog!(
"[pf-vd] cursor: forward flip enable={enable} stored (no live worker — applies at \
the next channel delivery)"
"[pf-vd] cursor: forward flip enable=1 stored (no live worker — applies at the \
next channel delivery)"
),
}
true