1
0
Fork 0
forked from wry/wry

all: make scroll axis handling more robust

This commit is contained in:
Julian Orth 2025-03-20 21:09:16 +01:00
parent bb569dfa00
commit 7305f68909
10 changed files with 38 additions and 33 deletions

View file

@ -1,6 +1,6 @@
use {
crate::{
backend::{InputDeviceId, KeyState},
backend::{InputDeviceId, KeyState, ScrollAxis},
client::Client,
fixed::Fixed,
ifs::wl_seat::{
@ -15,6 +15,7 @@ use {
object::{Object, Version},
wire::{JaySeatEventsId, jay_seat_events::*},
},
linearize::LinearizeExt,
std::{convert::Infallible, rc::Rc},
};
@ -95,7 +96,8 @@ impl JaySeatEvents {
source,
});
}
for axis in 0..1 {
for axis in ScrollAxis::variants() {
let axis = axis as usize;
if let Some(dist) = ps.v120[axis].get() {
self.client.event(Axis120 {
self_id: self.id,

View file

@ -54,6 +54,7 @@ use {
},
},
kbvm::{ModifierMask, state_machine::Event},
linearize::LinearizeExt,
smallvec::SmallVec,
std::{cell::RefCell, collections::hash_map::Entry, mem, rc::Rc},
};
@ -1173,7 +1174,8 @@ impl WlSeatGlobal {
}
let time = (event.time_usec.get() / 1000) as _;
self.for_each_pointer(Version::ALL, surface.client.id, |p| {
for i in 0..1 {
for i in ScrollAxis::variants() {
let i = i as usize;
let axis = i as _;
if let Some(delta) = event.v120[i].get() {
if p.seat.version >= AXIS_VALUE120_SINCE_VERSION {

View file

@ -21,6 +21,7 @@ use {
},
utils::{clonecell::CloneCell, smallmap::SmallMap},
},
linearize::LinearizeExt,
std::{
cell::Cell,
rc::{Rc, Weak},
@ -80,7 +81,8 @@ impl PointerOwnerHolder {
pub fn frame(&self, px_per_scroll_wheel: f64, seat: &Rc<WlSeatGlobal>, time_usec: u64) {
self.pending_scroll.time_usec.set(time_usec);
let pending = self.pending_scroll.take();
for axis in 0..2 {
for axis in ScrollAxis::variants() {
let axis = axis as usize;
if let Some(dist) = pending.v120[axis].get() {
let px = (dist as f64 / AXIS_120 as f64) * px_per_scroll_wheel;
pending.px[axis].set(Some(Fixed::from_f64(px)));

View file

@ -18,8 +18,8 @@ const ROLE: u32 = 0;
pub(super) const RELEASED: u32 = 0;
pub const PRESSED: u32 = 1;
pub const VERTICAL_SCROLL: u32 = 0;
pub const HORIZONTAL_SCROLL: u32 = 1;
pub const VERTICAL_SCROLL: usize = 0;
pub const HORIZONTAL_SCROLL: usize = 1;
pub const WHEEL: u32 = 0;
pub const FINGER: u32 = 1;