From 8128100cefabfb07ab1026cf99d8ca3a67be69a3 Mon Sep 17 00:00:00 2001 From: tophf Date: Sun, 26 Dec 2021 19:25:25 +0300 Subject: [PATCH] ensure editor window is visible fixes #1375 --- background/background.js | 14 ++++++++++++++ edit/edit.js | 1 + 2 files changed, 15 insertions(+) diff --git a/background/background.js b/background/background.js index 404639e5..f327938c 100644 --- a/background/background.js +++ b/background/background.js @@ -73,6 +73,20 @@ addAPI(/** @namespace API */ { const wndPos = wnd && prefs.get('windowPosition'); const wndBase = wnd && prefs.get('openEditInWindow.popup') ? {type: 'popup'} : {}; 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({ url: `${u}`, currentWindow: null, diff --git a/edit/edit.js b/edit/edit.js index 2e171735..123eea60 100644 --- a/edit/edit.js +++ b/edit/edit.js @@ -96,6 +96,7 @@ window.on('beforeunload', e => { if (editor.isWindowed && document.visibilityState === 'visible' && prefs.get('openEditInWindow') && + screenX !== -32000 && // Chrome uses this value for minimized windows ( // only if not maximized screenX > 0 || outerWidth < screen.availWidth || screenY > 0 || outerHeight < screen.availHeight ||