提交 1a1b92fb 编写于 作者: S SteVen Batten

don't display fallback menu unless we've closed the last window

上级 1e45ce6a
......@@ -31,12 +31,13 @@ export class Menubar {
private static readonly MAX_MENU_RECENT_ENTRIES = 10;
private isQuitting: boolean;
private appMenuInstalled: boolean;
private closedLastWindow: boolean;
private menuUpdater: RunOnceScheduler;
private nativeTabMenuItems: Electron.MenuItem[];
private menubarMenus: IMenubarData = {};
private menubarMenus: IMenubarData;
private keybindings: { [commandId: string]: IMenubarKeybinding };
......@@ -54,6 +55,8 @@ export class Menubar {
this.keybindings = Object.create(null);
this.closedLastWindow = false;
this.install();
this.registerListeners();
......@@ -149,9 +152,9 @@ export class Menubar {
return;
}
// Update menu if window count goes from N > 0 or 0 > N to update menu item enablement
if ((e.oldCount === 0 && e.newCount > 0) || (e.oldCount > 0 && e.newCount === 0)) {
this.closedLastWindow = e.newCount === 0;
this.scheduleUpdateMenu();
}
......@@ -379,18 +382,22 @@ export class Menubar {
switch (menuId) {
case 'File':
case 'Window':
case 'Help':
if (isMacintosh) {
return this.windowsMainService.getWindowCount() === 0 || !!this.menubarMenus[menuId];
return (this.windowsMainService.getWindowCount() === 0 && this.closedLastWindow) || (!!this.menubarMenus && !!this.menubarMenus[menuId]);
}
break;
case 'Window':
if (isMacintosh) {
return (this.windowsMainService.getWindowCount() === 0 && this.closedLastWindow) || !!this.menubarMenus;
}
default:
return this.windowsMainService.getWindowCount() > 0 && !!this.menubarMenus[menuId];
return this.windowsMainService.getWindowCount() > 0 && (!!this.menubarMenus && !!this.menubarMenus[menuId]);
}
}
private shouldFallback(menuId: string): boolean {
return this.shouldDrawMenu(menuId) && (this.windowsMainService.getWindowCount() === 0 && isMacintosh);
return this.shouldDrawMenu(menuId) && (this.windowsMainService.getWindowCount() === 0 && this.closedLastWindow && isMacintosh);
}
private setFallbackMenuById(menu: Electron.Menu, menuId: string): void {
......@@ -520,7 +527,7 @@ export class Menubar {
}
private setMenuById(menu: Electron.Menu, menuId: string): void {
if (this.menubarMenus[menuId]) {
if (this.menubarMenus && this.menubarMenus[menuId]) {
this.setMenu(menu, this.menubarMenus[menuId].items);
}
}
......
......@@ -98,7 +98,6 @@ export class MenuId {
static readonly MenubarDebugMenu = new MenuId();
static readonly MenubarNewBreakpointMenu = new MenuId();
static readonly MenubarTasksMenu = new MenuId();
static readonly MenubarWindowMenu = new MenuId();
static readonly MenubarPreferencesMenu = new MenuId();
static readonly MenubarHelpMenu = new MenuId();
static readonly MenubarTerminalMenu = new MenuId();
......
......@@ -62,7 +62,7 @@ export class MenubarPart extends Part {
'workbench.statusBar.visible',
'workbench.activityBar.visible',
'window.enableMenuBarMnemonics',
// 'window.nativeTabs'
'window.nativeTabs'
];
private topLevelMenus: {
......@@ -143,7 +143,6 @@ export class MenubarPart extends Part {
if (isMacintosh) {
this.topLevelMenus['Preferences'] = this._register(this.menuService.createMenu(MenuId.MenubarPreferencesMenu, this.contextKeyService));
this.topLevelMenus['Window'] = this._register(this.menuService.createMenu(MenuId.MenubarWindowMenu, this.contextKeyService));
}
this.menuUpdater = this._register(new RunOnceScheduler(() => this.doSetupMenubar(), 100));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册