fix(desktop): align and theme Windows caption controls (#45208)

This commit is contained in:
Luke Parker
2026-08-26 19:02:10 +10:00
committed by GitHub
Unverified
parent 4eaf533cd0
commit 24ac05868c
4 changed files with 12 additions and 7 deletions
+2 -2
View File
@@ -58,7 +58,7 @@ export function AppBaseProviders(
props: ParentProps<{
locale?: Locale
onNativeTranslations?: Parameters<typeof LanguageProvider>[0]["onNativeTranslations"]
onThemeApplied?: () => void
onThemeApplied?: (mode: "light" | "dark", scheme: "system" | "light" | "dark") => void
}>,
) {
return (
@@ -67,7 +67,7 @@ export function AppBaseProviders(
<ThemeProvider
onThemeApplied={(_, mode, scheme) => {
void window.api?.setTitlebar?.({ mode, scheme })
props.onThemeApplied?.()
props.onThemeApplied?.(mode, scheme)
}}
>
<LanguageProvider locale={props.locale} onNativeTranslations={props.onNativeTranslations}>
+2 -2
View File
@@ -54,7 +54,7 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
const titlebarZoom = () => (windows() ? Math.max(zoom(), minTitlebarZoom) : zoom())
const minHeight = () => {
if (mac()) return `${titlebarHeight / zoom()}px`
if (windows()) return `${titlebarHeight / Math.min(titlebarZoom(), 1)}px`
if (windows()) return `env(titlebar-area-height, ${titlebarHeight / Math.min(titlebarZoom(), 1)}px)`
return undefined
}
const windowsControlsWidth = () => `${windowsControlsBaseWidth / Math.max(titlebarZoom(), 1)}px`
@@ -324,7 +324,7 @@ export function Titlebar(props: { update?: TitlebarUpdate; debugTools?: { visibl
<div
class="h-full flex-1 overflow-hidden flex flex-row items-center gap-1.5 px-2 md:pr-3"
classList={{
"pt-2": !bottom(),
"pt-2": !bottom() && !windows(),
"pb-2": bottom(),
"md:pl-2": macTrafficLights(),
"md:pl-4": !macTrafficLights(),
@@ -72,8 +72,10 @@ export function getBackgroundColor() {
export function setTitlebar(win: BrowserWindow, theme: Partial<TitlebarTheme> = {}) {
titlebarThemes.set(win, theme)
// The macOS frame follows nativeTheme, not the renderer theme.
if (process.platform === "darwin") nativeTheme.themeSource = theme.scheme ?? theme.mode ?? "system"
// Native window controls follow nativeTheme, not the renderer theme.
if (process.platform === "darwin" || process.platform === "win32") {
nativeTheme.themeSource = theme.scheme ?? theme.mode ?? "system"
}
updateTitlebar(win)
}
@@ -141,7 +141,10 @@ function DesktopWindow(props: {
<AppBaseProviders
locale={locale.latest}
onNativeTranslations={(bundle) => void props.api.setNativeTranslations(bundle).catch(() => undefined)}
onThemeApplied={() => void props.api.themeReady()}
onThemeApplied={(mode, scheme) => {
void props.api.setTitlebar({ mode, scheme })
void props.api.themeReady()
}}
>
<Show when={true}>{(_) => <ReadyApp />}</Show>
</AppBaseProviders>