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