The critical part is : clear the old focus before notifying it. This prevents the old focus from running code that assumes it still owns pointer events (e.g., trying to release a grab). Accessibility: The Canary in the Coal Mine If you only test pointer focus registration with a mouse, you will ship bugs.

Screen readers, switch devices, and eye trackers all rely on . They inject synthetic pointer events with zero physical movement.

The best systems make pointer focus invisible. The worst make it unforgettable.

: Log WM_MOUSEENTER and WM_MOUSELEAVE with timestamps. If you see >2 pairs in <50ms, you have dribble. A Safer Registration Contract (Pseudocode) After years of debugging corrupted focus states, I’ve landed on a simple contract for any register_pointer_focus() implementation:

occurs when pointer focus registers and releases multiple times within a single frame—usually due to overlapping transparent hitboxes or async layout recalculations.

# 5. Post-condition: event ownership is unambiguous assert system.pointer_focus == candidate