ensure editor window is visible

fixes #1375
This commit is contained in:
tophf 2021-12-26 19:25:25 +03:00
parent 6afb4dc634
commit 8128100cef
2 changed files with 15 additions and 0 deletions

View File

@ -73,6 +73,20 @@ addAPI(/** @namespace API */ {
const wndPos = wnd && prefs.get('windowPosition'); const wndPos = wnd && prefs.get('windowPosition');
const wndBase = wnd && prefs.get('openEditInWindow.popup') ? {type: 'popup'} : {}; const wndBase = wnd && prefs.get('openEditInWindow.popup') ? {type: 'popup'} : {};
const ffBug = wnd && FIREFOX; // https://bugzil.la/1271047 const ffBug = wnd && FIREFOX; // https://bugzil.la/1271047
if (wndPos) {
const {left, top, width, height} = wndPos;
const r = left + width;
const b = top + height;
const peek = 32;
if (isNaN(r) || r < peek || left > screen.availWidth - peek || width < 100) {
delete wndPos.left;
delete wndPos.width;
}
if (isNaN(b) || b < peek || top > screen.availHeight - peek || height < 100) {
delete wndPos.top;
delete wndPos.height;
}
}
const tab = await openURL({ const tab = await openURL({
url: `${u}`, url: `${u}`,
currentWindow: null, currentWindow: null,

View File

@ -96,6 +96,7 @@ window.on('beforeunload', e => {
if (editor.isWindowed && if (editor.isWindowed &&
document.visibilityState === 'visible' && document.visibilityState === 'visible' &&
prefs.get('openEditInWindow') && prefs.get('openEditInWindow') &&
screenX !== -32000 && // Chrome uses this value for minimized windows
( // only if not maximized ( // only if not maximized
screenX > 0 || outerWidth < screen.availWidth || screenX > 0 || outerWidth < screen.availWidth ||
screenY > 0 || outerHeight < screen.availHeight || screenY > 0 || outerHeight < screen.availHeight ||