Skip to content

Commit

Permalink
ensure main window x/y is at least 0
Browse files Browse the repository at this point in the history
  • Loading branch information
tkohlmeier committed Jan 28, 2024
1 parent 8574a6c commit 9543c0d
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,27 @@ function registerGlobalKeyboardShortcut(toggleAction: () => void, newHotKey: Glo
}

function calculateX(display: Electron.Display): number {
return Math.round(Number(display.bounds.x + display.bounds.width / 2 - config.appearanceOptions.windowWidth / 2));
return Math.max(
0,
Math.round(Number(display.bounds.x + display.bounds.width / 2 - config.appearanceOptions.windowWidth / 2)),
);
}

function calculateY(display: Electron.Display): number {
return Math.round(
Number(
display.bounds.y +
display.bounds.height / 2 -
getMaxWindowHeight(
config.appearanceOptions.maxSearchResultsPerPage,
config.appearanceOptions.searchResultHeight,
config.appearanceOptions.userInputHeight,
config.appearanceOptions.userInputBottomMargin,
) /
2,
return Math.max(
0,
Math.round(
Number(
display.bounds.y +
display.bounds.height / 2 -
getMaxWindowHeight(
config.appearanceOptions.maxSearchResultsPerPage,
config.appearanceOptions.searchResultHeight,
config.appearanceOptions.userInputHeight,
config.appearanceOptions.userInputBottomMargin,
) /
2,
),
),
);
}
Expand Down

0 comments on commit 9543c0d

Please sign in to comment.