visibleOnAnyScreen: Log window and display bounds
This commit is contained in:
parent
6deb1594fa
commit
a3351ef9f9
1 changed files with 25 additions and 18 deletions
43
app/main.ts
43
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(
|
||||
|
|
Loading…
Reference in a new issue