Skip to content

add new titlebarvisiblity setting #155918

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
3 changes: 0 additions & 3 deletions src/vs/base/browser/ui/menu/menubar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as browser from 'vs/base/browser/browser';
import * as DOM from 'vs/base/browser/dom';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
Expand Down Expand Up @@ -787,8 +786,6 @@ export class MenuBar extends Disposable {
private setUnfocusedState(): void {
if (this.options.visibility === 'toggle' || this.options.visibility === 'hidden') {
this.focusState = MenubarState.HIDDEN;
} else if (this.options.visibility === 'classic' && browser.isFullscreen()) {
this.focusState = MenubarState.HIDDEN;
} else {
this.focusState = MenubarState.VISIBLE;
}
Expand Down
5 changes: 5 additions & 0 deletions src/vs/platform/window/common/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export function isFileToOpen(uriToOpen: IWindowOpenable): uriToOpen is IFileToOp
}

export type MenuBarVisibility = 'classic' | 'visible' | 'toggle' | 'hidden' | 'compact';
export type TitleBarVisibility = 'always' | 'windowed' | 'contents';

export function getMenuBarVisibility(configurationService: IConfigurationService): MenuBarVisibility {
const titleBarStyle = getTitleBarStyle(configurationService);
Expand All @@ -115,6 +116,10 @@ export function getMenuBarVisibility(configurationService: IConfigurationService
}
}

export function getTitleBarVisibility(configurationService: IConfigurationService): TitleBarVisibility {
return configurationService.getValue<TitleBarVisibility>('window.titleBarVisibility');
}

export interface IWindowsConfiguration {
readonly window: IWindowSettings;
}
Expand Down
69 changes: 37 additions & 32 deletions src/vs/workbench/browser/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Event, Emitter } from 'vs/base/common/event';
import { EventType, addDisposableListener, getClientArea, Dimension, position, size, IDimension, isAncestorUsingFlowTo, computeScreenAwareSize } from 'vs/base/browser/dom';
import { onDidChangeFullscreen, isFullscreen } from 'vs/base/browser/browser';
import { IWorkingCopyBackupService } from 'vs/workbench/services/workingCopy/common/workingCopyBackup';
import { isWindows, isLinux, isMacintosh, isWeb, isNative, isIOS } from 'vs/base/common/platform';
import { isWindows, isLinux, isMacintosh, isWeb, isIOS } from 'vs/base/common/platform';
import { EditorInputCapabilities, isResourceEditorInput, IUntypedEditorInput, pathsToEditors } from 'vs/workbench/common/editor';
import { SidebarPart } from 'vs/workbench/browser/parts/sidebar/sidebarPart';
import { PanelPart } from 'vs/workbench/browser/parts/panel/panelPart';
Expand All @@ -19,7 +19,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
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';
import { getTitleBarStyle, getMenuBarVisibility, IPath } from 'vs/platform/window/common/window';
import { getTitleBarStyle, getMenuBarVisibility, IPath, getTitleBarVisibility } from 'vs/platform/window/common/window';
import { IHostService } from 'vs/workbench/services/host/browser/host';
import { IEditor } from 'vs/editor/common/editorCommon';
import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
Expand Down Expand Up @@ -282,16 +282,11 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
if (visible !== this.windowState.runtime.menuBar.toggled) {
this.windowState.runtime.menuBar.toggled = visible;

const menuBarVisibility = getMenuBarVisibility(this.configurationService);
const wasVisible = this.isVisible(Parts.TITLEBAR_PART);
const shouldBeVisible = this.shouldShowTitleBar();

// The menu bar toggles the title bar in web because it does not need to be shown for window controls only
if (isWeb && menuBarVisibility === 'toggle') {
this.workbenchGrid.setViewVisible(this.titleBarPartView, this.shouldShowTitleBar());
}

// The menu bar toggles the title bar in full screen for toggle and classic settings
else if (this.windowState.runtime.fullscreen && (menuBarVisibility === 'toggle' || menuBarVisibility === 'classic')) {
this.workbenchGrid.setViewVisible(this.titleBarPartView, this.shouldShowTitleBar());
if (wasVisible !== shouldBeVisible) {
this.workbenchGrid.setViewVisible(this.titleBarPartView, shouldBeVisible);
}

// Move layout call to any time the menubar
Expand Down Expand Up @@ -986,35 +981,45 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
return false;
}

// macOS desktop does not need a title bar when full screen
if (isMacintosh && isNative) {
return !this.windowState.runtime.fullscreen;
}
const configuredTitleBarVisibility = getTitleBarVisibility(this.configurationService);

// non-fullscreen native must show the title bar
if (isNative && !this.windowState.runtime.fullscreen) {
if (configuredTitleBarVisibility === 'always') {
return true;
}

// with the command center enabled, we should always show
if (this.configurationService.getValue<boolean>('window.commandCenter')) {
const menuBarRequestsTitleBar = (() => {
switch (getMenuBarVisibility(this.configurationService)) {
case 'classic':
return !this.windowState.runtime.fullscreen || this.windowState.runtime.menuBar.toggled;
case 'compact':
case 'hidden':
return false;
case 'toggle':
return this.windowState.runtime.menuBar.toggled;
case 'visible':
return true;
default:
return isWeb ? false : !this.windowState.runtime.fullscreen || this.windowState.runtime.menuBar.toggled;
}
})();

const commandCenterRequestsTitleBar = this.configurationService.getValue<boolean>('window.commandCenter');

const layoutControlsRequestTitleBar = this.configurationService.getValue<boolean>('workbench.layoutControl.enabled');

if (!this.windowState.runtime.fullscreen) {
return true;
}

// remaining behavior is based on menubar visibility
switch (getMenuBarVisibility(this.configurationService)) {
case 'classic':
return !this.windowState.runtime.fullscreen || this.windowState.runtime.menuBar.toggled;
case 'compact':
case 'hidden':
return false;
case 'toggle':
return this.windowState.runtime.menuBar.toggled;
case 'visible':
return true;
default:
return isWeb ? false : !this.windowState.runtime.fullscreen || this.windowState.runtime.menuBar.toggled;
if (configuredTitleBarVisibility === 'contents') {
return menuBarRequestsTitleBar || commandCenterRequestsTitleBar || layoutControlsRequestTitleBar;
}

if (configuredTitleBarVisibility === 'windowed') {
return menuBarRequestsTitleBar;
}

return false;
}

focus(): void {
Expand Down
13 changes: 12 additions & 1 deletion src/vs/workbench/browser/workbench.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
'type': 'string',
'enum': ['classic', 'visible', 'toggle', 'hidden', 'compact'],
'markdownEnumDescriptions': [
localize('window.menuBarVisibility.classic', "Menu is displayed at the top of the window and only hidden in full screen mode."),
localize('window.menuBarVisibility.classic', "Menu is displayed at the top of the window. When {0} is {1} the menu is hidden in full screen mode. Otherwise, the menu is always visible.", '`#window.titleBarStyle#`', '`native`'),
localize('window.menuBarVisibility.visible', "Menu is always visible at the top of the window even in full screen mode."),
isMacintosh ?
localize('window.menuBarVisibility.toggle.mac', "Menu is hidden but can be displayed at the top of the window by executing the `Focus Application Menu` command.") :
Expand All @@ -565,6 +565,17 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
localize('menuBarVisibility', "Control the visibility of the menu bar. A setting of 'toggle' means that the menu bar is hidden and a single press of the Alt key will show it. A setting of 'compact' will move the menu into the side bar."),
'included': isWindows || isLinux || isWeb
},
'window.titleBarVisibility': {
'type': 'string',
'enum': ['always', 'windowed', 'contents'],
'markdownEnumDescriptions': [
localize('window.titleBarVisibility.always', "Title bar is always visible."),
localize('window.titleBarVisibility.windowed', "Title bar is visible when the window is not fullscreen."),
localize('window.titleBarVisibility.content', "Title bar is visible when the window is not fullscreen and in fullscreen if it contains interactive contents."),
],
'default': 'contents',
markdownDescription: localize('window.titleBarVisibility', "Control the visibility of the title bar. This setting only has an effect when {0} is set to {1}.", '`#window.titleBarStyle#`', '`custom`')
},
'window.enableMenuBarMnemonics': {
'type': 'boolean',
'default': true,
Expand Down