Internal — the four branches of apply_hwnd_opened against a
known label_hint. Lifted into its own enum so the function
can drop the &mut WindowMirror borrow before calling
state.bump_version() on the drift-emitting path (rustc E0499).
Placement grace window. CEF creates top-level windows hidden,
runs SetWindowPos to place them, then shows them. The
intermediate WM_HIDE events arrive before WM_FOREGROUND,
which would otherwise look like HiddenSinceOpen drift on
every fresh window. Hides occurring within this window of the
host’s ReportWindowOpened are part of normal placement and
don’t count.
Phase B.9.1 — handle Command::ReportHwndForegroundChanged.
Updates the “has been seen” flag. Never emits drift directly
— its role is to suppress future HiddenSinceOpen emissions.
Phase B.9.1 — handle Command::ReportHwndIconicChanged. Updates
state. No drift directly — operator can read steady state via
--diag wrr (B.9.2) if they want to see who’s minimized.
Phase B.9.1 — handle Command::ReportHwndPositionChanged.
Compares the new rect against state.monitors; emits
OffMonitor drift if it doesn’t intersect any monitor.
Suppressed when state.monitors is empty (we don’t yet know
the topology — first ReportMonitorTopologyChanged will
reconcile every label’s last_rect against fresh monitors).
Phase B.9.1 — handle Command::ReportHwndVisibilityChanged.
Drift fires only on visible=false for a known label that has
not been foregrounded since open AND is past the post-open
placement grace window.
Phase B.9.1 — handle Command::ReportMonitorTopologyChanged.
Replaces state.monitors wholesale, then re-evaluates every
known mirror’s last_rect against the new set. Emits
OffMonitor for any window that newly falls off (e.g. user
unplugged the external display where the window lived).
Sweep hidden_since_open_deferred mirrors and emit drift for any
that have crossed the placement grace boundary while still hidden
and never foregrounded. Called from reducer::update AFTER every
command processes so any recovery event the command itself
dispatched (visible=true / foreground change / window closed) has
a chance to clear the deferred state first. Without the AFTER
ordering, a slow placement whose first post-grace event is the
recovery itself would fire a spurious drift before the recovery
runs (codex P2 PR #725 round 2).
Phase B.9.1 — Win32 sentinel positions for “this window is
hidden.” CEF parks new windows here briefly between create
and first paint; same value family (SW_HIDE analog used by
ITaskbarList::DeleteTab removed windows). We suppress drift
emission for these but DO trigger corrective move (the user
shouldn’t see the sentinel).
Phase B.9.2 — pick a corrective target rect: centered on the
first monitor at a sensible default size (1280x800 or 70% of
monitor, whichever is smaller). None if the monitor list is
empty (caller suppresses corrective in that case).
Phase B.9.1 — per-kind severity classifier. The split is
deliberate: OrphanDestroy and HwndWithoutBrowser indicate a
real divergence between CEF identity and Win32 reality (a CEF
bug or a missed report path) — ERROR. OffMonitor,
HiddenSinceOpen, LingeringHwnd are operationally
significant (user can’t see / use the window) but don’t
indicate a state-machine bug — WARN. BrowserWithoutHwnd is
commonly transient (race window between OS create and host
link) — INFO; only meaningful if it doesn’t reconcile.