From 1cc21fd9e3eda15e5817a07e970d21189fee6419 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Sun, 2 Aug 2026 21:27:22 +0100 Subject: [PATCH] Enhance Windows startup window management - Introduced a delay for maximizing the window on startup to improve user experience on Windows. - Refactored window state application logic to ensure proper handling of window maximization and layout synchronization. - Updated platform checks to use a dedicated constant for Windows, improving code clarity and maintainability. --- src/desktop/window.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/desktop/window.js b/src/desktop/window.js index e400388..54be50e 100644 --- a/src/desktop/window.js +++ b/src/desktop/window.js @@ -7,6 +7,8 @@ import { import { sendToRenderer, setMessageSender } from './notify.js' const isMacOS = process.platform === 'darwin' +const isWindows = process.platform === 'win32' +const WINDOWS_STARTUP_MAXIMIZE_DELAY_MS = 1500 const DEV_SERVER_PORT = 5780 const DEV_SERVER_URL = `http://localhost:${DEV_SERVER_PORT}` @@ -144,7 +146,7 @@ function broadcastWindowState() { function applyStartupWindowState(window) { if (!window) return - if (isMacOS || process.platform === 'win32') { + if (isMacOS) { window.maximize?.() } @@ -168,10 +170,13 @@ function syncWindowsWebviewLayout(window) { function applyWindowsStartupWindowState(window) { if (!window) return - syncWindowsWebviewLayout(window) - setTimeout(() => syncWindowsWebviewLayout(window), 0) - setTimeout(() => syncWindowsWebviewLayout(window), 100) - setTimeout(broadcastWindowState, 100) + setTimeout(() => { + window.maximize?.() + syncWindowsWebviewLayout(window) + setTimeout(() => syncWindowsWebviewLayout(window), 0) + setTimeout(() => syncWindowsWebviewLayout(window), 100) + setTimeout(broadcastWindowState, 100) + }, WINDOWS_STARTUP_MAXIMIZE_DELAY_MS) } function setupWindowEvents(window) { @@ -264,7 +269,7 @@ export async function createMainWindow(rpc) { mainWindow.webview.on('dom-ready', () => { webviewDomReady = true - if (process.platform === 'win32') { + if (isWindows) { applyWindowsStartupWindowState(mainWindow) }