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

Title bar context menu action in full screen to show menu bar #236608

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
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
Loading