zwp_relative_pointer_v1_client_protocol/
zwp_relative_pointer_v1_client_protocol.rs

1// GENERATED FILE -- DO NOT EDIT
2//
3// Copyright © 2014      Jonas Ådahl
4// Copyright © 2015      Red Hat Inc.
5// 
6// Permission is hereby granted, free of charge, to any person obtaining a
7// copy of this software and associated documentation files (the "Software"),
8// to deal in the Software without restriction, including without limitation
9// the rights to use, copy, modify, merge, publish, distribute, sublicense,
10// and/or sell copies of the Software, and to permit persons to whom the
11// Software is furnished to do so, subject to the following conditions:
12// 
13// The above copyright notice and this permission notice (including the next
14// paragraph) shall be included in all copies or substantial portions of the
15// Software.
16// 
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE.
24
25#![allow(warnings)]
26#![allow(clippy::all)]
27use anyhow;
28#[allow(unused_imports)]
29use fuchsia_wayland_core::{Array, Enum, Fixed, NewId, NewObject};
30use fuchsia_wayland_core::{ArgKind, Arg, FromArgs, IntoMessage, Message,
31                            MessageGroupSpec, MessageHeader, MessageSpec, MessageType,
32                            ObjectId, EncodeError, DecodeError, Interface};
33
34#[allow(unused_imports)]
35use wayland_client_protocol::*;
36pub mod zwp_relative_pointer_manager_v1 {
37use super::*;
38
39/// get relative pointer objects
40///
41/// A global interface used for getting the relative pointer object for a
42/// given pointer.
43#[derive(Debug)]
44pub struct ZwpRelativePointerManagerV1;
45
46impl Interface for ZwpRelativePointerManagerV1 {
47    const NAME: &'static str = "zwp_relative_pointer_manager_v1";
48    const VERSION: u32 = 1;
49    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
50        // destroy
51        MessageSpec(&[
52        ]),
53        // get_relative_pointer
54        MessageSpec(&[
55            ArgKind::NewId,
56            ArgKind::Object,
57        ]),
58    ]);
59    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
60    ]);
61    type Incoming = Event;
62    type Outgoing = Request;
63}
64
65#[derive(Debug)]
66pub enum Request {
67
68    /// destroy the relative pointer manager object
69    ///
70    /// Used by the client to notify the server that it will no longer use this
71    /// relative pointer manager object.
72    Destroy,
73
74    /// get a relative pointer object
75    ///
76    /// Create a relative pointer interface given a wl_pointer object. See the
77    /// wp_relative_pointer interface for more details.
78    GetRelativePointer {
79        id: NewId,
80        pointer: ObjectId,
81    },
82}
83
84impl MessageType for Request {
85    fn log(&self, this: ObjectId) -> String {
86        match *self {
87            Request::Destroy {
88            } => {
89                format!("zwp_relative_pointer_manager_v1@{:?}::destroy()", this)
90            }
91            Request::GetRelativePointer {
92                ref id,
93                ref pointer,
94            } => {
95                format!("zwp_relative_pointer_manager_v1@{:?}::get_relative_pointer(id: {:?}, pointer: {:?})", this, id, pointer)
96            }
97        }
98    }
99    fn message_name(&self) -> &'static std::ffi::CStr{
100        match *self {
101            Request::Destroy { .. } => c"zwp_relative_pointer_manager_v1::destroy",
102            Request::GetRelativePointer { .. } => c"zwp_relative_pointer_manager_v1::get_relative_pointer",
103        }
104    }
105}
106#[derive(Debug)]
107pub enum Event {
108}
109
110impl MessageType for Event {
111    fn log(&self, this: ObjectId) -> String {
112        match *self {
113        }
114    }
115    fn message_name(&self) -> &'static std::ffi::CStr{
116        match *self {
117        }
118    }
119}
120impl IntoMessage for Request {
121    type Error = EncodeError;
122    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
123        let mut header = MessageHeader {
124            sender: id,
125            opcode: 0,
126            length: 0,
127        };
128        let mut msg = Message::new();
129        msg.write_header(&header)?;
130        match self {
131        Request::Destroy {
132        } => {
133            header.opcode = 0;
134        },
135        Request::GetRelativePointer {
136            id,
137            pointer,
138        } => {
139            msg.write_arg(Arg::NewId(id))?;
140            msg.write_arg(Arg::Object(pointer))?;
141            header.opcode = 1;
142        },
143        }
144        header.length = msg.bytes().len() as u16;
145        msg.rewind();
146        msg.write_header(&header)?;
147        Ok(msg)
148    }
149}
150impl FromArgs for Event {
151    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
152        match op {
153        _ => {
154            Err(DecodeError::InvalidOpcode(op).into())
155        },
156        }
157    }
158}
159} // mod zwp_relative_pointer_manager_v1
160
161pub use crate::zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1;
162pub use crate::zwp_relative_pointer_manager_v1::Request as ZwpRelativePointerManagerV1Request;
163pub use crate::zwp_relative_pointer_manager_v1::Event as ZwpRelativePointerManagerV1Event;
164pub mod zwp_relative_pointer_v1 {
165use super::*;
166
167/// relative pointer object
168///
169/// A wp_relative_pointer object is an extension to the wl_pointer interface
170/// used for emitting relative pointer events. It shares the same focus as
171/// wl_pointer objects of the same seat and will only emit events when it has
172/// focus.
173#[derive(Debug)]
174pub struct ZwpRelativePointerV1;
175
176impl Interface for ZwpRelativePointerV1 {
177    const NAME: &'static str = "zwp_relative_pointer_v1";
178    const VERSION: u32 = 1;
179    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
180        // destroy
181        MessageSpec(&[
182        ]),
183    ]);
184    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
185        // relative_motion
186        MessageSpec(&[
187            ArgKind::Uint,
188            ArgKind::Uint,
189            ArgKind::Fixed,
190            ArgKind::Fixed,
191            ArgKind::Fixed,
192            ArgKind::Fixed,
193        ]),
194    ]);
195    type Incoming = Event;
196    type Outgoing = Request;
197}
198
199#[derive(Debug)]
200pub enum Request {
201
202    /// release the relative pointer object
203    ///
204    Destroy,
205}
206
207impl MessageType for Request {
208    fn log(&self, this: ObjectId) -> String {
209        match *self {
210            Request::Destroy {
211            } => {
212                format!("zwp_relative_pointer_v1@{:?}::destroy()", this)
213            }
214        }
215    }
216    fn message_name(&self) -> &'static std::ffi::CStr{
217        match *self {
218            Request::Destroy { .. } => c"zwp_relative_pointer_v1::destroy",
219        }
220    }
221}
222#[derive(Debug)]
223pub enum Event {
224
225    /// relative pointer motion
226    ///
227    /// Relative x/y pointer motion from the pointer of the seat associated with
228    /// this object.
229    /// 
230    /// A relative motion is in the same dimension as regular wl_pointer motion
231    /// events, except they do not represent an absolute position. For example,
232    /// moving a pointer from (x, y) to (x', y') would have the equivalent
233    /// relative motion (x' - x, y' - y). If a pointer motion caused the
234    /// absolute pointer position to be clipped by for example the edge of the
235    /// monitor, the relative motion is unaffected by the clipping and will
236    /// represent the unclipped motion.
237    /// 
238    /// This event also contains non-accelerated motion deltas. The
239    /// non-accelerated delta is, when applicable, the regular pointer motion
240    /// delta as it was before having applied motion acceleration and other
241    /// transformations such as normalization.
242    /// 
243    /// Note that the non-accelerated delta does not represent 'raw' events as
244    /// they were read from some device. Pointer motion acceleration is device-
245    /// and configuration-specific and non-accelerated deltas and accelerated
246    /// deltas may have the same value on some devices.
247    /// 
248    /// Relative motions are not coupled to wl_pointer.motion events, and can be
249    /// sent in combination with such events, but also independently. There may
250    /// also be scenarios where wl_pointer.motion is sent, but there is no
251    /// relative motion. The order of an absolute and relative motion event
252    /// originating from the same physical motion is not guaranteed.
253    /// 
254    /// If the client needs button events or focus state, it can receive them
255    /// from a wl_pointer object of the same seat that the wp_relative_pointer
256    /// object is associated with.
257    RelativeMotion {
258        /// high 32 bits of a 64 bit timestamp with microsecond granularity
259        utime_hi: u32,
260        /// low 32 bits of a 64 bit timestamp with microsecond granularity
261        utime_lo: u32,
262        /// the x component of the motion vector
263        dx: Fixed,
264        /// the y component of the motion vector
265        dy: Fixed,
266        /// the x component of the unaccelerated motion vector
267        dx_unaccel: Fixed,
268        /// the y component of the unaccelerated motion vector
269        dy_unaccel: Fixed,
270    },
271}
272
273impl MessageType for Event {
274    fn log(&self, this: ObjectId) -> String {
275        match *self {
276            Event::RelativeMotion {
277                ref utime_hi,
278                ref utime_lo,
279                ref dx,
280                ref dy,
281                ref dx_unaccel,
282                ref dy_unaccel,
283            } => {
284                format!("zwp_relative_pointer_v1@{:?}::relative_motion(utime_hi: {:?}, utime_lo: {:?}, dx: {:?}, dy: {:?}, dx_unaccel: {:?}, dy_unaccel: {:?})", this, utime_hi, utime_lo, dx, dy, dx_unaccel, dy_unaccel)
285            }
286        }
287    }
288    fn message_name(&self) -> &'static std::ffi::CStr{
289        match *self {
290            Event::RelativeMotion { .. } => c"zwp_relative_pointer_v1::relative_motion",
291        }
292    }
293}
294impl IntoMessage for Request {
295    type Error = EncodeError;
296    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
297        let mut header = MessageHeader {
298            sender: id,
299            opcode: 0,
300            length: 0,
301        };
302        let mut msg = Message::new();
303        msg.write_header(&header)?;
304        match self {
305        Request::Destroy {
306        } => {
307            header.opcode = 0;
308        },
309        }
310        header.length = msg.bytes().len() as u16;
311        msg.rewind();
312        msg.write_header(&header)?;
313        Ok(msg)
314    }
315}
316impl FromArgs for Event {
317    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
318        match op {
319        0 /* relative_motion */ => {
320            let mut iter = args.into_iter();
321            Ok(Event::RelativeMotion {
322                utime_hi: iter.next()
323                                             .ok_or(DecodeError::InsufficientArgs)?
324                                             .as_uint()?,
325                utime_lo: iter.next()
326                                             .ok_or(DecodeError::InsufficientArgs)?
327                                             .as_uint()?,
328                dx: iter.next()
329                                             .ok_or(DecodeError::InsufficientArgs)?
330                                             .as_fixed()?.into(),
331                dy: iter.next()
332                                             .ok_or(DecodeError::InsufficientArgs)?
333                                             .as_fixed()?.into(),
334                dx_unaccel: iter.next()
335                                             .ok_or(DecodeError::InsufficientArgs)?
336                                             .as_fixed()?.into(),
337                dy_unaccel: iter.next()
338                                             .ok_or(DecodeError::InsufficientArgs)?
339                                             .as_fixed()?.into(),
340
341            })
342        },
343        _ => {
344            Err(DecodeError::InvalidOpcode(op).into())
345        },
346        }
347    }
348}
349} // mod zwp_relative_pointer_v1
350
351pub use crate::zwp_relative_pointer_v1::ZwpRelativePointerV1;
352pub use crate::zwp_relative_pointer_v1::Request as ZwpRelativePointerV1Request;
353pub use crate::zwp_relative_pointer_v1::Event as ZwpRelativePointerV1Event;