input: rename axix_smooth to axis_px
This commit is contained in:
parent
64416d417b
commit
20f0fba553
7 changed files with 18 additions and 21 deletions
|
|
@ -176,7 +176,7 @@ pub enum InputEvent {
|
||||||
state: KeyState,
|
state: KeyState,
|
||||||
},
|
},
|
||||||
|
|
||||||
AxisSmooth {
|
AxisPx {
|
||||||
dist: Fixed,
|
dist: Fixed,
|
||||||
axis: ScrollAxis,
|
axis: ScrollAxis,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,7 @@ impl MetalBackend {
|
||||||
axis,
|
axis,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
InputEvent::AxisSmooth {
|
InputEvent::AxisPx {
|
||||||
dist: Fixed::from_f64(scroll),
|
dist: Fixed::from_f64(scroll),
|
||||||
axis,
|
axis,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,7 @@ impl WlSeatGlobal {
|
||||||
|
|
||||||
InputEvent::AxisSource { source } => self.pointer_owner.axis_source(source),
|
InputEvent::AxisSource { source } => self.pointer_owner.axis_source(source),
|
||||||
InputEvent::Axis120 { dist, axis } => self.pointer_owner.axis_120(dist, axis),
|
InputEvent::Axis120 { dist, axis } => self.pointer_owner.axis_120(dist, axis),
|
||||||
InputEvent::AxisSmooth { dist, axis } => self.pointer_owner.axis_smooth(dist, axis),
|
InputEvent::AxisPx { dist, axis } => self.pointer_owner.axis_px(dist, axis),
|
||||||
InputEvent::AxisStop { axis } => self.pointer_owner.axis_stop(axis),
|
InputEvent::AxisStop { axis } => self.pointer_owner.axis_stop(axis),
|
||||||
InputEvent::AxisFrame { time_usec } => self.pointer_owner.frame(dev, self, time_usec),
|
InputEvent::AxisFrame { time_usec } => self.pointer_owner.frame(dev, self, time_usec),
|
||||||
}
|
}
|
||||||
|
|
@ -564,7 +564,7 @@ impl WlSeatGlobal {
|
||||||
}
|
}
|
||||||
let px = (delta as f64 / AXIS_120 as f64) * dev.px_per_scroll_wheel.get();
|
let px = (delta as f64 / AXIS_120 as f64) * dev.px_per_scroll_wheel.get();
|
||||||
p.send_axis(time, axis, Fixed::from_f64(px));
|
p.send_axis(time, axis, Fixed::from_f64(px));
|
||||||
} else if let Some(delta) = event.smooth[i].get() {
|
} else if let Some(delta) = event.px[i].get() {
|
||||||
p.send_axis(time, axis, delta);
|
p.send_axis(time, axis, delta);
|
||||||
}
|
}
|
||||||
if p.seat.version >= AXIS_STOP_SINCE_VERSION && event.stop[i].get() {
|
if p.seat.version >= AXIS_STOP_SINCE_VERSION && event.stop[i].get() {
|
||||||
|
|
|
||||||
|
|
@ -44,8 +44,8 @@ impl PointerOwnerHolder {
|
||||||
self.pending_scroll.v120[axis as usize].set(Some(delta));
|
self.pending_scroll.v120[axis as usize].set(Some(delta));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn axis_smooth(&self, delta: Fixed, axis: ScrollAxis) {
|
pub fn axis_px(&self, delta: Fixed, axis: ScrollAxis) {
|
||||||
self.pending_scroll.smooth[axis as usize].set(Some(delta));
|
self.pending_scroll.px[axis as usize].set(Some(delta));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn axis_stop(&self, axis: ScrollAxis) {
|
pub fn axis_stop(&self, axis: ScrollAxis) {
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ pub const AXIS_VALUE120_SINCE_VERSION: u32 = 8;
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
pub struct PendingScroll {
|
pub struct PendingScroll {
|
||||||
pub v120: [Cell<Option<i32>>; 2],
|
pub v120: [Cell<Option<i32>>; 2],
|
||||||
pub smooth: [Cell<Option<Fixed>>; 2],
|
pub px: [Cell<Option<Fixed>>; 2],
|
||||||
pub stop: [Cell<bool>; 2],
|
pub stop: [Cell<bool>; 2],
|
||||||
pub source: Cell<Option<u32>>,
|
pub source: Cell<Option<u32>>,
|
||||||
pub time_usec: Cell<u64>,
|
pub time_usec: Cell<u64>,
|
||||||
|
|
@ -51,10 +51,7 @@ impl PendingScroll {
|
||||||
Cell::new(self.v120[0].take()),
|
Cell::new(self.v120[0].take()),
|
||||||
Cell::new(self.v120[1].take()),
|
Cell::new(self.v120[1].take()),
|
||||||
],
|
],
|
||||||
smooth: [
|
px: [Cell::new(self.px[0].take()), Cell::new(self.px[1].take())],
|
||||||
Cell::new(self.smooth[0].take()),
|
|
||||||
Cell::new(self.smooth[1].take()),
|
|
||||||
],
|
|
||||||
stop: [
|
stop: [
|
||||||
Cell::new(self.stop[0].take()),
|
Cell::new(self.stop[0].take()),
|
||||||
Cell::new(self.stop[1].take()),
|
Cell::new(self.stop[1].take()),
|
||||||
|
|
|
||||||
|
|
@ -318,9 +318,9 @@ impl TestBackendMouse {
|
||||||
|
|
||||||
pub fn scroll_px(&self, dy: i32) {
|
pub fn scroll_px(&self, dy: i32) {
|
||||||
self.common.event(InputEvent::AxisSource {
|
self.common.event(InputEvent::AxisSource {
|
||||||
source: AxisSource::Wheel,
|
source: AxisSource::Finger,
|
||||||
});
|
});
|
||||||
self.common.event(InputEvent::AxisSmooth {
|
self.common.event(InputEvent::AxisPx {
|
||||||
dist: Fixed::from_int(dy),
|
dist: Fixed::from_int(dy),
|
||||||
axis: ScrollAxis::Vertical,
|
axis: ScrollAxis::Vertical,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -12,31 +12,31 @@ use {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Scroller {
|
pub struct Scroller {
|
||||||
v120: Cell<i32>,
|
v120: Cell<i32>,
|
||||||
smooth: Cell<f64>,
|
px: Cell<f64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Scroller {
|
impl Scroller {
|
||||||
pub fn handle(&self, scroll: &PendingScroll) -> Option<i32> {
|
pub fn handle(&self, scroll: &PendingScroll) -> Option<i32> {
|
||||||
let n = if let Some(d) = scroll.v120[VERTICAL_SCROLL as usize].get() {
|
let n = if let Some(d) = scroll.v120[VERTICAL_SCROLL as usize].get() {
|
||||||
self.smooth.set(0.0);
|
self.px.set(0.0);
|
||||||
let mut v120 = self.v120.get() + d;
|
let mut v120 = self.v120.get() + d;
|
||||||
let discrete = v120 / AXIS_120;
|
let discrete = v120 / AXIS_120;
|
||||||
v120 -= discrete * AXIS_120;
|
v120 -= discrete * AXIS_120;
|
||||||
self.v120.set(v120);
|
self.v120.set(v120);
|
||||||
discrete
|
discrete
|
||||||
} else if let Some(smooth) = scroll.smooth[VERTICAL_SCROLL as usize].get() {
|
} else if let Some(px) = scroll.px[VERTICAL_SCROLL as usize].get() {
|
||||||
self.v120.set(0);
|
self.v120.set(0);
|
||||||
let mut smooth = self.smooth.get() + smooth.to_f64();
|
let mut px = self.px.get() + px.to_f64();
|
||||||
let discrete = (smooth / PX_PER_SCROLL).trunc();
|
let discrete = (px / PX_PER_SCROLL).trunc();
|
||||||
smooth -= discrete * PX_PER_SCROLL;
|
px -= discrete * PX_PER_SCROLL;
|
||||||
self.smooth.set(smooth);
|
self.px.set(px);
|
||||||
discrete as _
|
discrete as _
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
if scroll.stop[VERTICAL_SCROLL as usize].get() {
|
if scroll.stop[VERTICAL_SCROLL as usize].get() {
|
||||||
self.v120.set(0);
|
self.v120.set(0);
|
||||||
self.smooth.set(0.0);
|
self.px.set(0.0);
|
||||||
}
|
}
|
||||||
if n != 0 {
|
if n != 0 {
|
||||||
Some(n)
|
Some(n)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue