diff --git a/src/Makefile b/src/Makefile index eb4232c..243049d 100755 --- a/src/Makefile +++ b/src/Makefile @@ -140,8 +140,9 @@ $(build_dir)/$(chrome_source_root)/%.js: $(chrome_source_root)/%.js then \ cp -f $< $@; \ else \ - echo "Stripping comments from JS file $<"; \ + echo "Stripping debug calls from JS file $<"; \ sed '/mozt\.Debug\.dump/d' $< > $@; \ + sed '/mozt\.Debug\.debug/d' $< > $@; \ fi $(build_dir)/$(modules_dir)/commons.js: $(modules_dir)/commons.js diff --git a/src/chrome/content/overlay.js b/src/chrome/content/overlay.js index 1ab5cbd..4bfc80c 100644 --- a/src/chrome/content/overlay.js +++ b/src/chrome/content/overlay.js @@ -4,7 +4,6 @@ Components.utils.import("resource://gre/modules/ctypes.jsm"); Components.utils.import("resource://moztray/LibC.js"); Components.utils.import("resource://moztray/LibGObject.js"); -Components.utils.import("resource://moztray/LibGdkWindow.js"); Components.utils.import("resource://moztray/LibGtkStatusIcon.js"); Components.utils.import("resource://moztray/commons.js"); @@ -12,130 +11,110 @@ const MOZT_ICON_DIR = "chrome/skin/"; const MOZT_ICON_SUFFIX = "32.png"; - -var mozt_getBaseWindow = function(win) { - var bw; - try { - bw = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIWebNavigation) - .QueryInterface(Components.interfaces.nsIDocShellTreeItem) - .treeOwner - .QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIXULWindow) - .docShell - .QueryInterface(Components.interfaces.nsIBaseWindow); - } catch (ex) { - bw = null; - setTimeout(function() {throw ex; }, 0); - // ignore no-interface exception - } - return bw; +/** + * mozt namespace. + */ +if ("undefined" == typeof(mozt)) { + var mozt = {}; }; -var mozt_getAllWindows = function() { - try { - var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); - } catch (err) { - alert(err); - return; - } +mozt.Handler = { + _windowsHidden: false, - var baseWindows = new Array(); - var e = wm.getEnumerator(null); - while (e.hasMoreElements()) { - var w = e.getNext(); - baseWindows[baseWindows.length] = mozt_getBaseWindow(w); - } + _getBaseWindow: function(win) { + var bw; + try { // thx Neil Deakin !! + bw = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor) + .getInterface(Components.interfaces.nsIWebNavigation) + .QueryInterface(Components.interfaces.nsIDocShellTreeItem) + .treeOwner + .QueryInterface(Components.interfaces.nsIInterfaceRequestor) + .getInterface(Components.interfaces.nsIBaseWindow); + } catch (ex) { + bw = null; + setTimeout(function() {throw ex; }, 0); + // ignore no-interface exception + } + return bw; + }, - // e = wm.getEnumerator(null); - // // e = wm.getXULWindowEnumerator(null); - // while(e.hasMoreElements()) { - // let win = e.getNext().QueryInterface(Components.interfaces.nsIDOMChromeWindow); - // // let win = e.getNext().QueryInterface(Components.interfaces.nsIXULWindow); - // mozt.Debug.debug("WINDOW TITLE = " + win.document.documentElement.getAttribute("title") ); - // } + _getAllWindows: function() { + mozt.Debug.debug("_getAllWindows"); + var baseWindows = new Array(); + var e = mozt.Utils.windowMediator.getEnumerator(null); + while (e.hasMoreElements()) { + var w = e.getNext(); + baseWindows[baseWindows.length] = this._getBaseWindow(w); + } + return baseWindows; + }, - return baseWindows; -}; + /* + * might need to remember position... + * var outX = {}, outY = {}, outCX = {}, outCY = {}; + * bw.getPositionAndSize(outX, outY, outCX, outCY); + * mozt.Debug.debug("pos: " + * + outX.value + ", " + * + outY.value + ", " + * + outCX.value + ", " + * + outCY.value + * ); + */ + showHideToTray: function(a1, a2, a3) { + mozt.Debug.debug("showHideToTray"); -var mozt_hideToTray = function() { - mozt.Debug.debug("mozt_hideToTray"); -/* - var toto = gBrowser.getBrowserForDocument(content.document) - .docShell - .QueryInterface(Components.interfaces.nsIBaseWindow) - .parentNativeWindow; - mozt.Debug.debug("toto: " + toto); -*/ - var baseWindows = mozt_getAllWindows(); - mozt.Debug.dump("baseWindows: " + baseWindows.length); - for(var i=0; i