~eliasnaur/gio-patches

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH gio] app: [Wayland] prevent recursive scroll event processing

Details
Message ID
<20240708141905.2243976-1-christopher.waldon.dev@gmail.com>
DKIM signature
pass
Download raw message
Patch: +8 -6
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

[gio/patches] build success

builds.sr.ht <builds@sr.ht>
Details
Message ID
<D2K8A0WYZCJB.1FI40AL2LS2CD@fra02>
In-Reply-To
<20240708141905.2243976-1-christopher.waldon.dev@gmail.com> (view parent)
DKIM signature
missing
Download raw message
gio/patches: SUCCESS in 10m51s

[app: [Wayland] prevent recursive scroll event processing][0] from [Chris Waldon][1]

[0]: https://lists.sr.ht/~eliasnaur/gio-patches/patches/53753
[1]: christopher.waldon.dev@gmail.com

✓ #1271080 SUCCESS gio/patches/freebsd.yml https://builds.sr.ht/~eliasnaur/job/1271080
✓ #1271079 SUCCESS gio/patches/apple.yml   https://builds.sr.ht/~eliasnaur/job/1271079
✓ #1271082 SUCCESS gio/patches/openbsd.yml https://builds.sr.ht/~eliasnaur/job/1271082
✓ #1271081 SUCCESS gio/patches/linux.yml   https://builds.sr.ht/~eliasnaur/job/1271081
Reply to thread Export thread (mbox)