diff options
author | Kris Maglione <maglione.k@gmail.com> | 2011-08-14 17:06:46 -0400 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2011-08-14 17:06:46 -0400 |
commit | 236a894c8913d8da6e2297dca1cacf363bca8a51 (patch) | |
tree | 14b6704db7df8ba88f07aadb0fdb0acf8e4a5d26 | |
parent | 1509ee96e5f6e223ad6397258f2d2c01730f2daf (diff) | |
download | pentadactyl-236a894c8913d8da6e2297dca1cacf363bca8a51.tar.gz |
Add dactyl instance tracking.
-rw-r--r-- | common/components/commandline-handler.js | 4 | ||||
-rw-r--r-- | common/content/events.js | 11 | ||||
-rw-r--r-- | common/modules/util.jsm | 7 |
3 files changed, 16 insertions, 6 deletions
diff --git a/common/components/commandline-handler.js b/common/components/commandline-handler.js index e4362d97..ba2c578c 100644 --- a/common/components/commandline-handler.js +++ b/common/components/commandline-handler.js @@ -51,9 +51,7 @@ CommandLineHandler.prototype = { if (remote) { commandLine.preventDefault = true; require(global, "services"); - let win = services.windowMediator.getMostRecentWindow("navigator:browser"); - if (win && win.dactyl) - win.dactyl.execute(remote); + util.dactyl.execute(remote); } } catch(e) { diff --git a/common/content/events.js b/common/content/events.js index 34884ba7..1b3a3d80 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -495,6 +495,12 @@ var Events = Module("events", { this._activeMenubar = false; this.listen(window, this, "events"); + + util.windows = [window].concat(util.windows); + }, + + destroy: function destroy() { + util.windows = util.windows.filter(function (w) w != window); }, signals: { @@ -705,7 +711,7 @@ var Events = Module("events", { let event = DOM.Event(doc, type, evt); if (!evt_obj.dactylString && !mode) - events.dispatch(target, event, evt); + DOM.Event.dispatch(target, event, evt); else if (type === "keypress") events.events.keypress.call(events, event); } @@ -1153,6 +1159,9 @@ var Events = Module("events", { focus: function onFocus(event) { let elem = event.originalTarget; + if (elem == window) + util.windows = [window].concat(util.windows.filter(function (w) w != window)); + elem.dactylHadFocus = true; if (event.target instanceof Ci.nsIDOMXULTextBoxElement) if (Events.isHidden(elem, true)) diff --git a/common/modules/util.jsm b/common/modules/util.jsm index cd0d2722..59ba36bd 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -66,6 +66,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), this.addObserver(this); this.overlays = {}; + this.windows = []; }, cleanup: function cleanup() { @@ -84,14 +85,16 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), } }, - // FIXME: Only works for Pentadactyl - get activeWindow() services.windowMediator.getMostRecentWindow("navigator:browser"), + get activeWindow() this.windows[0], + dactyl: update(function dactyl(obj) { if (obj) var global = Class.objectGlobal(obj); + return { __noSuchMethod__: function (meth, args) { let win = util.activeWindow; + var dactyl = global && global.dactyl || win && win.dactyl; if (!dactyl) return null; |