提交 98a3c4fe 编写于 作者: S SteVen Batten

reduce work when menu is not visible

fixes #108712
上级 a45abdbd
......@@ -122,7 +122,7 @@ export abstract class MenubarControl extends Disposable {
this._register(this.configurationService.onDidChangeConfiguration(e => this.onConfigurationUpdated(e)));
// Listen to update service
this.updateService.onStateChange(() => this.updateMenubar());
this.updateService.onStateChange(() => this.onUpdateStateChange());
// Listen for changes in recently opened menu
this._register(this.workspacesService.onRecentlyOpenedChange(() => { this.onRecentlyOpenedChange(); }));
......@@ -148,6 +148,14 @@ export abstract class MenubarControl extends Disposable {
return label;
}
protected onUpdateStateChange(): void {
this.updateMenubar();
}
protected onUpdateKeybindings(): void {
this.updateMenubar();
}
protected getOpenRecentActions(): (Separator | IAction & { uri: URI })[] {
if (!this.recentlyOpened) {
return [];
......@@ -193,7 +201,7 @@ export abstract class MenubarControl extends Disposable {
}
}
private onRecentlyOpenedChange(): void {
protected onRecentlyOpenedChange(): void {
this.workspacesService.getRecentlyOpened().then(recentlyOpened => {
this.recentlyOpened = recentlyOpened;
this.updateMenubar();
......@@ -266,6 +274,7 @@ export class CustomMenubarControl extends MenubarControl {
private container: HTMLElement | undefined;
private alwaysOnMnemonics: boolean = false;
private focusInsideMenubar: boolean = false;
private visible: boolean = true;
private readonly _onVisibilityChange: Emitter<boolean>;
private readonly _onFocusStateChange: Emitter<boolean>;
......@@ -530,6 +539,12 @@ export class CustomMenubarControl extends MenubarControl {
return currentSidebarLocation === 'right' ? Direction.Left : Direction.Right;
}
private onDidVisibilityChange(visible: boolean): void {
this.visible = visible;
this.onRecentlyOpenedChange();
this._onVisibilityChange.fire(visible);
}
private setupCustomMenubar(firstTime: boolean): void {
// If there is no container, we cannot setup the menubar
if (!this.container) {
......@@ -554,7 +569,7 @@ export class CustomMenubarControl extends MenubarControl {
}
}));
this._register(this.menubar.onVisibilityChange(e => this._onVisibilityChange.fire(e)));
this._register(this.menubar.onVisibilityChange(e => this.onDidVisibilityChange(e)));
// Before we focus the menubar, stop updates to it so that focus-related context keys will work
this._register(DOM.addDisposableListener(this.container, DOM.EventType.FOCUS_IN, () => {
......@@ -668,6 +683,10 @@ export class CustomMenubarControl extends MenubarControl {
}
protected onDidChangeWindowFocus(hasFocus: boolean): void {
if (!this.visible) {
return;
}
super.onDidChangeWindowFocus(hasFocus);
if (this.container) {
......@@ -682,6 +701,30 @@ export class CustomMenubarControl extends MenubarControl {
}
}
protected onUpdateStateChange(): void {
if (!this.visible) {
return;
}
super.onUpdateStateChange();
}
protected onRecentlyOpenedChange(): void {
if (!this.visible) {
return;
}
super.onRecentlyOpenedChange();
}
protected onUpdateKeybindings(): void {
if (!this.visible) {
return;
}
super.onUpdateKeybindings();
}
protected registerListeners(): void {
super.registerListeners();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册