@@ -7,6 +7,7 @@ import * as Path from "node:path";
77import {
88 app ,
99 BrowserWindow ,
10+ type BrowserWindowConstructorOptions ,
1011 clipboard ,
1112 dialog ,
1213 ipcMain ,
@@ -118,6 +119,15 @@ const DESKTOP_UPDATE_CHANNEL = "latest";
118119const DESKTOP_UPDATE_ALLOW_PRERELEASE = false ;
119120const DESKTOP_LOOPBACK_HOST = "127.0.0.1" ;
120121const DESKTOP_REQUIRED_PORT_PROBE_HOSTS = [ "0.0.0.0" , "::" ] as const ;
122+ const TITLEBAR_HEIGHT = 40 ;
123+ const TITLEBAR_COLOR = "#01000000" ; // #00000000 does not work correctly on Linux
124+ const TITLEBAR_LIGHT_SYMBOL_COLOR = "#1f2937" ;
125+ const TITLEBAR_DARK_SYMBOL_COLOR = "#f8fafc" ;
126+
127+ type WindowTitleBarOptions = Pick <
128+ BrowserWindowConstructorOptions ,
129+ "titleBarOverlay" | "titleBarStyle" | "trafficLightPosition"
130+ > ;
121131
122132type DesktopUpdateErrorContext = DesktopUpdateState [ "errorContext" ] ;
123133type LinuxDesktopNamedApp = Electron . App & {
@@ -1649,6 +1659,46 @@ function getInitialWindowBackgroundColor(): string {
16491659 return nativeTheme . shouldUseDarkColors ? "#0a0a0a" : "#ffffff" ;
16501660}
16511661
1662+ function getWindowTitleBarOptions ( ) : WindowTitleBarOptions {
1663+ if ( process . platform === "darwin" ) {
1664+ return {
1665+ titleBarStyle : "hiddenInset" ,
1666+ trafficLightPosition : { x : 16 , y : 18 } ,
1667+ } ;
1668+ }
1669+
1670+ return {
1671+ titleBarStyle : "hidden" ,
1672+ titleBarOverlay : {
1673+ color : TITLEBAR_COLOR ,
1674+ height : TITLEBAR_HEIGHT ,
1675+ symbolColor : nativeTheme . shouldUseDarkColors
1676+ ? TITLEBAR_DARK_SYMBOL_COLOR
1677+ : TITLEBAR_LIGHT_SYMBOL_COLOR ,
1678+ } ,
1679+ } ;
1680+ }
1681+
1682+ function syncWindowAppearance ( window : BrowserWindow ) : void {
1683+ if ( window . isDestroyed ( ) ) {
1684+ return ;
1685+ }
1686+
1687+ window . setBackgroundColor ( getInitialWindowBackgroundColor ( ) ) ;
1688+ const { titleBarOverlay } = getWindowTitleBarOptions ( ) ;
1689+ if ( typeof titleBarOverlay === "object" ) {
1690+ window . setTitleBarOverlay ( titleBarOverlay ) ;
1691+ }
1692+ }
1693+
1694+ function syncAllWindowAppearance ( ) : void {
1695+ for ( const window of BrowserWindow . getAllWindows ( ) ) {
1696+ syncWindowAppearance ( window ) ;
1697+ }
1698+ }
1699+
1700+ nativeTheme . on ( "updated" , syncAllWindowAppearance ) ;
1701+
16521702function createWindow ( ) : BrowserWindow {
16531703 const window = new BrowserWindow ( {
16541704 width : 1100 ,
@@ -1660,8 +1710,7 @@ function createWindow(): BrowserWindow {
16601710 backgroundColor : getInitialWindowBackgroundColor ( ) ,
16611711 ...getIconOption ( ) ,
16621712 title : APP_DISPLAY_NAME ,
1663- titleBarStyle : "hiddenInset" ,
1664- trafficLightPosition : { x : 16 , y : 18 } ,
1713+ ...getWindowTitleBarOptions ( ) ,
16651714 webPreferences : {
16661715 preload : Path . join ( __dirname , "preload.js" ) ,
16671716 contextIsolation : true ,
0 commit comments