From a78d1c38766f4b49b20e62f07ddca913275a440a Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Mon, 1 Apr 2024 16:33:38 -0400 Subject: [PATCH] Fix window shrinking on each launch (#3910) --- chrome/content/zotero/titlebar.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/chrome/content/zotero/titlebar.js b/chrome/content/zotero/titlebar.js index fc2e62c23b..455a0bbb9b 100644 --- a/chrome/content/zotero/titlebar.js +++ b/chrome/content/zotero/titlebar.js @@ -32,22 +32,26 @@ if (platforms) { else if (Zotero.isLinux && !platforms.includes("linux")) return; } +// Set attributes that affect window chrome sizing immediately, to avoid shrinking when +// AppWindow::LoadPersistentWindowState() restores width/height +// https://searchfox.org/mozilla-central/rev/10f46c9c638e0e5935ed9fa12aadc9d0d4e71ade/xpfe/appshell/AppWindow.cpp#2582-2584 + +// Create tab bar by default +document.documentElement.setAttribute('drawintitlebar', true); +document.documentElement.setAttribute('tabsintitlebar', true); +if (Zotero.isMac) { + document.documentElement.setAttribute('chromemargin', '0,-1,-1,-1'); +} +else { + document.documentElement.setAttribute('chromemargin', '0,2,2,2'); +} + window.addEventListener("load", function () { // Fix window without menubar/titlebar when Zotero is closed in full-screen mode in OS X 10.11+ if (Zotero.isMac && window.document.documentElement.getAttribute('sizemode') == 'fullscreen') { window.document.documentElement.setAttribute('sizemode', 'normal'); } - // Create tab bar by default - document.documentElement.setAttribute('drawintitlebar', true); - document.documentElement.setAttribute('tabsintitlebar', true); - if (Zotero.isMac) { - document.documentElement.setAttribute('chromemargin', '0,-1,-1,-1'); - } - else { - document.documentElement.setAttribute('chromemargin', '0,2,2,2'); - } - if (Zotero.isWin) { let windowIcon = document.querySelector(".titlebar-icon"); // Simulate Windows window control