Browse Source

Save Window State

Fixes #24
pull/92/merge
Ramiro Saenz 9 years ago
parent
commit
ad9dd5aa98
  1. 1
      app/package.json
  2. 22
      electron/main.js

1
app/package.json

@ -25,6 +25,7 @@
"author": "Ramiro Saenz",
"license": "MIT",
"dependencies": {
"electron-window-state": "^3.0.3",
"firebase": "^3.0.5",
"firebase-token-generator": "^2.0.0"
}

22
electron/main.js

@ -13,6 +13,8 @@ const appMenu = require('./menu');
const tray = require('./tray');
// Require for autpUpdate file
const autoupdater = require('./autoupdater');
// Window State Plugin
const windowStateKeeper = require('electron-window-state');
const MenuItem = electron.MenuItem;
@ -91,11 +93,21 @@ let mainWindow;
let isQuitting = false;
function createWindow () {
// Create the browser window.
// Load the previous state with fallback to defaults
let mainWindowState = windowStateKeeper({
defaultWidth: 1000
,defaultHeight: 800
,maximize: true
});
// Create the browser window using the state information
mainWindow = new BrowserWindow({
title: 'Rambox'
,skipTaskbar: false
,icon: __dirname + '/../resources/Icon.png'
,x: mainWindowState.x
,y: mainWindowState.y
,width: mainWindowState.width
,height: mainWindowState.height
,webPreferences: {
webSecurity: false
,nodeIntegration: true
@ -104,10 +116,12 @@ function createWindow () {
}
});
process.setMaxListeners(100);
// Let us register listeners on the window, so we can update the state
// automatically (the listeners will be removed when the window is closed)
// and restore the maximized or full screen state
mainWindowState.manage(mainWindow);
// Start maximize
mainWindow.maximize();
process.setMaxListeners(100);
// and load the index.html of the app.
mainWindow.loadURL('file://' + __dirname + '/../index.html');

Loading…
Cancel
Save