rust-windowing / rust-windowing/winit

Dark mode for menus

Open
#4,690 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

S - enhancement
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.