summaryrefslogtreecommitdiff
path: root/common/content/dactyl.js
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2010-12-18 15:27:45 -0500
committerKris Maglione <maglione.k@gmail.com>2010-12-18 15:27:45 -0500
commit4ff7172c77b5f04fcc71c3c6e176f4c259540c8f (patch)
tree7d1e0d1c419e96eb0861689f345a749ca992e165 /common/content/dactyl.js
parent0af241568b04ce187acfa6e1a06b6ccbfa88bd6f (diff)
downloadpentadactyl-4ff7172c77b5f04fcc71c3c6e176f4c259540c8f.tar.gz
Import the bulk of a focus management patch near the top of my queue.
Diffstat (limited to 'common/content/dactyl.js')
-rw-r--r--common/content/dactyl.js34
1 files changed, 24 insertions, 10 deletions
diff --git a/common/content/dactyl.js b/common/content/dactyl.js
index 938536fd..c5273ffa 100644
--- a/common/content/dactyl.js
+++ b/common/content/dactyl.js
@@ -87,9 +87,6 @@ const Dactyl = Module("dactyl", {
get menuItems() Dactyl.getMenuItems(),
- /** @property {Element} The currently focused element. */
- get focus() document.commandDispatcher.focusedElement,
-
// Global constants
CURRENT_TAB: [],
NEW_TAB: [],
@@ -385,6 +382,20 @@ const Dactyl = Module("dactyl", {
return res;
},
+ focus: function (elem, flags) {
+ try {
+ if (elem instanceof Document)
+ elem = elem.defaultView;
+ if (elem instanceof Window)
+ services.focus.clearFocus(elem);
+ else
+ services.focus.setFocus(elem, flags || Ci.nsIFocusManager.FLAG_BYMOUSE|Ci.nsIFocusManager.FLAG_BYMOVEFOCUS);
+ } catch (e) {
+ util.dump(elem);
+ util.reportError(e);
+ }
+ },
+
/**
* Focuses the content window.
*
@@ -413,21 +424,24 @@ const Dactyl = Module("dactyl", {
}
catch (e) {}
- if (clearFocusedElement)
- if (dactyl.focus)
- dactyl.focus.blur();
- else if (win && Editor.getEditor(win)) {
+ if (clearFocusedElement) {
+ services.focus.clearFocus(window);
+ if (win && Editor.getEditor(win)) {
win.blur();
if (win.frameElement)
win.frameElement.blur();
}
+ }
if (elem instanceof Window && Editor.getEditor(elem))
elem = window;
- if (elem && elem != dactyl.focus)
- elem.focus();
- },
+ if (elem && elem != dactyl.focusedElement)
+ dactyl.focus(elem);
+ },
+
+ /** @property {Element} The currently focused element. */
+ get focusedElement() services.focus.getFocusedElementForWindow(window, true, {}),
/**
* Returns whether this Dactyl extension supports *feature*.