From 4d72392f1d76affffbddf7eafc13c220b8b07a0a Mon Sep 17 00:00:00 2001 From: Kdu Date: Fri, 24 May 2024 15:02:45 -0300 Subject: [PATCH] Fix main window maximizing from splash The code checks whether the initial window starts maximized, if so, prevents the splash from starting maximized and leaves the main window maximized. --- src/main/services/window-manager.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/services/window-manager.ts b/src/main/services/window-manager.ts index 02e0e444..66d27cae 100644 --- a/src/main/services/window-manager.ts +++ b/src/main/services/window-manager.ts @@ -20,6 +20,8 @@ export class WindowManager { public static splashWindow: Electron.BrowserWindow | null = null; public static isReadyToShowMainWindow = false; + private static isMainMaximize = false; + private static loadURL(hash = "") { // HMR for renderer base on electron-vite cli. // Load the remote URL for development or the local html file for production. @@ -71,6 +73,10 @@ export class WindowManager { this.loadSplashURL(); this.splashWindow.removeMenu(); + if (this.splashWindow?.isMaximized()) { + this.splashWindow?.unmaximize(); + this.isMainMaximize = true; + } } public static createMainWindow() { @@ -119,9 +125,7 @@ export class WindowManager { this.isReadyToShowMainWindow = true; this.splashWindow?.close(); this.createMainWindow(); - if (this.splashWindow?.isMaximized()) { - this.mainWindow?.maximize(); - } + if (this.isMainMaximize) this.mainWindow?.maximize(); } public static redirect(hash: string) {