Skip to content

Commit

Permalink
Titlebar overlay is not enabled (fix #158203) (#158251)
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero authored Aug 16, 2022
1 parent 4b6ccd8 commit 2857051
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/vs/platform/window/common/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>('window.experimental.windowControlsOverlay.enabled');
const configuredUseWindowControlsOverlay = configurationService.getValue<boolean | undefined>('window.experimental.windowControlsOverlay.enabled');
if (typeof configuredUseWindowControlsOverlay === 'boolean') {
return configuredUseWindowControlsOverlay;
}

return true; // enabled by default
}

export interface IPath<T = IEditorOptions> extends IPathData<T> {
Expand Down
6 changes: 5 additions & 1 deletion src/vs/platform/windows/electron-main/windowImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];
Expand Down Expand Up @@ -280,6 +282,8 @@ export class CodeWindow extends Disposable implements ICodeWindow {
color: titleBarColor,
symbolColor
};

this.hasWindowControlOverlay = true;
}
}

Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 2857051

Please sign in to comment.