wayland_bridge/
pointer_constraints.rs1use crate::client::Client;
6use crate::object::{NewObjectExt, ObjectRef, RequestReceiver};
7use anyhow::Error;
8use zwp_pointer_constraints_v1_server_protocol::{
9 ZwpConfinedPointerV1, ZwpConfinedPointerV1Request, ZwpLockedPointerV1,
10 ZwpLockedPointerV1Request, ZwpPointerConstraintsV1, ZwpPointerConstraintsV1Request,
11};
12
13pub struct PointerConstraints;
15
16impl RequestReceiver<ZwpPointerConstraintsV1> for PointerConstraints {
17 fn receive(
18 this: ObjectRef<Self>,
19 request: ZwpPointerConstraintsV1Request,
20 client: &mut Client,
21 ) -> Result<(), Error> {
22 match request {
23 ZwpPointerConstraintsV1Request::Destroy => {
24 client.delete_id(this.id())?;
25 }
26 ZwpPointerConstraintsV1Request::LockPointer { id, .. } => {
27 id.implement(client, LockedPointer)?;
28 }
29 ZwpPointerConstraintsV1Request::ConfinePointer { id, .. } => {
30 id.implement(client, ConfinedPointer)?;
31 }
32 }
33 Ok(())
34 }
35}
36
37struct LockedPointer;
38
39impl RequestReceiver<ZwpLockedPointerV1> for LockedPointer {
40 fn receive(
41 this: ObjectRef<Self>,
42 request: ZwpLockedPointerV1Request,
43 client: &mut Client,
44 ) -> Result<(), Error> {
45 match request {
46 ZwpLockedPointerV1Request::Destroy => {
47 client.delete_id(this.id())?;
48 }
49 ZwpLockedPointerV1Request::SetCursorPositionHint { .. } => {}
50 ZwpLockedPointerV1Request::SetRegion { .. } => {}
51 }
52 Ok(())
53 }
54}
55
56struct ConfinedPointer;
57
58impl RequestReceiver<ZwpConfinedPointerV1> for ConfinedPointer {
59 fn receive(
60 this: ObjectRef<Self>,
61 request: ZwpConfinedPointerV1Request,
62 client: &mut Client,
63 ) -> Result<(), Error> {
64 match request {
65 ZwpConfinedPointerV1Request::Destroy => {
66 client.delete_id(this.id())?;
67 }
68 ZwpConfinedPointerV1Request::SetRegion { .. } => {}
69 }
70 Ok(())
71 }
72}