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

Windows Dark Theme Support #6901

Closed
mortyobnoxious opened this issue Aug 30, 2019 · 10 comments · Fixed by #11473
Closed

Windows Dark Theme Support #6901

mortyobnoxious opened this issue Aug 30, 2019 · 10 comments · Fixed by #11473

Comments

@mortyobnoxious
Copy link

Hi, this is when window is active:
image

This is when it's inactive:
image

Top bar of the File Explorer is dark when window is inactive.

But with MPV, it's white when window is inactive(not focused).
image

Could you please add support for this.

@Artoriuz
Copy link

Artoriuz commented Sep 2, 2019

Just to add, I think the title bar should be black if you have dark theme turned on and a compliant program while also not explicitly telling windows to use your accent colour on it.

We can see this behaviour on a few Win32 things, like the file explorer and powershell. I don't believe this should be a lot of work but I'm also not entirely sure it's properly documented. It might be part of XAML Islands.

darktitle

I think the browsers can also switch between their themes whenever you change the global windows setting, but they're drawing their own decorations.

@stax76
Copy link
Contributor

stax76 commented Sep 5, 2019

I thought it might be a window style but it ain't.

It's likely win32 non client area custom paint or there is a function that can set it.

@stax76
Copy link
Contributor

stax76 commented Sep 5, 2019

It was asked at stack overflow without anybody knowing the answer.

https://stackoverflow.com/questions/57124243/winforms-dark-title-bar-on-windows-10

@rossy
Copy link
Member

rossy commented Sep 21, 2019

Here's something interesting in microsoft/terminal:
https://github.com/microsoft/terminal/blob/56c35945b97f/src/interactivity/win32/windowtheme.cpp#L34-L51

It seems like Microsoft are using internal undocumented APIs (as usual) to enable these features for their first-party software. I wrote a test program to call these two functions, and it seems to work:

image

This only works in the release version of Windows 10 though. In the insiders build, it seems like these APIs are no longer enough to enable dark mode. Dark mode doesn't work for the console in the insiders build either, but it still works for Explorer.

I'd like to enable dark mode for mpv, but not while it's an internal API that changes between each release of Windows 10. (Especially not while it requires that call-by-ordinal ShouldAppsUseDarkMode API to check if dark mode is enabled or not.) Hopefully they add a public API, or at least a stable undocumented API, to the next Windows 10 release.

@davidhewitt
Copy link

I've been trying out similar at rust-windowing/winit#1217 . I'm also on insiders. After a little experimentation I found that the DwmSetWindowAttribute call works for me if I use 20 instead of 19 as the definition of DWMA_USE_IMMERSIVE_DARK_MODE. Perhaps you'll find that also is the case for you?

Accordingly, I'm considering using a build version check to switch between 19 or 20. But at the moment the only evidence that I can find that 20 works is me! (Googling for further evidence is how I've stumbled on this issue.)

@kcohar
Copy link

kcohar commented Jan 24, 2020

Was this on insider's? @davidhewitt

@davidhewitt
Copy link

davidhewitt commented Jan 25, 2020

In the end I went for the approach showcased in this repository, which works for most Windows 10 versions from 2018 and up: https://github.com/ysc3839/win32-darkmode

(Insiders and stable)

@kcohar
Copy link

kcohar commented Jan 25, 2020

Hey that's perfect, that could work here too

@plashenkov
Copy link

Hey there, is there any movement on this?

mpv is the best and the player of my choice, the only problem is the white titlebar when all Windows is in the dark mode.

kasper93 added a commit to kasper93/mpv that referenced this issue Mar 19, 2023
…stem setting

This is now documented way to allow dark mode window frame appearance:

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

I'm not interested in various undocumented APIs to make context menu
dark and so on.

Documentation says this DWM attribute is supported starting with Windows
11 Build 22000. It seems to work well on Windows 10... while in fact
doesn't work on Windows 11, at lest on my system. Feel free to report it
to Microsoft and ping me when they release proper API for that. Until
then this small improvment is a step the right direction.

Fixes: mpv-player#6901
kasper93 added a commit to kasper93/mpv that referenced this issue Mar 19, 2023
…stem setting

This is now documented way to allow dark mode window frame appearance:

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

I'm not interested in various undocumented APIs to make context menu
dark and so on.

Documentation says this DWM attribute is supported starting with Windows
11 Build 22000. It seems to work well on Windows 10... while in fact
doesn't work on Windows 11, at least on my system. Feel free to report it
to Microsoft and ping me when they release proper API for that. Until
then this small improvement is a step the right direction.

Fixes: mpv-player#6901
kasper93 added a commit to kasper93/mpv that referenced this issue Mar 19, 2023
…stem setting

This is now documented way to allow dark mode window frame appearance:

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

I'm not interested in various undocumented APIs to make context menu
dark and so on.

Documentation says this DWM attribute is supported starting with Windows
11 Build 22000. It seems to work well on Windows 10... while in fact
doesn't work on Windows 11, at least on my system. Feel free to report it
to Microsoft and ping me when they release proper API for that. Until
then this small improvement is a step in the right direction.

Fixes: mpv-player#6901
kasper93 added a commit to kasper93/mpv that referenced this issue Mar 19, 2023
…stem setting

This is now documented way to allow dark mode window frame appearance:

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

I'm not interested in various undocumented APIs to make context menu
dark and so on.

Documentation says this DWM attribute is supported starting with Windows
11 Build 22000. It seems to work well on Windows 10... while in fact
doesn't work on Windows 11, at least on my system. Feel free to report it
to Microsoft and ping me when they release proper API for that. Until
then this small improvement is a step in the right direction.

Fixes: mpv-player#6901
kasper93 added a commit to kasper93/mpv that referenced this issue 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: mpv-player#6901
kasper93 added a commit to kasper93/mpv that referenced this issue 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: mpv-player#6901
kasper93 added a commit to kasper93/mpv that referenced this issue Mar 24, 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: mpv-player#6901
kasper93 added a commit to kasper93/mpv that referenced this issue Mar 24, 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: mpv-player#6901
kasper93 added a commit to kasper93/mpv that referenced this issue Mar 24, 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: mpv-player#6901
sfan5 pushed a commit that referenced this issue Apr 4, 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
@plashenkov
Copy link

Yay! Thank you! Everything is great now!

dyphire pushed a commit to dyphire/mpv that referenced this issue Jul 8, 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: mpv-player#6901
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants