use crate::client::Client;
use crate::object::{NewObjectExt, ObjectRef, RequestReceiver};
use anyhow::Error;
use zwp_pointer_constraints_v1_server_protocol::{
ZwpConfinedPointerV1, ZwpConfinedPointerV1Request, ZwpLockedPointerV1,
ZwpLockedPointerV1Request, ZwpPointerConstraintsV1, ZwpPointerConstraintsV1Request,
};
pub struct PointerConstraints;
impl RequestReceiver<ZwpPointerConstraintsV1> for PointerConstraints {
fn receive(
this: ObjectRef<Self>,
request: ZwpPointerConstraintsV1Request,
client: &mut Client,
) -> Result<(), Error> {
match request {
ZwpPointerConstraintsV1Request::Destroy => {
client.delete_id(this.id())?;
}
ZwpPointerConstraintsV1Request::LockPointer { id, .. } => {
id.implement(client, LockedPointer)?;
}
ZwpPointerConstraintsV1Request::ConfinePointer { id, .. } => {
id.implement(client, ConfinedPointer)?;
}
}
Ok(())
}
}
struct LockedPointer;
impl RequestReceiver<ZwpLockedPointerV1> for LockedPointer {
fn receive(
this: ObjectRef<Self>,
request: ZwpLockedPointerV1Request,
client: &mut Client,
) -> Result<(), Error> {
match request {
ZwpLockedPointerV1Request::Destroy => {
client.delete_id(this.id())?;
}
ZwpLockedPointerV1Request::SetCursorPositionHint { .. } => {}
ZwpLockedPointerV1Request::SetRegion { .. } => {}
}
Ok(())
}
}
struct ConfinedPointer;
impl RequestReceiver<ZwpConfinedPointerV1> for ConfinedPointer {
fn receive(
this: ObjectRef<Self>,
request: ZwpConfinedPointerV1Request,
client: &mut Client,
) -> Result<(), Error> {
match request {
ZwpConfinedPointerV1Request::Destroy => {
client.delete_id(this.id())?;
}
ZwpConfinedPointerV1Request::SetRegion { .. } => {}
}
Ok(())
}
}