Skip to content

Commit 896c32b

Browse files
authored
Enable WCO on Insiders and Exploration (microsoft#166386)
Ref microsoft#161218
1 parent 184ba7b commit 896c32b

File tree

5 files changed

+16
-9
lines changed

5 files changed

+16
-9
lines changed

src/vs/platform/window/common/window.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { NativeParsedArgs } from 'vs/platform/environment/common/argv';
1414
import { FileType } from 'vs/platform/files/common/files';
1515
import { LogLevel } from 'vs/platform/log/common/log';
1616
import { PolicyDefinition, PolicyValue } from 'vs/platform/policy/common/policy';
17+
import { IProductService } from 'vs/platform/product/common/productService';
1718
import { IPartsSplash } from 'vs/platform/theme/common/themeService';
1819
import { IUserDataProfile } from 'vs/platform/userDataProfile/common/userDataProfile';
1920
import { IAnyWorkspaceIdentifier, ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
@@ -163,7 +164,7 @@ export function getTitleBarStyle(configurationService: IConfigurationService): '
163164
return isLinux ? 'native' : 'custom'; // default to custom on all macOS and Windows
164165
}
165166

166-
export function useWindowControlsOverlay(configurationService: IConfigurationService): boolean {
167+
export function useWindowControlsOverlay(configurationService: IConfigurationService, productService: IProductService): boolean {
167168
if (!isWindows || isWeb) {
168169
return false; // only supported on a desktop Windows instance
169170
}
@@ -177,7 +178,9 @@ export function useWindowControlsOverlay(configurationService: IConfigurationSer
177178
return configuredUseWindowControlsOverlay;
178179
}
179180

180-
return false; // disable by default
181+
// Default to true for Insider and Exploration to match with
182+
// app.getPreferredSystemLanguages() only being available on those builds.
183+
return productService.quality === 'insider' || productService.quality === 'exploration';
181184
}
182185

183186
export interface IPath<T = IEditorOptions> extends IPathData<T> {

src/vs/platform/windows/electron-main/windowImpl.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
274274
options.frame = false;
275275
}
276276

277-
if (useWindowControlsOverlay(this.configurationService)) {
277+
if (useWindowControlsOverlay(this.configurationService, this.productService)) {
278278

279279
// This logic will not perfectly guess the right colors
280280
// to use on initialization, but prefer to keep things
@@ -305,7 +305,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
305305
}
306306

307307
// Update the window controls immediately based on cached values
308-
if (useCustomTitleStyle && ((isWindows && useWindowControlsOverlay(this.configurationService)) || isMacintosh)) {
308+
if (useCustomTitleStyle && ((isWindows && useWindowControlsOverlay(this.configurationService, this.productService)) || isMacintosh)) {
309309
const cachedWindowControlHeight = this.stateMainService.getItem<number>((CodeWindow.windowControlHeightStateStorageKey));
310310
if (cachedWindowControlHeight) {
311311
this.updateWindowControls({ height: cachedWindowControlHeight });

src/vs/workbench/browser/parts/titlebar/titlebarPart.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { IHoverDelegate } from 'vs/base/browser/ui/iconLabel/iconHoverDelegate';
3636
import { IHoverService } from 'vs/workbench/services/hover/browser/hover';
3737
import { Categories } from 'vs/platform/action/common/actionCommonCategories';
3838
import { MenuWorkbenchToolBar } from 'vs/platform/actions/browser/toolbar';
39+
import { IProductService } from 'vs/platform/product/common/productService';
3940

4041
export class TitlebarPart extends Part implements ITitleService {
4142

@@ -89,12 +90,13 @@ export class TitlebarPart extends Part implements ITitleService {
8990
@IConfigurationService protected readonly configurationService: IConfigurationService,
9091
@IBrowserWorkbenchEnvironmentService protected readonly environmentService: IBrowserWorkbenchEnvironmentService,
9192
@IInstantiationService protected readonly instantiationService: IInstantiationService,
93+
@IProductService protected readonly productService: IProductService,
9294
@IThemeService themeService: IThemeService,
9395
@IStorageService storageService: IStorageService,
9496
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
9597
@IContextKeyService private readonly contextKeyService: IContextKeyService,
9698
@IHostService private readonly hostService: IHostService,
97-
@IHoverService hoverService: IHoverService,
99+
@IHoverService hoverService: IHoverService
98100
) {
99101
super(Parts.TITLEBAR_PART, { hasTitle: false }, themeService, storageService, layoutService);
100102
this.windowTitle = this._register(instantiationService.createInstance(WindowTitle));

src/vs/workbench/electron-sandbox/desktop.contribution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ import product from 'vs/platform/product/common/product';
207207
},
208208
'window.experimental.windowControlsOverlay.enabled': {
209209
'type': 'boolean',
210-
'default': false,
210+
'default': product.quality === 'insider' || product.quality === 'exploration', // switch back to true when app.getLocale() isn't used anymore.
211211
'scope': ConfigurationScope.APPLICATION,
212212
'description': localize('windowControlsOverlay', "Use window controls provided by the platform instead of our HTML-based window controls. Changes require a full restart to apply."),
213213
'included': isWindows

src/vs/workbench/electron-sandbox/parts/titlebar/titlebarPart.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
2222
import { Codicon } from 'vs/base/common/codicons';
2323
import { NativeMenubarControl } from 'vs/workbench/electron-sandbox/parts/titlebar/menubarControl';
2424
import { IHoverService } from 'vs/workbench/services/hover/browser/hover';
25+
import { IProductService } from 'vs/platform/product/common/productService';
2526

2627
export class TitlebarPart extends BrowserTitleBarPart {
2728
private maxRestoreControl: HTMLElement | undefined;
@@ -58,6 +59,7 @@ export class TitlebarPart extends BrowserTitleBarPart {
5859
@IConfigurationService configurationService: IConfigurationService,
5960
@INativeWorkbenchEnvironmentService environmentService: INativeWorkbenchEnvironmentService,
6061
@IInstantiationService instantiationService: IInstantiationService,
62+
@IProductService productService: IProductService,
6163
@IThemeService themeService: IThemeService,
6264
@IStorageService storageService: IStorageService,
6365
@IWorkbenchLayoutService layoutService: IWorkbenchLayoutService,
@@ -66,7 +68,7 @@ export class TitlebarPart extends BrowserTitleBarPart {
6668
@INativeHostService private readonly nativeHostService: INativeHostService,
6769
@IHoverService hoverService: IHoverService,
6870
) {
69-
super(contextMenuService, configurationService, environmentService, instantiationService, themeService, storageService, layoutService, contextKeyService, hostService, hoverService);
71+
super(contextMenuService, configurationService, environmentService, instantiationService, productService, themeService, storageService, layoutService, contextKeyService, hostService, hoverService);
7072

7173
this.environmentService = environmentService;
7274
}
@@ -216,7 +218,7 @@ export class TitlebarPart extends BrowserTitleBarPart {
216218
super.updateStyles();
217219

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

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

0 commit comments

Comments
 (0)