From 89ea66ba2b425a3a797a9429746a83532bf548b2 Mon Sep 17 00:00:00 2001 From: TC Date: Sat, 22 Jan 2022 19:57:23 +0100 Subject: [PATCH] Simplify off-screen check --- index.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 146a4f81..8360f147 100644 --- a/index.js +++ b/index.js @@ -131,14 +131,21 @@ function createMainWindow() { if (windowPosition) { const { x, y } = windowPosition; 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)) { + 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}`); + console.log( + `Window tried to render offscreen, windowSize=${winSize}, displaySize=${displaySize}, position=${windowPosition}` + ); } - } else { + } else { win.setPosition(x, y); } }