mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
fixes #70893
This commit is contained in:
parent
dfaff021a8
commit
2710db93e2
|
@ -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: {} };
|
||||
|
|
Loading…
Reference in a new issue