diff options
| author | Stephen Blott | 2015-03-16 09:35:24 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-03-16 09:43:55 +0000 |
| commit | 1ae621489da091e6d9430da248d0e6eaab606f35 (patch) | |
| tree | 25140d7ffde666de42251fb8118f1a6e4c8fbf57 | |
| parent | 23cb1677bbc79328e7329fab4400f671ea6aee23 (diff) | |
| download | vimium-1ae621489da091e6d9430da248d0e6eaab606f35.tar.bz2 | |
Activate vomnibar in window.top.
This changes vomnibar commands to activate not in the current frame, but
in window.top. Consequently, the vomnibar always appears in the same
position, and we don't get odd looking vomnibars in small frames.
Apart from the better UX, this seems to be the right thing to do.
Vomnibar commands apply to tabs (not frames).
Currently incomplete:
- On exit, the focus is not returned to the frame which originally
had the focus. (It's returned to window.top).
- The vomnibar can lose the focus and not hide itself for various
frame/click combinations.
| -rw-r--r-- | content_scripts/ui_component.coffee | 3 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 10 |
2 files changed, 12 insertions, 1 deletions
diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee index dadc84b5..b582cb5d 100644 --- a/content_scripts/ui_component.coffee +++ b/content_scripts/ui_component.coffee @@ -36,6 +36,9 @@ class UIComponent @postMessage message if message? @iframeElement.classList.remove "vimiumUIComponentHidden" @iframeElement.classList.add "vimiumUIComponentShowing" + # The window may not have the focus. We focus it now so that the focus listener below isn't triggered + # immediately. + window.focus() window.addEventListener "focus", @onFocus = (event) => if event.target == window window.removeEventListener "focus", @onFocus diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 429657fc..0aaee3db 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -241,7 +241,7 @@ initializeOnDomReady = -> # Tell the background page we're in the dom ready state. chrome.runtime.connect({ name: "domReady" }) CursorHider.init() - Vomnibar.init() + Vomnibar.init() if window.top == window registerFrame = -> # Don't register frameset containers; focusing them is no use. @@ -258,6 +258,14 @@ unregisterFrame = -> tab_is_closing: window.top == window.self executePageCommand = (request) -> + # Vomnibar commands are handled in the tab's main frame. + if request.command.split(".")[0] == "Vomnibar" + if window.top == window + Utils.invokeCommandString request.command + refreshCompletionKeys request + return + + # All other commands are handled in their frame. return unless frameId == request.frameId if (request.passCountToFunction) |
