diff --git a/app/main.ts b/app/main.ts index 0e26a38d0a36..e68c84c27273 100644 --- a/app/main.ts +++ b/app/main.ts @@ -735,25 +735,32 @@ async function createWindow() { (await systemTraySettingCache.get()) === SystemTraySetting.MinimizeToAndStartInSystemTray; - const visibleOnAnyScreen = some(screen.getAllDisplays(), display => { - if ( - isNumber(windowOptions.x) && - isNumber(windowOptions.y) && - isNumber(windowOptions.width) && - isNumber(windowOptions.height) - ) { - return isVisible(windowOptions as BoundsType, get(display, 'bounds')); - } - - getLogger().error( - "visibleOnAnyScreen: windowOptions didn't have valid bounds fields" + const haveFullWindowsBounds = + isNumber(windowOptions.x) && + isNumber(windowOptions.y) && + isNumber(windowOptions.width) && + isNumber(windowOptions.height); + if (haveFullWindowsBounds) { + getLogger().info( + `visibleOnAnyScreen(window): x=${windowOptions.x}, y=${windowOptions.y}, ` + + `width=${windowOptions.width}, height=${windowOptions.height}` ); - return false; - }); - if (!visibleOnAnyScreen) { - getLogger().info('Location reset needed'); - delete windowOptions.x; - delete windowOptions.y; + + const visibleOnAnyScreen = some(screen.getAllDisplays(), display => { + const displayBounds = get(display, 'bounds'); + getLogger().info( + `visibleOnAnyScreen(display #${display.id}): ` + + `x=${displayBounds.x}, y=${displayBounds.y}, ` + + `width=${displayBounds.width}, height=${displayBounds.height}` + ); + + return isVisible(windowOptions as BoundsType, displayBounds); + }); + if (!visibleOnAnyScreen) { + getLogger().info('visibleOnAnyScreen: Location reset needed'); + delete windowOptions.x; + delete windowOptions.y; + } } getLogger().info(