diff --git a/index.js b/index.js index 07801d58..146a4f81 100644 --- a/index.js +++ b/index.js @@ -127,9 +127,20 @@ function createMainWindow() { autoHideMenuBar: config.get("options.hideMenu"), }); remote.enable(win.webContents); + if (windowPosition) { const { x, y } = windowPosition; - win.setPosition(x, y); + const winSize = win.getSize(); + const displaySize = electron.screen.getDisplayNearestPoint(windowPosition).bounds; + if((x + winSize[0] < displaySize.x - 8 || x - winSize[0] > displaySize.x + displaySize.width) || + (y < displaySize.y - 8 || y > displaySize.y + displaySize.height)) { + //Window is offscreen + if (is.dev()) { + console.log(`Window tried to render offscreen, windowSize=${winSize}, displaySize=${displaySize}, position=${windowPosition}`); + } + } else { + win.setPosition(x, y); + } } if (windowMaximized) { win.maximize();