From 67bf654d5763787bfbe263d9d4883f5f5b1a6b72 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Mon, 21 Apr 2014 18:20:30 +0200 Subject: [PATCH] Handle scrolled frame correctly --- qutebrowser/browser/hints.py | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 715156b8f..1e6879845 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -290,15 +290,20 @@ class HintManager(QObject): def fire(self, keystr): """Fire a completed hint.""" elem = self._elems[keystr].elem - logging.debug("Clicking on: {}".format(elem.toPlainText())) self.stop() + point = elem.geometry().topLeft() + scrollpos = self._frame.scrollPosition() + logging.debug("Clicking on \"{}\" at {}/{} - {}/{}".format( + elem.toPlainText(), point.x(), point.y(), scrollpos.x(), + scrollpos.y())) + point -= scrollpos events = [ - QMouseEvent(QEvent.MouseMove, elem.geometry().topLeft(), - Qt.NoButton, Qt.NoButton, Qt.NoModifier), - QMouseEvent(QEvent.MouseButtonPress, elem.geometry().topLeft(), - Qt.LeftButton, Qt.NoButton, Qt.NoModifier), - QMouseEvent(QEvent.MouseButtonRelease, elem.geometry().topLeft(), - Qt.LeftButton, Qt.NoButton, Qt.NoModifier), + QMouseEvent(QEvent.MouseMove, point, Qt.NoButton, Qt.NoButton, + Qt.NoModifier), + QMouseEvent(QEvent.MouseButtonPress, point, Qt.LeftButton, + Qt.NoButton, Qt.NoModifier), + QMouseEvent(QEvent.MouseButtonRelease, point, Qt.LeftButton, + Qt.NoButton, Qt.NoModifier), ] for evt in events: self.mouse_event.emit(evt)