diff options
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/ui_component.coffee | 15 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 1 |
2 files changed, 6 insertions, 10 deletions
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 |
