wayland: implement wl_touch
Co-authored-by: Julian Orth <ju.orth@gmail.com>
This commit is contained in:
parent
905e2dd7ba
commit
681c1ad033
35 changed files with 1071 additions and 52 deletions
|
|
@ -1,29 +1,20 @@
|
|||
use {
|
||||
crate::{
|
||||
client::ClientError,
|
||||
fixed::Fixed,
|
||||
ifs::wl_seat::WlSeat,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
wire::{wl_touch::*, WlTouchId},
|
||||
object::{Object, Version},
|
||||
wire::{wl_touch::*, WlSurfaceId, WlTouchId},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
#[allow(dead_code)]
|
||||
const DOWN: u32 = 0;
|
||||
pub const SHAPE_SINCE_VERSION: Version = Version(6);
|
||||
#[allow(dead_code)]
|
||||
const UP: u32 = 1;
|
||||
#[allow(dead_code)]
|
||||
const MOTION: u32 = 2;
|
||||
#[allow(dead_code)]
|
||||
const FRAME: u32 = 3;
|
||||
#[allow(dead_code)]
|
||||
const CANCEL: u32 = 4;
|
||||
#[allow(dead_code)]
|
||||
const SHAPE: u32 = 5;
|
||||
#[allow(dead_code)]
|
||||
const ORIENTATION: u32 = 6;
|
||||
pub const ORIENTATION_DIRECTION_SINCE_VERSION: Version = Version(6);
|
||||
|
||||
pub struct WlTouch {
|
||||
id: WlTouchId,
|
||||
|
|
@ -39,12 +30,79 @@ impl WlTouch {
|
|||
tracker: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn send_down(
|
||||
&self,
|
||||
serial: u32,
|
||||
time: u32,
|
||||
surface: WlSurfaceId,
|
||||
id: i32,
|
||||
x: Fixed,
|
||||
y: Fixed,
|
||||
) {
|
||||
self.seat.client.event(Down {
|
||||
self_id: self.id,
|
||||
serial,
|
||||
time,
|
||||
surface,
|
||||
id,
|
||||
x,
|
||||
y,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn send_up(&self, serial: u32, time: u32, id: i32) {
|
||||
self.seat.client.event(Up {
|
||||
self_id: self.id,
|
||||
serial,
|
||||
time,
|
||||
id,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn send_motion(&self, time: u32, id: i32, x: Fixed, y: Fixed) {
|
||||
self.seat.client.event(Motion {
|
||||
self_id: self.id,
|
||||
time,
|
||||
id,
|
||||
x,
|
||||
y,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn send_frame(&self) {
|
||||
self.seat.client.event(Frame { self_id: self.id })
|
||||
}
|
||||
|
||||
pub fn send_cancel(&self) {
|
||||
self.seat.client.event(Cancel { self_id: self.id })
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn send_shape(&self, id: i32, major: Fixed, minor: Fixed) {
|
||||
self.seat.client.event(Shape {
|
||||
self_id: self.id,
|
||||
id,
|
||||
major,
|
||||
minor,
|
||||
})
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn send_orientation(&self, id: i32, orientation: Fixed) {
|
||||
self.seat.client.event(Orientation {
|
||||
self_id: self.id,
|
||||
id,
|
||||
orientation,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl WlTouchRequestHandler for WlTouch {
|
||||
type Error = WlTouchError;
|
||||
|
||||
fn release(&self, _req: Release, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||
self.seat.touches.remove(&self.id);
|
||||
self.seat.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue