diff --git a/src/vs/workbench/browser/actions/layoutActions.ts b/src/vs/workbench/browser/actions/layoutActions.ts index 75253e235de..cdd04eab035 100644 --- a/src/vs/workbench/browser/actions/layoutActions.ts +++ b/src/vs/workbench/browser/actions/layoutActions.ts @@ -22,7 +22,7 @@ import { IPaneCompositePartService } from '../../services/panecomposite/browser/ import { ToggleAuxiliaryBarAction } from '../parts/auxiliarybar/auxiliaryBarActions.js'; import { TogglePanelAction } from '../parts/panel/panelActions.js'; import { ICommandService } from '../../../platform/commands/common/commands.js'; -import { AuxiliaryBarVisibleContext, PanelAlignmentContext, PanelVisibleContext, SideBarVisibleContext, FocusedViewContext, InEditorZenModeContext, IsMainEditorCenteredLayoutContext, MainEditorAreaVisibleContext, IsMainWindowFullscreenContext, PanelPositionContext, IsAuxiliaryWindowFocusedContext, TitleBarStyleContext } from '../../common/contextkeys.js'; +import { AuxiliaryBarVisibleContext, PanelAlignmentContext, PanelVisibleContext, SideBarVisibleContext, FocusedViewContext, InEditorZenModeContext, IsMainEditorCenteredLayoutContext, MainEditorAreaVisibleContext, IsMainWindowFullscreenContext, PanelPositionContext, IsAuxiliaryWindowFocusedContext } from '../../common/contextkeys.js'; import { Codicon } from '../../../base/common/codicons.js'; import { ThemeIcon } from '../../../base/common/themables.js'; import { DisposableStore } from '../../../base/common/lifecycle.js'; @@ -30,7 +30,6 @@ import { registerIcon } from '../../../platform/theme/common/iconRegistry.js'; import { ICommandActionTitle } from '../../../platform/action/common/action.js'; import { mainWindow } from '../../../base/browser/window.js'; import { IKeybindingService } from '../../../platform/keybinding/common/keybinding.js'; -import { TitlebarStyle } from '../../../platform/window/common/window.js'; import { IPreferencesService } from '../../services/preferences/common/preferences.js'; // Register Icons @@ -798,20 +797,6 @@ if (isWindows || isLinux || isWeb) { return accessor.get(IWorkbenchLayoutService).toggleMenuBar(); } }); - - // Add separately to title bar context menu so we can use a different title - for (const menuId of [MenuId.TitleBarContext, MenuId.TitleBarTitleContext]) { - MenuRegistry.appendMenuItem(menuId, { - command: { - id: 'workbench.action.toggleMenuBar', - title: localize('miMenuBarNoMnemonic', "Menu Bar"), - toggled: ContextKeyExpr.and(IsMacNativeContext.toNegated(), ContextKeyExpr.notEquals('config.window.menuBarVisibility', 'hidden'), ContextKeyExpr.notEquals('config.window.menuBarVisibility', 'toggle'), ContextKeyExpr.notEquals('config.window.menuBarVisibility', 'compact')) - }, - when: ContextKeyExpr.and(IsAuxiliaryWindowFocusedContext.toNegated(), ContextKeyExpr.notEquals(TitleBarStyleContext.key, TitlebarStyle.NATIVE), IsMainWindowFullscreenContext.negate()), - group: '2_config', - order: 0 - }); - } } // --- Reset View Locations diff --git a/src/vs/workbench/browser/parts/titlebar/titlebarActions.ts b/src/vs/workbench/browser/parts/titlebar/titlebarActions.ts index f84bf3f06b7..7eba94561f0 100644 --- a/src/vs/workbench/browser/parts/titlebar/titlebarActions.ts +++ b/src/vs/workbench/browser/parts/titlebar/titlebarActions.ts @@ -8,13 +8,15 @@ import { IConfigurationService } from '../../../../platform/configuration/common import { ServicesAccessor } from '../../../../platform/instantiation/common/instantiation.js'; import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js'; import { LayoutSettings } from '../../../services/layout/browser/layoutService.js'; -import { Action2, MenuId, registerAction2 } from '../../../../platform/actions/common/actions.js'; +import { Action2, MenuId, MenuRegistry, registerAction2 } from '../../../../platform/actions/common/actions.js'; import { ContextKeyExpr, ContextKeyExpression, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js'; import { ACCOUNTS_ACTIVITY_ID, GLOBAL_ACTIVITY_ID } from '../../../common/activity.js'; import { IAction } from '../../../../base/common/actions.js'; import { IsAuxiliaryWindowFocusedContext, IsMainWindowFullscreenContext, TitleBarStyleContext, TitleBarVisibleContext } from '../../../common/contextkeys.js'; import { CustomTitleBarVisibility, TitleBarSetting, TitlebarStyle } from '../../../../platform/window/common/window.js'; import { isLinux, isNative } from '../../../../base/common/platform.js'; +import { Categories } from '../../../../platform/action/common/actionCommonCategories.js'; +import { IsMacNativeContext } from '../../../../platform/contextkey/common/contextkeys.js'; // --- Context Menu Actions --- // @@ -279,6 +281,43 @@ if (isLinux && isNative) { }); } +for (const menuId of [MenuId.TitleBarContext, MenuId.TitleBarTitleContext]) { + MenuRegistry.appendMenuItem(menuId, { + command: { + id: 'workbench.action.toggleMenuBar', + title: localize('miMenuBarNoMnemonic', "Menu Bar"), + toggled: ContextKeyExpr.and(IsMacNativeContext.toNegated(), ContextKeyExpr.notEquals('config.window.menuBarVisibility', 'hidden'), ContextKeyExpr.notEquals('config.window.menuBarVisibility', 'toggle'), ContextKeyExpr.notEquals('config.window.menuBarVisibility', 'compact')) + }, + when: ContextKeyExpr.and(IsAuxiliaryWindowFocusedContext.toNegated(), ContextKeyExpr.notEquals(TitleBarStyleContext.key, TitlebarStyle.NATIVE), IsMainWindowFullscreenContext.negate()), + group: '2_config', + order: 0 + }); +} + +registerAction2(class extends Action2 { + + constructor() { + super({ + id: 'workbench.action.toggleMenuBarInFullScreen', + title: localize2('menuBar', "Menu Bar"), + category: Categories.View, + toggled: ContextKeyExpr.equals('config.window.menuBarVisibility', 'visible'), + menu: [{ + id: MenuId.TitleBarContext, + group: '2_config', + order: 0, + when: ContextKeyExpr.and(IsAuxiliaryWindowFocusedContext.toNegated(), ContextKeyExpr.notEquals(TitleBarStyleContext.key, TitlebarStyle.NATIVE), IsMainWindowFullscreenContext, IsMacNativeContext.negate()), + }] + }); + } + + run(accessor: ServicesAccessor): void { + const configurationService = accessor.get(IConfigurationService); + const isVisible = configurationService.getValue('window.menuBarVisibility') === 'visible'; + configurationService.updateValue('window.menuBarVisibility', isVisible ? 'classic' : 'visible'); + } +}); + // --- Toolbar actions --- // export const ACCOUNTS_ACTIVITY_TILE_ACTION: IAction = {