Skip to content

Commit

Permalink
Merge pull request #7 from rbiggers/window-state
Browse files Browse the repository at this point in the history
Added window state management
  • Loading branch information
rbiggers committed Jun 25, 2019
2 parents f810201 + 1fb24e4 commit e5f3f00
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
17 changes: 14 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const {

const path = require('path');
const devtron = require('devtron');
const windowStateKeeper = require('electron-window-state');
const { version } = require('./package.json');
const GitHubApi = require('./GitHubApi');

Expand All @@ -22,6 +23,7 @@ if (process.mas) app.setName('Electron Pandora');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow = null;
let mainWindowState = null;
let pandoraView = null;

// In this file you can include the rest of your app's specific main process
Expand Down Expand Up @@ -259,10 +261,17 @@ function initialize() {
makeSingleInstance();

function createWindow() {
// Create the browser window.
// Create the browser window with state.
mainWindowState = windowStateKeeper({
defaultWidth: 1280,
defaultHeight: 720,
});

const windowOptions = {
width: 1280,
height: 720,
x: mainWindowState.x,
y: mainWindowState.y,
width: mainWindowState.width,
height: mainWindowState.height,
titleBarStyle: 'hidden',
title: app.getName(),
webPreferences: {
Expand All @@ -272,6 +281,8 @@ function initialize() {

mainWindow = new BrowserWindow(windowOptions);

mainWindowState.manage(mainWindow);

// and load the index.html of the app.
mainWindow.loadURL(path.join('file://', __dirname, '/index.html'));

Expand Down
15 changes: 11 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"dependencies": {
"devtron": "^1.4.0",
"electron-dl": "1.14.0",
"electron-window-state": "5.0.3",
"glob": "^7.1.3",
"mocha": "6.1.4",
"request": "2.88.0",
Expand Down

0 comments on commit e5f3f00

Please sign in to comment.