use crate::client::Client;
use crate::client::LookupError;
use crate::globals::Global;
use crate::globals::GlobalName;
use crate::ifs::wl_seat::zwp_pointer_gesture_hold_v1::ZwpPointerGestureHoldV1;
use crate::ifs::wl_seat::zwp_pointer_gesture_pinch_v1::ZwpPointerGesturePinchV1;
use crate::ifs::wl_seat::zwp_pointer_gesture_swipe_v1::ZwpPointerGestureSwipeV1;
use crate::leaks::Tracker;
use crate::object::Version;
use crate::wire::ZwpPointerGesturesV1Id;
use crate::wire::zwp_pointer_gestures_v1::*;
use jay_proc::Global;
use jay_proc::Object;
use std::convert::Infallible;
use std::rc::Rc;
#[derive(Global)]
pub struct ZwpPointerGesturesV1Global {
name: GlobalName,
}
#[derive(Object)]
pub struct ZwpPointerGesturesV1 {
id: ZwpPointerGesturesV1Id,
client: Rc<Client>,
tracker: Tracker<Self>,
version: Version,
}
impl ZwpPointerGesturesV1Global {
pub fn new(name: GlobalName) -> Self {
Self { name }
}
fn bind_(
self: Rc<Self>,
id: ZwpPointerGesturesV1Id,
client: &Rc<Client>,
version: Version,
) -> Result<(), Infallible> {
let obj = Rc::new(ZwpPointerGesturesV1 {
id,
client: client.clone(),
tracker: Default::default(),
version,
});
track!(client, obj);
client.add_client_obj(&obj);
Ok(())
}
}
impl Global for ZwpPointerGesturesV1Global {
fn version(&self) -> u32 {
3
}
}
impl ZwpPointerGesturesV1RequestHandler for ZwpPointerGesturesV1 {
type Error = LookupError;
fn get_swipe_gesture(&self, req: GetSwipeGesture, _slf: &Rc<Self>) -> Result<(), Self::Error> {
let seat = self.client.lookup(req.pointer)?.seat.global.clone();
let obj = Rc::new(ZwpPointerGestureSwipeV1 {
id: req.id,
client: self.client.clone(),
seat: seat.clone(),
tracker: Default::default(),
version: self.version,
});
track!(self.client, obj);
self.client.add_client_obj(&obj);
seat.swipe_bindings.add(&self.client, &obj);
Ok(())
}
fn get_pinch_gesture(&self, req: GetPinchGesture, _slf: &Rc<Self>) -> Result<(), Self::Error> {
let seat = self.client.lookup(req.pointer)?.seat.global.clone();
let obj = Rc::new(ZwpPointerGesturePinchV1 {
id: req.id,
client: self.client.clone(),
seat: seat.clone(),
tracker: Default::default(),
version: self.version,
});
track!(self.client, obj);
self.client.add_client_obj(&obj);
seat.pinch_bindings.add(&self.client, &obj);
Ok(())
}
fn release(&self, _req: Release, _slf: &Rc<Self>) -> Result<(), Self::Error> {
self.client.remove_obj(self);
Ok(())
}
fn get_hold_gesture(&self, req: GetHoldGesture, _slf: &Rc<Self>) -> Result<(), Self::Error> {
let seat = self.client.lookup(req.pointer)?.seat.global.clone();
let obj = Rc::new(ZwpPointerGestureHoldV1 {
id: req.id,
client: self.client.clone(),
seat: seat.clone(),
tracker: Default::default(),
version: self.version,
});
track!(self.client, obj);
self.client.add_client_obj(&obj);
seat.hold_bindings.add(&self.client, &obj);
Ok(())
}
}