visibleOnAnyScreen: Log window and display bounds

This commit is contained in:
Scott Nonnenberg 2024-09-18 10:36:50 +10:00 committed by GitHub
parent 6deb1594fa
commit a3351ef9f9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -735,25 +735,32 @@ async function createWindow() {
(await systemTraySettingCache.get()) === (await systemTraySettingCache.get()) ===
SystemTraySetting.MinimizeToAndStartInSystemTray; SystemTraySetting.MinimizeToAndStartInSystemTray;
const visibleOnAnyScreen = some(screen.getAllDisplays(), display => { const haveFullWindowsBounds =
if ( isNumber(windowOptions.x) &&
isNumber(windowOptions.x) && isNumber(windowOptions.y) &&
isNumber(windowOptions.y) && isNumber(windowOptions.width) &&
isNumber(windowOptions.width) && isNumber(windowOptions.height);
isNumber(windowOptions.height) if (haveFullWindowsBounds) {
) { getLogger().info(
return isVisible(windowOptions as BoundsType, get(display, 'bounds')); `visibleOnAnyScreen(window): x=${windowOptions.x}, y=${windowOptions.y}, ` +
} `width=${windowOptions.width}, height=${windowOptions.height}`
getLogger().error(
"visibleOnAnyScreen: windowOptions didn't have valid bounds fields"
); );
return false;
}); const visibleOnAnyScreen = some(screen.getAllDisplays(), display => {
if (!visibleOnAnyScreen) { const displayBounds = get(display, 'bounds');
getLogger().info('Location reset needed'); getLogger().info(
delete windowOptions.x; `visibleOnAnyScreen(display #${display.id}): ` +
delete windowOptions.y; `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( getLogger().info(