Only emit perc_changed signal when the percentage actually changed

QtWebEngine emits scrollPositionChanged a lot during smooth scrolling, and
there's no reason we need to update percentages when they didn't *actually*
change.

This reduces the updates with a single spacebar press from 6-7 to 2-3 on my
machine, which might not be enough though.

See #2233
This commit is contained in:
Florian Bruhin 2017-10-06 08:51:48 +02:00
parent e1d358f4c1
commit 1d50c2c39a
2 changed files with 4 additions and 2 deletions

View File

@ -106,6 +106,7 @@ Fixes
- The "try again" button on error pages works correctly again.
- :spawn -u -d is now disallowed.
- :spawn -d shows error messages correctly now.
- Performance improvements for smooth scrolling
v0.11.0
-------

View File

@ -333,9 +333,10 @@ class WebEngineScroller(browsertab.AbstractScroller):
perc_y = min(100, round(100 / dy * jsret['px']['y']))
self._at_bottom = math.ceil(jsret['px']['y']) >= dy
self._pos_perc = perc_x, perc_y
self.perc_changed.emit(*self._pos_perc)
if self._pos_perc != (perc_x, perc_y):
self._pos_perc = perc_x, perc_y
self.perc_changed.emit(*self._pos_perc)
js_code = javascript.assemble('scroll', 'pos')
self._tab.run_js_async(js_code, update_pos_cb)