From ed04aacd736fe126e64a59234b966438564d3af1 Mon Sep 17 00:00:00 2001 From: Vishwas Shashidhar Date: Tue, 22 May 2018 13:55:47 +0530 Subject: [PATCH 1/2] ELECTRON-479: fix launch on startup issue on first time launch (#375) - fix launch on startup first time launch issue --- js/main.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/main.js b/js/main.js index 6a7a4187..00662423 100644 --- a/js/main.js +++ b/js/main.js @@ -301,9 +301,12 @@ function setupFirstTimeLaunch() { * @returns {Promise} */ function setStartup(lStartup) { + log.send(logLevels.INFO, `launch on startup parameter value is ${lStartup}`); return new Promise((resolve) => { - let launchOnStartup = (lStartup === 'true'); + let launchOnStartup = (String(lStartup) === 'true'); + log.send(logLevels.INFO, `launchOnStartup value is ${launchOnStartup}`); if (launchOnStartup) { + log.send(logLevels.INFO, `enabling launch on startup`); symphonyAutoLauncher.enable(); return resolve(); } From dde5c7097a71abe84daf383de10339e820e3d9ca Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Tue, 22 May 2018 14:29:28 +0530 Subject: [PATCH 2/2] Electron-350 (Store/Restore maximized and fullscreen application state on launch) (#377) - Update the app to its previous state when the app is launched - swap checks --- js/windowMgr.js | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/js/windowMgr.js b/js/windowMgr.js index a82872f0..55e00ecb 100644 --- a/js/windowMgr.js +++ b/js/windowMgr.js @@ -160,7 +160,7 @@ function doCreateMainWindow(initialUrl, initialBounds) { // if bounds if not fully contained in some display then use default size // and position. - if (!isInDisplayBounds(bounds)) { + if (!isInDisplayBounds(bounds) || initialBounds.isMaximized || initialBounds.isFullScreen) { bounds = null; } @@ -189,10 +189,22 @@ function doCreateMainWindow(initialUrl, initialBounds) { mainWindow = new BrowserWindow(newWinOpts); mainWindow.winName = 'main'; - let throttledMainWinBoundsChange = throttle(5000, saveMainWinBounds); + let throttledMainWinBoundsChange = throttle(1000, saveMainWinBounds); mainWindow.on('move', throttledMainWinBoundsChange); mainWindow.on('resize', throttledMainWinBoundsChange); + if (initialBounds && !isNodeEnv) { + // maximizes the application if previously maximized + if (initialBounds.isMaximized) { + mainWindow.maximize(); + } + + // Sets the application to full-screen if previously set to full-screen + if (isMac && initialBounds.isFullScreen) { + mainWindow.setFullScreen(true); + } + } + function retry() { if (!isOnline) { loadErrors.showNetworkConnectivityError(mainWindow, url, retry); @@ -611,6 +623,12 @@ app.on('before-quit', function () { function saveMainWinBounds() { let newBounds = getWindowSizeAndPosition(mainWindow); + // set application full-screen and maximized state + if (mainWindow && !mainWindow.isDestroyed()) { + newBounds.isMaximized = mainWindow.isMaximized(); + newBounds.isFullScreen = mainWindow.isFullScreen(); + } + if (newBounds) { updateConfigField('mainWinPos', newBounds); }