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...
This commit is contained in:
Ian Douglas Scott 2025-10-02 14:41:20 -07:00 • committed by Ashley Wulber
parent 329c4c0a84
commit 621713fe15
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820

View file

@ -147,9 +147,17 @@ impl PointerHandler for SctkState {
horizontal, horizontal,
vertical, vertical,
source, source,
} => WindowEvent::MouseWheel { } => {
device_id: Default::default(), let delta = if horizontal.value120 != 0
delta: if horizontal.discrete > 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( MouseScrollDelta::LineDelta(
-horizontal.discrete as f32, -horizontal.discrete as f32,
-vertical.discrete as f32, -vertical.discrete as f32,
@ -161,13 +169,18 @@ impl PointerHandler for SctkState {
-vertical.absolute, -vertical.absolute,
), ),
) )
}, };
phase: if horizontal.stop {
TouchPhase::Ended WindowEvent::MouseWheel {
} else { device_id: Default::default(),
TouchPhase::Moved delta,
}, phase: if horizontal.stop {
}, TouchPhase::Ended
} else {
TouchPhase::Moved
},
}
}
}, },
)); ));
} }