wl-pointer: don't send motion events if the position did not change
This commit is contained in:
parent
760658522c
commit
4c0e6d9b51
2 changed files with 7 additions and 1 deletions
|
|
@ -4,7 +4,7 @@ use std::{
|
||||||
ops::{Add, AddAssign, Sub, SubAssign},
|
ops::{Add, AddAssign, Sub, SubAssign},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
|
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Default)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct Fixed(pub i32);
|
pub struct Fixed(pub i32);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ pub struct WlPointer {
|
||||||
id: WlPointerId,
|
id: WlPointerId,
|
||||||
pub seat: Rc<WlSeat>,
|
pub seat: Rc<WlSeat>,
|
||||||
pub tracker: Tracker<Self>,
|
pub tracker: Tracker<Self>,
|
||||||
|
last_motion: Cell<(Fixed, Fixed)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WlPointer {
|
impl WlPointer {
|
||||||
|
|
@ -82,10 +83,12 @@ impl WlPointer {
|
||||||
id,
|
id,
|
||||||
seat: seat.clone(),
|
seat: seat.clone(),
|
||||||
tracker: Default::default(),
|
tracker: Default::default(),
|
||||||
|
last_motion: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_enter(&self, serial: u32, surface: WlSurfaceId, x: Fixed, y: Fixed) {
|
pub fn send_enter(&self, serial: u32, surface: WlSurfaceId, x: Fixed, y: Fixed) {
|
||||||
|
self.last_motion.set((x, y));
|
||||||
self.seat.client.event(Enter {
|
self.seat.client.event(Enter {
|
||||||
self_id: self.id,
|
self_id: self.id,
|
||||||
serial,
|
serial,
|
||||||
|
|
@ -104,6 +107,9 @@ impl WlPointer {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send_motion(&self, time: u32, x: Fixed, y: Fixed) {
|
pub fn send_motion(&self, time: u32, x: Fixed, y: Fixed) {
|
||||||
|
if self.last_motion.replace((x, y)) == (x, y) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
self.seat.client.event(Motion {
|
self.seat.client.event(Motion {
|
||||||
self_id: self.id,
|
self_id: self.id,
|
||||||
time,
|
time,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue