commit 9d20e2a827011a11c1bd7b041f33e051017b8ade
parent e10c3e2e72237fb9bfba00943fdbb3ab6966f5f6
Author: Simon Kornblith <simon@simonster.com>
Date: Tue, 31 Jan 2012 22:22:45 -0500
A slightly less sketchy reactivate hack
Diffstat:
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js
@@ -772,18 +772,18 @@ var Zotero_QuickFormat = new function () {
referencePanel.openPopup(document.documentElement, "after_start", 15,
null, false, false, null);
if(!Zotero.isMac && !Zotero.isWin) {
- // When it opens, we will lose focus
- referencePanel.addEventListener("popupshown", function() {
- referencePanel.removeEventListener("popupshown", arguments.callee, false);
- _refocusQfe();
-
- // This is a nasty hack, but seems to be necessary to fix loss of focus on Linux
- window.setTimeout(function() { _refocusQfe(); }, 25);
- window.setTimeout(function() { _refocusQfe(); }, 50);
- window.setTimeout(function() { _refocusQfe(); }, 100);
- window.setTimeout(function() { _refocusQfe(); }, 175);
- window.setTimeout(function() { _refocusQfe(); }, 250);
- }, false);
+ // When the reference panel opens, we may lose focus on Linux. We thus look for a
+ // deactivate event within 1 second of the panel open request.
+ var eventHandler = function(e) {
+ if(e.target !== window) return;
+ window.removeEventListener("deactivate", eventHandler, false);
+ window.clearTimeout(timeoutID);
+ window.setTimeout(function() { _refocusQfe(); }, 0);
+ };
+ window.addEventListener("deactivate", eventHandler, false);
+ var timeoutID = window.setTimeout(function() {
+ window.removeEventListener("deactivate", eventHandler, false);
+ }, 1000);
}
}