zwp_relative_pointer_v1_server_protocol/
zwp_relative_pointer_v1_server_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_server_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 = Request;
62    type Outgoing = Event;
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: NewObject<ZwpRelativePointerV1>,
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 Event {
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        }
132        header.length = msg.bytes().len() as u16;
133        msg.rewind();
134        msg.write_header(&header)?;
135        Ok(msg)
136    }
137}
138impl FromArgs for Request {
139    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
140        match op {
141        0 /* destroy */ => {
142            let mut iter = args.into_iter();
143            Ok(Request::Destroy {
144
145            })
146        },
147        1 /* get_relative_pointer */ => {
148            let mut iter = args.into_iter();
149            Ok(Request::GetRelativePointer {
150                id: iter.next()
151                                             .ok_or(DecodeError::InsufficientArgs)?
152                                             .as_new_id()?.into(),
153                pointer: iter.next()
154                                             .ok_or(DecodeError::InsufficientArgs)?
155                                             .as_object()?,
156
157            })
158        },
159        _ => {
160            Err(DecodeError::InvalidOpcode(op).into())
161        },
162        }
163    }
164}
165} // mod zwp_relative_pointer_manager_v1
166
167pub use crate::zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1;
168pub use crate::zwp_relative_pointer_manager_v1::Request as ZwpRelativePointerManagerV1Request;
169pub use crate::zwp_relative_pointer_manager_v1::Event as ZwpRelativePointerManagerV1Event;
170pub mod zwp_relative_pointer_v1 {
171use super::*;
172
173/// relative pointer object
174///
175/// A wp_relative_pointer object is an extension to the wl_pointer interface
176/// used for emitting relative pointer events. It shares the same focus as
177/// wl_pointer objects of the same seat and will only emit events when it has
178/// focus.
179#[derive(Debug)]
180pub struct ZwpRelativePointerV1;
181
182impl Interface for ZwpRelativePointerV1 {
183    const NAME: &'static str = "zwp_relative_pointer_v1";
184    const VERSION: u32 = 1;
185    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
186        // destroy
187        MessageSpec(&[
188        ]),
189    ]);
190    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
191        // relative_motion
192        MessageSpec(&[
193            ArgKind::Uint,
194            ArgKind::Uint,
195            ArgKind::Fixed,
196            ArgKind::Fixed,
197            ArgKind::Fixed,
198            ArgKind::Fixed,
199        ]),
200    ]);
201    type Incoming = Request;
202    type Outgoing = Event;
203}
204
205#[derive(Debug)]
206pub enum Request {
207
208    /// release the relative pointer object
209    ///
210    Destroy,
211}
212
213impl MessageType for Request {
214    fn log(&self, this: ObjectId) -> String {
215        match *self {
216            Request::Destroy {
217            } => {
218                format!("zwp_relative_pointer_v1@{:?}::destroy()", this)
219            }
220        }
221    }
222    fn message_name(&self) -> &'static std::ffi::CStr{
223        match *self {
224            Request::Destroy { .. } => c"zwp_relative_pointer_v1::destroy",
225        }
226    }
227}
228#[derive(Debug)]
229pub enum Event {
230
231    /// relative pointer motion
232    ///
233    /// Relative x/y pointer motion from the pointer of the seat associated with
234    /// this object.
235    /// 
236    /// A relative motion is in the same dimension as regular wl_pointer motion
237    /// events, except they do not represent an absolute position. For example,
238    /// moving a pointer from (x, y) to (x', y') would have the equivalent
239    /// relative motion (x' - x, y' - y). If a pointer motion caused the
240    /// absolute pointer position to be clipped by for example the edge of the
241    /// monitor, the relative motion is unaffected by the clipping and will
242    /// represent the unclipped motion.
243    /// 
244    /// This event also contains non-accelerated motion deltas. The
245    /// non-accelerated delta is, when applicable, the regular pointer motion
246    /// delta as it was before having applied motion acceleration and other
247    /// transformations such as normalization.
248    /// 
249    /// Note that the non-accelerated delta does not represent 'raw' events as
250    /// they were read from some device. Pointer motion acceleration is device-
251    /// and configuration-specific and non-accelerated deltas and accelerated
252    /// deltas may have the same value on some devices.
253    /// 
254    /// Relative motions are not coupled to wl_pointer.motion events, and can be
255    /// sent in combination with such events, but also independently. There may
256    /// also be scenarios where wl_pointer.motion is sent, but there is no
257    /// relative motion. The order of an absolute and relative motion event
258    /// originating from the same physical motion is not guaranteed.
259    /// 
260    /// If the client needs button events or focus state, it can receive them
261    /// from a wl_pointer object of the same seat that the wp_relative_pointer
262    /// object is associated with.
263    RelativeMotion {
264        /// high 32 bits of a 64 bit timestamp with microsecond granularity
265        utime_hi: u32,
266        /// low 32 bits of a 64 bit timestamp with microsecond granularity
267        utime_lo: u32,
268        /// the x component of the motion vector
269        dx: Fixed,
270        /// the y component of the motion vector
271        dy: Fixed,
272        /// the x component of the unaccelerated motion vector
273        dx_unaccel: Fixed,
274        /// the y component of the unaccelerated motion vector
275        dy_unaccel: Fixed,
276    },
277}
278
279impl MessageType for Event {
280    fn log(&self, this: ObjectId) -> String {
281        match *self {
282            Event::RelativeMotion {
283                ref utime_hi,
284                ref utime_lo,
285                ref dx,
286                ref dy,
287                ref dx_unaccel,
288                ref dy_unaccel,
289            } => {
290                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)
291            }
292        }
293    }
294    fn message_name(&self) -> &'static std::ffi::CStr{
295        match *self {
296            Event::RelativeMotion { .. } => c"zwp_relative_pointer_v1::relative_motion",
297        }
298    }
299}
300impl IntoMessage for Event {
301    type Error = EncodeError;
302    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
303        let mut header = MessageHeader {
304            sender: id,
305            opcode: 0,
306            length: 0,
307        };
308        let mut msg = Message::new();
309        msg.write_header(&header)?;
310        match self {
311        Event::RelativeMotion {
312            utime_hi,
313            utime_lo,
314            dx,
315            dy,
316            dx_unaccel,
317            dy_unaccel,
318        } => {
319            msg.write_arg(Arg::Uint(utime_hi))?;
320            msg.write_arg(Arg::Uint(utime_lo))?;
321            msg.write_arg(Arg::Fixed(dx))?;
322            msg.write_arg(Arg::Fixed(dy))?;
323            msg.write_arg(Arg::Fixed(dx_unaccel))?;
324            msg.write_arg(Arg::Fixed(dy_unaccel))?;
325            header.opcode = 0;
326        },
327        }
328        header.length = msg.bytes().len() as u16;
329        msg.rewind();
330        msg.write_header(&header)?;
331        Ok(msg)
332    }
333}
334impl FromArgs for Request {
335    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
336        match op {
337        0 /* destroy */ => {
338            let mut iter = args.into_iter();
339            Ok(Request::Destroy {
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;