diff --git a/qutebrowser/browser/browsertab.py b/qutebrowser/browser/browsertab.py index 0c86da8f9..66116b34c 100644 --- a/qutebrowser/browser/browsertab.py +++ b/qutebrowser/browser/browsertab.py @@ -23,7 +23,7 @@ import itertools from PyQt5.QtCore import pyqtSignal, pyqtSlot, QUrl, QObject, QSizeF from PyQt5.QtGui import QIcon -from PyQt5.QtWidgets import QWidget +from PyQt5.QtWidgets import QWidget, QApplication from qutebrowser.keyinput import modeman from qutebrowser.config import config @@ -562,9 +562,15 @@ class AbstractTab(QWidget): self._load_status = val self.load_status_changed.emit(val.name) + def _event_target(self): + """Return the widget events should be sent to.""" + raise NotImplementedError + def send_event(self, evt): """Send the given event to the underlying widget.""" - raise NotImplementedError + recipient = self._event_target() + QApplication.sendEvent(recipient, evt) + @pyqtSlot(QUrl) def _on_link_clicked(self, url): diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 99464468d..6ec26c3df 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -26,7 +26,6 @@ import functools from PyQt5.QtCore import pyqtSlot, Qt, QEvent, QPoint, QUrl from PyQt5.QtGui import QKeyEvent, QIcon -from PyQt5.QtWidgets import QApplication # pylint: disable=no-name-in-module,import-error,useless-suppression from PyQt5.QtWebEngineWidgets import QWebEnginePage, QWebEngineScript # pylint: enable=no-name-in-module,import-error,useless-suppression @@ -526,6 +525,5 @@ class WebEngineTab(browsertab.AbstractTab): except AttributeError: log.stub('contentsSizeChanged, on Qt < 5.7') - def send_event(self, evt): - recipient = self._widget.focusProxy() - QApplication.sendEvent(recipient, evt) + def _event_target(self): + return self._widget.focusProxy() diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py index 1d4d36a02..a8895f6e5 100644 --- a/qutebrowser/browser/webkit/webkittab.py +++ b/qutebrowser/browser/webkit/webkittab.py @@ -28,7 +28,6 @@ from PyQt5.QtCore import (pyqtSlot, Qt, QEvent, QUrl, QPoint, QTimer, QSizeF, from PyQt5.QtGui import QKeyEvent from PyQt5.QtWebKitWidgets import QWebPage, QWebFrame from PyQt5.QtWebKit import QWebSettings -from PyQt5.QtWidgets import QApplication from PyQt5.QtPrintSupport import QPrinter from qutebrowser.browser import browsertab @@ -696,5 +695,5 @@ class WebKitTab(browsertab.AbstractTab): frame.initialLayoutCompleted.connect(self._on_history_trigger) page.link_clicked.connect(self._on_link_clicked) - def send_event(self, evt): - QApplication.sendEvent(self._widget, evt) + def _event_target(self): + return self._widget