Reimplement wheelEvent of WebView to fix scrolling
Hiding scrollbars in 1bfbdd79e4
broke
scrolling because the WebKit implementation wants a scrollbar to do
scrolling.
We fix this by just handling the mouse wheel ourselves.
This commit is contained in:
parent
2c2c79af2e
commit
5c4ce7ae09
@ -277,6 +277,10 @@ DATA = OrderedDict([
|
|||||||
('forward-unbound-keys',
|
('forward-unbound-keys',
|
||||||
SettingValue(types.Bool(), 'false'),
|
SettingValue(types.Bool(), 'false'),
|
||||||
"Whether to forward unbound keys to the website in normal mode."),
|
"Whether to forward unbound keys to the website in normal mode."),
|
||||||
|
|
||||||
|
('scroll-amount',
|
||||||
|
SettingValue(types.Float(minval=0), '0.5'),
|
||||||
|
"How many pixels to scroll per 1/8 degree mousewheel delta."),
|
||||||
)),
|
)),
|
||||||
|
|
||||||
('tabbar', sect.KeyValue(
|
('tabbar', sect.KeyValue(
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import functools
|
import functools
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt
|
from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QPoint
|
||||||
from PyQt5.QtWidgets import QApplication
|
from PyQt5.QtWidgets import QApplication
|
||||||
from PyQt5.QtWebKit import QWebSettings
|
from PyQt5.QtWebKit import QWebSettings
|
||||||
from PyQt5.QtWebKitWidgets import QWebView, QWebPage
|
from PyQt5.QtWebKitWidgets import QWebView, QWebPage
|
||||||
@ -526,3 +526,17 @@ class WebView(QWebView):
|
|||||||
self._mousepress_insertmode(e)
|
self._mousepress_insertmode(e)
|
||||||
self._mousepress_opentarget(e)
|
self._mousepress_opentarget(e)
|
||||||
return super().mousePressEvent(e)
|
return super().mousePressEvent(e)
|
||||||
|
|
||||||
|
def wheelEvent(self, e):
|
||||||
|
"""Override wheelEvent because we handle scrolling ourselves.
|
||||||
|
|
||||||
|
WebKit's scrolling doesn't allow us to scroll while scrollbars are
|
||||||
|
enabled...
|
||||||
|
"""
|
||||||
|
if not e.pixelDelta().isNull():
|
||||||
|
delta = QPoint(e.pixelDelta())
|
||||||
|
else:
|
||||||
|
delta = e.angleDelta() * config.get('input', 'scroll-amount')
|
||||||
|
frame = self.page_.currentFrame()
|
||||||
|
pos = frame.scrollPosition() - delta
|
||||||
|
frame.setScrollPosition(pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user