Title bar follows the system dark or light theme (VICTORY_DARK_TITLE, on by default) #1788

Manually merged
github merged 2 commits from github-bot/gh-1788 into main 2026-11-29 08:21:48 +00:00 AGit
Owner

@⁠Jesper-Andersson on GitHub · 2026-11-29 00:05 UTC · original
Jesper-Andersson:pr/dark-title → main · +184 −0 · 5 files · 2 commits · merged 2026-11-29 08:16 UTC

Tested in game: the title bar was dark on a Windows 11 dark-theme desktop (checked by eye on 2026-11-29, RTX 2070 SUPER). This ran on our branch, which has the same commits merged onto our own base, not on this PR branch itself. A live theme switch while the game runs was not tested.

On by default. VICTORY_DARK_TITLE=0 turns it off.

Relates to: no issue; this PR is my claim for the idea.

What it changes

The game window's caption stayed light on a dark-mode desktop. It now follows the system's apps theme.

Behaviour change: on by default. VICTORY_DARK_TITLE=0 turns it off and leaves the window as it was.

  • At the first top-level window (crates/victory-hle/src/modules/theme.rs), the apps theme is read from HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize AppsUseLightTheme (0 is dark; a missing value counts as light). It is passed to DwmSetWindowAttribute with DWMWA_USE_IMMERSIVE_DARK_MODE (20), with a fallback to 19 for Windows 10 before 20H1.
  • The caption repaints only after a frame change, so a SetWindowPos with SWP_FRAMECHANGED | NOMOVE | NOSIZE | NOZORDER | NOACTIVATE follows.
  • The window procedure applies it again on WM_SETTINGCHANGE with "ImmersiveColorSet" (top-level window only), so a theme switch while the game runs shows at once.
  • VICTORY_DARK_TITLE: unset or auto follows the system, 1 is always dark, 0 is off.
  • windows-sys gains Win32_Graphics_Dwm and Win32_System_Registry. No new crate, and no dependency on the window icon PR.
  • One line in docs/findings.md.

The caption exists only in the default windowed mode. With VICTORY_FULLSCREEN=1 the window becomes a popup with no caption, so this has no visible effect there. The check above was in the default windowed mode. Borderless was not tested.

Nothing from the game is involved: the code holds only system API names and our own switch name.

Sources (Microsoft Learn): "Support Dark and Light themes in Win32 apps", DwmSetWindowAttribute and DWMWINDOWATTRIBUTE (DWMWA_USE_IMMERSIVE_DARK_MODE), WM_SETTINGCHANGE, RegGetValueW.

