Don't save maximized editor window size&pos

This fixes the bug with reloading the editor tab in a maximized state: previously the window was losing its state.

Assuming a detached editor window normally is expected to have a smaller size and custom position, the user may occasionally maximize it for convenience, in which case we don't save its size and position.

Even if this assumption is wrong, it's easy to manually resize the window to fill the entire screen so that the size/position are remembered.
This commit is contained in:
tophf 2017-06-06 16:44:16 +03:00
parent 4559162d45
commit d36489216c

13
edit.js
View File

@ -423,7 +423,9 @@ document.addEventListener("wheel", function(event) {
chrome.tabs.query({currentWindow: true}, function(tabs) {
var windowId = tabs[0].windowId;
if (prefs.get("openEditInWindow")) {
if (sessionStorage.saveSizeOnClose && 'left' in prefs.get('windowPosition', {})) {
if (sessionStorage.saveSizeOnClose
&& 'left' in prefs.get('windowPosition', {})
&& !isWindowMaximized()) {
// window was reopened via Ctrl-Shift-T etc.
chrome.windows.update(windowId, prefs.get('windowPosition'));
}
@ -458,8 +460,15 @@ function goBackToManage(event) {
}
}
function isWindowMaximized() {
return window.screenLeft == 0
&& window.screenTop == 0
&& window.outerWidth == screen.availWidth
&& window.outerHeight == screen.availHeight;
}
window.onbeforeunload = function() {
if (saveSizeOnClose) {
if (saveSizeOnClose && !isWindowMaximized()) {
prefs.set("windowPosition", {
left: screenLeft,
top: screenTop,