Merge pull request #406 from tadeokondrak/ei-scroll-axes
ei: Fix flipped scroll axes
This commit is contained in:
commit
47e1ae41fc
10 changed files with 48 additions and 32 deletions
|
|
@ -280,7 +280,7 @@ pub enum KeyState {
|
||||||
Pressed,
|
Pressed,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq, Linearize)]
|
||||||
pub enum ScrollAxis {
|
pub enum ScrollAxis {
|
||||||
Horizontal = HORIZONTAL_SCROLL as _,
|
Horizontal = HORIZONTAL_SCROLL as _,
|
||||||
Vertical = VERTICAL_SCROLL as _,
|
Vertical = VERTICAL_SCROLL as _,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,9 @@ use {
|
||||||
crate::{
|
crate::{
|
||||||
cli::{GlobalArgs, SeatTestArgs},
|
cli::{GlobalArgs, SeatTestArgs},
|
||||||
fixed::Fixed,
|
fixed::Fixed,
|
||||||
ifs::wl_seat::wl_pointer::{CONTINUOUS, FINGER, PendingScroll, WHEEL},
|
ifs::wl_seat::wl_pointer::{
|
||||||
|
CONTINUOUS, FINGER, HORIZONTAL_SCROLL, PendingScroll, VERTICAL_SCROLL, WHEEL,
|
||||||
|
},
|
||||||
tools::tool_client::{Handle, ToolClient, with_tool_client},
|
tools::tool_client::{Handle, ToolClient, with_tool_client},
|
||||||
wire::{
|
wire::{
|
||||||
jay_compositor::{GetSeats, Seat, SeatEvents},
|
jay_compositor::{GetSeats, Seat, SeatEvents},
|
||||||
|
|
@ -188,14 +190,14 @@ async fn run(seat_test: Rc<SeatTest>) {
|
||||||
let st = seat_test.clone();
|
let st = seat_test.clone();
|
||||||
AxisFrame::handle(tc, se, ps.clone(), move |ps, ev| {
|
AxisFrame::handle(tc, se, ps.clone(), move |ps, ev| {
|
||||||
let source = ps.source.take();
|
let source = ps.source.take();
|
||||||
let px_x = ps.px[0].take();
|
let px_x = ps.px[HORIZONTAL_SCROLL].take();
|
||||||
let px_y = ps.px[1].take();
|
let px_y = ps.px[VERTICAL_SCROLL].take();
|
||||||
let stop_x = ps.stop[0].take();
|
let stop_x = ps.stop[HORIZONTAL_SCROLL].take();
|
||||||
let stop_y = ps.stop[1].take();
|
let stop_y = ps.stop[VERTICAL_SCROLL].take();
|
||||||
let v120_x = ps.v120[0].take();
|
let v120_x = ps.v120[HORIZONTAL_SCROLL].take();
|
||||||
let v120_y = ps.v120[1].take();
|
let v120_y = ps.v120[VERTICAL_SCROLL].take();
|
||||||
let inverted_x = ps.inverted[0].get();
|
let inverted_x = ps.inverted[HORIZONTAL_SCROLL].get();
|
||||||
let inverted_y = ps.inverted[1].get();
|
let inverted_y = ps.inverted[VERTICAL_SCROLL].get();
|
||||||
if all || ev.seat == seat {
|
if all || ev.seat == seat {
|
||||||
if all {
|
if all {
|
||||||
print!("Seat: {}, ", st.name(ev.seat));
|
print!("Seat: {}, ", st.name(ev.seat));
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ use {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
linearize::LinearizeExt,
|
||||||
std::{cell::Cell, rc::Rc},
|
std::{cell::Cell, rc::Rc},
|
||||||
thiserror::Error,
|
thiserror::Error,
|
||||||
};
|
};
|
||||||
|
|
@ -204,7 +205,7 @@ impl EiDeviceRequestHandler for EiDevice {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
let mut need_frame = false;
|
let mut need_frame = false;
|
||||||
for axis in [ScrollAxis::Horizontal, ScrollAxis::Vertical] {
|
for axis in ScrollAxis::variants() {
|
||||||
let idx = axis as usize;
|
let idx = axis as usize;
|
||||||
if let Some(v120) = self.scroll_v120[idx].take() {
|
if let Some(v120) = self.scroll_v120[idx].take() {
|
||||||
need_frame = true;
|
need_frame = true;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ use {
|
||||||
ei_object::{EiObject, EiVersion},
|
ei_object::{EiObject, EiVersion},
|
||||||
},
|
},
|
||||||
fixed::Fixed,
|
fixed::Fixed,
|
||||||
|
ifs::wl_seat::wl_pointer::{HORIZONTAL_SCROLL, VERTICAL_SCROLL},
|
||||||
leaks::Tracker,
|
leaks::Tracker,
|
||||||
wire_ei::{
|
wire_ei::{
|
||||||
EiScrollId,
|
EiScrollId,
|
||||||
|
|
@ -65,8 +66,8 @@ impl EiScrollRequestHandler for EiScroll {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn client_scroll(&self, req: ClientScroll, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
fn client_scroll(&self, req: ClientScroll, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
self.device.scroll_px[0].set(Some(req.x));
|
self.device.scroll_px[HORIZONTAL_SCROLL].set(Some(req.x));
|
||||||
self.device.scroll_px[1].set(Some(req.y));
|
self.device.scroll_px[VERTICAL_SCROLL].set(Some(req.y));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,8 +76,8 @@ impl EiScrollRequestHandler for EiScroll {
|
||||||
req: ClientScrollDiscrete,
|
req: ClientScrollDiscrete,
|
||||||
_slf: &Rc<Self>,
|
_slf: &Rc<Self>,
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
self.device.scroll_v120[0].set(Some(req.x));
|
self.device.scroll_v120[HORIZONTAL_SCROLL].set(Some(req.x));
|
||||||
self.device.scroll_v120[1].set(Some(req.y));
|
self.device.scroll_v120[VERTICAL_SCROLL].set(Some(req.y));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,8 +86,8 @@ impl EiScrollRequestHandler for EiScroll {
|
||||||
req: ClientScrollStop,
|
req: ClientScrollStop,
|
||||||
_slf: &Rc<Self>,
|
_slf: &Rc<Self>,
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
self.device.scroll_stop[0].set(Some(req.x != 0));
|
self.device.scroll_stop[HORIZONTAL_SCROLL].set(Some(req.x != 0));
|
||||||
self.device.scroll_stop[1].set(Some(req.y != 0));
|
self.device.scroll_stop[VERTICAL_SCROLL].set(Some(req.y != 0));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,10 @@ use {
|
||||||
ei_object::{EiInterface, EiObject, EiVersion},
|
ei_object::{EiInterface, EiObject, EiVersion},
|
||||||
},
|
},
|
||||||
fixed::Fixed,
|
fixed::Fixed,
|
||||||
ifs::wl_seat::{PhysicalKeyboardId, WlSeatGlobal, wl_pointer::PendingScroll},
|
ifs::wl_seat::{
|
||||||
|
PhysicalKeyboardId, WlSeatGlobal,
|
||||||
|
wl_pointer::{HORIZONTAL_SCROLL, PendingScroll, VERTICAL_SCROLL},
|
||||||
|
},
|
||||||
keyboard::{DynKeyboardState, KeyboardState, KeyboardStateId},
|
keyboard::{DynKeyboardState, KeyboardState, KeyboardStateId},
|
||||||
leaks::Tracker,
|
leaks::Tracker,
|
||||||
tree::Node,
|
tree::Node,
|
||||||
|
|
@ -163,14 +166,17 @@ impl EiSeat {
|
||||||
}
|
}
|
||||||
if let Some(b) = self.scroll.get() {
|
if let Some(b) = self.scroll.get() {
|
||||||
b.send_scroll(
|
b.send_scroll(
|
||||||
ps.px[0].get().unwrap_or_default(),
|
ps.px[HORIZONTAL_SCROLL].get().unwrap_or_default(),
|
||||||
ps.px[1].get().unwrap_or_default(),
|
ps.px[VERTICAL_SCROLL].get().unwrap_or_default(),
|
||||||
);
|
);
|
||||||
b.send_scroll_discrete(
|
b.send_scroll_discrete(
|
||||||
ps.v120[0].get().unwrap_or_default(),
|
ps.v120[HORIZONTAL_SCROLL].get().unwrap_or_default(),
|
||||||
ps.v120[1].get().unwrap_or_default(),
|
ps.v120[VERTICAL_SCROLL].get().unwrap_or_default(),
|
||||||
|
);
|
||||||
|
b.send_scroll_stop(
|
||||||
|
ps.stop[HORIZONTAL_SCROLL].get(),
|
||||||
|
ps.stop[VERTICAL_SCROLL].get(),
|
||||||
);
|
);
|
||||||
b.send_scroll_stop(ps.stop[0].get(), ps.stop[1].get());
|
|
||||||
b.device.send_frame(self.client.serial(), time_usec);
|
b.device.send_frame(self.client.serial(), time_usec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
backend::{InputDeviceId, KeyState},
|
backend::{InputDeviceId, KeyState, ScrollAxis},
|
||||||
client::Client,
|
client::Client,
|
||||||
fixed::Fixed,
|
fixed::Fixed,
|
||||||
ifs::wl_seat::{
|
ifs::wl_seat::{
|
||||||
|
|
@ -15,6 +15,7 @@ use {
|
||||||
object::{Object, Version},
|
object::{Object, Version},
|
||||||
wire::{JaySeatEventsId, jay_seat_events::*},
|
wire::{JaySeatEventsId, jay_seat_events::*},
|
||||||
},
|
},
|
||||||
|
linearize::LinearizeExt,
|
||||||
std::{convert::Infallible, rc::Rc},
|
std::{convert::Infallible, rc::Rc},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -95,7 +96,8 @@ impl JaySeatEvents {
|
||||||
source,
|
source,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
for axis in 0..1 {
|
for axis in ScrollAxis::variants() {
|
||||||
|
let axis = axis as usize;
|
||||||
if let Some(dist) = ps.v120[axis].get() {
|
if let Some(dist) = ps.v120[axis].get() {
|
||||||
self.client.event(Axis120 {
|
self.client.event(Axis120 {
|
||||||
self_id: self.id,
|
self_id: self.id,
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ use {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
kbvm::{ModifierMask, state_machine::Event},
|
kbvm::{ModifierMask, state_machine::Event},
|
||||||
|
linearize::LinearizeExt,
|
||||||
smallvec::SmallVec,
|
smallvec::SmallVec,
|
||||||
std::{cell::RefCell, collections::hash_map::Entry, mem, rc::Rc},
|
std::{cell::RefCell, collections::hash_map::Entry, mem, rc::Rc},
|
||||||
};
|
};
|
||||||
|
|
@ -1173,7 +1174,8 @@ impl WlSeatGlobal {
|
||||||
}
|
}
|
||||||
let time = (event.time_usec.get() / 1000) as _;
|
let time = (event.time_usec.get() / 1000) as _;
|
||||||
self.for_each_pointer(Version::ALL, surface.client.id, |p| {
|
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 _;
|
let axis = i as _;
|
||||||
if let Some(delta) = event.v120[i].get() {
|
if let Some(delta) = event.v120[i].get() {
|
||||||
if p.seat.version >= AXIS_VALUE120_SINCE_VERSION {
|
if p.seat.version >= AXIS_VALUE120_SINCE_VERSION {
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ use {
|
||||||
},
|
},
|
||||||
utils::{clonecell::CloneCell, smallmap::SmallMap},
|
utils::{clonecell::CloneCell, smallmap::SmallMap},
|
||||||
},
|
},
|
||||||
|
linearize::LinearizeExt,
|
||||||
std::{
|
std::{
|
||||||
cell::Cell,
|
cell::Cell,
|
||||||
rc::{Rc, Weak},
|
rc::{Rc, Weak},
|
||||||
|
|
@ -80,7 +81,8 @@ impl PointerOwnerHolder {
|
||||||
pub fn frame(&self, px_per_scroll_wheel: f64, seat: &Rc<WlSeatGlobal>, time_usec: u64) {
|
pub fn frame(&self, px_per_scroll_wheel: f64, seat: &Rc<WlSeatGlobal>, time_usec: u64) {
|
||||||
self.pending_scroll.time_usec.set(time_usec);
|
self.pending_scroll.time_usec.set(time_usec);
|
||||||
let pending = self.pending_scroll.take();
|
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() {
|
if let Some(dist) = pending.v120[axis].get() {
|
||||||
let px = (dist as f64 / AXIS_120 as f64) * px_per_scroll_wheel;
|
let px = (dist as f64 / AXIS_120 as f64) * px_per_scroll_wheel;
|
||||||
pending.px[axis].set(Some(Fixed::from_f64(px)));
|
pending.px[axis].set(Some(Fixed::from_f64(px)));
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ const ROLE: u32 = 0;
|
||||||
pub(super) const RELEASED: u32 = 0;
|
pub(super) const RELEASED: u32 = 0;
|
||||||
pub const PRESSED: u32 = 1;
|
pub const PRESSED: u32 = 1;
|
||||||
|
|
||||||
pub const VERTICAL_SCROLL: u32 = 0;
|
pub const VERTICAL_SCROLL: usize = 0;
|
||||||
pub const HORIZONTAL_SCROLL: u32 = 1;
|
pub const HORIZONTAL_SCROLL: usize = 1;
|
||||||
|
|
||||||
pub const WHEEL: u32 = 0;
|
pub const WHEEL: u32 = 0;
|
||||||
pub const FINGER: u32 = 1;
|
pub const FINGER: u32 = 1;
|
||||||
|
|
|
||||||
|
|
@ -17,14 +17,14 @@ pub struct Scroller {
|
||||||
|
|
||||||
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].get() {
|
||||||
self.px.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(px) = scroll.px[VERTICAL_SCROLL as usize].get() {
|
} else if let Some(px) = scroll.px[VERTICAL_SCROLL].get() {
|
||||||
self.v120.set(0);
|
self.v120.set(0);
|
||||||
let mut px = self.px.get() + px.to_f64();
|
let mut px = self.px.get() + px.to_f64();
|
||||||
let discrete = (px / PX_PER_SCROLL).trunc();
|
let discrete = (px / PX_PER_SCROLL).trunc();
|
||||||
|
|
@ -34,7 +34,7 @@ impl Scroller {
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
if scroll.stop[VERTICAL_SCROLL as usize].get() {
|
if scroll.stop[VERTICAL_SCROLL].get() {
|
||||||
self.v120.set(0);
|
self.v120.set(0);
|
||||||
self.px.set(0.0);
|
self.px.set(0.0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue