From 468ed83a6808717fd5bca086ecf8ed2e65933fa8 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sun, 26 Jan 2014 16:58:55 +0100 Subject: [PATCH] Re-implement popup passthrough more robustly MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Commit 35f48d24bf5c broke popup passthrough a bit, unfortunately. It works for the context menu, but not for the menu bar. It is time to ditch the unreliable onpopupshowing/onpopuphiding and checking properties on root windows for determining if popups are open. Now we simply just loop through all menupopups and panels and check if any of them are open. If so, don’t do anything. Otherwise, proceed as normal. --- extension/packages/events.coffee | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/extension/packages/events.coffee b/extension/packages/events.coffee index c9163a4..2a74732 100644 --- a/extension/packages/events.coffee +++ b/extension/packages/events.coffee @@ -19,15 +19,6 @@ keyStrFromEvent = (event) -> return null -# Passthrough mode is activated when VimFx should temporarily stop processing keyboard input, for -# example when a menu is shown. -popupPassthrough = false -checkPassthrough = (event) -> - if event.target.nodeName in ['menupopup', 'panel'] - popupPassthrough = switch event.type - when 'popupshown' then true - when 'popuphidden' then false - suppress = false suppressEvent = (event) -> if suppress @@ -49,10 +40,13 @@ windowsListeners = # No matter what, always reset the `suppress` flag, so we don't suppress more than intended. suppress = false - # Suppress popup passthrough mode if there is no passthrough mode on the root document - return if popupPassthrough and !!utils.getEventRootWindow(event).document.popupNode return if getPref('disabled') + return unless rootWindow = utils.getEventRootWindow(event) + popups = rootWindow.document.querySelectorAll('menupopup, panel') + for popup in popups + return if popup.state == 'open' + return unless window = utils.getEventCurrentTabWindow(event) return unless vim = vimBucket.get(window) @@ -75,9 +69,6 @@ windowsListeners = keypress: suppressEvent keyup: suppressEvent - popupshown: checkPassthrough - popuphidden: checkPassthrough - # When the top level window closes we should release all Vims that were # associated with tabs in this window DOMWindowClose: (event) -> -- 2.39.3