rust-windowing / rust-windowing/winit
Dark mode for menus
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 6.2k
- Forks
- 1.3k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 9
Description
Description
The current winit implementation of dark mode on Windows does not enable it for menus (e.g. tray context, title bar context). For that, you need to call another undocumented function from uxtheme.dll: SetPreferredAppMode, ordinal 135 (which seems to be available since Windows 10 1903, aka build 18362). Calling it with AllowDark makes Windows switch the color mode of the menus automatically on user's settings changes, which is pretty convenient, but the color mode can be forced using the other variants.
I've seen mpv use it in the wild, and this discussion which goes in depth about Windows and its apparent lack of care for its own OS.
Note that this is an application setting. It only needs to be called once and doesn't require any event loop or window. The function seems to return the previous mode that was chosen, so if it returns anything other than Default or AllowDark, it can be changed back.
Relevant piece of C code:
enum class PreferredAppMode
{
Default,
AllowDark,
ForceDark,
ForceLight,
Max
};
typedef PreferredAppMode (WINAPI* SetPreferredAppMode_t)(PreferredAppMode);
Relevant platforms
Windows
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating winit’s existing Windows dark-mode implementation and its platform entry points. Review the linked SetPreferredAppMode API details and the relevant C example, then integrate the application-level call without requiring an event loop. Done means Windows menus, including tray and title-bar context menus, follow the user’s dark-mode setting.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- desktop, operating-systems
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100