diff options
| author | Stephen Blott | 2015-03-17 10:32:40 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-03-17 10:32:40 +0000 |
| commit | 9461d30b0d19fd65dc43e18bebec1fe0fd3ee818 (patch) | |
| tree | 38336fe71a9d0d345a98b526a417024f23d12bdb | |
| parent | aa8d00fd9779d4061431dbdcb7a70b9c39e8049a (diff) | |
| download | vimium-9461d30b0d19fd65dc43e18bebec1fe0fd3ee818.tar.bz2 | |
Activate vomnibar in window.top; hide on focus.
| -rw-r--r-- | background_scripts/main.coffee | 4 | ||||
| -rw-r--r-- | content_scripts/ui_component.coffee | 15 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 1 |
3 files changed, 10 insertions, 10 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index b8c015d7..0b19ce4a 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -657,6 +657,10 @@ handleFrameFocused = (request, sender) -> if frameIdsForTab[tabId]? frameIdsForTab[tabId] = [request.frameId, (frameIdsForTab[tabId].filter (id) -> id != request.frameId)...] + # Inform all frames that a frame has received the focus. + chrome.tabs.sendMessage sender.tab.id, + name: "frameFocused" + frameId: request.frameId # Send a message to a all frames in the current tab. sendMessageToFrames = (request, sender) -> diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee index 82398727..64dddf67 100644 --- a/content_scripts/ui_component.coffee +++ b/content_scripts/ui_component.coffee @@ -15,6 +15,11 @@ class UIComponent # Hide the iframe, but don't interfere with the focus. @hide false + # If any frame in the current tab receives the focus, then we hide the vomnibar. + chrome.runtime.onMessage.addListener (request) => + @hide false if @showing and request.name == "frameFocused" + false # Free up response handler. + # Open a port and pass it to the iframe via window.postMessage. openPort: -> messageChannel = new MessageChannel() @@ -37,21 +42,11 @@ 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 - @onFocus = null - @postMessage "hide" @showing = true hide: (focusWindow = true)-> @iframeElement.classList.remove "vimiumUIComponentShowing" @iframeElement.classList.add "vimiumUIComponentHidden" - window.removeEventListener "focus", @onFocus if @onFocus - @onFocus = null if focusWindow and @options?.frameId? chrome.runtime.sendMessage handler: "sendMessageToFrames" diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index eb951c33..941b2bc2 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -178,6 +178,7 @@ initializePreDomReady = -> currentKeyQueue: (request) -> keyQueue = request.keyQueue handlerStack.bubbleEvent "registerKeyQueue", { keyQueue: keyQueue } + frameFocused: -> # A frame has received the focus. We don't care, here. The Vomnibar/UI-component cares. chrome.runtime.onMessage.addListener (request, sender, sendResponse) -> # In the options page, we will receive requests from both content and background scripts. ignore those |
