Skip to content

Commit

Permalink
closes #232780
Browse files Browse the repository at this point in the history
  • Loading branch information
benibenj committed Dec 19, 2024
1 parent 613ad56 commit eb3b58c
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 17 deletions.
17 changes: 1 addition & 16 deletions src/vs/workbench/browser/actions/layoutActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ 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';
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
Expand Down Expand Up @@ -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
Expand Down
41 changes: 40 additions & 1 deletion src/vs/workbench/browser/parts/titlebar/titlebarActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 --- //

Expand Down Expand Up @@ -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 = {
Expand Down

0 comments on commit eb3b58c

Please sign in to comment.