Skip to content

feat: add force-native option to window.menuStyle #250801

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

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
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 @@ -136,6 +136,7 @@ export const enum MenuStyleConfiguration {
CUSTOM = 'custom',
NATIVE = 'native',
INHERIT = 'inherit',
FORCE_NATIVE = 'force-native',
}

export function hasNativeContextMenu(configurationService: IConfigurationService, titleBarStyle?: TitlebarStyle): boolean {
Expand All @@ -146,6 +147,10 @@ export function hasNativeContextMenu(configurationService: IConfigurationService
const nativeTitle = hasNativeTitlebar(configurationService, titleBarStyle);
const windowConfigurations = configurationService.getValue<IWindowSettings | undefined>('window');

if (windowConfigurations?.menuStyle === MenuStyleConfiguration.FORCE_NATIVE) {
return true;
}

if (windowConfigurations?.menuStyle === MenuStyleConfiguration.NATIVE) {
// Do not support native menu with custom title bar
if (!isMacintosh && !nativeTitle) {
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/electron-sandbox/desktop.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ import { registerWorkbenchContribution2, WorkbenchPhase } from '../common/contri
},
'window.menuStyle': {
'type': 'string',
'enum': ['custom', 'native', 'inherit'],
'enum': isMacintosh ? ['custom', 'native', 'inherit'] : ['custom', 'native', 'inherit', 'force-native'],
'markdownEnumDescriptions': isMacintosh ?
[
localize(`window.menuStyle.custom.mac`, "Use the custom context menu."),
Expand All @@ -274,6 +274,7 @@ import { registerWorkbenchContribution2, WorkbenchPhase } from '../common/contri
localize(`window.menuStyle.custom`, "Use the custom menu."),
localize(`window.menuStyle.native`, "Use the native menu. This is ignored when {0} is set to {1}.", '`#window.titleBarStyle#`', '`custom`'),
localize(`window.menuStyle.inherit`, "Matches the menu style to the title bar style defined in {0}.", '`#window.titleBarStyle#`'),
localize(`window.menuStyle.force-native`, "Use the native menu. Opposed to {0}, this is not ignored when {1} is set to {2}.", '`native', '`#window.titleBarStyle#`', '`custom`'),
],
'default': isMacintosh ? 'native' : 'inherit',
'scope': ConfigurationScope.APPLICATION,
Expand Down