Skip to content

Commit

Permalink
fix app starting offscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
Araxeus committed Jan 11, 2022
1 parent ec4c2e9 commit e8bbc5e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e8bbc5e

Please sign in to comment.