commit 00fdeb3bf9d5f6bd46e21cc631fc2321214356bc parent a8631f760ac5ce882ca6a3c87b7dc15b6a6643e2 Author: Simon Kornblith <simon@simonster.com> Date: Sat, 2 Jul 2011 20:36:44 +0000 Focus window in command line handler Diffstat:
| M | components/zotero-command-line-handler.js | | | 13 | +++++++++---- |
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/components/zotero-command-line-handler.js b/components/zotero-command-line-handler.js @@ -80,11 +80,16 @@ ZoteroCommandLineHandler.prototype = { if(param) { var uri = cmdLine.resolveURI(param); if(uri.schemeIs("zotero")) { - // Don't open a new window - cmdLine.preventDefault = true; - - Components.classes["@mozilla.org/network/protocol;1?name=zotero"] + // Check for existing window and focus it + var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] + .getService(Components.interfaces.nsIWindowMediator); + var win = wm.getMostRecentWindow("navigator:browser"); + if(win) { + cmdLine.preventDefault = true; + win.focus(); + Components.classes["@mozilla.org/network/protocol;1?name=zotero"] .createInstance(Components.interfaces.nsIProtocolHandler).newChannel(uri); + } } } }