diff --git a/common/content/commandline.js b/common/content/commandline.js index 546a927d..4dd50eee 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -329,6 +329,8 @@ var CommandMode = Class("CommandMode", { this.completions.complete(true, false); }, + get holdFocus() this.widgets.active.command.inputField, + get mappingSelf() this, get widgets() commandline.widgets, @@ -801,12 +803,8 @@ var CommandLine = Module("commandline", { } ]).toObject(), { - blur: function onBlur(event) { - if (this.commandMode && event.originalTarget === this.widgets.active.command.inputField) - dactyl.focus(this.widgets.active.command.inputField); - }, focus: function onFocus(event) { - if (!this.commandMode + if (!this.commandSession && event.originalTarget === this.widgets.active.command.inputField) { event.target.blur(); dactyl.beep(); diff --git a/common/content/events.js b/common/content/events.js index 90e92f2b..26217d4a 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -966,7 +966,8 @@ var Events = Module("events", { blur: function onBlur(event) { let elem = event.originalTarget; - if (event.originalTarget instanceof Window && services.focus.activeWindow == null) { + if (elem instanceof Window && services.focus.activeWindow == null + && document.commandDispatcher.focusedWindow !== window) { // Deals with circumstances where, after the main window // blurs while a collapsed frame has focus, re-activating // the main window does not restore focus and we lose key @@ -974,6 +975,12 @@ var Events = Module("events", { services.focus.clearFocus(window); document.commandDispatcher.focusedWindow = Editor.getEditor(content) ? window : content; } + + let hold = modes.topOfStack.params.holdFocus; + if (elem == hold) { + dactyl.focus(hold); + this.timeout(function () { dactyl.focus(hold); }); + } }, // TODO: Merge with onFocusChange