Skip to content

Commit 09c5a6e

Browse files
authored
fix menubar visibility events when moving menubar (microsoft#153179)
fixes microsoft#151063
1 parent 551cf46 commit 09c5a6e

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/vs/base/browser/ui/menu/menubar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ export class MenuBar extends Disposable {
746746
this._onFocusStateChange.fire(this.focusState >= MenubarState.FOCUSED);
747747
}
748748

749-
private get isVisible(): boolean {
749+
get isVisible(): boolean {
750750
return this.focusState >= MenubarState.VISIBLE;
751751
}
752752

src/vs/workbench/browser/parts/titlebar/menubarControl.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,11 @@ export class CustomMenubarControl extends MenubarControl {
698698
}));
699699

700700
this.reinstallDisposables.add(attachMenuStyler(this.menubar, this.themeService));
701+
702+
// Fire visibility change for the first install if menu is shown
703+
if (this.menubar.isVisible) {
704+
this.onDidVisibilityChange(true);
705+
}
701706
} else {
702707
this.menubar?.update(this.getMenuBarOptions());
703708
}

src/vs/workbench/browser/parts/titlebar/titlebarPart.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ export class TitlebarPart extends Part implements ITitleService {
180180

181181
protected onMenubarVisibilityChanged(visible: boolean): void {
182182
if (isWeb || isWindows || isLinux) {
183-
this.adjustTitleMarginToCenter();
183+
if (this.lastLayoutDimensions) {
184+
this.layout(this.lastLayoutDimensions.width, this.lastLayoutDimensions.height);
185+
}
184186

185187
this._onMenubarVisibilityChange.fire(visible);
186188
}
@@ -197,6 +199,8 @@ export class TitlebarPart extends Part implements ITitleService {
197199
this.menubar.remove();
198200
this.menubar = undefined;
199201
}
202+
203+
this.onMenubarVisibilityChanged(false);
200204
}
201205

202206
protected installMenubar(): void {
@@ -210,9 +214,9 @@ export class TitlebarPart extends Part implements ITitleService {
210214
this.menubar = this.rootContainer.insertBefore($('div.menubar'), this.title);
211215
this.menubar.setAttribute('role', 'menubar');
212216

213-
this.customMenubar.create(this.menubar);
214-
215217
this._register(this.customMenubar.onVisibilityChange(e => this.onMenubarVisibilityChanged(e)));
218+
219+
this.customMenubar.create(this.menubar);
216220
}
217221

218222
private updateTitle(): void {

0 commit comments

Comments
 (0)