From 21c1dec59a1b95e9c9172e5e886637828b9d0bef Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 28 Jul 2016 14:56:42 +0200 Subject: [PATCH] Actually handle contents_size_changed correctly --- qutebrowser/browser/hints.py | 5 +++-- qutebrowser/browser/webkit/webkittab.py | 9 ++++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index d59267c92..e1e57d02e 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -811,6 +811,7 @@ class HintManager(QObject): self._context.args = args self._context.group = group self._init_elements() + tab.contents_size_changed.connect(self.on_contents_size_changed) message_bridge = objreg.get('message-bridge', scope='window', window=self._win_id) message_bridge.set_text(self._get_text()) @@ -1010,8 +1011,8 @@ class HintManager(QObject): raise cmdexc.CommandError("No hint {}!".format(keystring)) self.fire(keystring, force=True) - @pyqtSlot('QSize') - def on_contents_size_changed(self, _size): + @pyqtSlot() + def on_contents_size_changed(self): """Reposition hints if contents size changed.""" log.hints.debug("Contents size changed...!") for e in self._context.all_elems: diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py index 15c670567..be69c94ba 100644 --- a/qutebrowser/browser/webkit/webkittab.py +++ b/qutebrowser/browser/webkit/webkittab.py @@ -23,7 +23,8 @@ import sys import functools import xml.etree.ElementTree -from PyQt5.QtCore import pyqtSlot, Qt, QEvent, QUrl, QPoint, QTimer +from PyQt5.QtCore import (pyqtSlot, Qt, QEvent, QUrl, QPoint, QTimer, QSizeF, + QSize) from PyQt5.QtGui import QKeyEvent from PyQt5.QtWebKitWidgets import QWebPage, QWebFrame from PyQt5.QtWebKit import QWebSettings @@ -596,6 +597,10 @@ class WebKitTab(browsertab.AbstractTab): # https://github.com/The-Compiler/qutebrowser/issues/263 frame.contentsSizeChanged.connect(self.contents_size_changed) + @pyqtSlot(QSize) + def _on_contents_size_changed(self, size): + self.contents_size_changed.emit(QSizeF(size)) + def _connect_signals(self): view = self._widget page = view.page() @@ -611,3 +616,5 @@ class WebKitTab(browsertab.AbstractTab): page.networkAccessManager().sslErrors.connect(self._on_ssl_errors) frame.loadFinished.connect(self._on_frame_load_finished) view.iconChanged.connect(self._on_webkit_icon_changed) + page.frameCreated.connect(self._on_frame_created) + frame.contentsSizeChanged.connect(self._on_contents_size_changed)