From 00fdeb3bf9d5f6bd46e21cc631fc2321214356bc Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sat, 2 Jul 2011 20:36:44 +0000 Subject: [PATCH] Focus window in command line handler --- 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 index e78c12590..709380994 100644 --- 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); + } } } }