From 80411d3f93cf77d274faa2d5e4e3a37bda128b76 Mon Sep 17 00:00:00 2001 From: Ryan Adolf Date: Tue, 12 Dec 2017 12:25:18 -0800 Subject: [PATCH] Make titlebar render correctly on reload --- .../browser/parts/titlebar/titlebarPart.ts | 15 +++++++++------ src/vs/workbench/electron-browser/workbench.ts | 12 +++++++++--- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts index 5c167923a65..d23816f45f7 100644 --- a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts +++ b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts @@ -299,12 +299,8 @@ export class TitlebarPart extends Part implements ITitleService { this.windowService.closeWindow().then(null, errors.onUnexpectedError); }); - this.windowService.onDidChangeMaximize((maximized) => { - ($(this.titleContainer).getHTMLElement().querySelector('.window-maximize') as SVGElement).style.display = maximized ? 'none' : 'inline'; - ($(this.titleContainer).getHTMLElement().querySelector('.window-unmaximize') as SVGElement).style.display = maximized ? 'inline' : 'none'; - $(this.titleContainer).getHTMLElement().style.paddingLeft = maximized ? '0.15em' : '0.5em'; - $(this.titleContainer).getHTMLElement().style.paddingRight = maximized ? 'calc(2em / 12)' : '0'; - }, this); + this.windowService.isMaximized().then((max) => this.onDidChangeMaximized(max), errors.onUnexpectedError); + this.windowService.onDidChangeMaximize(this.onDidChangeMaximized, this); } // Since the title area is used to drag the window, we do not want to steal focus from the @@ -321,6 +317,13 @@ export class TitlebarPart extends Part implements ITitleService { return this.titleContainer; } + private onDidChangeMaximized(maximized: boolean) { + ($(this.titleContainer).getHTMLElement().querySelector('.window-maximize') as SVGElement).style.display = maximized ? 'none' : 'inline'; + ($(this.titleContainer).getHTMLElement().querySelector('.window-unmaximize') as SVGElement).style.display = maximized ? 'inline' : 'none'; + $(this.titleContainer).getHTMLElement().style.paddingLeft = maximized ? '0.15em' : '0.5em'; + $(this.titleContainer).getHTMLElement().style.paddingRight = maximized ? 'calc(2em / 12)' : '0'; + } + protected updateStyles(): void { super.updateStyles(); diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index 9f165b7d419..32973ce26f7 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -584,9 +584,6 @@ export class Workbench implements IPartService { this.toDispose.push(this.titlebarPart); this.toShutdown.push(this.titlebarPart); serviceCollection.set(ITitleService, this.titlebarPart); - if (!isMacintosh && this.getCustomTitleBarStyle()) { - this.windowService.onDidChangeMaximize((max) => this.workbenchLayout.onMaximizeChange(max)); - } // History serviceCollection.set(IHistoryService, new SyncDescriptor(HistoryService)); @@ -1147,6 +1144,15 @@ export class Workbench implements IPartService { this.quickOpen // Quickopen ); + if (!isMacintosh && this.getCustomTitleBarStyle()) { + this.windowService.isMaximized().then((max) => { + console.log(this); + this.workbenchLayout.onMaximizeChange(max); + this.workbenchLayout.layout(); + }); + this.windowService.onDidChangeMaximize(this.workbenchLayout.onMaximizeChange, this.workbenchLayout); + } + this.toDispose.push(this.workbenchLayout); } -- GitLab