aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content_scripts/link_hints.coffee6
-rw-r--r--content_scripts/vimium_frontend.coffee3
2 files changed, 5 insertions, 4 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index f2b9cd0f..702ff69d 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -334,7 +334,7 @@ class LinkHintsMode
flashEl = DomUtils.addFlashRect linkMatched.rect
HintCoordinator.onExit.push -> DomUtils.removeElement flashEl
- if document.hasFocus()
+ if windowIsFocused()
startKeyboardBlocker (isSuccess) -> HintCoordinator.sendMessage "exit", {isSuccess}
# If we're using a keyboard blocker, then the frame with the focus sends the "exit" message, otherwise the
@@ -613,12 +613,12 @@ LocalHints =
isClickable ||= element.control? and (@getVisibleClickable element.control).length == 0
when "body"
isClickable ||=
- if element == document.body and not document.hasFocus() and
+ if element == document.body and not windowIsFocused() and
window.innerWidth > 3 and window.innerHeight > 3 and
document.body?.tagName.toLowerCase() != "frameset"
reason = "Frame."
isClickable ||=
- if element == document.body and document.hasFocus() and Scroller.isScrollableElement element
+ if element == document.body and windowIsFocused() and Scroller.isScrollableElement element
reason = "Scroll."
when "div", "ol", "ul"
isClickable ||=
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index 7d6fa9a0..39e8e5d8 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -8,7 +8,8 @@ normalMode = null
# We track whther the current window has the focus or not.
windowIsFocused = do ->
- windowHasFocus = document.hasFocus()
+ windowHasFocus = null
+ DomUtils.documentReady -> windowHasFocus = document.hasFocus()
window.addEventListener "focus", (event) -> windowHasFocus = true if event.target == window; true
window.addEventListener "blur", (event) -> windowHasFocus = false if event.target == window; true
-> windowHasFocus