diff --git a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts index 5c167923a65d6418c981b1ca622cfc2b5eec0e5d..d23816f45f7bc7c9a5f219d6a34b767ae56a67e0 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 9f165b7d4196a460611a289a5d9753fcd2365f0e..32973ce26f720affb53e477039889e2f0604f422 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); }