From 621713fe151d9e6d2ebc783ceba10c24da02e00e Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 2 Oct 2025 14:41:20 -0700 Subject: [PATCH] wayland: Fix handling of discrete/value120 scroll events - Should test `!= 0`, not `> 0`; can scroll in either direction - Test both vertical and horizontal - Use `value120` scroll if present (in which case, discrete is 0) I guess events should really have both line and pixel scroll, since some widgets want to use the pixel scroll values for input devices that have both? But I guess winit and Iced both need to be changed for that... --- .../wayland/handlers/seat/pointer.rs | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/winit/src/platform_specific/wayland/handlers/seat/pointer.rs b/winit/src/platform_specific/wayland/handlers/seat/pointer.rs index 6f3babca..b11e8092 100644 --- a/winit/src/platform_specific/wayland/handlers/seat/pointer.rs +++ b/winit/src/platform_specific/wayland/handlers/seat/pointer.rs @@ -147,9 +147,17 @@ impl PointerHandler for SctkState { horizontal, vertical, source, - } => WindowEvent::MouseWheel { - device_id: Default::default(), - delta: if horizontal.discrete > 0 { + } => { + let delta = if horizontal.value120 != 0 + || vertical.value120 != 0 + { + MouseScrollDelta::LineDelta( + -horizontal.value120 as f32 / 120., + -vertical.value120 as f32 / 120., + ) + } else if horizontal.discrete != 0 + || vertical.discrete != 0 + { MouseScrollDelta::LineDelta( -horizontal.discrete as f32, -vertical.discrete as f32, @@ -161,13 +169,18 @@ impl PointerHandler for SctkState { -vertical.absolute, ), ) - }, - phase: if horizontal.stop { - TouchPhase::Ended - } else { - TouchPhase::Moved - }, - }, + }; + + WindowEvent::MouseWheel { + device_id: Default::default(), + delta, + phase: if horizontal.stop { + TouchPhase::Ended + } else { + TouchPhase::Moved + }, + } + } }, )); }