Skip to content

Commit

Permalink
Enable WCO on all builds
Browse files Browse the repository at this point in the history
Fixes #161218
Fixes #164397
  • Loading branch information
rzhao271 committed Nov 23, 2022
1 parent 3df5eee commit 09624fb
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 30 deletions.
26 changes: 11 additions & 15 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,16 @@ if (locale) {
nlsConfigurationPromise = getNLSConfiguration(product.commit, userDataPath, metaDataFile, locale);
}

if (product.quality === 'insider' || product.quality === 'exploration') {

// Pass in the locale to Electron so that the
// Windows Control Overlay is rendered correctly on Windows,
// and so that the traffic lights are rendered properly
// on macOS when using a custom titlebar.
// If the locale is `qps-ploc`, the Microsoft
// Pseudo Language Language Pack is being used.
// In that case, use `en` as the Electron locale.

const electronLocale = (!locale || locale === 'qps-ploc') ? 'en' : locale;
app.commandLine.appendSwitch('lang', electronLocale);
}
// Pass in the locale to Electron so that the
// Windows Control Overlay is rendered correctly on Windows,
// and so that the traffic lights are rendered properly
// on macOS when using a custom titlebar.
// If the locale is `qps-ploc`, the Microsoft
// Pseudo Language Language Pack is being used.
// In that case, use `en` as the Electron locale.

const electronLocale = (!locale || locale === 'qps-ploc') ? 'en' : locale;
app.commandLine.appendSwitch('lang', electronLocale);

