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

(cherry picked from commit 1d50c2c39a)
This commit is contained in:
Florian Bruhin 2017-10-06 08:51:48 +02:00
parent 38bccd4fdd
commit 3eaad092b8
2 changed files with 6 additions and 2 deletions

View File

@ -25,6 +25,9 @@ Fixes
- Fixed printing on macOS.
- Closing a pinned tab via mouse now also prompts for confirmation.
- 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

@ -345,9 +345,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)