1
0
Fork 0
forked from wry/wry

Merge pull request #708 from khyperia/scroll-accumulator

Add scroll accumulator for seats below version 8
This commit is contained in:
mahkoh 2025-12-30 14:00:03 +01:00 committed by GitHub
commit 411af0ea18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 3 deletions

View file

@ -1459,7 +1459,11 @@ impl WlSeatGlobal {
if p.seat.version >= AXIS_VALUE120_SINCE_VERSION {
p.send_axis_value120(axis, delta);
} else if p.seat.version >= AXIS_DISCRETE_SINCE_VERSION {
p.send_axis_discrete(axis, delta / AXIS_120);
let mut accumulator = p.v120_accumulator[i].get();
accumulator += delta;
p.send_axis_discrete(axis, accumulator / AXIS_120);
accumulator %= AXIS_120;
p.v120_accumulator[i].set(accumulator);
}
}
if let Some(delta) = event.px[i].get() {
@ -1472,8 +1476,11 @@ impl WlSeatGlobal {
}
p.send_axis(time, axis, delta);
}
if p.seat.version >= AXIS_STOP_SINCE_VERSION && event.stop[i].get() {
p.send_axis_stop(time, axis);
if event.stop[i].get() {
if p.seat.version >= AXIS_STOP_SINCE_VERSION {
p.send_axis_stop(time, axis);
}
p.v120_accumulator[i].set(0);
}
}
if p.seat.version >= POINTER_FRAME_SINCE_VERSION {

View file

@ -74,6 +74,7 @@ pub struct WlPointer {
pub seat: Rc<WlSeat>,
pub tracker: Tracker<Self>,
last_motion: Cell<(Fixed, Fixed)>,
pub v120_accumulator: [Cell<i32>; 2],
}
impl WlPointer {
@ -83,11 +84,15 @@ impl WlPointer {
seat: seat.clone(),
tracker: Default::default(),
last_motion: Default::default(),
v120_accumulator: Default::default(),
}
}
pub fn send_enter(&self, serial: u64, surface: WlSurfaceId, mut x: Fixed, mut y: Fixed) {
self.last_motion.set((x, y));
for accumulator in &self.v120_accumulator {
accumulator.set(0);
}
logical_to_client_wire_scale!(self.seat.client, x, y);
self.seat.client.event(Enter {
self_id: self.id,