HiDPI & Retina Coordinate Math: Perfect Multi-Monitor Window Alignment Without Distortion
How operating systems calculate HiDPI coordinate scaling. Fix blurred overlays, coordinate misalignment, and DPI scaling jumps across 4K and Retina displays.
When connecting a 4K external display (150% scaling) to a laptop with native 200% Retina scaling, naive window coordinate math causes floating overlays to jump, stretch, or miscalculate click areas.
The Complexity of Mixed DPI Multi-Monitor Setups
Users frequently share an external monitor on Zoom while keeping reference tools open. Mismatched scale factors cause window coordinates to diverge.
macOS Points vs. Physical Pixels (NSScreen & backingScaleFactor)
macOS calculates coordinates in logical points (typically 2 physical pixels per point on Retina). Chameleon queries [NSScreen backingScaleFactor] to size rendering surfaces accurately.
Windows Per-Monitor DPI Awareness V2 (DPI_AWARENESS_CONTEXT)
By declaring DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 in application manifests, Windows delegates native scaling to the application, eliminating DWM bitmap scaling blur.
Mathematical Transformation of HUD Coordinates
Chameleon maps display boundaries into a continuous virtual desktop coordinate space, ensuring smooth window positioning across disparate monitor resolutions.