Skip to content

Conversation

@ckaiser
Copy link
Member

@ckaiser ckaiser commented Nov 30, 2025

Adds a C++/WinRT based event listener to the WindowWin, which avoids having to check for ColorSpace changes manually when the window moves/is activated/etc.

This only works on Windows 11, but since 10 is EOL I think that's fine. It comes with the cost of having to construct a WinRT DispatcherQueue since it won't work without one, so that's something to evaluate.

I've made compilation optional in case it conflicts with older Windows SDKs that don't have the headers or access to the WindowsApp library. I've tested it with multiple monitors on Windows 11 and on a virtual machine in 10 (works the same as before).

Since I was also doing event stuff I snuck in a few extra tweaks:

  • The check now also tests if the colorspaces are nearlyEqual() before sending out the event.
  • Added an equality check to setScale() which should avoid a WM_SIZING event (and therefore yet another check) - I did not see this breaking anything with scaled displays but I'm not 100% sure if it could have unintended side effects.
  • The dark theme check now only triggers when it's the proper event, instead of on every WM_SETTINGCHANGE

@dacap
Copy link
Member

dacap commented Dec 1, 2025

At the moment I'm not sure if we should introduce WinRT as a dependency. We must keep Win7 compatibility, and I'm not sure if linking with this will break Win7.

Anyway doing some research found this: https://learn.microsoft.com/en-us/windows/win32/wcs/wcs-registry-keys

It looks like the "official" way to generate this "display profile change" is listening a couple of registry entries: https://learn.microsoft.com/en-us/windows/win32/wcs/wcs-registry-keys#desktop-applications

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.

2 participants