Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to hide title bar when not showing menu bar #141847

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)));
}

private 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