// Load our code once ready
app.once('ready', function () {
Expand Down Expand Up @@ -576,8 +573,7 @@ async function resolveNlsConfiguration() {
// VS Code moves to Electron 22.
// Ref https://github.com/microsoft/vscode/issues/159813
// and https://github.com/electron/electron/pull/36035
if ((product.quality === 'insider' || product.quality === 'exploration')
&& 'getPreferredSystemLanguages' in app
if ('getPreferredSystemLanguages' in app
&& typeof app.getPreferredSystemLanguages === 'function'
&& app.getPreferredSystemLanguages().length) {
appLocale = app.getPreferredSystemLanguages()[0];
Expand Down
8 changes: 3 additions & 5 deletions src/vs/platform/window/common/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
import { FileType } from 'vs/platform/files/common/files';
import { LogLevel } from 'vs/platform/log/common/log';
import { PolicyDefinition, PolicyValue } from 'vs/platform/policy/common/policy';
import { IProductService } from 'vs/platform/product/common/productService';
import { IPartsSplash } from 'vs/platform/theme/common/themeService';
import { IUserDataProfile } from 'vs/platform/userDataProfile/common/userDataProfile';
import { IAnyWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
Expand Down Expand Up @@ -164,7 +163,7 @@ export function getTitleBarStyle(configurationService: IConfigurationService): '
return isLinux ? 'native' : 'custom'; // default to custom on all macOS and Windows
}

export function useWindowControlsOverlay(configurationService: IConfigurationService, productService: IProductService): boolean {
export function useWindowControlsOverlay(configurationService: IConfigurationService): boolean {
if (!isWindows || isWeb) {
return false; // only supported on a desktop Windows instance
}
Expand All @@ -178,9 +177,8 @@ export function useWindowControlsOverlay(configurationService: IConfigurationSer
return configuredUseWindowControlsOverlay;
}

// Default to true for Insider and Exploration to match with
// app.getPreferredSystemLanguages() only being available on those builds.
return productService.quality === 'insider' || productService.quality === 'exploration';
// Default to true.
return true;
}

export interface IPath<T = IEditorOptions> extends IPathData<T> {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/windows/electron-main/windowImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
options.frame = false;
}

if (useWindowControlsOverlay(this.configurationService, this.productService)) {
if (useWindowControlsOverlay(this.configurationService)) {

// This logic will not perfectly guess the right colors
// to use on initialization, but prefer to keep things
Expand Down Expand Up @@ -316,7 +316,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
}

// Update the window controls immediately based on cached values
if (useCustomTitleStyle && ((isWindows && useWindowControlsOverlay(this.configurationService, this.productService)) || isMacintosh)) {
if (useCustomTitleStyle && ((isWindows && useWindowControlsOverlay(this.configurationService)) || isMacintosh)) {
const cachedWindowControlHeight = this.stateMainService.getItem<number>((CodeWindow.windowControlHeightStateStorageKey));
if (cachedWindowControlHeight) {
this.updateWindowControls({ height: cachedWindowControlHeight });
Expand Down
2 changes: 0 additions & 2 deletions src/vs/workbench/browser/parts/titlebar/titlebarPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { IHoverDelegate } from 'vs/base/browser/ui/iconLabel/iconHoverDelegate';
import { IHoverService } from 'vs/workbench/services/hover/browser/hover';
import { Categories } from 'vs/platform/action/common/actionCommonCategories';
import { MenuWorkbenchToolBar } from 'vs/platform/actions/browser/toolbar';
import { IProductService } from 'vs/platform/product/common/productService';

export class TitlebarPart extends Part implements ITitleService {

Expand Down Expand Up @@ -90,7 +89,6 @@ export class TitlebarPart extends Part implements ITitleService {
@IConfigurationService protected readonly configurationService: IConfigurationService,
@IBrowserWorkbenchEnvironmentService protected readonly environmentService: IBrowserWorkbenchEnvironmentService,
@IInstantiationService protected readonly instantiationService: IInstantiationService,
@IProductService protected readonly productService: IProductService,
@IThemeService themeService: IThemeService,
@IStorageService storageService: IStorageService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/electron-sandbox/desktop.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ import product from 'vs/platform/product/common/product';
},
'window.experimental.windowControlsOverlay.enabled': {
'type': 'boolean',
'default': product.quality === 'insider' || product.quality === 'exploration', // switch back to true when app.getLocale() isn't used anymore.
'default': true,
'scope': ConfigurationScope.APPLICATION,
'description': localize('windowControlsOverlay', "Use window controls provided by the platform instead of our HTML-based window controls. Changes require a full restart to apply."),
'included': isWindows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { Codicon } from 'vs/base/common/codicons';
import { NativeMenubarControl } from 'vs/workbench/electron-sandbox/parts/titlebar/menubarControl';
import { IHoverService } from 'vs/workbench/services/hover/browser/hover';
import { IProductService } from 'vs/platform/product/common/productService';

export class TitlebarPart extends BrowserTitleBarPart {
private maxRestoreControl: HTMLElement | undefined;
Expand Down Expand Up @@ -59,7 +58,6 @@ export class TitlebarPart extends BrowserTitleBarPart {
@IConfigurationService configurationService: IConfigurationService,
@INativeWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService,
@IInstantiationService instantiationService: IInstantiationService,
@IProductService productService: IProductService,
@IThemeService themeService: IThemeService,
@IStorageService storageService: IStorageService,
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
Expand All @@ -68,7 +66,7 @@ export class TitlebarPart extends BrowserTitleBarPart {
@INativeHostService private readonly nativeHostService: INativeHostService,
@IHoverService hoverService: IHoverService,
) {
super(contextMenuService, configurationService, environmentService, instantiationService, productService, themeService, storageService, layoutService, contextKeyService, hostService, hoverService);
super(contextMenuService, configurationService, environmentService, instantiationService, themeService, storageService, layoutService, contextKeyService, hostService, hoverService);

this.environmentService = environmentService;
}
Expand Down Expand Up @@ -218,7 +216,7 @@ export class TitlebarPart extends BrowserTitleBarPart {
super.updateStyles();

// WCO styles only supported on Windows currently
if (useWindowControlsOverlay(this.configurationService, this.productService)) {
if (useWindowControlsOverlay(this.configurationService)) {
if (!this.cachedWindowControlStyles ||
this.cachedWindowControlStyles.bgColor !== this.element.style.backgroundColor ||
this.cachedWindowControlStyles.fgColor !== this.element.style.color) {
Expand All @@ -230,7 +228,7 @@ export class TitlebarPart extends BrowserTitleBarPart {
override layout(width: number, height: number): void {
super.layout(width, height);

if (useWindowControlsOverlay(this.configurationService, this.productService) ||
if (useWindowControlsOverlay(this.configurationService) ||
(isMacintosh && isNative && getTitleBarStyle(this.configurationService) === 'custom')) {
// When the user goes into full screen mode, the height of the title bar becomes 0.
// Instead, set it back to the default titlebar height for Catalina users
Expand Down

0 comments on commit 09624fb

Please sign in to comment.