From 306eff2f94a665b4e41ea4dd5604a604283f8dba Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 13 Jun 2020 00:19:01 +0200 Subject: [PATCH] Improve lost focusproxy handling Disable the workaround if not on Qt 5.11, don't log if nothing was found, and clean up the code a bit. --- qutebrowser/browser/webengine/webview.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/qutebrowser/browser/webengine/webview.py b/qutebrowser/browser/webengine/webview.py index 2b197323b..be507c8b6 100644 --- a/qutebrowser/browser/webengine/webview.py +++ b/qutebrowser/browser/webengine/webview.py @@ -66,20 +66,26 @@ class WebEngineView(QWebEngineView): However, it sometimes isn't, so we use this as a WORKAROUND for https://bugreports.qt.io/browse/QTBUG-68727 - This got introduced in Qt 5.11.0 and fixed in 5.12.0. + The above bug got introduced in Qt 5.11.0 and fixed in 5.12.0. """ - if 'lost-focusproxy' not in objects.debug_flags: - proxy = self.focusProxy() - if proxy is not None: - return proxy + proxy = self.focusProxy() + + if 'lost-focusproxy' in objects.debug_flags: + proxy = None + + if (proxy is not None or + not qtutils.version_check('5.11', compiled=False) or + qtutils.version_check('5.12', compiled=False)): + return proxy # We don't want e.g. a QMenu. rwhv_class = 'QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget' children = [c for c in self.findChildren(QWidget) if c.isVisible() and c.inherits(rwhv_class)] - log.webview.debug("Found possibly lost focusProxy: {}" - .format(children)) + if children: + log.webview.debug("Found possibly lost focusProxy: {}" + .format(children)) return children[-1] if children else None