fix app starting offscreen

This commit is contained in:
Araxeus
2022-01-11 20:14:33 +02:00
parent ec4c2e92af
commit e8bbc5ec1c

View File

@ -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();