Vixen
dd8b0a81
csharp
public static class WindowsAccent

The accent colour Windows is set to, read as the pair it draws a selection with.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

COLOR_HIGHLIGHT and COLOR_HIGHLIGHTTEXT, and ⚠ not DWM\ColorizationColor, which is what this was expected to read. Three things decide it, and the third is the one that settles it:

⚠ The colourisation word's high byte is an opacity and not an alpha. DWM stores AARRGGBB where the AA is how far the glass is blended, commonly 0xC4 on a stock machine — so a reader that takes it as the accent's alpha publishes a three-quarters-transparent accent, and SystemAccent has no way to tell that from a colour a user chose. Every plausible mistake in that word is invisible at the destination: the byte order differs between DWM\AccentColor (AABBGGRR) and DWM\ColorizationColor (AARRGGBB), and a swapped pair is a window painted a colour nobody picked.

⚠ DWM publishes no text colour at all, and half a read moves nothing. PlatformInput.ApplyAccent puts root.system-accent on for the accent and its text or not at all, because a rule firing on half a read leaves the theme's own text sitting on a colour the theme did not choose. A DWM-only reader would therefore have filled AccentColor and left --accent exactly where it was: a finished thing nothing draws with.

And the role this fills is the selection. ControlTheme.vcss spends --accent on the focus ring, the switch, the spinner and the selection; COLOR_HIGHLIGHT is by definition the colour Windows draws a selection in, and COLOR_HIGHLIGHTTEXT is what it draws on top. That is the same pairing macOS is read as — controlAccentColor with alternateSelectedControlTextColor, the text on a selected row — so the two desktops answer the same question rather than two adjacent ones, and the pair is guaranteed to contrast because Windows guarantees it.

⚠ The wrong answer this cannot see. Whether COLOR_HIGHLIGHT tracks the accent a user picks in Settings, or stays on the classic selection blue, is a property of the Windows build and could not be measured on the machine this was written on. Both are a colour the system chose rather than one this repository invented, which is why it is acceptable to ship unmeasured where a mis-decoded DWM word would not be — but a Windows runner whose accent has been moved off the default is where WindowsAccentTests is worth the most.

Returned in sRGB, because SystemAccent is: the conversion to linear happens once, at the PlatformInput boundary that knows what a SystemPalette holds.

Methods (1)

Used by (2)

  • DesktopAppearanceVixen.Platform.Desktop
  • WindowsAccentTestsVixen.Platform.Windows.Tests