Skip to content

Fix DPI-aware TreeView glyph rendering in Translucent Windows - #5

Open
63OR63 wants to merge 1 commit into
Undisputed00x:mainfrom
63OR63:fix-translucent-windows-treeview-dpi
Open

Fix DPI-aware TreeView glyph rendering in Translucent Windows#5
63OR63 wants to merge 1 commit into
Undisputed00x:mainfrom
63OR63:fix-translucent-windows-treeview-dpi

Conversation

@63OR63

@63OR63 63OR63 commented Aug 9, 2026

Copy link
Copy Markdown

Description

Fixes oversized and blurry TreeView expand/collapse chevrons at non-100% display scaling when Windows theme custom rendering is enabled.

The issue is especially noticeable in the File Explorer navigation pane and also occurs with fractional/custom scaling values such as 120%.

Cause

The existing TreeView glyph rendering path has several DPI-related issues:

  • Explorer::TreeView detection relies on exact floating-point comparison (width / (16 * scale) == 1), which is unreliable at fractional scaling because the expected size can be fractional while the actual RECT dimensions are integers.
  • Glyph geometry is derived from the global DPI scale rather than the actual physical target size.
  • Fractionally scaled stroke widths and coordinates can fall between physical pixels, resulting in excessive antialiasing.
  • The already-rasterized glyph is passed through DrawNineGridStretch(), introducing another bitmap scaling step.

Fix

The TreeView glyph is now rendered directly at the final physical target size:

  • The actual pRect dimensions are passed to CacheTreeViewGlyph().
  • Explorer::TreeView detection uses rounded expected physical dimensions instead of exact floating-point equality.
  • Vector scale is derived from the actual target dimensions.
  • Stroke width is rounded to whole physical pixels and vector coordinates are snapped to the corresponding pixel grid.
  • Cached glyphs are recreated when their dimensions don't match the current target.
  • The finished bitmap is drawn 1:1 with AlphaBlend() instead of being resized with DrawNineGridStretch().

This avoids resampling an already-rasterized glyph and keeps the chevrons sharp at fractional DPI scaling.

Tested successfully in File Explorer at 100%, custom 120%, 125%, 150%, and 175% display scaling.

Screenshots

Before the fix, at 125% display scaling:
before

After the fix, at 125% display scaling:
after

Changelog

  • Fixed TreeView expand/collapse chevrons being oversized and blurry at non-100% display scaling.
  • Improved TreeView glyph rendering for fractional/custom DPI scaling.

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.

1 participant