Skip to content

fix: report the system accent colour consistently on Windows - #54353

Merged
MarshallOfSound merged 2 commits into
mainfrom
fix/win-accent-color-observer
Sep 25, 2026
Merged

MarshallOfSound merged 2 commits into
mainfrom
fix/win-accent-color-observer

Conversation

@MarshallOfSound

@MarshallOfSound MarshallOfSound commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Description of Change

On Windows systemPreferences.getAccentColor() read HKCU\...\DWM\AccentColor, but accent-color-changed emitted the DWM colorization colour from WM_DWMCOLORIZATIONCOLORCHANGED through a separate lowercase formatter, so the event's newColor did not match getAccentColor() and the change de-duplication never matched on the first event. NativeWindowViews had two more readers of the same registry key.

  • Use ui::AccentColorObserver for getAccentColor(), the accent-color-changed event and the window frame accent colour; it watches the DWM key and prefers the UISettings value Windows actually applies.
  • NativeWindowViews reapplies the frame colour from the observer's notification instead of from WM_DWMCOLORIZATIONCOLORCHANGED / WM_SETTINGCHANGE, which can arrive before the observer has re-read the registry; accent-color-changed is emitted from a posted task (as on Linux) rather than inside the observer's notification.
  • Remove systemPreferences' hidden WS_POPUP broadcast window and the registry helpers in color_util / native_window_views_win.

Checklist

Release Notes

Notes: Fixed accent-color-changed on Windows reporting a colour that differed from systemPreferences.getAccentColor().

@MarshallOfSound MarshallOfSound added semver/patch backwards-compatible bug fixes target/44-x-y PR should also be added to the "44-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 25, 2026
@MarshallOfSound MarshallOfSound self-assigned this Sep 25, 2026
systemPreferences read HKCU\...\DWM\AccentColor directly for
getAccentColor() but emitted 'accent-color-changed' with the DWM
*colorization* colour from WM_DWMCOLORIZATIONCOLORCHANGED, formatted by a
separate lowercase helper, so the event's newColor did not match
getAccentColor() and the change de-duplication never matched on the first
event. NativeWindowViews kept two more registry readers for the same key.

Use ui::AccentColorObserver for all of it: it watches the DWM key, prefers
the UISettings value Windows actually applies, and exposes
ShouldUseAccentColorForWindowFrame(). This removes systemPreferences'
hidden WS_POPUP broadcast window.
…ations

NativeWindowViews read the observer's cached colour from the
WM_DWMCOLORIZATIONCOLORCHANGED / WM_SETTINGCHANGE handlers, which can run
before the observer's registry watch has refreshed that cache, and nothing
reapplied the colour afterwards. Subscribe to the observer instead and drop
the message handlers. Also emit systemPreferences' accent-color-changed from
a posted task rather than from inside the observer's notification.
@MarshallOfSound
MarshallOfSound force-pushed the fix/win-accent-color-observer branch from 8691bba to c16933d Compare September 25, 2026 10:30
@MarshallOfSound
MarshallOfSound enabled auto-merge (squash) September 25, 2026 16:39
@MarshallOfSound
MarshallOfSound merged commit 8453f62 into main Sep 25, 2026
73 checks passed
@MarshallOfSound
MarshallOfSound deleted the fix/win-accent-color-observer branch September 25, 2026 16:42
@release-clerk

release-clerk Bot commented Sep 25, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed accent-color-changed on Windows reporting a colour that differed from systemPreferences.getAccentColor().

@trop

trop Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "44-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot added needs-manual-bp/44-x-y and removed target/44-x-y PR should also be added to the "44-x-y" branch. labels Sep 25, 2026
@trop

trop Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "45-x-y", please check out #54405

@trop trop Bot added in-flight/45-x-y and removed target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 25, 2026
@trop

trop Bot commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

@MarshallOfSound has manually backported this PR to "44-x-y", please check out #54409

@trop trop Bot added in-flight/44-x-y merged/45-x-y PR was merged to the "45-x-y" branch. and removed needs-manual-bp/44-x-y in-flight/45-x-y labels Sep 25, 2026
MarshallOfSound added a commit that referenced this pull request Sep 25, 2026
…#54409)

fix: report the system accent colour consistently on Windows (#54353)

* fix: report the system accent colour consistently on Windows

systemPreferences read HKCU\...\DWM\AccentColor directly for
getAccentColor() but emitted 'accent-color-changed' with the DWM
*colorization* colour from WM_DWMCOLORIZATIONCOLORCHANGED, formatted by a
separate lowercase helper, so the event's newColor did not match
getAccentColor() and the change de-duplication never matched on the first
event. NativeWindowViews kept two more registry readers for the same key.

Use ui::AccentColorObserver for all of it: it watches the DWM key, prefers
the UISettings value Windows actually applies, and exposes
ShouldUseAccentColorForWindowFrame(). This removes systemPreferences'
hidden WS_POPUP broadcast window.

* fix: refresh the frame accent colour from AccentColorObserver notifications

NativeWindowViews read the observer's cached colour from the
WM_DWMCOLORIZATIONCOLORCHANGED / WM_SETTINGCHANGE handlers, which can run
before the observer's registry watch has refreshed that cache, and nothing
reapplied the colour afterwards. Subscribe to the observer instead and drop
the message handlers. Also emit systemPreferences' accent-color-changed from
a posted task rather than from inside the observer's notification.

(cherry picked from commit 8453f62)
@trop trop Bot added merged/44-x-y PR was merged to the "44-x-y" branch. and removed in-flight/44-x-y labels Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants