From 53c09a81a653113195e2212a971de6eb0a3523e9 Mon Sep 17 00:00:00 2001 From: Tobias Ortmayr Date: Thu, 12 Dec 2024 10:35:11 +0100 Subject: [PATCH] fix: window maximization when using splash screen (#14219) Avoids eager restore of maximized state in TheiaElectronWindow. Calling `window.maximize()` implicitly also makes the window visible. Therefore we have to check if the window is already visible before restoring the maximizeState. If the window is not yet visible yet we restore the state once the window is shown. Fixes #14218 --- .../src/electron-main/theia-electron-window.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/core/src/electron-main/theia-electron-window.ts b/packages/core/src/electron-main/theia-electron-window.ts index 720865f8f59e1..c116eb0844487 100644 --- a/packages/core/src/electron-main/theia-electron-window.ts +++ b/packages/core/src/electron-main/theia-electron-window.ts @@ -186,10 +186,18 @@ export class TheiaElectronWindow { } protected restoreMaximizedState(): void { - if (this.options.isMaximized) { - this._window.maximize(); + const restore = () => { + if (this.options.isMaximized) { + this._window.maximize(); + } else { + this._window.unmaximize(); + } + }; + + if (this._window.isVisible()) { + restore(); } else { - this._window.unmaximize(); + this._window.once('show', () => restore()); } }