From cee88cd7ca0a630d79beeca0ed98b9d3b4aeb59e Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 6 Jun 2018 13:06:50 +0200 Subject: [PATCH] Initial proof of concept for pseudo layout Fixes #3920 - hopefully properly this time... --- qutebrowser/browser/webengine/webenginetab.py | 22 ------------------- qutebrowser/browser/webengine/webview.py | 10 +++++++++ qutebrowser/misc/miscwidgets.py | 16 ++++++++++++++ 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 4ce8b8bdd..ca053563a 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -1057,28 +1057,6 @@ class WebEngineTab(browsertab.AbstractTab): def _on_navigation_request(self, navigation): super()._on_navigation_request(navigation) - if qtutils.version_check('5.11.0', exact=True, compiled=False): - # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-68224 - layout = self._widget.layout() - count = layout.count() - children = self._widget.findChildren(QWidget) - if not count and children: - log.webview.warning("Found children not in layout: {}, " - "focus proxy {} (QTBUG-68224)".format( - children, self._widget.focusProxy())) - if count > 1: - log.webview.debug("Found {} widgets! (QTBUG-68224)" - .format(count)) - for i in range(count): - item = layout.itemAt(i) - if item is None: - continue - widget = item.widget() - if widget is not self._widget.focusProxy(): - log.webview.debug("Removing widget {} (QTBUG-68224)" - .format(widget)) - layout.removeWidget(widget) - if not navigation.accepted or not navigation.is_main_frame: return diff --git a/qutebrowser/browser/webengine/webview.py b/qutebrowser/browser/webengine/webview.py index 70cd11e0d..f597e960c 100644 --- a/qutebrowser/browser/webengine/webview.py +++ b/qutebrowser/browser/webengine/webview.py @@ -21,6 +21,7 @@ import functools +import sip from PyQt5.QtCore import pyqtSignal, pyqtSlot, QUrl, PYQT_VERSION from PyQt5.QtGui import QPalette from PyQt5.QtWebEngineWidgets import (QWebEngineView, QWebEnginePage, @@ -30,6 +31,7 @@ from qutebrowser.browser import shared from qutebrowser.browser.webengine import certificateerror, webenginesettings from qutebrowser.config import config from qutebrowser.utils import log, debug, usertypes, jinja, objreg, qtutils +from qutebrowser.misc import miscwidgets class WebEngineView(QWebEngineView): @@ -51,9 +53,17 @@ class WebEngineView(QWebEngineView): parent=self) self.setPage(page) + sip.delete(self.layout()) + self._layout = miscwidgets.PseudoLayout(self) + def shutdown(self): self.page().shutdown() + def resizeEvent(self, _event): + proxy = self.focusProxy() + if proxy: + proxy.setGeometry(self.rect()) + def createWindow(self, wintype): """Called by Qt when a page wants to create a new window. diff --git a/qutebrowser/misc/miscwidgets.py b/qutebrowser/misc/miscwidgets.py index ffdfc951a..908ea6235 100644 --- a/qutebrowser/misc/miscwidgets.py +++ b/qutebrowser/misc/miscwidgets.py @@ -266,6 +266,22 @@ class WrapperLayout(QLayout): self._widget.deleteLater() +class PseudoLayout(QLayout): + + def addItem(self, item): + assert self.parent() is not None + item.widget().setParent(self.parent()) + + def removeItem(self, item): + item.widget().setParent(None) + + def count(self): + return 0 + + def itemAt(self, _pos): + return None + + class FullscreenNotification(QLabel): """A label telling the user this page is now fullscreen."""