@@ -7,7 +7,6 @@ import * as Path from "node:path";
77import {
88 app ,
99 BrowserWindow ,
10- type BrowserWindowConstructorOptions ,
1110 clipboard ,
1211 dialog ,
1312 ipcMain ,
@@ -86,6 +85,10 @@ import { isArm64HostRunningIntelBuild, resolveDesktopRuntimeInfo } from "./runti
8685import { resolveDesktopAppBranding } from "./appBranding.ts" ;
8786import { bindFirstRevealTrigger , type RevealSubscription } from "./windowReveal.ts" ;
8887import { resolveTailscaleAdvertisedEndpoints } from "./tailscaleEndpointProvider.ts" ;
88+ import {
89+ getWindowTitleBarOptions ,
90+ shouldRelaunchForClientSettingsChange ,
91+ } from "./windowTitleBar.ts" ;
8992
9093syncShellEnvironment ( ) ;
9194
@@ -176,11 +179,6 @@ function resolvePickFolderDefaultPath(rawOptions: unknown): string | undefined {
176179}
177180const DESKTOP_LOOPBACK_HOST = "127.0.0.1" ;
178181const DESKTOP_REQUIRED_PORT_PROBE_HOSTS = [ "0.0.0.0" , "::" ] as const ;
179- const TITLEBAR_HEIGHT = 40 ;
180- const TITLEBAR_COLOR = "#01000000" ; // #00000000 does not work correctly on Linux
181- const TITLEBAR_LIGHT_SYMBOL_COLOR = "#1f2937" ;
182- const TITLEBAR_DARK_SYMBOL_COLOR = "#f8fafc" ;
183-
184182function normalizeContextMenuItems ( source : readonly ContextMenuItem [ ] ) : ContextMenuItem [ ] {
185183 const normalizedItems : ContextMenuItem [ ] = [ ] ;
186184
@@ -210,11 +208,6 @@ function normalizeContextMenuItems(source: readonly ContextMenuItem[]): ContextM
210208 return normalizedItems ;
211209}
212210
213- type WindowTitleBarOptions = Pick <
214- BrowserWindowConstructorOptions ,
215- "titleBarOverlay" | "titleBarStyle" | "trafficLightPosition"
216- > ;
217-
218211type DesktopUpdateErrorContext = DesktopUpdateState [ "errorContext" ] ;
219212type LinuxDesktopNamedApp = Electron . App & {
220213 setDesktopName ?: ( desktopName : string ) => void ;
@@ -1677,9 +1670,19 @@ function registerIpcHandlers(): void {
16771670 throw new Error ( "Invalid client settings payload." ) ;
16781671 }
16791672
1680- clientSettings = rawSettings as ClientSettings ;
1681- writeClientSettings ( CLIENT_SETTINGS_PATH , clientSettings ) ;
1673+ const nextClientSettings = rawSettings as ClientSettings ;
1674+ const shouldRelaunch = shouldRelaunchForClientSettingsChange (
1675+ clientSettings ,
1676+ nextClientSettings ,
1677+ ) ;
1678+
1679+ clientSettings = nextClientSettings ;
1680+ writeClientSettings ( CLIENT_SETTINGS_PATH , nextClientSettings ) ;
16821681 syncAllWindowAppearance ( ) ;
1682+
1683+ if ( shouldRelaunch ) {
1684+ relaunchDesktopApp ( "client-settings-hideWindowControls" ) ;
1685+ }
16831686 } ) ;
16841687
16851688 ipcMain . removeHandler ( GET_SAVED_ENVIRONMENT_REGISTRY_CHANNEL ) ;
@@ -2010,40 +2013,16 @@ function getInitialWindowBackgroundColor(): string {
20102013 return nativeTheme . shouldUseDarkColors ? "#0a0a0a" : "#ffffff" ;
20112014}
20122015
2013- function getWindowTitleBarOptions ( hideWindowControls : boolean ) : WindowTitleBarOptions {
2014- if ( process . platform === "darwin" ) {
2015- if ( hideWindowControls ) {
2016- return { titleBarStyle : "hidden" } ;
2017- }
2018- return {
2019- titleBarStyle : "hiddenInset" ,
2020- trafficLightPosition : { x : 16 , y : 18 } ,
2021- } ;
2022- }
2023-
2024- if ( hideWindowControls ) {
2025- return {
2026- titleBarStyle : "hidden" ,
2027- titleBarOverlay : {
2028- color : TITLEBAR_COLOR ,
2029- height : TITLEBAR_HEIGHT ,
2030- symbolColor : nativeTheme . shouldUseDarkColors
2031- ? TITLEBAR_DARK_SYMBOL_COLOR
2032- : TITLEBAR_LIGHT_SYMBOL_COLOR ,
2033- } ,
2034- } ;
2035- }
2036-
2037- return { titleBarStyle : "default" } ;
2038- }
2039-
20402016function syncWindowAppearance ( window : BrowserWindow ) : void {
20412017 if ( window . isDestroyed ( ) ) {
20422018 return ;
20432019 }
20442020
20452021 window . setBackgroundColor ( getInitialWindowBackgroundColor ( ) ) ;
2046- const { titleBarOverlay } = getWindowTitleBarOptions ( clientSettings . hideWindowControls ) ;
2022+ const { titleBarOverlay } = getWindowTitleBarOptions ( {
2023+ platform : process . platform ,
2024+ hideWindowControls : clientSettings . hideWindowControls ,
2025+ } ) ;
20472026 if ( typeof titleBarOverlay === "object" ) {
20482027 window . setTitleBarOverlay ( titleBarOverlay ) ;
20492028 }
@@ -2068,7 +2047,10 @@ function createWindow(): BrowserWindow {
20682047 backgroundColor : getInitialWindowBackgroundColor ( ) ,
20692048 ...getIconOption ( ) ,
20702049 title : APP_DISPLAY_NAME ,
2071- ...getWindowTitleBarOptions ( clientSettings . hideWindowControls ) ,
2050+ ...getWindowTitleBarOptions ( {
2051+ platform : process . platform ,
2052+ hideWindowControls : clientSettings . hideWindowControls ,
2053+ } ) ,
20722054 webPreferences : {
20732055 preload : Path . join ( __dirname , "preload.cjs" ) ,
20742056 contextIsolation : true ,
0 commit comments