From 2857051bb4e1bd7177c0d48b468b665c5a53b3c1 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Tue, 16 Aug 2022 02:53:58 -0700 Subject: [PATCH] Titlebar overlay is not enabled (fix #158203) (#158251) --- src/vs/platform/window/common/window.ts | 12 ++++++++---- src/vs/platform/windows/electron-main/windowImpl.ts | 6 +++++- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/vs/platform/window/common/window.ts b/src/vs/platform/window/common/window.ts index f50c4f9b38d96..dde2bd581d40b 100644 --- a/src/vs/platform/window/common/window.ts +++ b/src/vs/platform/window/common/window.ts @@ -165,16 +165,20 @@ export function getTitleBarStyle(configurationService: IConfigurationService): ' } export function useWindowControlsOverlay(configurationService: IConfigurationService, environmentService: IEnvironmentService): boolean { - // Window Controls Overlay are only configurable on Windows if (!isWindows || isWeb || !environmentService.isBuilt) { - return false; + return false; // only supported on a built desktop windows instance } if (getTitleBarStyle(configurationService) === 'native') { - return false; + return false; // only supported when title bar is custom } - return configurationService.getValue('window.experimental.windowControlsOverlay.enabled'); + const configuredUseWindowControlsOverlay = configurationService.getValue('window.experimental.windowControlsOverlay.enabled'); + if (typeof configuredUseWindowControlsOverlay === 'boolean') { + return configuredUseWindowControlsOverlay; + } + + return true; // enabled by default } export interface IPath extends IPathData { diff --git a/src/vs/platform/windows/electron-main/windowImpl.ts b/src/vs/platform/windows/electron-main/windowImpl.ts index f3a49e1d388cd..918f407fcdc61 100644 --- a/src/vs/platform/windows/electron-main/windowImpl.ts +++ b/src/vs/platform/windows/electron-main/windowImpl.ts @@ -143,6 +143,8 @@ export class CodeWindow extends Disposable implements ICodeWindow { private representedFilename: string | undefined; private documentEdited: boolean | undefined; + private readonly hasWindowControlOverlay: boolean = false; + private readonly whenReadyCallbacks: { (window: ICodeWindow): void }[] = []; private readonly touchBarGroups: TouchBarSegmentedControl[] = []; @@ -280,6 +282,8 @@ export class CodeWindow extends Disposable implements ICodeWindow { color: titleBarColor, symbolColor }; + + this.hasWindowControlOverlay = true; } } @@ -1072,7 +1076,7 @@ export class CodeWindow extends Disposable implements ICodeWindow { } // Windows: window control overlay (WCO) - if (isWindows && useWindowControlsOverlay(this.configurationService, this.environmentMainService)) { + if (isWindows && this.hasWindowControlOverlay) { this._win.setTitleBarOverlay({ color: options.backgroundColor?.trim() === '' ? undefined : options.backgroundColor, symbolColor: options.foregroundColor?.trim() === '' ? undefined : options.foregroundColor,