This commit is contained in:
SteVen Batten 2019-10-18 18:07:35 -07:00
parent dfaff021a8
commit 2710db93e2
2 changed files with 18 additions and 4 deletions

View file

@ -120,6 +120,9 @@ export abstract class MenubarControl extends Disposable {
protected abstract doUpdateMenubar(firstTime: boolean): void;
protected registerListeners(): void {
// Listen for window focus changes
this._register(this.hostService.onDidChangeFocus(e => this.onDidChangeWindowFocus(e)));
// Update when config changes
this._register(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationUpdated(e)));
@ -178,6 +181,13 @@ export abstract class MenubarControl extends Disposable {
return result;
}
protected onDidChangeWindowFocus(hasFocus: boolean): void {
// When we regain focus, update the recent menu items
if (hasFocus) {
this.onRecentlyOpenedChange();
}
}
private onConfigurationUpdated(event: IConfigurationChangeEvent): void {
if (this.keys.some(key => event.affectsConfiguration(key))) {
this.updateMenubar();
@ -636,7 +646,9 @@ export class CustomMenubarControl extends MenubarControl {
}
}
private onDidChangeWindowFocus(hasFocus: boolean): void {
protected onDidChangeWindowFocus(hasFocus: boolean): void {
super.onDidChangeWindowFocus(hasFocus);
if (this.container) {
if (hasFocus) {
DOM.removeClass(this.container, 'inactive');
@ -652,9 +664,6 @@ export class CustomMenubarControl extends MenubarControl {
protected registerListeners(): void {
super.registerListeners();
// Listen for window focus changes
this._register(this.hostService.onDidChangeFocus(e => this.onDidChangeWindowFocus(e)));
// Listen for maximize/unmaximize
if (!isWeb) {
this._register(Event.any(

View file

@ -702,6 +702,11 @@ class NativeMenubarControl extends MenubarControl {
}
protected doUpdateMenubar(firstTime: boolean): void {
// Since the native menubar is shared between windows (main process)
// only allow the focused window to update the menubar
if (!this.hostService.hasFocus) {
return;
}
// Send menus to main process to be rendered by Electron
const menubarData = { menus: {}, keybindings: {} };