Skip to content

Commit

Permalink
Merge pull request #21 from tborychowski/patch-1
Browse files Browse the repository at this point in the history
allow to use this module from the renderer process
  • Loading branch information
mawie81 committed Mar 13, 2017
2 parents b79b444 + 6de6045 commit 6a51baf
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ var mkdirp = require('mkdirp');
var deepEqual = require('deep-equal');

module.exports = function (options) {
var app = electron.app;
var screen = electron.screen;
var app = electron.app || electron.remote.app;
var screen = electron.screen || electron.remote.screen;
var state;
var winRef;
var stateChangeTimer;
Expand Down Expand Up @@ -73,17 +73,19 @@ module.exports = function (options) {
if (!win) {
return;
}

var winBounds = win.getBounds();
if (isNormal(win)) {
state.x = winBounds.x;
state.y = winBounds.y;
state.width = winBounds.width;
state.height = winBounds.height;
}
state.isMaximized = win.isMaximized();
state.isFullScreen = win.isFullScreen();
state.displayBounds = screen.getDisplayMatching(winBounds).bounds;
// don't throw an error when window was closed
try {
var winBounds = win.getBounds();
if (isNormal(win)) {
state.x = winBounds.x;
state.y = winBounds.y;
state.width = winBounds.width;
state.height = winBounds.height;
}
state.isMaximized = win.isMaximized();
state.isFullScreen = win.isFullScreen();
state.displayBounds = screen.getDisplayMatching(winBounds).bounds;
} catch (err) {}
}

function saveState(win) {
Expand Down

0 comments on commit 6a51baf

Please sign in to comment.