saved layout (#62)

* saved layout

* fix fieldName check
This commit is contained in:
Lynn
2017-04-20 11:54:11 -07:00
committed by GitHub
parent 9785baacc3
commit 439f283916
11 changed files with 413 additions and 113 deletions

View File

@@ -0,0 +1,29 @@
'use strict'
const electron = require('electron');
/**
* Returns true if given rectangle is contained within the workArea of at
* least one of the screens.
* @param {x: Number, y: Number, width: Number, height: Number} rect
* @return {Boolean} true if condition in desc is met.
*/
function isInDisplayBounds(rect) {
if (!rect) {
return false;
}
let displays = electron.screen.getAllDisplays();
for(let i = 0, len = displays.length; i < len; i++) {
let workArea = displays[i].workArea;
if (rect.x >= workArea.x && rect.y >= workArea.y &&
((rect.x + rect.width) <= (workArea.x + workArea.width)) &&
((rect.y + rect.height) <= (workArea.y + workArea.height))) {
return true;
}
}
return false;
}
module.exports = isInDisplayBounds;