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

@ -21,6 +21,7 @@ use {
},
},
},
linearize::LinearizeExt,
std::{cell::Cell, rc::Rc},
thiserror::Error,
};
@ -204,7 +205,7 @@ impl EiDeviceRequestHandler for EiDevice {
}
{
let mut need_frame = false;
for axis in [ScrollAxis::Horizontal, ScrollAxis::Vertical] {
for axis in ScrollAxis::variants() {
let idx = axis as usize;
if let Some(v120) = self.scroll_v120[idx].take() {
need_frame = true;

View file

@ -66,8 +66,8 @@ impl EiScrollRequestHandler for EiScroll {
}
fn client_scroll(&self, req: ClientScroll, _slf: &Rc<Self>) -> Result<(), Self::Error> {
self.device.scroll_px[HORIZONTAL_SCROLL as usize].set(Some(req.x));
self.device.scroll_px[VERTICAL_SCROLL as usize].set(Some(req.y));
self.device.scroll_px[HORIZONTAL_SCROLL].set(Some(req.x));
self.device.scroll_px[VERTICAL_SCROLL].set(Some(req.y));
Ok(())
}
@ -76,8 +76,8 @@ impl EiScrollRequestHandler for EiScroll {
req: ClientScrollDiscrete,
_slf: &Rc<Self>,
) -> Result<(), Self::Error> {
self.device.scroll_v120[HORIZONTAL_SCROLL as usize].set(Some(req.x));
self.device.scroll_v120[VERTICAL_SCROLL as usize].set(Some(req.y));
self.device.scroll_v120[HORIZONTAL_SCROLL].set(Some(req.x));
self.device.scroll_v120[VERTICAL_SCROLL].set(Some(req.y));
Ok(())
}
@ -86,8 +86,8 @@ impl EiScrollRequestHandler for EiScroll {
req: ClientScrollStop,
_slf: &Rc<Self>,
) -> Result<(), Self::Error> {
self.device.scroll_stop[HORIZONTAL_SCROLL as usize].set(Some(req.x != 0));
self.device.scroll_stop[VERTICAL_SCROLL as usize].set(Some(req.y != 0));
self.device.scroll_stop[HORIZONTAL_SCROLL].set(Some(req.x != 0));
self.device.scroll_stop[VERTICAL_SCROLL].set(Some(req.y != 0));
Ok(())
}
}

View file

@ -166,18 +166,16 @@ impl EiSeat {
}
if let Some(b) = self.scroll.get() {
b.send_scroll(
ps.px[HORIZONTAL_SCROLL as usize].get().unwrap_or_default(),
ps.px[VERTICAL_SCROLL as usize].get().unwrap_or_default(),
ps.px[HORIZONTAL_SCROLL].get().unwrap_or_default(),
ps.px[VERTICAL_SCROLL].get().unwrap_or_default(),
);
b.send_scroll_discrete(
ps.v120[HORIZONTAL_SCROLL as usize]
.get()
.unwrap_or_default(),
ps.v120[VERTICAL_SCROLL as usize].get().unwrap_or_default(),
ps.v120[HORIZONTAL_SCROLL].get().unwrap_or_default(),
ps.v120[VERTICAL_SCROLL].get().unwrap_or_default(),
);
b.send_scroll_stop(
ps.stop[HORIZONTAL_SCROLL as usize].get(),
ps.stop[VERTICAL_SCROLL as usize].get(),
ps.stop[HORIZONTAL_SCROLL].get(),
ps.stop[VERTICAL_SCROLL].get(),
);
b.device.send_frame(self.client.serial(), time_usec);
}