Skip to content

fix(desktop): match the Windows title bar color to the app surface - #547

Merged
huichen merged 1 commit into
mainfrom
claude/windows-caption-color
Sep 10, 2026
Merged

huichen merged 1 commit into
mainfrom
claude/windows-caption-color

Conversation

@huichen

@huichen huichen commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Problem

On Windows the desktop window's top strip renders in a different color from the rest of the window. The frame is drawn by DWM, so a decorated window gets the system caption color — a light gray band, tinted by the wallpaper when transparency is on — sitting directly above the webview's white canvas. macOS never shows this seam because titleBarStyle: "Overlay" hands the top strip to the app.

Measured on a live window before the fix (top band #F3F3F3 vs. app surface #FFFFFF):

y=0..60    #F3F3F3   <- native caption
y=70..     #FFFFFF   <- webview (surface)

Fix

match_windows_caption_color runs in setup, next to the existing taskbar-icon fix:

  • Windows 11 (21H2+, build 22000): pin DWMWA_CAPTION_COLOR to the surface token (#ffffff) and DWMWA_TEXT_COLOR to ink (#172033), so the caption matches the app's own top strip.
  • Clear DWMWA_USE_IMMERSIVE_DARK_MODE so a dark system theme cannot darken the caption either (the app palette is light-only).
  • Older builds reject these attributes; the Result is ignored and the default is left in place, so this degrades to today's behavior.

Verification

Verified against a live window with the same DWM call: setting DWMWA_CAPTION_COLOR to white turned the previously #F3F3F3 band to #FFFFFF, matching the webview surface.

  • cargo fmt --check / cargo clippy --all-targets -- -D warnings under desktop/src-tauri — clean
  • cargo test --lib windows_caption — passes (mock-app no-op arm; the color effect itself is only observable on a live window)

Note: 25 pre-existing git/temp-dir tests in this crate fail on this machine both before and after the change (child-process spawn denied in the shell environment); they are unrelated to this diff.

The Windows frame is drawn by DWM, so a decorated window gets the system
caption color -- a light gray band (wallpaper-tinted when transparency is
on) sitting directly above the webview's white canvas. macOS never shows
this seam because 	itleBarStyle: Overlay hands the top strip to the app.

On Windows 11 (21H2+) pin the caption and title-text colors to the app
palette (surface / ink from tailwind.config.js), and clear the dark-mode
attribute so a dark system theme cannot darken the caption either.
Unsupported attributes on older builds are rejected and leave the default.
@huichen
huichen enabled auto-merge (squash) September 10, 2026 13:25
@huichen
huichen merged commit 3e29ad7 into main Sep 10, 2026
12 checks passed
@huichen
huichen deleted the claude/windows-caption-color branch September 10, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant