Skip to content

win32: natural sizes and paddings at the monitor's DPI (#171) - #172

Merged
nicolas-maman merged 1 commit into
mainfrom
fix/171-win32-dpi-defaults
Sep 19, 2026
Merged

nicolas-maman merged 1 commit into
mainfrom
fix/171-win32-dpi-defaults

Conversation

@nicolas-maman

Copy link
Copy Markdown
Contributor

Closes #171.

The measure's defaults for a control with no size of its own — a field 140×26, a slider 140×26, a progress bar 140×16, a text area 200×80, a button's 24/10 of padding, a label's 4/4, a checkbox's 18px box and 28px gap, a divider's 12, the catch-all 100×24 — were 96-DPI numbers used as pixels. After #170 the font follows the monitor's DPI, so on a 150% monitor these were two thirds of themselves around a face that had grown: a 26px field around an 18px font clips.

w32_px(hwnd, n) = MulDiv(n, dpi, 96) at the window's DPI (the system's while the widget sits on the hidden holder), applied to every default and padding in measure_widget_intrinsic. A DPI change already lays the tree out again through w32_refont_tree (#170), so the new sizes take effect on the monitor the window moves to. The dead second WK_DIVIDER branch (2×2, unreachable behind the 12×12 one) is removed.

At 96 DPI this is the identity, which is what this box and CI run at: the 74-spec headless sweep and the on-screen subset from #170 apply unchanged (same backend, identity numbers). The non-96 case is correct by construction; a screen grab on a 125%/150% monitor would be the proof, and this machine has none.

Closes #171. The measure's defaults for a control with no size of its
own (a field 140x26, a progress bar 140x16, a text area 200x80, a
button's 24/10 of padding, a checkbox's box and gap) were 96-DPI numbers
used as pixels, so on a 150% monitor they were two thirds of themselves
around a font that had grown. w32_px scales them at the window's DPI;
a DPI change already lays the tree out again through w32_refont_tree.
The dead second WK_DIVIDER branch (2x2, unreachable behind the 12x12
one) is gone.
@nicolas-maman
nicolas-maman merged commit a6bd77a into main Sep 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

win32: fixed pixel defaults in measure_widget do not scale with DPI

1 participant