Remember and Recall window layout so that position+size persist

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/3622/head
Michael Telatynski 2017-04-12 18:13:25 +01:00
parent e40c6905dd
commit 76008e8abd
2 changed files with 16 additions and 1 deletions

View File

@ -30,6 +30,8 @@ const tray = require('./tray');
const VectorMenu = require('./vectormenu'); const VectorMenu = require('./vectormenu');
const windowStateKeeper = require('electron-window-state');
let vectorConfig = {}; let vectorConfig = {};
try { try {
vectorConfig = require('../../webapp/config.json'); vectorConfig = require('../../webapp/config.json');
@ -186,11 +188,21 @@ electron.app.on('ready', () => {
process.platform == 'win32' ? 'ico' : 'png' process.platform == 'win32' ? 'ico' : 'png'
); );
// Load the previous window state with fallback to defaults
let mainWindowState = windowStateKeeper({
defaultWidth: 1024,
defaultHeight: 768,
});
mainWindow = new electron.BrowserWindow({ mainWindow = new electron.BrowserWindow({
icon: icon_path, icon: icon_path,
width: 1024, height: 768,
show: false, show: false,
autoHideMenuBar: true, autoHideMenuBar: true,
x: mainWindowState.x,
y: mainWindowState.y,
width: mainWindowState.width,
height: mainWindowState.height,
}); });
mainWindow.loadURL(`file://${__dirname}/../../webapp/index.html`); mainWindow.loadURL(`file://${__dirname}/../../webapp/index.html`);
electron.Menu.setApplicationMenu(VectorMenu); electron.Menu.setApplicationMenu(VectorMenu);
@ -226,6 +238,8 @@ electron.app.on('ready', () => {
onLinkContextMenu(ev, params); onLinkContextMenu(ev, params);
} }
}); });
mainWindowState.manage(mainWindow);
}); });
electron.app.on('window-all-closed', () => { electron.app.on('window-all-closed', () => {

View File

@ -96,6 +96,7 @@
"css-raw-loader": "^0.1.1", "css-raw-loader": "^0.1.1",
"electron-builder": "^11.2.4", "electron-builder": "^11.2.4",
"electron-builder-squirrel-windows": "^11.2.1", "electron-builder-squirrel-windows": "^11.2.1",
"electron-window-state": "^4.1.0",
"emojione": "^2.2.7", "emojione": "^2.2.7",
"eslint": "^3.14.0", "eslint": "^3.14.0",
"eslint-config-google": "^0.7.1", "eslint-config-google": "^0.7.1",