diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index acebcd3e9f43a8..6b1d7fab87d5a8 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -16,7 +16,7 @@ import { PanelPart } from 'vs/workbench/browser/parts/panel/panelPart'; import { Position, Parts, PanelOpensMaximizedOptions, IWorkbenchLayoutService, positionToString, panelOpensMaximizedFromString, PanelAlignment } from 'vs/workbench/services/layout/browser/layoutService'; import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace'; import { IStorageService, StorageScope, WillSaveStateReason } from 'vs/platform/storage/common/storage'; -import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration'; import { ITitleService } from 'vs/workbench/services/title/common/titleService'; import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { StartupKind, ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle'; @@ -260,6 +260,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi // Menubar visibility changes if ((isWindows || isLinux || isWeb) && getTitleBarStyle(this.configurationService) === 'custom') { this._register(this.titleService.onMenubarVisibilityChange(visible => this.onMenubarToggled(visible))); + this._register(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationChanged(e))); } // Theme changes @@ -269,6 +270,13 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi this._register(this.hostService.onDidChangeFocus(e => this.onWindowFocusChanged(e))); } + protected onConfigurationChanged(event: IConfigurationChangeEvent): void { + if (event.affectsConfiguration('window.menuBarVisibility') && this.configurationService.getValue('window.hideTitleBarWithoutMenuBar') || event.affectsConfiguration('window.hideTitleBarWithoutMenuBar')) { + this.workbenchGrid.setViewVisible(this.titleBarPartView, this.shouldShowTitleBar()); + this._onDidLayout.fire(this._dimension); + } + } + private onMenubarToggled(visible: boolean) { if (visible !== this.windowState.runtime.menuBar.toggled) { this.windowState.runtime.menuBar.toggled = visible; @@ -283,6 +291,10 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi else if (this.windowState.runtime.fullscreen && (menuBarVisibility === 'toggle' || menuBarVisibility === 'classic')) { this.workbenchGrid.setViewVisible(this.titleBarPartView, this.shouldShowTitleBar()); } + // The menu bar toggles the title bar with the hideTitleBarWithoutMenuBar setting enabled + else if ((menuBarVisibility === 'toggle' || menuBarVisibility === 'classic') && this.configurationService.getValue('window.hideTitleBarWithoutMenuBar')) { + this.workbenchGrid.setViewVisible(this.titleBarPartView, this.shouldShowTitleBar()); + } // Move layout call to any time the menubar // is toggled to update consumers of offset @@ -958,7 +970,7 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi } // non-fullscreen native must show the title bar - if (isNative && !this.windowState.runtime.fullscreen) { + if (isNative && !this.windowState.runtime.fullscreen && !this.configurationService.getValue('window.hideTitleBarWithoutMenuBar')) { return true; } diff --git a/src/vs/workbench/electron-sandbox/desktop.contribution.ts b/src/vs/workbench/electron-sandbox/desktop.contribution.ts index c939e4c6c80308..c6fb0c0265d94c 100644 --- a/src/vs/workbench/electron-sandbox/desktop.contribution.ts +++ b/src/vs/workbench/electron-sandbox/desktop.contribution.ts @@ -189,6 +189,12 @@ import { TELEMETRY_SETTING_ID } from 'vs/platform/telemetry/common/telemetry'; 'scope': ConfigurationScope.APPLICATION, 'description': localize('titleBarStyle', "Adjust the appearance of the window title bar. On Linux and Windows, this setting also affects the application and context menu appearances. Changes require a full restart to apply.") }, + 'window.hideTitleBarWithoutMenuBar': { + 'type': 'boolean', + 'default': false, + 'scope': ConfigurationScope.APPLICATION, + 'description': localize('hideTitleBarWithoutMenuBar', "Controls whether to hide the custom title bar when it is not needed to display the menu bar."), + }, 'window.dialogStyle': { 'type': 'string', 'enum': ['native', 'custom'],