-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable dark menus on Windows 11 builds greater than 22631 #788
Conversation
9be42bf
to
0645d27
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
Allow Windows builds greater than 22631 to access "private" APIs. (Tested on Windows 11 Insiders Canary build 25926)
Okay, the max version check was just in there as a precaution against future breakage, but removing it is okay as the risk seems low (plus the build numbers are all over the place anyway).
Update PreferredAppMode enum
Do you have some source that those are the official names? Otherwise I don't see much reason to rename those (it'd just be some names that someone else has made up).
Call AllowDarkModeForWindow (@133) from dark::set_titlebar_mode. This fixes the menubar / context menus to use dark mode.
I don't see any difference from this on build 25926; menus are already dark with the max version check removed. Could you elaborate on what this is fixing?
so, yeah, this change alone may be just the one needed (see laterfor some of my thoughts).
i think the names come from the disassembly of uxtheme.dll@122 (screenshot from IDA free, with pdb symbols loaded acquired via windbg): with a little digging around this reads as such: PreferredAppMode g_preferredAppMode; // set by uxtheme@135 (SetPreferredAppMode)
BOOL g_isSystemAppModeLight; // contains the user setting
BOOL ShouldAppUserDarkMode()
{
BOOL result;
result = FALSE;
// substituting the names makes sense here:
if( g_preferredAppMode != ForceLight && ( !g_isSystemAppModeLight || g_preferredAppMode == ForceDark ) )
return TRUE;
return FALSE;
}
hm, yeah.. i first added the latter, then realized there's the build number check ... 👼 however, looking at the disassembly of uxtheme.dll@133 (AllowDarkModeForWindow) just relays the call to uxtheme.dll@140 (AllowDarkModeForWindowWithTelemetryId, same sig), which after checking a HWND prop via GetPropW, calls an unexported and kinda convoluted function (ApplyStringProp), which SetPropW-s some props on the HWND... ...which may or may not be just triggering telemetry of dark mode usage. hard to tell. so, yeah, at this point the latter (ie: calling AllowDarkModeForWindow) doesn't seem absolutely necessary, in this case at least. (and would also incur a name change/clarification of dark::set_titlebar_mode) |
Okay, removing the max version check and changing Other changes I don't think are necessary so would remove those.
Not sure on the mechanism, but IIRC |
33d641a
to
e52ff0c
Compare
e52ff0c
to
5ed9e99
Compare
Allow Windows builds greater than 22631 to access "private" APIs. (Tested on Windows 11 Insiders Canary build 25926)
5ed9e99
to
23d980c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build was failing – have updated this to get it over the line. Will merge shortly.
PreferredAppMode
enumAllowDarkModeForWindow
(@133
) fromdark::set_titlebar_mode
. This fixes the menubar / context menus to use dark mode.Tested both the x86 build (with foobar2000 v1.6.16) and the x64 build (with foobar2000 v2.1 preview 2023-08-01).