From e8bbc5ec1cd3d60e84fd1f0db1f0ffc2d1f6c879 Mon Sep 17 00:00:00 2001 From: Araxeus <78568641+Araxeus@users.noreply.github.com> Date: Tue, 11 Jan 2022 20:14:33 +0200 Subject: [PATCH] fix app starting offscreen --- index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 6bf40ec1..06c6d98b 100644 --- a/index.js +++ b/index.js @@ -124,7 +124,14 @@ function createMainWindow() { remote.enable(win.webContents); if (windowPosition) { const { x, y } = windowPosition; - win.setPosition(x, y); + if(x + win.getSize()[0] < 0 || x - win.getSize()[0] > electron.screen.getDisplayNearestPoint({x, y}).bounds.width) { + //Window is offscreen + if (is.dev()) { + console.log(`Window tried to render offscreen, Width=${win.getSize()[0]}, nearestDisplayPointer.bounds=${electron.screen.getDisplayNearestPoint({x, y}).bounds}, position=${{x, y}}`); + } + } else { + win.setPosition(x, y); + } } if (windowMaximized) { win.maximize();