Skip to content

Commit

Permalink
Add option to hide title bar when not showing menu bar
Browse files Browse the repository at this point in the history
  • Loading branch information
DorianRudolph committed Jan 30, 2022
1 parent 584d534 commit 69772d5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/vs/workbench/browser/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 6 additions & 0 deletions src/vs/workbench/electron-sandbox/desktop.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down

0 comments on commit 69772d5

Please sign in to comment.