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()) ===
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(