From 1ae621489da091e6d9430da248d0e6eaab606f35 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 16 Mar 2015 09:35:24 +0000 Subject: 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. --- content_scripts/ui_component.coffee | 3 +++ content_scripts/vimium_frontend.coffee | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'content_scripts') 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) -- cgit v1.2.3