How it was tested

  • GPU and profile: RTX 2070 SUPER 8 GB, Windows 11, Series S, 1080p, DLSS Performance (frame generation off, ray tracing off)
  • Before: a light caption on a dark-mode desktop.
  • After: the caption is dark on a Windows 11 dark-theme desktop. Seen on our branch (the same commits merged onto our base), not on this PR branch. Not checked: a live theme switch while the game runs, and a light-theme desktop.
  • For shader changes, the wave sizes tested: N/A (no shader change)
  • cargo test passed for the crates it touches: yes: 203 passed, 0 failed, 3 ignored, plus no_dll_planting 1 passed (-p victory-hle; the unit tests cover the registry value mapping, the switch and the setting name). cargo clippy -p victory-hle --all-targets: no warnings in victory-hle (the warnings that remain are main's own, in victory-shader and victory-gpu, so -D warnings stops there before reaching this crate). cargo xtask policy: fails only on upstream's own crates/victory-shader/src/emit/lower.rs (667,523 bytes, over the 655,360-byte limit; the same on main, see #1429/#1493/#1527). This PR does not touch that file, and every changed file passes.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches (dark mode, DWM, theme, title bar, lifecycle.rs). Related: none sets the caption theme. #1002, #1009, #1067 and #753 also change the window procedure in lifecycle.rs. This PR adds a few lines there (theme::apply in hook, and the WM_SETTINGCHANGE handling). Companion PR (separate, independent, touches the same two spots in lifecycle.rs): the window icon, pr/window-icon.

This was written with AI assistance (Claude Code).

**@⁠Jesper-Andersson** on GitHub · 2026-11-29 00:05 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/1788) `Jesper-Andersson:pr/dark-title` → `main` · +184 −0 · 5 files · 2 commits · merged 2026-11-29 08:16 UTC <!-- Labels are in the title: pr-feature, startup. No window/UI area label exists, so startup is the closest one (it is the window made at start). --> Tested in game: the title bar was dark on a Windows 11 dark-theme desktop (checked by eye on 2026-11-29, RTX 2070 SUPER). This ran on our branch, which has the same commits merged onto our own base, not on this PR branch itself. A live theme switch while the game runs was not tested. On by default. `VICTORY_DARK_TITLE=0` turns it off. Relates to: no issue; this PR is my claim for the idea. ## What it changes The game window's caption stayed light on a dark-mode desktop. It now follows the system's apps theme. **Behaviour change: on by default.** `VICTORY_DARK_TITLE=0` turns it off and leaves the window as it was. - At the first top-level window (`crates/victory-hle/src/modules/theme.rs`), the apps theme is read from `HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize` `AppsUseLightTheme` (0 is dark; a missing value counts as light). It is passed to `DwmSetWindowAttribute` with `DWMWA_USE_IMMERSIVE_DARK_MODE` (20), with a fallback to 19 for Windows 10 before 20H1. - The caption repaints only after a frame change, so a `SetWindowPos` with `SWP_FRAMECHANGED | NOMOVE | NOSIZE | NOZORDER | NOACTIVATE` follows. - The window procedure applies it again on `WM_SETTINGCHANGE` with `"ImmersiveColorSet"` (top-level window only), so a theme switch while the game runs shows at once. - `VICTORY_DARK_TITLE`: unset or `auto` follows the system, `1` is always dark, `0` is off. - `windows-sys` gains `Win32_Graphics_Dwm` and `Win32_System_Registry`. No new crate, and no dependency on the window icon PR. - One line in `docs/findings.md`. The caption exists only in the default windowed mode. With `VICTORY_FULLSCREEN=1` the window becomes a popup with no caption, so this has no visible effect there. The check above was in the default windowed mode. Borderless was not tested. Nothing from the game is involved: the code holds only system API names and our own switch name. Sources (Microsoft Learn): "Support Dark and Light themes in Win32 apps", DwmSetWindowAttribute and DWMWINDOWATTRIBUTE (DWMWA_USE_IMMERSIVE_DARK_MODE), WM_SETTINGCHANGE, RegGetValueW. ## How it was tested - GPU and profile: RTX 2070 SUPER 8 GB, Windows 11, Series S, 1080p, DLSS Performance (frame generation off, ray tracing off) - Before: a light caption on a dark-mode desktop. - After: the caption is dark on a Windows 11 dark-theme desktop. Seen on our branch (the same commits merged onto our base), not on this PR branch. **Not checked:** a live theme switch while the game runs, and a light-theme desktop. - For shader changes, the wave sizes tested: N/A (no shader change) - `cargo test` passed for the crates it touches: yes: 203 passed, 0 failed, 3 ignored, plus `no_dll_planting` 1 passed (`-p victory-hle`; the unit tests cover the registry value mapping, the switch and the setting name). `cargo clippy -p victory-hle --all-targets`: no warnings in victory-hle (the warnings that remain are main's own, in victory-shader and victory-gpu, so `-D warnings` stops there before reaching this crate). `cargo xtask policy`: fails only on upstream's own `crates/victory-shader/src/emit/lower.rs` (667,523 bytes, over the 655,360-byte limit; the same on main, see #1429/#1493/#1527). This PR does not touch that file, and every changed file passes. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches (dark mode, DWM, theme, title bar, `lifecycle.rs`). Related: none sets the caption theme. #1002, #1009, #1067 and #753 also change the window procedure in `lifecycle.rs`. This PR adds a few lines there (`theme::apply` in `hook`, and the `WM_SETTINGCHANGE` handling). Companion PR (separate, independent, touches the same two spots in `lifecycle.rs`): the window icon, `pr/window-icon`. This was written with AI assistance (Claude Code).
The window's caption stayed light on a dark-mode desktop. At the first
top-level window (crates/victory-hle/src/modules/theme.rs) the apps theme is
read from HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize
AppsUseLightTheme (0 is dark, missing is light) and passed to
DwmSetWindowAttribute with DWMWA_USE_IMMERSIVE_DARK_MODE (20), falling back to
19 for Windows 10 before 20H1. The caption repaints only after a frame change,
so a SetWindowPos with SWP_FRAMECHANGED | NOMOVE | NOSIZE | NOZORDER |
NOACTIVATE follows. The window procedure applies it again on WM_SETTINGCHANGE
whose string is "ImmersiveColorSet", so a theme switch while the game runs
shows at once.

VICTORY_DARK_TITLE: unset or "auto" follows the system (default on, a
behaviour change for the PR description), "1" is always dark, "0" leaves the
window alone. windows-sys gains Win32_Graphics_Dwm and Win32_System_Registry;
no new crate. Unit tests cover the registry value, the switch and the setting
name.

Sources: Microsoft Learn: Support Dark and Light themes in Win32 apps,
DwmSetWindowAttribute and DWMWINDOWATTRIBUTE (DWMWA_USE_IMMERSIVE_DARK_MODE),
WM_SETTINGCHANGE, RegGetValueW.

This change was made with AI assistance (Claude Code).
clippy::not_unsafe_ptr_arg_deref flagged apply and apply_for_setting: as
public functions they take a window handle (a raw pointer) without being
unsafe. Only lifecycle calls them, so pub(crate) is enough and the lint no
longer applies.

This change was made with AI assistance (Claude Code).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-29 00:10:17 +00:00
github manually merged commit 9798e53d2e into main 2026-11-29 08:21:48 +00:00
This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!1788
No description provided.