Only apply workaround for QTBUG-68076 on non-background tabs

Previously, we would focus webviews even if they were in the
background to work around https://bugreports.qt.io/browse/QTBUG-68076.
This adjusts that to only occur when needed.
This commit is contained in:
Jay Kamat 2018-05-16 12:45:01 -07:00
parent 71d55e9213
commit 77c8575a88
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5
4 changed files with 18 additions and 13 deletions

View File

@ -847,7 +847,14 @@ class AbstractTab(QWidget):
if predict:
self.predicted_navigation.emit(url)
def openurl(self, url, *, predict=True):
def openurl(self, url, *, predict=True, background=False):
"""Open the given URL in this tab.
Arguments:
url: The QUrl to open.
predict: If set to False, predicted_navigation is not emitted.
background: Whether the tab is being opened in the background.
"""
raise NotImplementedError
def reload(self, *, force=False):

View File

@ -782,15 +782,10 @@ class WebEngineTab(browsertab.AbstractTab):
self.zoom.set_factor(self._saved_zoom)
self._saved_zoom = None
def openurl(self, url, *, predict=True):
"""Open the given URL in this tab.
Arguments:
url: The QUrl to open.
predict: If set to False, predicted_navigation is not emitted.
"""
def openurl(self, url, *, predict=True, background=False):
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-68076
self._widget.setFocus()
if not background:
self._widget.setFocus()
self._saved_zoom = self.zoom.factor()
self._openurl_prepare(url, predict=predict)
self._widget.load(url)

View File

@ -673,9 +673,11 @@ class WebKitTab(browsertab.AbstractTab):
settings = widget.settings()
settings.setAttribute(QWebSettings.PrivateBrowsingEnabled, True)
def openurl(self, url, *, predict=True):
# pylint: disable=unused-argument
def openurl(self, url, *, predict=True, background=False):
self._openurl_prepare(url, predict=predict)
self._widget.openurl(url)
# pylint: enable=unused-argument
def url(self, requested=False):
frame = self._widget.page().mainFrame()

View File

@ -477,11 +477,12 @@ class TabbedBrowser(QWidget):
idx = self._get_new_tab_idx(related)
self.widget.insertTab(idx, tab, "")
if url is not None:
tab.openurl(url)
if background is None:
background = config.val.tabs.background
if url is not None:
tab.openurl(url, background=background)
if background:
# Make sure the background tab has the correct initial size.
# With a foreground tab, it's going to be resized correctly by the