Skip to content

fix(window): match title-bar control symbols to the app theme (#26) - #48

Merged
mrsibe merged 1 commit into
mainfrom
fix/issue-26-titlebar-symbol-color
Sep 24, 2026
Merged

mrsibe merged 1 commit into
mainfrom
fix/issue-26-titlebar-symbol-color

Conversation

@mrsibe

@mrsibe mrsibe commented Sep 24, 2026

Copy link
Copy Markdown
Owner

Problem

Fixes #26.

With the light theme enabled, the window controls in the top-right corner
(minimize / maximize / close) were almost invisible.

Root cause

The windows use titleBarStyle: 'hidden' plus a transparent titleBarOverlay,
so the OS draws the control symbols on top of the renderer. mainWindow.ts,
quizWindow.ts and mindMapWindow.ts hardcoded symbolColor: 'white', which
only reads on the dark title bar. The light title bar is #fafafa, so white
symbols disappeared.

ankiWindow.ts was already theme-aware, but used
nativeTheme.shouldUseDarkColors || theme === 'dark'; the renderer always
follows the app setting, so an OS-dark machine with the app set to light still
got white symbols on the light bar.

Fix

  • Add src/main/windows/titleBarOverlay.ts with titleBarSymbolColor,
    titleBarOverlayOptions and applyTitleBarTheme.
  • Build the overlay from the current theme in all four windows and re-apply the
    symbol colour in the existing settings-change listeners, so it follows a live
    theme switch.
  • Drop the nativeTheme special case in ankiWindow.ts.

Verification

  • npm run typecheck (node / web / test) — pass
  • npm run lint — pass
  • npm run check:design — pass
  • npm test — 22 pass (adds test/titleBarOverlay.test.ts covering both themes)
  • npm run build — pass

Not verified: the actual OS-drawn title bar was not screenshotted on a
Windows/Linux desktop in this environment; the change only sets
symbolColor, which the test pins.

The OS draws minimize / maximize / close on the transparent title-bar
overlay using `symbolColor`. mainWindow, quizWindow and mindMapWindow
hardcoded it to `white`, so in light mode the symbols were white on the
`#fafafa` title bar and effectively invisible (issue #26).

Derive the symbol colour from the app theme in one helper and reapply it
when the theme changes, so the controls stay legible in both modes. This
also replaces ankiWindow's `nativeTheme.shouldUseDarkColors || theme ===
'dark'` check: the renderer always follows the app setting, so an OS-dark
machine with the app set to light got white symbols on the light bar.

Fixes #26
@github-actions github-actions Bot added the bug Something isn't working label Sep 24, 2026
@mrsibe
mrsibe merged commit 1d21902 into main Sep 24, 2026
4 checks passed
@mrsibe
mrsibe deleted the fix/issue-26-titlebar-symbol-color branch September 24, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

功能按键显示BUG

1 participant