check if window.y is offscreen

This commit is contained in:
Araxeus
2022-01-16 19:52:08 +02:00
parent e8bbc5ec1c
commit 68bd691702

View File

@ -122,12 +122,16 @@ function createMainWindow() {
autoHideMenuBar: config.get("options.hideMenu"), autoHideMenuBar: config.get("options.hideMenu"),
}); });
remote.enable(win.webContents); remote.enable(win.webContents);
if (windowPosition) { if (windowPosition) {
const { x, y } = windowPosition; const { x, y } = windowPosition;
if(x + win.getSize()[0] < 0 || x - win.getSize()[0] > electron.screen.getDisplayNearestPoint({x, y}).bounds.width) { const winSize = win.getSize();
const displaySize = electron.screen.getDisplayNearestPoint(windowPosition).bounds;
if((x + winSize[0] < 0 || x -winSize[0] > displaySize.width) ||
(y < 0 || y > displaySize.height)) {
//Window is offscreen //Window is offscreen
if (is.dev()) { 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}}`); console.log(`Window tried to render offscreen, windowSize=${winSize}, displaySize=${displaySize}, position=${windowPosition}`);
} }
} else { } else {
win.setPosition(x, y); win.setPosition(x, y);