MSW: Defer dark mode system colour change event (PR #26698)

10 views
Skip to first unread message

Steve Cornett

unread,
Jul 15, 2026, 12:23:49 PM (2 days ago) Jul 15
to wx-...@googlegroups.com, Subscribed

These changes address an issue with unreliable WM_SETTINGCHANGE "ImmersiveColorSet" messages upon switching between dark and light mode. See #26692.

Normally when the system switches between modes, Windows sends two WM_SETTINGCHANGE messages - one before the switch and one after. The problem addressed is that the second message never appears. The reason is unknown. It may be due to a timeout, since this message is broadcast using SendMessageTimeout().

The fix has two parts.

  1. When the WM_SETTINGCHANGE is received, instead of immediately issuing a wxSysColourChangedEvent, we instead post WM_SYSCOLORCHANGE to defer that action until after the mode switch is finished. This guarantees we issue at least one wxSysColourChangedEvent after the mode switch.

  2. The change above exposed a latent bug in the dark mode initialization. The variable gs_wasActiveOnStartup was not initialized correctly because ShouldAppsUseDarkMode() did not return an accurate value until a window was created. This problem was masked by having two WM_SETTINGCHANGE messages, one with IsActive() true and one false. This caused the comparison IsActive() != gs_wasActiveOnStartup to be true one time despite gs_wasActiveOnStartup begin wrong. The solution is to call the undocumented API RefreshImmersiveColorPolicyState() so that ShouldAppsUseDarkMode() returns the correct value.


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/26698

Commit Summary

  • ccd0df3 Defer dark mode system colour change event

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26698@github.com>

Reply all
Reply to author
Forward
0 new messages