-
Notifications
You must be signed in to change notification settings - Fork 570
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
Add dark mode support for Windows. #2196
Conversation
Thanks for the PR! Given that our theme is dark, this makes total sense. But can I also check my understanding of the situation with you? (I don't use windows much, so I might be way off.) So the page you linked to describes a way of determining whether the theme is "dark" or "light," and the ideal would be to adapt druid's default colors according to that. This PR does not do anything about changing druid's theme, but it does tell windows that druid supports dark themes, so that windows can draw a dark titlebar when a dark theme is enabled. This is a little misleading but it's still an improvement over the status quo (and we'll want this code anyway, once we start actually supporting dark/light modes). |
Yes you are correct. This allows Windows to restyle the title bar to the system-preferred mode. This is disabled by default for backwards compatibility reasons. It does not allow the application to respond to the system-preferred mode. This would probably take a bit more work to pipe the events up to the application layer through the shell and write the code to detect it. I could look into it in a future change when I have some more time! |
It looks like the function to query theme color is in the windows-rs library so I would have to pull this in as a dependency to add the theme mode detection functions: https://github.com/microsoft/windows-rs/blob/cbc54970034445e0e50ae548ab8d93768548a4fb/crates/libs/windows/src/Windows/UI/ViewManagement/mod.rs#L3677 |
Got it, thanks! I think there was some discussion in the past about moving to windows-rs, but I don't remember the conclusion. And anyway it's definitely out of scope for this PR! Would you mind adding an entry to the changelog? Other than that, I think this is good to go. |
Yes A changelog entry would be nice indeed. You can read about it in our CONTRIBUTING.md. It should probably be clear about the limited nature of this work though. So something like Windows: Dark mode support for the titlebar under the Added section. |
Add a changelog entry, thanks! |
Sorry, I forgot to tell you: the PR and author links in the changelog aren't magic: they're all defined at the bottom of the file... |
Fixed, thanks! |
Finally got around to testing this and as far as I can tell this doesn't actually have any automatic theme switching by the OS. Now Druid apps always have a dark title bar. @dristic have you seen the title bar be light after this change? |
When testing locally I see the same thing. It looks like I have to add the color detection hook in to see if we need to set the title bar to dark or not. I will get this fixed and open another PR. Good catch! |
Small edit to let Windows theme the title bar with dark mode support. I followed the instructions at the bottom of this page: https://docs.microsoft.com/en-us/windows/apps/desktop/modernize/apply-windows-themes
Here is how it looks:

First time contributing so let me know if I missed anything. Thanks!