Skip to content
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

win32: follow Windows settings and update dark mode state #11473

Merged
merged 1 commit into from
Apr 4, 2023

Conversation

kasper93
Copy link
Contributor

@kasper93 kasper93 commented Mar 19, 2023

Microsoft documented how to enable dark mode for title bar:

https://learn.microsoft.com/windows/apps/desktop/modernize/apply-windows-themes https://learn.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute

Documentation says to set the DWMWA_USE_IMMERSIVE_DARK_MODE attribute to TRUE to honor dark mode for the window, FALSE to always use light mode. While in fact setting it to TRUE causes dark mode to be always enabled, regardless of the settings. Since it is quite unlikely that it will be fixed, just use UxTheme API to check if dark mode should be applied and while at it enable it fully. Ideally this function should only call the DwmSetWindowAttribute(), but it just doesn't work as documented.

Fixes: #6901

@Myaanee
Copy link

Myaanee commented Mar 19, 2023

Tested on latest Win11, works as expected now, switching to white theme also works.
image

@Myaanee
Copy link

Myaanee commented Mar 22, 2023

@rossy or @sfan5 mind reviewing and merging? PR seems straightforward, however #11469 needs more input.

@kasper93
Copy link
Contributor Author

however #11469 needs more input.

I don't have much time during a week and it turned out there are few quirks to fix with regards to initial window position/size. That I need to fix first.

This PR is indeed complete and ready for review.

meson.build Show resolved Hide resolved
video/out/w32_common.c Outdated Show resolved Hide resolved
video/out/w32_common.c Outdated Show resolved Hide resolved
video/out/w32_common.c Outdated Show resolved Hide resolved
video/out/w32_common.c Outdated Show resolved Hide resolved
@kasper93 kasper93 force-pushed the win32_dark branch 3 times, most recently from a01f620 to 681bc9c Compare March 24, 2023 23:21
Microsoft documented how to enable dark mode for title bar:

https://learn.microsoft.com/windows/apps/desktop/modernize/apply-windows-themes
https://learn.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute

Documentation says to set the DWMWA_USE_IMMERSIVE_DARK_MODE attribute to
TRUE to honor dark mode for the window, FALSE to always use light mode.
While in fact setting it to TRUE causes dark mode to be always enabled,
regardless of the settings. Since it is quite unlikely that it will be
fixed, just use UxTheme API to check if dark mode should be applied and
while at it enable it fully. Ideally this function should only call the
DwmSetWindowAttribute(), but it just doesn't work as documented.

Fixes: mpv-player#6901
Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works

@hooke007
Copy link
Contributor

I wonder if currently it's difficult to add an option for users to use dark mode "auto" , "always" or "never"?

@kasper93
Copy link
Contributor Author

I wonder if currently it's difficult to add an option for users to use dark mode "auto" , "always" or "never"?

It would be easy, but what is the usecase for that? mpv doesn't have any ui elements affected except title bar, which doesn't really make sense to not follow system settings.

@dyphire
Copy link
Contributor

dyphire commented Dec 13, 2023

I wonder if currently it's difficult to add an option for users to use dark mode "auto" , "always" or "never"?

It would be easy, but what is the usecase for that? mpv doesn't have any ui elements affected except title bar, which doesn't really make sense to not follow system settings.

Given that the cplugin based menu implemented in the #5500 (comment) is also controlled by dark mode, we now have other UI elements affected by this, and there may be more in the future. It is time to add options to control the behavior of mpv's dark mode.

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.

Windows Dark Theme Support
5 participants