diff options
author | Akshit Kr Nagpal <akshitkrnagpal@gmail.com> | 2018-06-21 01:08:53 +0530 |
---|---|---|
committer | Saúl Ibarra Corretgé <s@saghul.net> | 2018-06-20 21:38:53 +0200 |
commit | 93d8268a68db286cfec44f4020117c7087863402 (patch) | |
tree | cb257914555340027d6db494f2c475cb0a15ffb8 /main.js | |
parent | 994a605ce0b9cbf31ca74431f925d8f43b7bbea3 (diff) |
Remember Window State
Diffstat (limited to 'main.js')
-rw-r--r-- | main.js | 47 |
1 files changed, 29 insertions, 18 deletions
@@ -1,7 +1,13 @@ /* global __dirname, process */ -const electron = require('electron'); +const { + app: APP, + BrowserWindow, + Menu, + shell +} = require('electron'); const isDev = require('electron-is-dev'); +const windowStateKeeper = require('electron-window-state'); const { setupAlwaysOnTopMain, initPopupsConfigurationMain, @@ -10,8 +16,6 @@ const { const path = require('path'); const URL = require('url'); -const { app: APP, BrowserWindow, Menu } = electron; - /** * Load debug utilities (don't open the DevTools window by default though). */ @@ -39,20 +43,6 @@ const indexURL = URL.format({ let jitsiMeetWindow = null; /** - * Options used when creating the main Jitsi Meet window. - */ -const jitsiMeetWindowOptions = { - width: 800, - height: 600, - minWidth: 800, - minHeight: 600, - titleBarStyle: 'hidden', - webPreferences: { - nativeWindowOpen: true - } -}; - -/** * Sets the APP object listeners. */ function setAPPListeners() { @@ -87,7 +77,28 @@ function setAPPListeners() { function createJitsiMeetWindow() { Menu.setApplicationMenu(null); + // Load the previous state with fallback to defaults + const jitsiMeetWindowState = windowStateKeeper({ + defaultWidth: 800, + defaultHeight: 600 + }); + + // Options used when creating the main Jitsi Meet window. + const jitsiMeetWindowOptions = { + x: jitsiMeetWindowState.x, + y: jitsiMeetWindowState.y, + width: jitsiMeetWindowState.width, + height: jitsiMeetWindowState.height, + minWidth: 800, + minHeight: 600, + titleBarStyle: 'hidden', + webPreferences: { + nativeWindowOpen: true + } + }; + jitsiMeetWindow = new BrowserWindow(jitsiMeetWindowOptions); + jitsiMeetWindowState.manage(jitsiMeetWindow); jitsiMeetWindow.loadURL(indexURL); initPopupsConfigurationMain(jitsiMeetWindow); @@ -96,7 +107,7 @@ function createJitsiMeetWindow() { if (!target || target === 'browser') { event.preventDefault(); - electron.shell.openExternal(url); + shell.openExternal(url); } }); |