Skip to content

Commit 25a84b2

Browse files
authoredFeb 20, 2024··
Improve title rendering on menu bar change (#13317)
1 parent f83986a commit 25a84b2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed
 

‎packages/core/src/electron-browser/menu/electron-menu-contribution.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { inject, injectable, postConstruct } from 'inversify';
1818
import { Command, CommandContribution, CommandRegistry, isOSX, isWindows, MenuModelRegistry, MenuContribution, Disposable, nls } from '../../common';
1919
import {
2020
codicon, ConfirmDialog, KeybindingContribution, KeybindingRegistry, PreferenceScope, Widget,
21-
FrontendApplication, FrontendApplicationContribution, CommonMenus, CommonCommands, Dialog, Message, ApplicationShell,
21+
FrontendApplication, FrontendApplicationContribution, CommonMenus, CommonCommands, Dialog, Message, ApplicationShell, PreferenceService, animationFrame,
2222
} from '../../browser';
2323
import { ElectronMainMenuFactory } from './electron-main-menu-factory';
2424
import { FrontendApplicationStateService, FrontendApplicationState } from '../../browser/frontend-application-state';
@@ -441,6 +441,9 @@ export class CustomTitleWidget extends Widget {
441441
@inject(ApplicationShell)
442442
protected readonly applicationShell: ApplicationShell;
443443

444+
@inject(PreferenceService)
445+
protected readonly preferenceService: PreferenceService;
446+
444447
constructor() {
445448
super();
446449
this.id = 'theia-custom-title';
@@ -452,6 +455,11 @@ export class CustomTitleWidget extends Widget {
452455
this.windowTitleService.onDidChangeTitle(title => {
453456
this.updateTitle(title);
454457
});
458+
this.preferenceService.onPreferenceChanged(e => {
459+
if (e.preferenceName === 'window.menuBarVisibility') {
460+
animationFrame().then(() => this.adjustTitleToCenter());
461+
}
462+
});
455463
}
456464

457465
protected override onResize(msg: Widget.ResizeMessage): void {

0 commit comments

Comments
 (0)
Please sign in to comment.