summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2010-10-03 10:24:01 -0400
committerKris Maglione <maglione.k@gmail.com>2010-10-03 10:24:01 -0400
commit69ed86178d29ed79189b8af95ee3f979966ca5de (patch)
tree3530bf1ff4d3d06bc1e315e858c7e8dbb6f60b41 /common
parentc85b53232ff8afdae2258566d2154b87ee887091 (diff)
downloadpentadactyl-69ed86178d29ed79189b8af95ee3f979966ca5de.tar.gz
Take focus from elements when they collapse. Small naming fix for Doug's sake. Closes issue #36.
--HG-- extra : rebase_source : aa0f776bafdeddc8a8b45ca3430de18ab535babc
Diffstat (limited to 'common')
-rw-r--r--common/content/autocommands.js4
-rw-r--r--common/content/dactyl.js10
-rw-r--r--common/content/events.js20
3 files changed, 26 insertions, 8 deletions
diff --git a/common/content/autocommands.js b/common/content/autocommands.js
index fc1b882e..894bc67d 100644
--- a/common/content/autocommands.js
+++ b/common/content/autocommands.js
@@ -271,10 +271,6 @@ const AutoCommands = Module("autocommands", {
{
completer: function () Iterator(update({ all: "All Events" }, config.autocommands))
});
-
- options.add(["strictfocus", "sf"],
- "Prevent scripts from focusing input elements without user intervention",
- "boolean", true);
}
});
diff --git a/common/content/dactyl.js b/common/content/dactyl.js
index df41e43a..d929a660 100644
--- a/common/content/dactyl.js
+++ b/common/content/dactyl.js
@@ -1222,6 +1222,7 @@ const Dactyl = Module("dactyl", {
for (let [, group] in Iterator(groups))
if (!group.feature || dactyl.has(group.feature))
group.setter(value);
+ events.checkFocus();
return value;
},
completer: function (context) {
@@ -1715,12 +1716,13 @@ const Dactyl = Module("dactyl", {
"./*[@toolbarname=" + util.escapeString(name, "'") + "]",
document, toolbox).snapshotItem(0);
- let tbcmd = function (names, desc, action, filter) {
+ let toolbarCommand = function (names, desc, action, filter) {
commands.add(names, desc,
function (args) {
let toolbar = findToolbar(args[0] || "");
dactyl.assert(toolbar, "E474: Invalid argument");
action(toolbar);
+ events.checkFocus();
}, {
argcount: "1",
completer: function (context) {
@@ -1732,13 +1734,13 @@ const Dactyl = Module("dactyl", {
});
};
- tbcmd(["toolbars[how]", "tbs[how]"], "Show the named toolbar",
+ toolbarCommand(["toolbars[how]", "tbs[how]"], "Show the named toolbar",
function (toolbar) toolbar.collapsed = false,
function (item) item.item.collapsed);
- tbcmd(["toolbarh[ide]", "tbh[ide]"], "Hide the named toolbar",
+ toolbarCommand(["toolbarh[ide]", "tbh[ide]"], "Hide the named toolbar",
function (toolbar) toolbar.collapsed = true,
function (item) !item.item.collapsed);
- tbcmd(["toolbart[oggle]", "tbt[oggle]"], "Toggle the named toolbar",
+ toolbarCommand(["toolbart[oggle]", "tbt[oggle]"], "Toggle the named toolbar",
function (toolbar) toolbar.collapsed = !toolbar.collapsed);
}
diff --git a/common/content/events.js b/common/content/events.js
index d8a80ebd..42dbb5ae 100644
--- a/common/content/events.js
+++ b/common/content/events.js
@@ -693,6 +693,21 @@ const Events = Module("events", {
}
},
+ /**
+ * Ensures that the currently focused element is visible and blurs
+ * it if it's not.
+ */
+ checkFocus: function () {
+ if (dactyl.focus) {
+ let rect = dactyl.focus.getBoundingClientRect();
+ if (!rect.width || !rect.height) {
+ dactyl.focus.blur();
+ // onFocusChange needs to die.
+ this.onFocusChange();
+ }
+ }
+ },
+
// TODO: Merge with onFocusChange
onFocus: function (event) {
let elem = event.originalTarget;
@@ -1157,6 +1172,11 @@ const Events = Module("events", {
},
{ arg: true, count: true });
},
+ options: function () {
+ options.add(["strictfocus", "sf"],
+ "Prevent scripts from focusing input elements without user intervention",
+ "boolean", true);
+ },
sanitizer: function () {
sanitizer.addItem("macros", {
description: "Saved macros",