diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index 2a9662eef..4d4f6380a 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -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): diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index fb04dc120..f0e2b85b6 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -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) diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py index 9d5305f10..352372ba4 100644 --- a/qutebrowser/browser/webkit/webkittab.py +++ b/qutebrowser/browser/webkit/webkittab.py @@ -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() diff --git a/qutebrowser/mainwindow/tabbedbrowser.py b/qutebrowser/mainwindow/tabbedbrowser.py index c473f914d..0f9efc014 100644 --- a/qutebrowser/mainwindow/tabbedbrowser.py +++ b/qutebrowser/mainwindow/tabbedbrowser.py @@ -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