提交 2710db93 编写于 作者: S SteVen Batten

fixes #70893

上级 dfaff021
......@@ -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(
......
......@@ -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: {} };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册