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:
parent
329c4c0a84
commit
621713fe15
1 changed files with 23 additions and 10 deletions
|
|
@ -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
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue