zwp_relative_pointer_v1_client_protocol/
zwp_relative_pointer_v1_client_protocol.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
// GENERATED FILE -- DO NOT EDIT
//
// Copyright © 2014      Jonas Ådahl
// Copyright © 2015      Red Hat Inc.
// 
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice (including the next
// paragraph) shall be included in all copies or substantial portions of the
// Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.

#![allow(warnings)]
#![allow(clippy::all)]
use anyhow;
#[allow(unused_imports)]
use fuchsia_wayland_core::{Array, Enum, Fixed, NewId, NewObject};
use fuchsia_wayland_core::{ArgKind, Arg, FromArgs, IntoMessage, Message,
                            MessageGroupSpec, MessageHeader, MessageSpec, MessageType,
                            ObjectId, EncodeError, DecodeError, Interface};

#[allow(unused_imports)]
use wayland_client_protocol::*;
pub mod zwp_relative_pointer_manager_v1 {
use super::*;

/// get relative pointer objects
///
/// A global interface used for getting the relative pointer object for a
/// given pointer.
#[derive(Debug)]
pub struct ZwpRelativePointerManagerV1;

impl Interface for ZwpRelativePointerManagerV1 {
    const NAME: &'static str = "zwp_relative_pointer_manager_v1";
    const VERSION: u32 = 1;
    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
        // destroy
        MessageSpec(&[
        ]),
        // get_relative_pointer
        MessageSpec(&[
            ArgKind::NewId,
            ArgKind::Object,
        ]),
    ]);
    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
    ]);
    type Incoming = Event;
    type Outgoing = Request;
}

#[derive(Debug)]
pub enum Request {

    /// destroy the relative pointer manager object
    ///
    /// Used by the client to notify the server that it will no longer use this
    /// relative pointer manager object.
    Destroy,

    /// get a relative pointer object
    ///
    /// Create a relative pointer interface given a wl_pointer object. See the
    /// wp_relative_pointer interface for more details.
    GetRelativePointer {
        id: NewId,
        pointer: ObjectId,
    },
}

impl MessageType for Request {
    fn log(&self, this: ObjectId) -> String {
        match *self {
            Request::Destroy {
            } => {
                format!("zwp_relative_pointer_manager_v1@{:?}::destroy()", this)
            }
            Request::GetRelativePointer {
                ref id,
                ref pointer,
            } => {
                format!("zwp_relative_pointer_manager_v1@{:?}::get_relative_pointer(id: {:?}, pointer: {:?})", this, id, pointer)
            }
        }
    }
    fn message_name(&self) -> &'static std::ffi::CStr{
        match *self {
            Request::Destroy { .. } => c"zwp_relative_pointer_manager_v1::destroy",
            Request::GetRelativePointer { .. } => c"zwp_relative_pointer_manager_v1::get_relative_pointer",
        }
    }
}
#[derive(Debug)]
pub enum Event {
}

impl MessageType for Event {
    fn log(&self, this: ObjectId) -> String {
        match *self {
        }
    }
    fn message_name(&self) -> &'static std::ffi::CStr{
        match *self {
        }
    }
}
impl IntoMessage for Request {
    type Error = EncodeError;
    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
        let mut header = MessageHeader {
            sender: id,
            opcode: 0,
            length: 0,
        };
        let mut msg = Message::new();
        msg.write_header(&header)?;
        match self {
        Request::Destroy {
        } => {
            header.opcode = 0;
        },
        Request::GetRelativePointer {
            id,
            pointer,
        } => {
            msg.write_arg(Arg::NewId(id))?;
            msg.write_arg(Arg::Object(pointer))?;
            header.opcode = 1;
        },
        }
        header.length = msg.bytes().len() as u16;
        msg.rewind();
        msg.write_header(&header)?;
        Ok(msg)
    }
}
impl FromArgs for Event {
    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
        match op {
        _ => {
            Err(DecodeError::InvalidOpcode(op).into())
        },
        }
    }
}
} // mod zwp_relative_pointer_manager_v1

pub use crate::zwp_relative_pointer_manager_v1::ZwpRelativePointerManagerV1;
pub use crate::zwp_relative_pointer_manager_v1::Request as ZwpRelativePointerManagerV1Request;
pub use crate::zwp_relative_pointer_manager_v1::Event as ZwpRelativePointerManagerV1Event;
pub mod zwp_relative_pointer_v1 {
use super::*;

/// relative pointer object
///
/// A wp_relative_pointer object is an extension to the wl_pointer interface
/// used for emitting relative pointer events. It shares the same focus as
/// wl_pointer objects of the same seat and will only emit events when it has
/// focus.
#[derive(Debug)]
pub struct ZwpRelativePointerV1;

impl Interface for ZwpRelativePointerV1 {
    const NAME: &'static str = "zwp_relative_pointer_v1";
    const VERSION: u32 = 1;
    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
        // destroy
        MessageSpec(&[
        ]),
    ]);
    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
        // relative_motion
        MessageSpec(&[
            ArgKind::Uint,
            ArgKind::Uint,
            ArgKind::Fixed,
            ArgKind::Fixed,
            ArgKind::Fixed,
            ArgKind::Fixed,
        ]),
    ]);
    type Incoming = Event;
    type Outgoing = Request;
}

#[derive(Debug)]
pub enum Request {

    /// release the relative pointer object
    ///
    Destroy,
}

impl MessageType for Request {
    fn log(&self, this: ObjectId) -> String {
        match *self {
            Request::Destroy {
            } => {
                format!("zwp_relative_pointer_v1@{:?}::destroy()", this)
            }
        }
    }
    fn message_name(&self) -> &'static std::ffi::CStr{
        match *self {
            Request::Destroy { .. } => c"zwp_relative_pointer_v1::destroy",
        }
    }
}
#[derive(Debug)]
pub enum Event {

    /// relative pointer motion
    ///
    /// Relative x/y pointer motion from the pointer of the seat associated with
    /// this object.
    /// 
    /// A relative motion is in the same dimension as regular wl_pointer motion
    /// events, except they do not represent an absolute position. For example,
    /// moving a pointer from (x, y) to (x', y') would have the equivalent
    /// relative motion (x' - x, y' - y). If a pointer motion caused the
    /// absolute pointer position to be clipped by for example the edge of the
    /// monitor, the relative motion is unaffected by the clipping and will
    /// represent the unclipped motion.
    /// 
    /// This event also contains non-accelerated motion deltas. The
    /// non-accelerated delta is, when applicable, the regular pointer motion
    /// delta as it was before having applied motion acceleration and other
    /// transformations such as normalization.
    /// 
    /// Note that the non-accelerated delta does not represent 'raw' events as
    /// they were read from some device. Pointer motion acceleration is device-
    /// and configuration-specific and non-accelerated deltas and accelerated
    /// deltas may have the same value on some devices.
    /// 
    /// Relative motions are not coupled to wl_pointer.motion events, and can be
    /// sent in combination with such events, but also independently. There may
    /// also be scenarios where wl_pointer.motion is sent, but there is no
    /// relative motion. The order of an absolute and relative motion event
    /// originating from the same physical motion is not guaranteed.
    /// 
    /// If the client needs button events or focus state, it can receive them
    /// from a wl_pointer object of the same seat that the wp_relative_pointer
    /// object is associated with.
    RelativeMotion {
        /// high 32 bits of a 64 bit timestamp with microsecond granularity
        utime_hi: u32,
        /// low 32 bits of a 64 bit timestamp with microsecond granularity
        utime_lo: u32,
        /// the x component of the motion vector
        dx: Fixed,
        /// the y component of the motion vector
        dy: Fixed,
        /// the x component of the unaccelerated motion vector
        dx_unaccel: Fixed,
        /// the y component of the unaccelerated motion vector
        dy_unaccel: Fixed,
    },
}

impl MessageType for Event {
    fn log(&self, this: ObjectId) -> String {
        match *self {
            Event::RelativeMotion {
                ref utime_hi,
                ref utime_lo,
                ref dx,
                ref dy,
                ref dx_unaccel,
                ref dy_unaccel,
            } => {
                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)
            }
        }
    }
    fn message_name(&self) -> &'static std::ffi::CStr{
        match *self {
            Event::RelativeMotion { .. } => c"zwp_relative_pointer_v1::relative_motion",
        }
    }
}
impl IntoMessage for Request {
    type Error = EncodeError;
    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
        let mut header = MessageHeader {
            sender: id,
            opcode: 0,
            length: 0,
        };
        let mut msg = Message::new();
        msg.write_header(&header)?;
        match self {
        Request::Destroy {
        } => {
            header.opcode = 0;
        },
        }
        header.length = msg.bytes().len() as u16;
        msg.rewind();
        msg.write_header(&header)?;
        Ok(msg)
    }
}
impl FromArgs for Event {
    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
        match op {
        0 /* relative_motion */ => {
            let mut iter = args.into_iter();
            Ok(Event::RelativeMotion {
                utime_hi: iter.next()
                                             .ok_or(DecodeError::InsufficientArgs)?
                                             .as_uint()?,
                utime_lo: iter.next()
                                             .ok_or(DecodeError::InsufficientArgs)?
                                             .as_uint()?,
                dx: iter.next()
                                             .ok_or(DecodeError::InsufficientArgs)?
                                             .as_fixed()?.into(),
                dy: iter.next()
                                             .ok_or(DecodeError::InsufficientArgs)?
                                             .as_fixed()?.into(),
                dx_unaccel: iter.next()
                                             .ok_or(DecodeError::InsufficientArgs)?
                                             .as_fixed()?.into(),
                dy_unaccel: iter.next()
                                             .ok_or(DecodeError::InsufficientArgs)?
                                             .as_fixed()?.into(),

            })
        },
        _ => {
            Err(DecodeError::InvalidOpcode(op).into())
        },
        }
    }
}
} // mod zwp_relative_pointer_v1

pub use crate::zwp_relative_pointer_v1::ZwpRelativePointerV1;
pub use crate::zwp_relative_pointer_v1::Request as ZwpRelativePointerV1Request;
pub use crate::zwp_relative_pointer_v1::Event as ZwpRelativePointerV1Event;