Fix rapid hinting with QtWebEngine
There were actually two issues here: - The override_target was reset too early - now acceptNavigationRequest/createWindow is responsible for resetting it. - The QTBUG-54419 workaround opened any tabs in the background instead of preserving their position/focus. Fixes #2086.
This commit is contained in:
parent
5de07246be
commit
30827c1239
@ -365,10 +365,9 @@ class AbstractWebElement(collections.abc.MutableMapping):
|
|||||||
self._tab.send_event(evt)
|
self._tab.send_event(evt)
|
||||||
|
|
||||||
def after_click():
|
def after_click():
|
||||||
"""Move cursor to end and reset override_target after clicking."""
|
"""Move cursor to end after clicking."""
|
||||||
if self.is_text_input() and self.is_editable():
|
if self.is_text_input() and self.is_editable():
|
||||||
self._tab.caret.move_to_end_of_document()
|
self._tab.caret.move_to_end_of_document()
|
||||||
self._tab.data.override_target = None
|
|
||||||
QTimer.singleShot(0, after_click)
|
QTimer.singleShot(0, after_click)
|
||||||
|
|
||||||
def hover(self):
|
def hover(self):
|
||||||
|
@ -82,6 +82,7 @@ class WebEngineView(QWebEngineView):
|
|||||||
|
|
||||||
if override_target is not None:
|
if override_target is not None:
|
||||||
target = override_target
|
target = override_target
|
||||||
|
self._tabdata.override_target = None
|
||||||
elif wintype == QWebEnginePage.WebBrowserWindow:
|
elif wintype == QWebEnginePage.WebBrowserWindow:
|
||||||
log.webview.debug("createWindow with WebBrowserWindow - when does "
|
log.webview.debug("createWindow with WebBrowserWindow - when does "
|
||||||
"this happen?!")
|
"this happen?!")
|
||||||
|
@ -473,6 +473,7 @@ class BrowserPage(QWebPage):
|
|||||||
|
|
||||||
if self._tabdata.override_target is not None:
|
if self._tabdata.override_target is not None:
|
||||||
target = self._tabdata.override_target
|
target = self._tabdata.override_target
|
||||||
|
self._tabdata.override_target = None
|
||||||
else:
|
else:
|
||||||
target = self.open_target
|
target = self.open_target
|
||||||
|
|
||||||
|
@ -369,7 +369,10 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
"""
|
"""
|
||||||
if url is not None:
|
if url is not None:
|
||||||
qtutils.ensure_valid(url)
|
qtutils.ensure_valid(url)
|
||||||
log.webview.debug("Creating new tab with URL {}".format(url))
|
log.webview.debug("Creating new tab with URL {}, background {}, "
|
||||||
|
"explicit {}, idx {}".format(
|
||||||
|
url, background, explicit, idx))
|
||||||
|
|
||||||
if config.get('tabs', 'tabs-are-windows') and self.count() > 0:
|
if config.get('tabs', 'tabs-are-windows') and self.count() > 0:
|
||||||
from qutebrowser.mainwindow import mainwindow
|
from qutebrowser.mainwindow import mainwindow
|
||||||
window = mainwindow.MainWindow()
|
window = mainwindow.MainWindow()
|
||||||
@ -521,13 +524,15 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
|
|
||||||
# If needed, re-open the tab as a workaround for QTBUG-54419.
|
# If needed, re-open the tab as a workaround for QTBUG-54419.
|
||||||
# See https://bugreports.qt.io/browse/QTBUG-54419
|
# See https://bugreports.qt.io/browse/QTBUG-54419
|
||||||
|
background = self.currentIndex() != idx
|
||||||
|
|
||||||
if (tab.backend == usertypes.Backend.QtWebEngine and
|
if (tab.backend == usertypes.Backend.QtWebEngine and
|
||||||
tab.needs_qtbug54419_workaround):
|
tab.needs_qtbug54419_workaround):
|
||||||
log.misc.debug("Doing QTBUG-54419 workaround for {}, "
|
log.misc.debug("Doing QTBUG-54419 workaround for {}, "
|
||||||
"url {}".format(tab, url))
|
"url {}".format(tab, url))
|
||||||
self.setUpdatesEnabled(False)
|
self.setUpdatesEnabled(False)
|
||||||
try:
|
try:
|
||||||
self.tabopen(url)
|
self.tabopen(url, background=background, idx=idx)
|
||||||
self.close_tab(tab, add_undo=False)
|
self.close_tab(tab, add_undo=False)
|
||||||
finally:
|
finally:
|
||||||
self.setUpdatesEnabled(True)
|
self.setUpdatesEnabled(True)
|
||||||
|
@ -112,6 +112,18 @@ Feature: Using hints
|
|||||||
And I hint with args "links yank-primary" and follow a
|
And I hint with args "links yank-primary" and follow a
|
||||||
Then the clipboard should contain "http://localhost:(port)/data/hello.txt"
|
Then the clipboard should contain "http://localhost:(port)/data/hello.txt"
|
||||||
|
|
||||||
|
Scenario: Rapid hinting
|
||||||
|
When I open data/hints/rapid.html
|
||||||
|
And I run :tab-only
|
||||||
|
And I hint with args "all tab-bg --rapid"
|
||||||
|
And I run :follow-hint a
|
||||||
|
And I run :follow-hint s
|
||||||
|
And I run :leave-mode
|
||||||
|
Then the following tabs should be open:
|
||||||
|
- data/hints/rapid.html (active)
|
||||||
|
- data/hello.txt
|
||||||
|
- data/hello2.txt
|
||||||
|
|
||||||
Scenario: Using hint --rapid to hit multiple buttons
|
Scenario: Using hint --rapid to hit multiple buttons
|
||||||
When I open data/hints/buttons.html
|
When I open data/hints/buttons.html
|
||||||
And I hint with args "--rapid"
|
And I hint with args "--rapid"
|
||||||
|
Loading…
Reference in New Issue
Block a user