This commit zeroes the accumulated scroll distance on the window before invoking the
event delivery code, since the event delivery code is able to call back into the scroll
processing. Prior to this change, the callback could re-processing the scroll delta
while magnifying it by a factor of 10.
Fixes: https://todo.sr.ht/~eliasnaur/gio/599
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
---
app/os_wayland.go | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/app/os_wayland.go b/app/os_wayland.go
index 393f4c7f..24d1d874 100644
--- a/app/os_wayland.go
+++ b/app/os_wayland.go
@@ -1633,6 +1633,14 @@ func (w *window) flushScroll() {
if total == (f32.Point{}) {
return
}
+ if w.scroll.steps == (image.Point{}) {
+ w.fling.xExtrapolation.SampleDelta(w.scroll.time, -w.scroll.dist.X)
+ w.fling.yExtrapolation.SampleDelta(w.scroll.time, -w.scroll.dist.Y)
+ }
+ // Zero scroll distance prior to calling ProcessEvent, otherwise we may recursively
+ // re-process the scroll distance.
+ w.scroll.dist = f32.Point{}
+ w.scroll.steps = image.Point{}
w.ProcessEvent(pointer.Event{
Kind: pointer.Scroll,
Source: pointer.Mouse,
@@ -1642,12 +1650,6 @@ func (w *window) flushScroll() {
Time: w.scroll.time,
Modifiers: w.disp.xkb.Modifiers(),
})
- if w.scroll.steps == (image.Point{}) {
- w.fling.xExtrapolation.SampleDelta(w.scroll.time, -w.scroll.dist.X)
- w.fling.yExtrapolation.SampleDelta(w.scroll.time, -w.scroll.dist.Y)
- }
- w.scroll.dist = f32.Point{}
- w.scroll.steps = image.Point{}
}
func (w *window) onPointerMotion(x, y C.wl_fixed_t, t C.uint32_t) {
--
2.45.2