From 487c9d265e32149c03fca01ccbc3af0dc3fc09ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20Vay=C3=A1?= Date: Wed, 15 Jul 2020 22:13:15 +0200 Subject: [PATCH] [MM-26832] don't show the window until it is ready (#1345) * [MM-26832] don't show the window until it is ready * [MM-26832] allow the app to still paint itself while initially hidden * fix tests, ensure it appears if not using silent mode --- src/main/mainWindow.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/main/mainWindow.js b/src/main/mainWindow.js index 3e18dc8c..ed390014 100644 --- a/src/main/mainWindow.js +++ b/src/main/mainWindow.js @@ -44,7 +44,7 @@ function createMainWindow(config, options) { windowOptions = {width: defaultWindowWidth, height: defaultWindowHeight}; } - const {hideOnStartup, trayIconShown} = options; + const {hideOnStartup} = options; const {maximized: windowIsMaximized} = windowOptions; if (process.platform === 'linux') { @@ -53,7 +53,8 @@ function createMainWindow(config, options) { Object.assign(windowOptions, { title: app.name, fullscreenable: true, - show: hideOnStartup || false, + show: false, // don't start the window until it is ready and only if it isn't hidden + paintWhenInitiallyHidden: true, // we want it to start painting to get info from the webapp minWidth: minimumWindowWidth, minHeight: minimumWindowHeight, frame: !isFramelessWindow(), @@ -75,15 +76,6 @@ function createMainWindow(config, options) { const indexURL = global.isDev ? 'http://localhost:8080/browser/index.html' : `file://${app.getAppPath()}/browser/index.html`; mainWindow.loadURL(indexURL); - // handle hiding the app when launched by auto-start - if (hideOnStartup) { - if (trayIconShown && process.platform !== 'darwin') { - mainWindow.hide(); - } else { - mainWindow.minimize(); - } - } - mainWindow.once('ready-to-show', () => { mainWindow.webContents.zoomLevel = 0;