Skip to content

Commit

Permalink
Make sure window is visible (#3008)
Browse files Browse the repository at this point in the history
  • Loading branch information
kawanakaiku authored Feb 6, 2023
1 parent 875edf1 commit edcd5ed
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,12 @@ function runApp() {
const boundsDoc = await baseHandlers.settings._findBounds()
if (typeof boundsDoc?.value === 'object') {
const { maximized, fullScreen, ...bounds } = boundsDoc.value
const allDisplaysSummaryWidth = screen
.getAllDisplays()
.reduce((accumulator, { size: { width } }) => accumulator + width, 0)
const windowVisible = screen.getAllDisplays().some(display => {
const { x, y, width, height } = display.bounds
return !(bounds.x > x + width || bounds.x + bounds.width < x || bounds.y > y + height || bounds.y + bounds.height < y)
})

if (allDisplaysSummaryWidth >= bounds.x) {
if (windowVisible) {
newWindow.setBounds({
x: bounds.x,
y: bounds.y,
Expand Down

0 comments on commit edcd5ed

Please sign in to comment.