wayland_server_protocol/
wayland_server_protocol.rs

1// GENERATED FILE -- DO NOT EDIT
2//
3// Copyright © 2008-2011 Kristian Høgsberg
4// Copyright © 2010-2011 Intel Corporation
5// Copyright © 2012-2013 Collabora, Ltd.
6// 
7// Permission is hereby granted, free of charge, to any person
8// obtaining a copy of this software and associated documentation files
9// (the "Software"), to deal in the Software without restriction,
10// including without limitation the rights to use, copy, modify, merge,
11// publish, distribute, sublicense, and/or sell copies of the Software,
12// and to permit persons to whom the Software is furnished to do so,
13// subject to the following conditions:
14// 
15// The above copyright notice and this permission notice (including the
16// next paragraph) shall be included in all copies or substantial
17// portions of the Software.
18// 
19// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22// NONINFRINGEMENT.  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23// BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26// SOFTWARE.
27
28#![allow(warnings)]
29#![allow(clippy::all)]
30use anyhow;
31#[allow(unused_imports)]
32use fuchsia_wayland_core::{Array, Enum, Fixed, NewId, NewObject};
33use fuchsia_wayland_core::{ArgKind, Arg, FromArgs, IntoMessage, Message,
34                            MessageGroupSpec, MessageHeader, MessageSpec, MessageType,
35                            ObjectId, EncodeError, DecodeError, Interface};
36pub mod wl_display {
37use super::*;
38
39/// core global object
40///
41/// The core global object.  This is a special singleton object.  It
42/// is used for internal Wayland protocol features.
43#[derive(Debug)]
44pub struct WlDisplay;
45
46impl Interface for WlDisplay {
47    const NAME: &'static str = "wl_display";
48    const VERSION: u32 = 1;
49    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
50        // sync
51        MessageSpec(&[
52            ArgKind::NewId,
53        ]),
54        // get_registry
55        MessageSpec(&[
56            ArgKind::NewId,
57        ]),
58    ]);
59    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
60        // error
61        MessageSpec(&[
62            ArgKind::Object,
63            ArgKind::Uint,
64            ArgKind::String,
65        ]),
66        // delete_id
67        MessageSpec(&[
68            ArgKind::Uint,
69        ]),
70    ]);
71    type Incoming = Request;
72    type Outgoing = Event;
73}
74
75#[derive(Debug)]
76pub enum Request {
77
78    /// asynchronous roundtrip
79    ///
80    /// The sync request asks the server to emit the 'done' event
81    /// on the returned wl_callback object.  Since requests are
82    /// handled in-order and events are delivered in-order, this can
83    /// be used as a barrier to ensure all previous requests and the
84    /// resulting events have been handled.
85    /// 
86    /// The object returned by this request will be destroyed by the
87    /// compositor after the callback is fired and as such the client must not
88    /// attempt to use it after that point.
89    /// 
90    /// The callback_data passed in the callback is the event serial.
91    Sync {
92        /// callback object for the sync request
93        callback: NewObject<WlCallback>,
94    },
95
96    /// get global registry object
97    ///
98    /// This request creates a registry object that allows the client
99    /// to list and bind the global objects available from the
100    /// compositor.
101    /// 
102    /// It should be noted that the server side resources consumed in
103    /// response to a get_registry request can only be released when the
104    /// client disconnects, not when the client side proxy is destroyed.
105    /// Therefore, clients should invoke get_registry as infrequently as
106    /// possible to avoid wasting memory.
107    GetRegistry {
108        /// global registry object
109        registry: NewObject<WlRegistry>,
110    },
111}
112
113impl MessageType for Request {
114    fn log(&self, this: ObjectId) -> String {
115        match *self {
116            Request::Sync {
117                ref callback,
118            } => {
119                format!("wl_display@{:?}::sync(callback: {:?})", this, callback)
120            }
121            Request::GetRegistry {
122                ref registry,
123            } => {
124                format!("wl_display@{:?}::get_registry(registry: {:?})", this, registry)
125            }
126        }
127    }
128    fn message_name(&self) -> &'static std::ffi::CStr{
129        match *self {
130            Request::Sync { .. } => c"wl_display::sync",
131            Request::GetRegistry { .. } => c"wl_display::get_registry",
132        }
133    }
134}
135#[derive(Debug)]
136pub enum Event {
137
138    /// fatal error event
139    ///
140    /// The error event is sent out when a fatal (non-recoverable)
141    /// error has occurred.  The object_id argument is the object
142    /// where the error occurred, most often in response to a request
143    /// to that object.  The code identifies the error and is defined
144    /// by the object interface.  As such, each interface defines its
145    /// own set of error codes.  The message is a brief description
146    /// of the error, for (debugging) convenience.
147    Error {
148        /// object where the error occurred
149        object_id: ObjectId,
150        /// error code
151        code: u32,
152        /// error description
153        message: String,
154    },
155
156    /// acknowledge object ID deletion
157    ///
158    /// This event is used internally by the object ID management
159    /// logic. When a client deletes an object that it had created,
160    /// the server will send this event to acknowledge that it has
161    /// seen the delete request. When the client receives this event,
162    /// it will know that it can safely reuse the object ID.
163    DeleteId {
164        /// deleted object ID
165        id: u32,
166    },
167}
168
169impl MessageType for Event {
170    fn log(&self, this: ObjectId) -> String {
171        match *self {
172            Event::Error {
173                ref object_id,
174                ref code,
175                ref message,
176            } => {
177                format!("wl_display@{:?}::error(object_id: {:?}, code: {:?}, message: {:?})", this, object_id, code, message)
178            }
179            Event::DeleteId {
180                ref id,
181            } => {
182                format!("wl_display@{:?}::delete_id(id: {:?})", this, id)
183            }
184        }
185    }
186    fn message_name(&self) -> &'static std::ffi::CStr{
187        match *self {
188            Event::Error { .. } => c"wl_display::error",
189            Event::DeleteId { .. } => c"wl_display::delete_id",
190        }
191    }
192}
193impl IntoMessage for Event {
194    type Error = EncodeError;
195    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
196        let mut header = MessageHeader {
197            sender: id,
198            opcode: 0,
199            length: 0,
200        };
201        let mut msg = Message::new();
202        msg.write_header(&header)?;
203        match self {
204        Event::Error {
205            object_id,
206            code,
207            message,
208        } => {
209            msg.write_arg(Arg::Object(object_id))?;
210            msg.write_arg(Arg::Uint(code))?;
211            msg.write_arg(Arg::String(message))?;
212            header.opcode = 0;
213        },
214        Event::DeleteId {
215            id,
216        } => {
217            msg.write_arg(Arg::Uint(id))?;
218            header.opcode = 1;
219        },
220        }
221        header.length = msg.bytes().len() as u16;
222        msg.rewind();
223        msg.write_header(&header)?;
224        Ok(msg)
225    }
226}
227impl FromArgs for Request {
228    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
229        match op {
230        0 /* sync */ => {
231            let mut iter = args.into_iter();
232            Ok(Request::Sync {
233                callback: iter.next()
234                                             .ok_or(DecodeError::InsufficientArgs)?
235                                             .as_new_id()?.into(),
236
237            })
238        },
239        1 /* get_registry */ => {
240            let mut iter = args.into_iter();
241            Ok(Request::GetRegistry {
242                registry: iter.next()
243                                             .ok_or(DecodeError::InsufficientArgs)?
244                                             .as_new_id()?.into(),
245
246            })
247        },
248        _ => {
249            Err(DecodeError::InvalidOpcode(op).into())
250        },
251        }
252    }
253}
254
255/// global error values
256///
257/// These errors are global and can be emitted in response to any
258/// server request.
259#[derive(Copy, Clone, Debug, Eq, PartialEq)]
260#[repr(u32)]
261pub enum Error {
262    /// server couldn't find object,
263    InvalidObject = 0,
264    /// method doesn't exist on the specified interface or malformed request,
265    InvalidMethod = 1,
266    /// server is out of memory,
267    NoMemory = 2,
268    /// implementation error in compositor,
269    Implementation = 3,
270}
271
272impl Error {
273    pub fn from_bits(v: u32) -> Option<Self> {
274        match v {
275        0 => Some(Error::InvalidObject),
276        1 => Some(Error::InvalidMethod),
277        2 => Some(Error::NoMemory),
278        3 => Some(Error::Implementation),
279        _ => None,
280        }
281    }
282
283    pub fn bits(&self) -> u32 {
284        *self as u32
285    }
286}
287impl Into<Arg> for Error {
288    fn into(self) -> Arg {
289        Arg::Uint(self.bits())
290    }
291}
292} // mod wl_display
293
294pub use crate::wl_display::WlDisplay;
295pub use crate::wl_display::Request as WlDisplayRequest;
296pub use crate::wl_display::Event as WlDisplayEvent;
297pub mod wl_registry {
298use super::*;
299
300/// global registry object
301///
302/// The singleton global registry object.  The server has a number of
303/// global objects that are available to all clients.  These objects
304/// typically represent an actual object in the server (for example,
305/// an input device) or they are singleton objects that provide
306/// extension functionality.
307/// 
308/// When a client creates a registry object, the registry object
309/// will emit a global event for each global currently in the
310/// registry.  Globals come and go as a result of device or
311/// monitor hotplugs, reconfiguration or other events, and the
312/// registry will send out global and global_remove events to
313/// keep the client up to date with the changes.  To mark the end
314/// of the initial burst of events, the client can use the
315/// wl_display.sync request immediately after calling
316/// wl_display.get_registry.
317/// 
318/// A client can bind to a global object by using the bind
319/// request.  This creates a client-side handle that lets the object
320/// emit events to the client and lets the client invoke requests on
321/// the object.
322#[derive(Debug)]
323pub struct WlRegistry;
324
325impl Interface for WlRegistry {
326    const NAME: &'static str = "wl_registry";
327    const VERSION: u32 = 1;
328    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
329        // bind
330        MessageSpec(&[
331            ArgKind::Uint,
332            ArgKind::String,
333            ArgKind::Uint,
334            ArgKind::NewId,
335        ]),
336    ]);
337    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
338        // global
339        MessageSpec(&[
340            ArgKind::Uint,
341            ArgKind::String,
342            ArgKind::Uint,
343        ]),
344        // global_remove
345        MessageSpec(&[
346            ArgKind::Uint,
347        ]),
348    ]);
349    type Incoming = Request;
350    type Outgoing = Event;
351}
352
353#[derive(Debug)]
354pub enum Request {
355
356    /// bind an object to the display
357    ///
358    /// Binds a new, client-created object to the server using the
359    /// specified name as the identifier.
360    Bind {
361        /// unique numeric name of the object
362        name: u32,
363        id_interface_name: String,
364        id_interface_version: u32,
365        /// bounded object
366        id: ObjectId,
367    },
368}
369
370impl MessageType for Request {
371    fn log(&self, this: ObjectId) -> String {
372        match *self {
373            Request::Bind {
374                ref name,
375                ref id_interface_name,
376                ref id_interface_version,
377                ref id,
378            } => {
379                format!("wl_registry@{:?}::bind(name: {:?}, id_interface_name: {:?}, id_interface_version: {:?}, id: {:?})", this, name, id_interface_name, id_interface_version, id)
380            }
381        }
382    }
383    fn message_name(&self) -> &'static std::ffi::CStr{
384        match *self {
385            Request::Bind { .. } => c"wl_registry::bind",
386        }
387    }
388}
389#[derive(Debug)]
390pub enum Event {
391
392    /// announce global object
393    ///
394    /// Notify the client of global objects.
395    /// 
396    /// The event notifies the client that a global object with
397    /// the given name is now available, and it implements the
398    /// given version of the given interface.
399    Global {
400        /// numeric name of the global object
401        name: u32,
402        /// interface implemented by the object
403        interface: String,
404        /// interface version
405        version: u32,
406    },
407
408    /// announce removal of global object
409    ///
410    /// Notify the client of removed global objects.
411    /// 
412    /// This event notifies the client that the global identified
413    /// by name is no longer available.  If the client bound to
414    /// the global using the bind request, the client should now
415    /// destroy that object.
416    /// 
417    /// The object remains valid and requests to the object will be
418    /// ignored until the client destroys it, to avoid races between
419    /// the global going away and a client sending a request to it.
420    GlobalRemove {
421        /// numeric name of the global object
422        name: u32,
423    },
424}
425
426impl MessageType for Event {
427    fn log(&self, this: ObjectId) -> String {
428        match *self {
429            Event::Global {
430                ref name,
431                ref interface,
432                ref version,
433            } => {
434                format!("wl_registry@{:?}::global(name: {:?}, interface: {:?}, version: {:?})", this, name, interface, version)
435            }
436            Event::GlobalRemove {
437                ref name,
438            } => {
439                format!("wl_registry@{:?}::global_remove(name: {:?})", this, name)
440            }
441        }
442    }
443    fn message_name(&self) -> &'static std::ffi::CStr{
444        match *self {
445            Event::Global { .. } => c"wl_registry::global",
446            Event::GlobalRemove { .. } => c"wl_registry::global_remove",
447        }
448    }
449}
450impl IntoMessage for Event {
451    type Error = EncodeError;
452    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
453        let mut header = MessageHeader {
454            sender: id,
455            opcode: 0,
456            length: 0,
457        };
458        let mut msg = Message::new();
459        msg.write_header(&header)?;
460        match self {
461        Event::Global {
462            name,
463            interface,
464            version,
465        } => {
466            msg.write_arg(Arg::Uint(name))?;
467            msg.write_arg(Arg::String(interface))?;
468            msg.write_arg(Arg::Uint(version))?;
469            header.opcode = 0;
470        },
471        Event::GlobalRemove {
472            name,
473        } => {
474            msg.write_arg(Arg::Uint(name))?;
475            header.opcode = 1;
476        },
477        }
478        header.length = msg.bytes().len() as u16;
479        msg.rewind();
480        msg.write_header(&header)?;
481        Ok(msg)
482    }
483}
484impl FromArgs for Request {
485    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
486        match op {
487        0 /* bind */ => {
488            let mut iter = args.into_iter();
489            Ok(Request::Bind {
490                name: iter.next()
491                                             .ok_or(DecodeError::InsufficientArgs)?
492                                             .as_uint()?,
493                id_interface_name: iter.next()
494                                             .ok_or(DecodeError::InsufficientArgs)?
495                                             .as_string()?,
496                id_interface_version: iter.next()
497                                             .ok_or(DecodeError::InsufficientArgs)?
498                                             .as_uint()?,
499                id: iter.next()
500                                             .ok_or(DecodeError::InsufficientArgs)?
501                                             .as_new_id()?.into(),
502
503            })
504        },
505        _ => {
506            Err(DecodeError::InvalidOpcode(op).into())
507        },
508        }
509    }
510}
511} // mod wl_registry
512
513pub use crate::wl_registry::WlRegistry;
514pub use crate::wl_registry::Request as WlRegistryRequest;
515pub use crate::wl_registry::Event as WlRegistryEvent;
516pub mod wl_callback {
517use super::*;
518
519/// callback object
520///
521/// Clients can handle the 'done' event to get notified when
522/// the related request is done.
523#[derive(Debug)]
524pub struct WlCallback;
525
526impl Interface for WlCallback {
527    const NAME: &'static str = "wl_callback";
528    const VERSION: u32 = 1;
529    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
530    ]);
531    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
532        // done
533        MessageSpec(&[
534            ArgKind::Uint,
535        ]),
536    ]);
537    type Incoming = Request;
538    type Outgoing = Event;
539}
540
541#[derive(Debug)]
542pub enum Request {
543}
544
545impl MessageType for Request {
546    fn log(&self, this: ObjectId) -> String {
547        match *self {
548        }
549    }
550    fn message_name(&self) -> &'static std::ffi::CStr{
551        match *self {
552        }
553    }
554}
555#[derive(Debug)]
556pub enum Event {
557
558    /// done event
559    ///
560    /// Notify the client when the related request is done.
561    Done {
562        /// request-specific data for the callback
563        callback_data: u32,
564    },
565}
566
567impl MessageType for Event {
568    fn log(&self, this: ObjectId) -> String {
569        match *self {
570            Event::Done {
571                ref callback_data,
572            } => {
573                format!("wl_callback@{:?}::done(callback_data: {:?})", this, callback_data)
574            }
575        }
576    }
577    fn message_name(&self) -> &'static std::ffi::CStr{
578        match *self {
579            Event::Done { .. } => c"wl_callback::done",
580        }
581    }
582}
583impl IntoMessage for Event {
584    type Error = EncodeError;
585    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
586        let mut header = MessageHeader {
587            sender: id,
588            opcode: 0,
589            length: 0,
590        };
591        let mut msg = Message::new();
592        msg.write_header(&header)?;
593        match self {
594        Event::Done {
595            callback_data,
596        } => {
597            msg.write_arg(Arg::Uint(callback_data))?;
598            header.opcode = 0;
599        },
600        }
601        header.length = msg.bytes().len() as u16;
602        msg.rewind();
603        msg.write_header(&header)?;
604        Ok(msg)
605    }
606}
607impl FromArgs for Request {
608    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
609        match op {
610        _ => {
611            Err(DecodeError::InvalidOpcode(op).into())
612        },
613        }
614    }
615}
616} // mod wl_callback
617
618pub use crate::wl_callback::WlCallback;
619pub use crate::wl_callback::Request as WlCallbackRequest;
620pub use crate::wl_callback::Event as WlCallbackEvent;
621pub mod wl_compositor {
622use super::*;
623
624/// the compositor singleton
625///
626/// A compositor.  This object is a singleton global.  The
627/// compositor is in charge of combining the contents of multiple
628/// surfaces into one displayable output.
629#[derive(Debug)]
630pub struct WlCompositor;
631
632impl Interface for WlCompositor {
633    const NAME: &'static str = "wl_compositor";
634    const VERSION: u32 = 4;
635    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
636        // create_surface
637        MessageSpec(&[
638            ArgKind::NewId,
639        ]),
640        // create_region
641        MessageSpec(&[
642            ArgKind::NewId,
643        ]),
644    ]);
645    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
646    ]);
647    type Incoming = Request;
648    type Outgoing = Event;
649}
650
651#[derive(Debug)]
652pub enum Request {
653
654    /// create new surface
655    ///
656    /// Ask the compositor to create a new surface.
657    CreateSurface {
658        /// the new surface
659        id: NewObject<WlSurface>,
660    },
661
662    /// create new region
663    ///
664    /// Ask the compositor to create a new region.
665    CreateRegion {
666        /// the new region
667        id: NewObject<WlRegion>,
668    },
669}
670
671impl MessageType for Request {
672    fn log(&self, this: ObjectId) -> String {
673        match *self {
674            Request::CreateSurface {
675                ref id,
676            } => {
677                format!("wl_compositor@{:?}::create_surface(id: {:?})", this, id)
678            }
679            Request::CreateRegion {
680                ref id,
681            } => {
682                format!("wl_compositor@{:?}::create_region(id: {:?})", this, id)
683            }
684        }
685    }
686    fn message_name(&self) -> &'static std::ffi::CStr{
687        match *self {
688            Request::CreateSurface { .. } => c"wl_compositor::create_surface",
689            Request::CreateRegion { .. } => c"wl_compositor::create_region",
690        }
691    }
692}
693#[derive(Debug)]
694pub enum Event {
695}
696
697impl MessageType for Event {
698    fn log(&self, this: ObjectId) -> String {
699        match *self {
700        }
701    }
702    fn message_name(&self) -> &'static std::ffi::CStr{
703        match *self {
704        }
705    }
706}
707impl IntoMessage for Event {
708    type Error = EncodeError;
709    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
710        let mut header = MessageHeader {
711            sender: id,
712            opcode: 0,
713            length: 0,
714        };
715        let mut msg = Message::new();
716        msg.write_header(&header)?;
717        match self {
718        }
719        header.length = msg.bytes().len() as u16;
720        msg.rewind();
721        msg.write_header(&header)?;
722        Ok(msg)
723    }
724}
725impl FromArgs for Request {
726    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
727        match op {
728        0 /* create_surface */ => {
729            let mut iter = args.into_iter();
730            Ok(Request::CreateSurface {
731                id: iter.next()
732                                             .ok_or(DecodeError::InsufficientArgs)?
733                                             .as_new_id()?.into(),
734
735            })
736        },
737        1 /* create_region */ => {
738            let mut iter = args.into_iter();
739            Ok(Request::CreateRegion {
740                id: iter.next()
741                                             .ok_or(DecodeError::InsufficientArgs)?
742                                             .as_new_id()?.into(),
743
744            })
745        },
746        _ => {
747            Err(DecodeError::InvalidOpcode(op).into())
748        },
749        }
750    }
751}
752} // mod wl_compositor
753
754pub use crate::wl_compositor::WlCompositor;
755pub use crate::wl_compositor::Request as WlCompositorRequest;
756pub use crate::wl_compositor::Event as WlCompositorEvent;
757pub mod wl_shm_pool {
758use super::*;
759
760/// a shared memory pool
761///
762/// The wl_shm_pool object encapsulates a piece of memory shared
763/// between the compositor and client.  Through the wl_shm_pool
764/// object, the client can allocate shared memory wl_buffer objects.
765/// All objects created through the same pool share the same
766/// underlying mapped memory. Reusing the mapped memory avoids the
767/// setup/teardown overhead and is useful when interactively resizing
768/// a surface or for many small buffers.
769#[derive(Debug)]
770pub struct WlShmPool;
771
772impl Interface for WlShmPool {
773    const NAME: &'static str = "wl_shm_pool";
774    const VERSION: u32 = 1;
775    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
776        // create_buffer
777        MessageSpec(&[
778            ArgKind::NewId,
779            ArgKind::Int,
780            ArgKind::Int,
781            ArgKind::Int,
782            ArgKind::Int,
783            ArgKind::Uint,
784        ]),
785        // destroy
786        MessageSpec(&[
787        ]),
788        // resize
789        MessageSpec(&[
790            ArgKind::Int,
791        ]),
792    ]);
793    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
794    ]);
795    type Incoming = Request;
796    type Outgoing = Event;
797}
798
799#[derive(Debug)]
800pub enum Request {
801
802    /// create a buffer from the pool
803    ///
804    /// Create a wl_buffer object from the pool.
805    /// 
806    /// The buffer is created offset bytes into the pool and has
807    /// width and height as specified.  The stride argument specifies
808    /// the number of bytes from the beginning of one row to the beginning
809    /// of the next.  The format is the pixel format of the buffer and
810    /// must be one of those advertised through the wl_shm.format event.
811    /// 
812    /// A buffer will keep a reference to the pool it was created from
813    /// so it is valid to destroy the pool immediately after creating
814    /// a buffer from it.
815    CreateBuffer {
816        /// buffer to create
817        id: NewObject<WlBuffer>,
818        /// buffer byte offset within the pool
819        offset: i32,
820        /// buffer width, in pixels
821        width: i32,
822        /// buffer height, in pixels
823        height: i32,
824        /// number of bytes from the beginning of one row to the beginning of the next row
825        stride: i32,
826        /// buffer pixel format
827        format: Enum<crate::wl_shm::Format>,
828    },
829
830    /// destroy the pool
831    ///
832    /// Destroy the shared memory pool.
833    /// 
834    /// The mmapped memory will be released when all
835    /// buffers that have been created from this pool
836    /// are gone.
837    Destroy,
838
839    /// change the size of the pool mapping
840    ///
841    /// This request will cause the server to remap the backing memory
842    /// for the pool from the file descriptor passed when the pool was
843    /// created, but using the new size.  This request can only be
844    /// used to make the pool bigger.
845    Resize {
846        /// new size of the pool, in bytes
847        size: i32,
848    },
849}
850
851impl MessageType for Request {
852    fn log(&self, this: ObjectId) -> String {
853        match *self {
854            Request::CreateBuffer {
855                ref id,
856                ref offset,
857                ref width,
858                ref height,
859                ref stride,
860                ref format,
861            } => {
862                format!("wl_shm_pool@{:?}::create_buffer(id: {:?}, offset: {:?}, width: {:?}, height: {:?}, stride: {:?}, format: {:?})", this, id, offset, width, height, stride, format)
863            }
864            Request::Destroy {
865            } => {
866                format!("wl_shm_pool@{:?}::destroy()", this)
867            }
868            Request::Resize {
869                ref size,
870            } => {
871                format!("wl_shm_pool@{:?}::resize(size: {:?})", this, size)
872            }
873        }
874    }
875    fn message_name(&self) -> &'static std::ffi::CStr{
876        match *self {
877            Request::CreateBuffer { .. } => c"wl_shm_pool::create_buffer",
878            Request::Destroy { .. } => c"wl_shm_pool::destroy",
879            Request::Resize { .. } => c"wl_shm_pool::resize",
880        }
881    }
882}
883#[derive(Debug)]
884pub enum Event {
885}
886
887impl MessageType for Event {
888    fn log(&self, this: ObjectId) -> String {
889        match *self {
890        }
891    }
892    fn message_name(&self) -> &'static std::ffi::CStr{
893        match *self {
894        }
895    }
896}
897impl IntoMessage for Event {
898    type Error = EncodeError;
899    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
900        let mut header = MessageHeader {
901            sender: id,
902            opcode: 0,
903            length: 0,
904        };
905        let mut msg = Message::new();
906        msg.write_header(&header)?;
907        match self {
908        }
909        header.length = msg.bytes().len() as u16;
910        msg.rewind();
911        msg.write_header(&header)?;
912        Ok(msg)
913    }
914}
915impl FromArgs for Request {
916    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
917        match op {
918        0 /* create_buffer */ => {
919            let mut iter = args.into_iter();
920            Ok(Request::CreateBuffer {
921                id: iter.next()
922                                             .ok_or(DecodeError::InsufficientArgs)?
923                                             .as_new_id()?.into(),
924                offset: iter.next()
925                                             .ok_or(DecodeError::InsufficientArgs)?
926                                             .as_int()?,
927                width: iter.next()
928                                             .ok_or(DecodeError::InsufficientArgs)?
929                                             .as_int()?,
930                height: iter.next()
931                                             .ok_or(DecodeError::InsufficientArgs)?
932                                             .as_int()?,
933                stride: iter.next()
934                                             .ok_or(DecodeError::InsufficientArgs)?
935                                             .as_int()?,
936                format: iter.next()
937                                             .ok_or(DecodeError::InsufficientArgs)?
938                                             .as_uint().map(|i| match crate::wl_shm::Format::from_bits(i) {
939                                      Some(e) => Enum::Recognized(e),
940                                      None => Enum::Unrecognized(i),
941                                 })?,
942
943            })
944        },
945        1 /* destroy */ => {
946            let mut iter = args.into_iter();
947            Ok(Request::Destroy {
948
949            })
950        },
951        2 /* resize */ => {
952            let mut iter = args.into_iter();
953            Ok(Request::Resize {
954                size: iter.next()
955                                             .ok_or(DecodeError::InsufficientArgs)?
956                                             .as_int()?,
957
958            })
959        },
960        _ => {
961            Err(DecodeError::InvalidOpcode(op).into())
962        },
963        }
964    }
965}
966} // mod wl_shm_pool
967
968pub use crate::wl_shm_pool::WlShmPool;
969pub use crate::wl_shm_pool::Request as WlShmPoolRequest;
970pub use crate::wl_shm_pool::Event as WlShmPoolEvent;
971pub mod wl_shm {
972use super::*;
973
974/// shared memory support
975///
976/// A singleton global object that provides support for shared
977/// memory.
978/// 
979/// Clients can create wl_shm_pool objects using the create_pool
980/// request.
981/// 
982/// At connection setup time, the wl_shm object emits one or more
983/// format events to inform clients about the valid pixel formats
984/// that can be used for buffers.
985#[derive(Debug)]
986pub struct WlShm;
987
988impl Interface for WlShm {
989    const NAME: &'static str = "wl_shm";
990    const VERSION: u32 = 1;
991    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
992        // create_pool
993        MessageSpec(&[
994            ArgKind::NewId,
995            ArgKind::Handle,
996            ArgKind::Int,
997        ]),
998    ]);
999    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
1000        // format
1001        MessageSpec(&[
1002            ArgKind::Uint,
1003        ]),
1004    ]);
1005    type Incoming = Request;
1006    type Outgoing = Event;
1007}
1008
1009#[derive(Debug)]
1010pub enum Request {
1011
1012    /// create a shm pool
1013    ///
1014    /// Create a new wl_shm_pool object.
1015    /// 
1016    /// The pool can be used to create shared memory based buffer
1017    /// objects.  The server will mmap size bytes of the passed file
1018    /// descriptor, to use as backing memory for the pool.
1019    CreatePool {
1020        /// pool to create
1021        id: NewObject<WlShmPool>,
1022        /// file descriptor for the pool
1023        fd: zx::Handle,
1024        /// pool size, in bytes
1025        size: i32,
1026    },
1027}
1028
1029impl MessageType for Request {
1030    fn log(&self, this: ObjectId) -> String {
1031        match *self {
1032            Request::CreatePool {
1033                ref id,
1034                ref fd,
1035                ref size,
1036            } => {
1037                format!("wl_shm@{:?}::create_pool(id: {:?}, fd: <handle>, size: {:?})", this, id, size)
1038            }
1039        }
1040    }
1041    fn message_name(&self) -> &'static std::ffi::CStr{
1042        match *self {
1043            Request::CreatePool { .. } => c"wl_shm::create_pool",
1044        }
1045    }
1046}
1047#[derive(Debug)]
1048pub enum Event {
1049
1050    /// pixel format description
1051    ///
1052    /// Informs the client about a valid pixel format that
1053    /// can be used for buffers. Known formats include
1054    /// argb8888 and xrgb8888.
1055    Format {
1056        /// buffer pixel format
1057        format: Format,
1058    },
1059}
1060
1061impl MessageType for Event {
1062    fn log(&self, this: ObjectId) -> String {
1063        match *self {
1064            Event::Format {
1065                ref format,
1066            } => {
1067                format!("wl_shm@{:?}::format(format: {:?})", this, format)
1068            }
1069        }
1070    }
1071    fn message_name(&self) -> &'static std::ffi::CStr{
1072        match *self {
1073            Event::Format { .. } => c"wl_shm::format",
1074        }
1075    }
1076}
1077impl IntoMessage for Event {
1078    type Error = EncodeError;
1079    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
1080        let mut header = MessageHeader {
1081            sender: id,
1082            opcode: 0,
1083            length: 0,
1084        };
1085        let mut msg = Message::new();
1086        msg.write_header(&header)?;
1087        match self {
1088        Event::Format {
1089            format,
1090        } => {
1091            msg.write_arg(Arg::Uint(format.bits()))?;
1092            header.opcode = 0;
1093        },
1094        }
1095        header.length = msg.bytes().len() as u16;
1096        msg.rewind();
1097        msg.write_header(&header)?;
1098        Ok(msg)
1099    }
1100}
1101impl FromArgs for Request {
1102    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
1103        match op {
1104        0 /* create_pool */ => {
1105            let mut iter = args.into_iter();
1106            Ok(Request::CreatePool {
1107                id: iter.next()
1108                                             .ok_or(DecodeError::InsufficientArgs)?
1109                                             .as_new_id()?.into(),
1110                fd: iter.next()
1111                                             .ok_or(DecodeError::InsufficientArgs)?
1112                                             .as_handle()?,
1113                size: iter.next()
1114                                             .ok_or(DecodeError::InsufficientArgs)?
1115                                             .as_int()?,
1116
1117            })
1118        },
1119        _ => {
1120            Err(DecodeError::InvalidOpcode(op).into())
1121        },
1122        }
1123    }
1124}
1125
1126/// wl_shm error values
1127///
1128/// These errors can be emitted in response to wl_shm requests.
1129#[derive(Copy, Clone, Debug, Eq, PartialEq)]
1130#[repr(u32)]
1131pub enum Error {
1132    /// buffer format is not known,
1133    InvalidFormat = 0,
1134    /// invalid size or stride during pool or buffer creation,
1135    InvalidStride = 1,
1136    /// mmapping the file descriptor failed,
1137    InvalidFd = 2,
1138}
1139
1140impl Error {
1141    pub fn from_bits(v: u32) -> Option<Self> {
1142        match v {
1143        0 => Some(Error::InvalidFormat),
1144        1 => Some(Error::InvalidStride),
1145        2 => Some(Error::InvalidFd),
1146        _ => None,
1147        }
1148    }
1149
1150    pub fn bits(&self) -> u32 {
1151        *self as u32
1152    }
1153}
1154impl Into<Arg> for Error {
1155    fn into(self) -> Arg {
1156        Arg::Uint(self.bits())
1157    }
1158}
1159
1160/// pixel formats
1161///
1162/// This describes the memory layout of an individual pixel.
1163/// 
1164/// All renderers should support argb8888 and xrgb8888 but any other
1165/// formats are optional and may not be supported by the particular
1166/// renderer in use.
1167/// 
1168/// The drm format codes match the macros defined in drm_fourcc.h, except
1169/// argb8888 and xrgb8888. The formats actually supported by the compositor
1170/// will be reported by the format event.
1171#[derive(Copy, Clone, Debug, Eq, PartialEq)]
1172#[repr(u32)]
1173pub enum Format {
1174    /// 32-bit ARGB format, [31:0] A:R:G:B 8:8:8:8 little endian,
1175    Argb8888 = 0,
1176    /// 32-bit RGB format, [31:0] x:R:G:B 8:8:8:8 little endian,
1177    Xrgb8888 = 1,
1178    /// 8-bit color index format, [7:0] C,
1179    C8 = 538982467,
1180    /// 8-bit RGB format, [7:0] R:G:B 3:3:2,
1181    Rgb332 = 943867730,
1182    /// 8-bit BGR format, [7:0] B:G:R 2:3:3,
1183    Bgr233 = 944916290,
1184    /// 16-bit xRGB format, [15:0] x:R:G:B 4:4:4:4 little endian,
1185    Xrgb4444 = 842093144,
1186    /// 16-bit xBGR format, [15:0] x:B:G:R 4:4:4:4 little endian,
1187    Xbgr4444 = 842089048,
1188    /// 16-bit RGBx format, [15:0] R:G:B:x 4:4:4:4 little endian,
1189    Rgbx4444 = 842094674,
1190    /// 16-bit BGRx format, [15:0] B:G:R:x 4:4:4:4 little endian,
1191    Bgrx4444 = 842094658,
1192    /// 16-bit ARGB format, [15:0] A:R:G:B 4:4:4:4 little endian,
1193    Argb4444 = 842093121,
1194    /// 16-bit ABGR format, [15:0] A:B:G:R 4:4:4:4 little endian,
1195    Abgr4444 = 842089025,
1196    /// 16-bit RBGA format, [15:0] R:G:B:A 4:4:4:4 little endian,
1197    Rgba4444 = 842088786,
1198    /// 16-bit BGRA format, [15:0] B:G:R:A 4:4:4:4 little endian,
1199    Bgra4444 = 842088770,
1200    /// 16-bit xRGB format, [15:0] x:R:G:B 1:5:5:5 little endian,
1201    Xrgb1555 = 892424792,
1202    /// 16-bit xBGR 1555 format, [15:0] x:B:G:R 1:5:5:5 little endian,
1203    Xbgr1555 = 892420696,
1204    /// 16-bit RGBx 5551 format, [15:0] R:G:B:x 5:5:5:1 little endian,
1205    Rgbx5551 = 892426322,
1206    /// 16-bit BGRx 5551 format, [15:0] B:G:R:x 5:5:5:1 little endian,
1207    Bgrx5551 = 892426306,
1208    /// 16-bit ARGB 1555 format, [15:0] A:R:G:B 1:5:5:5 little endian,
1209    Argb1555 = 892424769,
1210    /// 16-bit ABGR 1555 format, [15:0] A:B:G:R 1:5:5:5 little endian,
1211    Abgr1555 = 892420673,
1212    /// 16-bit RGBA 5551 format, [15:0] R:G:B:A 5:5:5:1 little endian,
1213    Rgba5551 = 892420434,
1214    /// 16-bit BGRA 5551 format, [15:0] B:G:R:A 5:5:5:1 little endian,
1215    Bgra5551 = 892420418,
1216    /// 16-bit RGB 565 format, [15:0] R:G:B 5:6:5 little endian,
1217    Rgb565 = 909199186,
1218    /// 16-bit BGR 565 format, [15:0] B:G:R 5:6:5 little endian,
1219    Bgr565 = 909199170,
1220    /// 24-bit RGB format, [23:0] R:G:B little endian,
1221    Rgb888 = 875710290,
1222    /// 24-bit BGR format, [23:0] B:G:R little endian,
1223    Bgr888 = 875710274,
1224    /// 32-bit xBGR format, [31:0] x:B:G:R 8:8:8:8 little endian,
1225    Xbgr8888 = 875709016,
1226    /// 32-bit RGBx format, [31:0] R:G:B:x 8:8:8:8 little endian,
1227    Rgbx8888 = 875714642,
1228    /// 32-bit BGRx format, [31:0] B:G:R:x 8:8:8:8 little endian,
1229    Bgrx8888 = 875714626,
1230    /// 32-bit ABGR format, [31:0] A:B:G:R 8:8:8:8 little endian,
1231    Abgr8888 = 875708993,
1232    /// 32-bit RGBA format, [31:0] R:G:B:A 8:8:8:8 little endian,
1233    Rgba8888 = 875708754,
1234    /// 32-bit BGRA format, [31:0] B:G:R:A 8:8:8:8 little endian,
1235    Bgra8888 = 875708738,
1236    /// 32-bit xRGB format, [31:0] x:R:G:B 2:10:10:10 little endian,
1237    Xrgb2101010 = 808669784,
1238    /// 32-bit xBGR format, [31:0] x:B:G:R 2:10:10:10 little endian,
1239    Xbgr2101010 = 808665688,
1240    /// 32-bit RGBx format, [31:0] R:G:B:x 10:10:10:2 little endian,
1241    Rgbx1010102 = 808671314,
1242    /// 32-bit BGRx format, [31:0] B:G:R:x 10:10:10:2 little endian,
1243    Bgrx1010102 = 808671298,
1244    /// 32-bit ARGB format, [31:0] A:R:G:B 2:10:10:10 little endian,
1245    Argb2101010 = 808669761,
1246    /// 32-bit ABGR format, [31:0] A:B:G:R 2:10:10:10 little endian,
1247    Abgr2101010 = 808665665,
1248    /// 32-bit RGBA format, [31:0] R:G:B:A 10:10:10:2 little endian,
1249    Rgba1010102 = 808665426,
1250    /// 32-bit BGRA format, [31:0] B:G:R:A 10:10:10:2 little endian,
1251    Bgra1010102 = 808665410,
1252    /// packed YCbCr format, [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian,
1253    Yuyv = 1448695129,
1254    /// packed YCbCr format, [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian,
1255    Yvyu = 1431918169,
1256    /// packed YCbCr format, [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian,
1257    Uyvy = 1498831189,
1258    /// packed YCbCr format, [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian,
1259    Vyuy = 1498765654,
1260    /// packed AYCbCr format, [31:0] A:Y:Cb:Cr 8:8:8:8 little endian,
1261    Ayuv = 1448433985,
1262    /// 2 plane YCbCr Cr:Cb format, 2x2 subsampled Cr:Cb plane,
1263    Nv12 = 842094158,
1264    /// 2 plane YCbCr Cb:Cr format, 2x2 subsampled Cb:Cr plane,
1265    Nv21 = 825382478,
1266    /// 2 plane YCbCr Cr:Cb format, 2x1 subsampled Cr:Cb plane,
1267    Nv16 = 909203022,
1268    /// 2 plane YCbCr Cb:Cr format, 2x1 subsampled Cb:Cr plane,
1269    Nv61 = 825644622,
1270    /// 3 plane YCbCr format, 4x4 subsampled Cb (1) and Cr (2) planes,
1271    Yuv410 = 961959257,
1272    /// 3 plane YCbCr format, 4x4 subsampled Cr (1) and Cb (2) planes,
1273    Yvu410 = 961893977,
1274    /// 3 plane YCbCr format, 4x1 subsampled Cb (1) and Cr (2) planes,
1275    Yuv411 = 825316697,
1276    /// 3 plane YCbCr format, 4x1 subsampled Cr (1) and Cb (2) planes,
1277    Yvu411 = 825316953,
1278    /// 3 plane YCbCr format, 2x2 subsampled Cb (1) and Cr (2) planes,
1279    Yuv420 = 842093913,
1280    /// 3 plane YCbCr format, 2x2 subsampled Cr (1) and Cb (2) planes,
1281    Yvu420 = 842094169,
1282    /// 3 plane YCbCr format, 2x1 subsampled Cb (1) and Cr (2) planes,
1283    Yuv422 = 909202777,
1284    /// 3 plane YCbCr format, 2x1 subsampled Cr (1) and Cb (2) planes,
1285    Yvu422 = 909203033,
1286    /// 3 plane YCbCr format, non-subsampled Cb (1) and Cr (2) planes,
1287    Yuv444 = 875713881,
1288    /// 3 plane YCbCr format, non-subsampled Cr (1) and Cb (2) planes,
1289    Yvu444 = 875714137,
1290    /// [7:0] R,
1291    R8 = 538982482,
1292    /// [15:0] R little endian,
1293    R16 = 540422482,
1294    /// [15:0] R:G 8:8 little endian,
1295    Rg88 = 943212370,
1296    /// [15:0] G:R 8:8 little endian,
1297    Gr88 = 943215175,
1298    /// [31:0] R:G 16:16 little endian,
1299    Rg1616 = 842221394,
1300    /// [31:0] G:R 16:16 little endian,
1301    Gr1616 = 842224199,
1302    /// [63:0] x:R:G:B 16:16:16:16 little endian,
1303    Xrgb16161616f = 1211388504,
1304    /// [63:0] x:B:G:R 16:16:16:16 little endian,
1305    Xbgr16161616f = 1211384408,
1306    /// [63:0] A:R:G:B 16:16:16:16 little endian,
1307    Argb16161616f = 1211388481,
1308    /// [63:0] A:B:G:R 16:16:16:16 little endian,
1309    Abgr16161616f = 1211384385,
1310    /// [31:0] X:Y:Cb:Cr 8:8:8:8 little endian,
1311    Xyuv8888 = 1448434008,
1312    /// [23:0] Cr:Cb:Y 8:8:8 little endian,
1313    Vuy888 = 875713878,
1314    /// Y followed by U then V, 10:10:10. Non-linear modifier only,
1315    Vuy101010 = 808670550,
1316    /// [63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 10:6:10:6:10:6:10:6 little endian per 2 Y pixels,
1317    Y210 = 808530521,
1318    /// [63:0] Cr0:0:Y1:0:Cb0:0:Y0:0 12:4:12:4:12:4:12:4 little endian per 2 Y pixels,
1319    Y212 = 842084953,
1320    /// [63:0] Cr0:Y1:Cb0:Y0 16:16:16:16 little endian per 2 Y pixels,
1321    Y216 = 909193817,
1322    /// [31:0] A:Cr:Y:Cb 2:10:10:10 little endian,
1323    Y410 = 808531033,
1324    /// [63:0] A:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian,
1325    Y412 = 842085465,
1326    /// [63:0] A:Cr:Y:Cb 16:16:16:16 little endian,
1327    Y416 = 909194329,
1328    /// [31:0] X:Cr:Y:Cb 2:10:10:10 little endian,
1329    Xvyu2101010 = 808670808,
1330    /// [63:0] X:0:Cr:0:Y:0:Cb:0 12:4:12:4:12:4:12:4 little endian,
1331    Xvyu1216161616 = 909334104,
1332    /// [63:0] X:Cr:Y:Cb 16:16:16:16 little endian,
1333    Xvyu16161616 = 942954072,
1334    /// [63:0]   A3:A2:Y3:0:Cr0:0:Y2:0:A1:A0:Y1:0:Cb0:0:Y0:0  1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian,
1335    Y0l0 = 810299481,
1336    /// [63:0]   X3:X2:Y3:0:Cr0:0:Y2:0:X1:X0:Y1:0:Cb0:0:Y0:0  1:1:8:2:8:2:8:2:1:1:8:2:8:2:8:2 little endian,
1337    X0l0 = 810299480,
1338    /// [63:0]   A3:A2:Y3:Cr0:Y2:A1:A0:Y1:Cb0:Y0  1:1:10:10:10:1:1:10:10:10 little endian,
1339    Y0l2 = 843853913,
1340    /// [63:0]   X3:X2:Y3:Cr0:Y2:X1:X0:Y1:Cb0:Y0  1:1:10:10:10:1:1:10:10:10 little endian,
1341    X0l2 = 843853912,
1342    Yuv4208bit = 942691673,
1343    Yuv42010bit = 808539481,
1344    Xrgb8888A8 = 943805016,
1345    Xbgr8888A8 = 943800920,
1346    Rgbx8888A8 = 943806546,
1347    Bgrx8888A8 = 943806530,
1348    Rgb888A8 = 943798354,
1349    Bgr888A8 = 943798338,
1350    Rgb565A8 = 943797586,
1351    Bgr565A8 = 943797570,
1352    /// non-subsampled Cr:Cb plane,
1353    Nv24 = 875714126,
1354    /// non-subsampled Cb:Cr plane,
1355    Nv42 = 842290766,
1356    /// 2x1 subsampled Cr:Cb plane, 10 bit per channel,
1357    P210 = 808530512,
1358    /// 2x2 subsampled Cr:Cb plane 10 bits per channel,
1359    P010 = 808530000,
1360    /// 2x2 subsampled Cr:Cb plane 12 bits per channel,
1361    P012 = 842084432,
1362    /// 2x2 subsampled Cr:Cb plane 16 bits per channel,
1363    P016 = 909193296,
1364}
1365
1366impl Format {
1367    pub fn from_bits(v: u32) -> Option<Self> {
1368        match v {
1369        0 => Some(Format::Argb8888),
1370        1 => Some(Format::Xrgb8888),
1371        538982467 => Some(Format::C8),
1372        943867730 => Some(Format::Rgb332),
1373        944916290 => Some(Format::Bgr233),
1374        842093144 => Some(Format::Xrgb4444),
1375        842089048 => Some(Format::Xbgr4444),
1376        842094674 => Some(Format::Rgbx4444),
1377        842094658 => Some(Format::Bgrx4444),
1378        842093121 => Some(Format::Argb4444),
1379        842089025 => Some(Format::Abgr4444),
1380        842088786 => Some(Format::Rgba4444),
1381        842088770 => Some(Format::Bgra4444),
1382        892424792 => Some(Format::Xrgb1555),
1383        892420696 => Some(Format::Xbgr1555),
1384        892426322 => Some(Format::Rgbx5551),
1385        892426306 => Some(Format::Bgrx5551),
1386        892424769 => Some(Format::Argb1555),
1387        892420673 => Some(Format::Abgr1555),
1388        892420434 => Some(Format::Rgba5551),
1389        892420418 => Some(Format::Bgra5551),
1390        909199186 => Some(Format::Rgb565),
1391        909199170 => Some(Format::Bgr565),
1392        875710290 => Some(Format::Rgb888),
1393        875710274 => Some(Format::Bgr888),
1394        875709016 => Some(Format::Xbgr8888),
1395        875714642 => Some(Format::Rgbx8888),
1396        875714626 => Some(Format::Bgrx8888),
1397        875708993 => Some(Format::Abgr8888),
1398        875708754 => Some(Format::Rgba8888),
1399        875708738 => Some(Format::Bgra8888),
1400        808669784 => Some(Format::Xrgb2101010),
1401        808665688 => Some(Format::Xbgr2101010),
1402        808671314 => Some(Format::Rgbx1010102),
1403        808671298 => Some(Format::Bgrx1010102),
1404        808669761 => Some(Format::Argb2101010),
1405        808665665 => Some(Format::Abgr2101010),
1406        808665426 => Some(Format::Rgba1010102),
1407        808665410 => Some(Format::Bgra1010102),
1408        1448695129 => Some(Format::Yuyv),
1409        1431918169 => Some(Format::Yvyu),
1410        1498831189 => Some(Format::Uyvy),
1411        1498765654 => Some(Format::Vyuy),
1412        1448433985 => Some(Format::Ayuv),
1413        842094158 => Some(Format::Nv12),
1414        825382478 => Some(Format::Nv21),
1415        909203022 => Some(Format::Nv16),
1416        825644622 => Some(Format::Nv61),
1417        961959257 => Some(Format::Yuv410),
1418        961893977 => Some(Format::Yvu410),
1419        825316697 => Some(Format::Yuv411),
1420        825316953 => Some(Format::Yvu411),
1421        842093913 => Some(Format::Yuv420),
1422        842094169 => Some(Format::Yvu420),
1423        909202777 => Some(Format::Yuv422),
1424        909203033 => Some(Format::Yvu422),
1425        875713881 => Some(Format::Yuv444),
1426        875714137 => Some(Format::Yvu444),
1427        538982482 => Some(Format::R8),
1428        540422482 => Some(Format::R16),
1429        943212370 => Some(Format::Rg88),
1430        943215175 => Some(Format::Gr88),
1431        842221394 => Some(Format::Rg1616),
1432        842224199 => Some(Format::Gr1616),
1433        1211388504 => Some(Format::Xrgb16161616f),
1434        1211384408 => Some(Format::Xbgr16161616f),
1435        1211388481 => Some(Format::Argb16161616f),
1436        1211384385 => Some(Format::Abgr16161616f),
1437        1448434008 => Some(Format::Xyuv8888),
1438        875713878 => Some(Format::Vuy888),
1439        808670550 => Some(Format::Vuy101010),
1440        808530521 => Some(Format::Y210),
1441        842084953 => Some(Format::Y212),
1442        909193817 => Some(Format::Y216),
1443        808531033 => Some(Format::Y410),
1444        842085465 => Some(Format::Y412),
1445        909194329 => Some(Format::Y416),
1446        808670808 => Some(Format::Xvyu2101010),
1447        909334104 => Some(Format::Xvyu1216161616),
1448        942954072 => Some(Format::Xvyu16161616),
1449        810299481 => Some(Format::Y0l0),
1450        810299480 => Some(Format::X0l0),
1451        843853913 => Some(Format::Y0l2),
1452        843853912 => Some(Format::X0l2),
1453        942691673 => Some(Format::Yuv4208bit),
1454        808539481 => Some(Format::Yuv42010bit),
1455        943805016 => Some(Format::Xrgb8888A8),
1456        943800920 => Some(Format::Xbgr8888A8),
1457        943806546 => Some(Format::Rgbx8888A8),
1458        943806530 => Some(Format::Bgrx8888A8),
1459        943798354 => Some(Format::Rgb888A8),
1460        943798338 => Some(Format::Bgr888A8),
1461        943797586 => Some(Format::Rgb565A8),
1462        943797570 => Some(Format::Bgr565A8),
1463        875714126 => Some(Format::Nv24),
1464        842290766 => Some(Format::Nv42),
1465        808530512 => Some(Format::P210),
1466        808530000 => Some(Format::P010),
1467        842084432 => Some(Format::P012),
1468        909193296 => Some(Format::P016),
1469        _ => None,
1470        }
1471    }
1472
1473    pub fn bits(&self) -> u32 {
1474        *self as u32
1475    }
1476}
1477impl Into<Arg> for Format {
1478    fn into(self) -> Arg {
1479        Arg::Uint(self.bits())
1480    }
1481}
1482} // mod wl_shm
1483
1484pub use crate::wl_shm::WlShm;
1485pub use crate::wl_shm::Request as WlShmRequest;
1486pub use crate::wl_shm::Event as WlShmEvent;
1487pub mod wl_buffer {
1488use super::*;
1489
1490/// content for a wl_surface
1491///
1492/// A buffer provides the content for a wl_surface. Buffers are
1493/// created through factory interfaces such as wl_drm, wl_shm or
1494/// similar. It has a width and a height and can be attached to a
1495/// wl_surface, but the mechanism by which a client provides and
1496/// updates the contents is defined by the buffer factory interface.
1497#[derive(Debug)]
1498pub struct WlBuffer;
1499
1500impl Interface for WlBuffer {
1501    const NAME: &'static str = "wl_buffer";
1502    const VERSION: u32 = 1;
1503    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
1504        // destroy
1505        MessageSpec(&[
1506        ]),
1507    ]);
1508    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
1509        // release
1510        MessageSpec(&[
1511        ]),
1512    ]);
1513    type Incoming = Request;
1514    type Outgoing = Event;
1515}
1516
1517#[derive(Debug)]
1518pub enum Request {
1519
1520    /// destroy a buffer
1521    ///
1522    /// Destroy a buffer. If and how you need to release the backing
1523    /// storage is defined by the buffer factory interface.
1524    /// 
1525    /// For possible side-effects to a surface, see wl_surface.attach.
1526    Destroy,
1527}
1528
1529impl MessageType for Request {
1530    fn log(&self, this: ObjectId) -> String {
1531        match *self {
1532            Request::Destroy {
1533            } => {
1534                format!("wl_buffer@{:?}::destroy()", this)
1535            }
1536        }
1537    }
1538    fn message_name(&self) -> &'static std::ffi::CStr{
1539        match *self {
1540            Request::Destroy { .. } => c"wl_buffer::destroy",
1541        }
1542    }
1543}
1544#[derive(Debug)]
1545pub enum Event {
1546
1547    /// compositor releases buffer
1548    ///
1549    /// Sent when this wl_buffer is no longer used by the compositor.
1550    /// The client is now free to reuse or destroy this buffer and its
1551    /// backing storage.
1552    /// 
1553    /// If a client receives a release event before the frame callback
1554    /// requested in the same wl_surface.commit that attaches this
1555    /// wl_buffer to a surface, then the client is immediately free to
1556    /// reuse the buffer and its backing storage, and does not need a
1557    /// second buffer for the next surface content update. Typically
1558    /// this is possible, when the compositor maintains a copy of the
1559    /// wl_surface contents, e.g. as a GL texture. This is an important
1560    /// optimization for GL(ES) compositors with wl_shm clients.
1561    Release,
1562}
1563
1564impl MessageType for Event {
1565    fn log(&self, this: ObjectId) -> String {
1566        match *self {
1567            Event::Release {
1568            } => {
1569                format!("wl_buffer@{:?}::release()", this)
1570            }
1571        }
1572    }
1573    fn message_name(&self) -> &'static std::ffi::CStr{
1574        match *self {
1575            Event::Release { .. } => c"wl_buffer::release",
1576        }
1577    }
1578}
1579impl IntoMessage for Event {
1580    type Error = EncodeError;
1581    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
1582        let mut header = MessageHeader {
1583            sender: id,
1584            opcode: 0,
1585            length: 0,
1586        };
1587        let mut msg = Message::new();
1588        msg.write_header(&header)?;
1589        match self {
1590        Event::Release {
1591        } => {
1592            header.opcode = 0;
1593        },
1594        }
1595        header.length = msg.bytes().len() as u16;
1596        msg.rewind();
1597        msg.write_header(&header)?;
1598        Ok(msg)
1599    }
1600}
1601impl FromArgs for Request {
1602    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
1603        match op {
1604        0 /* destroy */ => {
1605            let mut iter = args.into_iter();
1606            Ok(Request::Destroy {
1607
1608            })
1609        },
1610        _ => {
1611            Err(DecodeError::InvalidOpcode(op).into())
1612        },
1613        }
1614    }
1615}
1616} // mod wl_buffer
1617
1618pub use crate::wl_buffer::WlBuffer;
1619pub use crate::wl_buffer::Request as WlBufferRequest;
1620pub use crate::wl_buffer::Event as WlBufferEvent;
1621pub mod wl_data_offer {
1622use super::*;
1623
1624/// offer to transfer data
1625///
1626/// A wl_data_offer represents a piece of data offered for transfer
1627/// by another client (the source client).  It is used by the
1628/// copy-and-paste and drag-and-drop mechanisms.  The offer
1629/// describes the different mime types that the data can be
1630/// converted to and provides the mechanism for transferring the
1631/// data directly from the source client.
1632#[derive(Debug)]
1633pub struct WlDataOffer;
1634
1635impl Interface for WlDataOffer {
1636    const NAME: &'static str = "wl_data_offer";
1637    const VERSION: u32 = 3;
1638    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
1639        // accept
1640        MessageSpec(&[
1641            ArgKind::Uint,
1642            ArgKind::String,
1643        ]),
1644        // receive
1645        MessageSpec(&[
1646            ArgKind::String,
1647            ArgKind::Handle,
1648        ]),
1649        // destroy
1650        MessageSpec(&[
1651        ]),
1652        // finish
1653        MessageSpec(&[
1654        ]),
1655        // set_actions
1656        MessageSpec(&[
1657            ArgKind::Uint,
1658            ArgKind::Uint,
1659        ]),
1660    ]);
1661    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
1662        // offer
1663        MessageSpec(&[
1664            ArgKind::String,
1665        ]),
1666        // source_actions
1667        MessageSpec(&[
1668            ArgKind::Uint,
1669        ]),
1670        // action
1671        MessageSpec(&[
1672            ArgKind::Uint,
1673        ]),
1674    ]);
1675    type Incoming = Request;
1676    type Outgoing = Event;
1677}
1678
1679#[derive(Debug)]
1680pub enum Request {
1681
1682    /// accept one of the offered mime types
1683    ///
1684    /// Indicate that the client can accept the given mime type, or
1685    /// NULL for not accepted.
1686    /// 
1687    /// For objects of version 2 or older, this request is used by the
1688    /// client to give feedback whether the client can receive the given
1689    /// mime type, or NULL if none is accepted; the feedback does not
1690    /// determine whether the drag-and-drop operation succeeds or not.
1691    /// 
1692    /// For objects of version 3 or newer, this request determines the
1693    /// final result of the drag-and-drop operation. If the end result
1694    /// is that no mime types were accepted, the drag-and-drop operation
1695    /// will be cancelled and the corresponding drag source will receive
1696    /// wl_data_source.cancelled. Clients may still use this event in
1697    /// conjunction with wl_data_source.action for feedback.
1698    Accept {
1699        /// serial number of the accept request
1700        serial: u32,
1701        /// mime type accepted by the client
1702        mime_type: String,
1703    },
1704
1705    /// request that the data is transferred
1706    ///
1707    /// To transfer the offered data, the client issues this request
1708    /// and indicates the mime type it wants to receive.  The transfer
1709    /// happens through the passed file descriptor (typically created
1710    /// with the pipe system call).  The source client writes the data
1711    /// in the mime type representation requested and then closes the
1712    /// file descriptor.
1713    /// 
1714    /// The receiving client reads from the read end of the pipe until
1715    /// EOF and then closes its end, at which point the transfer is
1716    /// complete.
1717    /// 
1718    /// This request may happen multiple times for different mime types,
1719    /// both before and after wl_data_device.drop. Drag-and-drop destination
1720    /// clients may preemptively fetch data or examine it more closely to
1721    /// determine acceptance.
1722    Receive {
1723        /// mime type desired by receiver
1724        mime_type: String,
1725        /// file descriptor for data transfer
1726        fd: zx::Handle,
1727    },
1728
1729    /// destroy data offer
1730    ///
1731    /// Destroy the data offer.
1732    Destroy,
1733
1734    /// the offer will no longer be used
1735    ///
1736    /// Notifies the compositor that the drag destination successfully
1737    /// finished the drag-and-drop operation.
1738    /// 
1739    /// Upon receiving this request, the compositor will emit
1740    /// wl_data_source.dnd_finished on the drag source client.
1741    /// 
1742    /// It is a client error to perform other requests than
1743    /// wl_data_offer.destroy after this one. It is also an error to perform
1744    /// this request after a NULL mime type has been set in
1745    /// wl_data_offer.accept or no action was received through
1746    /// wl_data_offer.action.
1747    /// 
1748    /// If wl_data_offer.finish request is received for a non drag and drop
1749    /// operation, the invalid_finish protocol error is raised.
1750    Finish,
1751
1752    /// set the available/preferred drag-and-drop actions
1753    ///
1754    /// Sets the actions that the destination side client supports for
1755    /// this operation. This request may trigger the emission of
1756    /// wl_data_source.action and wl_data_offer.action events if the compositor
1757    /// needs to change the selected action.
1758    /// 
1759    /// This request can be called multiple times throughout the
1760    /// drag-and-drop operation, typically in response to wl_data_device.enter
1761    /// or wl_data_device.motion events.
1762    /// 
1763    /// This request determines the final result of the drag-and-drop
1764    /// operation. If the end result is that no action is accepted,
1765    /// the drag source will receive wl_data_source.cancelled.
1766    /// 
1767    /// The dnd_actions argument must contain only values expressed in the
1768    /// wl_data_device_manager.dnd_actions enum, and the preferred_action
1769    /// argument must only contain one of those values set, otherwise it
1770    /// will result in a protocol error.
1771    /// 
1772    /// While managing an "ask" action, the destination drag-and-drop client
1773    /// may perform further wl_data_offer.receive requests, and is expected
1774    /// to perform one last wl_data_offer.set_actions request with a preferred
1775    /// action other than "ask" (and optionally wl_data_offer.accept) before
1776    /// requesting wl_data_offer.finish, in order to convey the action selected
1777    /// by the user. If the preferred action is not in the
1778    /// wl_data_offer.source_actions mask, an error will be raised.
1779    /// 
1780    /// If the "ask" action is dismissed (e.g. user cancellation), the client
1781    /// is expected to perform wl_data_offer.destroy right away.
1782    /// 
1783    /// This request can only be made on drag-and-drop offers, a protocol error
1784    /// will be raised otherwise.
1785    SetActions {
1786        /// actions supported by the destination client
1787        dnd_actions: Enum<crate::wl_data_device_manager::DndAction>,
1788        /// action preferred by the destination client
1789        preferred_action: Enum<crate::wl_data_device_manager::DndAction>,
1790    },
1791}
1792
1793impl MessageType for Request {
1794    fn log(&self, this: ObjectId) -> String {
1795        match *self {
1796            Request::Accept {
1797                ref serial,
1798                ref mime_type,
1799            } => {
1800                format!("wl_data_offer@{:?}::accept(serial: {:?}, mime_type: {:?})", this, serial, mime_type)
1801            }
1802            Request::Receive {
1803                ref mime_type,
1804                ref fd,
1805            } => {
1806                format!("wl_data_offer@{:?}::receive(mime_type: {:?}, fd: <handle>)", this, mime_type)
1807            }
1808            Request::Destroy {
1809            } => {
1810                format!("wl_data_offer@{:?}::destroy()", this)
1811            }
1812            Request::Finish {
1813            } => {
1814                format!("wl_data_offer@{:?}::finish()", this)
1815            }
1816            Request::SetActions {
1817                ref dnd_actions,
1818                ref preferred_action,
1819            } => {
1820                format!("wl_data_offer@{:?}::set_actions(dnd_actions: {:?}, preferred_action: {:?})", this, dnd_actions, preferred_action)
1821            }
1822        }
1823    }
1824    fn message_name(&self) -> &'static std::ffi::CStr{
1825        match *self {
1826            Request::Accept { .. } => c"wl_data_offer::accept",
1827            Request::Receive { .. } => c"wl_data_offer::receive",
1828            Request::Destroy { .. } => c"wl_data_offer::destroy",
1829            Request::Finish { .. } => c"wl_data_offer::finish",
1830            Request::SetActions { .. } => c"wl_data_offer::set_actions",
1831        }
1832    }
1833}
1834#[derive(Debug)]
1835pub enum Event {
1836
1837    /// advertise offered mime type
1838    ///
1839    /// Sent immediately after creating the wl_data_offer object.  One
1840    /// event per offered mime type.
1841    Offer {
1842        /// offered mime type
1843        mime_type: String,
1844    },
1845
1846    /// notify the source-side available actions
1847    ///
1848    /// This event indicates the actions offered by the data source. It
1849    /// will be sent right after wl_data_device.enter, or anytime the source
1850    /// side changes its offered actions through wl_data_source.set_actions.
1851    SourceActions {
1852        /// actions offered by the data source
1853        source_actions: crate::wl_data_device_manager::DndAction,
1854    },
1855
1856    /// notify the selected action
1857    ///
1858    /// This event indicates the action selected by the compositor after
1859    /// matching the source/destination side actions. Only one action (or
1860    /// none) will be offered here.
1861    /// 
1862    /// This event can be emitted multiple times during the drag-and-drop
1863    /// operation in response to destination side action changes through
1864    /// wl_data_offer.set_actions.
1865    /// 
1866    /// This event will no longer be emitted after wl_data_device.drop
1867    /// happened on the drag-and-drop destination, the client must
1868    /// honor the last action received, or the last preferred one set
1869    /// through wl_data_offer.set_actions when handling an "ask" action.
1870    /// 
1871    /// Compositors may also change the selected action on the fly, mainly
1872    /// in response to keyboard modifier changes during the drag-and-drop
1873    /// operation.
1874    /// 
1875    /// The most recent action received is always the valid one. Prior to
1876    /// receiving wl_data_device.drop, the chosen action may change (e.g.
1877    /// due to keyboard modifiers being pressed). At the time of receiving
1878    /// wl_data_device.drop the drag-and-drop destination must honor the
1879    /// last action received.
1880    /// 
1881    /// Action changes may still happen after wl_data_device.drop,
1882    /// especially on "ask" actions, where the drag-and-drop destination
1883    /// may choose another action afterwards. Action changes happening
1884    /// at this stage are always the result of inter-client negotiation, the
1885    /// compositor shall no longer be able to induce a different action.
1886    /// 
1887    /// Upon "ask" actions, it is expected that the drag-and-drop destination
1888    /// may potentially choose a different action and/or mime type,
1889    /// based on wl_data_offer.source_actions and finally chosen by the
1890    /// user (e.g. popping up a menu with the available options). The
1891    /// final wl_data_offer.set_actions and wl_data_offer.accept requests
1892    /// must happen before the call to wl_data_offer.finish.
1893    Action {
1894        /// action selected by the compositor
1895        dnd_action: crate::wl_data_device_manager::DndAction,
1896    },
1897}
1898
1899impl MessageType for Event {
1900    fn log(&self, this: ObjectId) -> String {
1901        match *self {
1902            Event::Offer {
1903                ref mime_type,
1904            } => {
1905                format!("wl_data_offer@{:?}::offer(mime_type: {:?})", this, mime_type)
1906            }
1907            Event::SourceActions {
1908                ref source_actions,
1909            } => {
1910                format!("wl_data_offer@{:?}::source_actions(source_actions: {:?})", this, source_actions)
1911            }
1912            Event::Action {
1913                ref dnd_action,
1914            } => {
1915                format!("wl_data_offer@{:?}::action(dnd_action: {:?})", this, dnd_action)
1916            }
1917        }
1918    }
1919    fn message_name(&self) -> &'static std::ffi::CStr{
1920        match *self {
1921            Event::Offer { .. } => c"wl_data_offer::offer",
1922            Event::SourceActions { .. } => c"wl_data_offer::source_actions",
1923            Event::Action { .. } => c"wl_data_offer::action",
1924        }
1925    }
1926}
1927impl IntoMessage for Event {
1928    type Error = EncodeError;
1929    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
1930        let mut header = MessageHeader {
1931            sender: id,
1932            opcode: 0,
1933            length: 0,
1934        };
1935        let mut msg = Message::new();
1936        msg.write_header(&header)?;
1937        match self {
1938        Event::Offer {
1939            mime_type,
1940        } => {
1941            msg.write_arg(Arg::String(mime_type))?;
1942            header.opcode = 0;
1943        },
1944        Event::SourceActions {
1945            source_actions,
1946        } => {
1947            msg.write_arg(Arg::Uint(source_actions.bits()))?;
1948            header.opcode = 1;
1949        },
1950        Event::Action {
1951            dnd_action,
1952        } => {
1953            msg.write_arg(Arg::Uint(dnd_action.bits()))?;
1954            header.opcode = 2;
1955        },
1956        }
1957        header.length = msg.bytes().len() as u16;
1958        msg.rewind();
1959        msg.write_header(&header)?;
1960        Ok(msg)
1961    }
1962}
1963impl FromArgs for Request {
1964    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
1965        match op {
1966        0 /* accept */ => {
1967            let mut iter = args.into_iter();
1968            Ok(Request::Accept {
1969                serial: iter.next()
1970                                             .ok_or(DecodeError::InsufficientArgs)?
1971                                             .as_uint()?,
1972                mime_type: iter.next()
1973                                             .ok_or(DecodeError::InsufficientArgs)?
1974                                             .as_string()?,
1975
1976            })
1977        },
1978        1 /* receive */ => {
1979            let mut iter = args.into_iter();
1980            Ok(Request::Receive {
1981                mime_type: iter.next()
1982                                             .ok_or(DecodeError::InsufficientArgs)?
1983                                             .as_string()?,
1984                fd: iter.next()
1985                                             .ok_or(DecodeError::InsufficientArgs)?
1986                                             .as_handle()?,
1987
1988            })
1989        },
1990        2 /* destroy */ => {
1991            let mut iter = args.into_iter();
1992            Ok(Request::Destroy {
1993
1994            })
1995        },
1996        3 /* finish */ => {
1997            let mut iter = args.into_iter();
1998            Ok(Request::Finish {
1999
2000            })
2001        },
2002        4 /* set_actions */ => {
2003            let mut iter = args.into_iter();
2004            Ok(Request::SetActions {
2005                dnd_actions: iter.next()
2006                                             .ok_or(DecodeError::InsufficientArgs)?
2007                                             .as_uint().map(|i| match crate::wl_data_device_manager::DndAction::from_bits(i) {
2008                                      Some(e) => Enum::Recognized(e),
2009                                      None => Enum::Unrecognized(i),
2010                                 })?,
2011                preferred_action: iter.next()
2012                                             .ok_or(DecodeError::InsufficientArgs)?
2013                                             .as_uint().map(|i| match crate::wl_data_device_manager::DndAction::from_bits(i) {
2014                                      Some(e) => Enum::Recognized(e),
2015                                      None => Enum::Unrecognized(i),
2016                                 })?,
2017
2018            })
2019        },
2020        _ => {
2021            Err(DecodeError::InvalidOpcode(op).into())
2022        },
2023        }
2024    }
2025}
2026#[derive(Copy, Clone, Debug, Eq, PartialEq)]
2027#[repr(u32)]
2028pub enum Error {
2029    /// finish request was called untimely,
2030    InvalidFinish = 0,
2031    /// action mask contains invalid values,
2032    InvalidActionMask = 1,
2033    /// action argument has an invalid value,
2034    InvalidAction = 2,
2035    /// offer doesn't accept this request,
2036    InvalidOffer = 3,
2037}
2038
2039impl Error {
2040    pub fn from_bits(v: u32) -> Option<Self> {
2041        match v {
2042        0 => Some(Error::InvalidFinish),
2043        1 => Some(Error::InvalidActionMask),
2044        2 => Some(Error::InvalidAction),
2045        3 => Some(Error::InvalidOffer),
2046        _ => None,
2047        }
2048    }
2049
2050    pub fn bits(&self) -> u32 {
2051        *self as u32
2052    }
2053}
2054impl Into<Arg> for Error {
2055    fn into(self) -> Arg {
2056        Arg::Uint(self.bits())
2057    }
2058}
2059} // mod wl_data_offer
2060
2061pub use crate::wl_data_offer::WlDataOffer;
2062pub use crate::wl_data_offer::Request as WlDataOfferRequest;
2063pub use crate::wl_data_offer::Event as WlDataOfferEvent;
2064pub mod wl_data_source {
2065use super::*;
2066
2067/// offer to transfer data
2068///
2069/// The wl_data_source object is the source side of a wl_data_offer.
2070/// It is created by the source client in a data transfer and
2071/// provides a way to describe the offered data and a way to respond
2072/// to requests to transfer the data.
2073#[derive(Debug)]
2074pub struct WlDataSource;
2075
2076impl Interface for WlDataSource {
2077    const NAME: &'static str = "wl_data_source";
2078    const VERSION: u32 = 3;
2079    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
2080        // offer
2081        MessageSpec(&[
2082            ArgKind::String,
2083        ]),
2084        // destroy
2085        MessageSpec(&[
2086        ]),
2087        // set_actions
2088        MessageSpec(&[
2089            ArgKind::Uint,
2090        ]),
2091    ]);
2092    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
2093        // target
2094        MessageSpec(&[
2095            ArgKind::String,
2096        ]),
2097        // send
2098        MessageSpec(&[
2099            ArgKind::String,
2100            ArgKind::Handle,
2101        ]),
2102        // cancelled
2103        MessageSpec(&[
2104        ]),
2105        // dnd_drop_performed
2106        MessageSpec(&[
2107        ]),
2108        // dnd_finished
2109        MessageSpec(&[
2110        ]),
2111        // action
2112        MessageSpec(&[
2113            ArgKind::Uint,
2114        ]),
2115    ]);
2116    type Incoming = Request;
2117    type Outgoing = Event;
2118}
2119
2120#[derive(Debug)]
2121pub enum Request {
2122
2123    /// add an offered mime type
2124    ///
2125    /// This request adds a mime type to the set of mime types
2126    /// advertised to targets.  Can be called several times to offer
2127    /// multiple types.
2128    Offer {
2129        /// mime type offered by the data source
2130        mime_type: String,
2131    },
2132
2133    /// destroy the data source
2134    ///
2135    /// Destroy the data source.
2136    Destroy,
2137
2138    /// set the available drag-and-drop actions
2139    ///
2140    /// Sets the actions that the source side client supports for this
2141    /// operation. This request may trigger wl_data_source.action and
2142    /// wl_data_offer.action events if the compositor needs to change the
2143    /// selected action.
2144    /// 
2145    /// The dnd_actions argument must contain only values expressed in the
2146    /// wl_data_device_manager.dnd_actions enum, otherwise it will result
2147    /// in a protocol error.
2148    /// 
2149    /// This request must be made once only, and can only be made on sources
2150    /// used in drag-and-drop, so it must be performed before
2151    /// wl_data_device.start_drag. Attempting to use the source other than
2152    /// for drag-and-drop will raise a protocol error.
2153    SetActions {
2154        /// actions supported by the data source
2155        dnd_actions: Enum<crate::wl_data_device_manager::DndAction>,
2156    },
2157}
2158
2159impl MessageType for Request {
2160    fn log(&self, this: ObjectId) -> String {
2161        match *self {
2162            Request::Offer {
2163                ref mime_type,
2164            } => {
2165                format!("wl_data_source@{:?}::offer(mime_type: {:?})", this, mime_type)
2166            }
2167            Request::Destroy {
2168            } => {
2169                format!("wl_data_source@{:?}::destroy()", this)
2170            }
2171            Request::SetActions {
2172                ref dnd_actions,
2173            } => {
2174                format!("wl_data_source@{:?}::set_actions(dnd_actions: {:?})", this, dnd_actions)
2175            }
2176        }
2177    }
2178    fn message_name(&self) -> &'static std::ffi::CStr{
2179        match *self {
2180            Request::Offer { .. } => c"wl_data_source::offer",
2181            Request::Destroy { .. } => c"wl_data_source::destroy",
2182            Request::SetActions { .. } => c"wl_data_source::set_actions",
2183        }
2184    }
2185}
2186#[derive(Debug)]
2187pub enum Event {
2188
2189    /// a target accepts an offered mime type
2190    ///
2191    /// Sent when a target accepts pointer_focus or motion events.  If
2192    /// a target does not accept any of the offered types, type is NULL.
2193    /// 
2194    /// Used for feedback during drag-and-drop.
2195    Target {
2196        /// mime type accepted by the target
2197        mime_type: String,
2198    },
2199
2200    /// send the data
2201    ///
2202    /// Request for data from the client.  Send the data as the
2203    /// specified mime type over the passed file descriptor, then
2204    /// close it.
2205    Send {
2206        /// mime type for the data
2207        mime_type: String,
2208        /// file descriptor for the data
2209        fd: zx::Handle,
2210    },
2211
2212    /// selection was cancelled
2213    ///
2214    /// This data source is no longer valid. There are several reasons why
2215    /// this could happen:
2216    /// 
2217    /// - The data source has been replaced by another data source.
2218    /// - The drag-and-drop operation was performed, but the drop destination
2219    /// did not accept any of the mime types offered through
2220    /// wl_data_source.target.
2221    /// - The drag-and-drop operation was performed, but the drop destination
2222    /// did not select any of the actions present in the mask offered through
2223    /// wl_data_source.action.
2224    /// - The drag-and-drop operation was performed but didn't happen over a
2225    /// surface.
2226    /// - The compositor cancelled the drag-and-drop operation (e.g. compositor
2227    /// dependent timeouts to avoid stale drag-and-drop transfers).
2228    /// 
2229    /// The client should clean up and destroy this data source.
2230    /// 
2231    /// For objects of version 2 or older, wl_data_source.cancelled will
2232    /// only be emitted if the data source was replaced by another data
2233    /// source.
2234    Cancelled,
2235
2236    /// the drag-and-drop operation physically finished
2237    ///
2238    /// The user performed the drop action. This event does not indicate
2239    /// acceptance, wl_data_source.cancelled may still be emitted afterwards
2240    /// if the drop destination does not accept any mime type.
2241    /// 
2242    /// However, this event might however not be received if the compositor
2243    /// cancelled the drag-and-drop operation before this event could happen.
2244    /// 
2245    /// Note that the data_source may still be used in the future and should
2246    /// not be destroyed here.
2247    DndDropPerformed,
2248
2249    /// the drag-and-drop operation concluded
2250    ///
2251    /// The drop destination finished interoperating with this data
2252    /// source, so the client is now free to destroy this data source and
2253    /// free all associated data.
2254    /// 
2255    /// If the action used to perform the operation was "move", the
2256    /// source can now delete the transferred data.
2257    DndFinished,
2258
2259    /// notify the selected action
2260    ///
2261    /// This event indicates the action selected by the compositor after
2262    /// matching the source/destination side actions. Only one action (or
2263    /// none) will be offered here.
2264    /// 
2265    /// This event can be emitted multiple times during the drag-and-drop
2266    /// operation, mainly in response to destination side changes through
2267    /// wl_data_offer.set_actions, and as the data device enters/leaves
2268    /// surfaces.
2269    /// 
2270    /// It is only possible to receive this event after
2271    /// wl_data_source.dnd_drop_performed if the drag-and-drop operation
2272    /// ended in an "ask" action, in which case the final wl_data_source.action
2273    /// event will happen immediately before wl_data_source.dnd_finished.
2274    /// 
2275    /// Compositors may also change the selected action on the fly, mainly
2276    /// in response to keyboard modifier changes during the drag-and-drop
2277    /// operation.
2278    /// 
2279    /// The most recent action received is always the valid one. The chosen
2280    /// action may change alongside negotiation (e.g. an "ask" action can turn
2281    /// into a "move" operation), so the effects of the final action must
2282    /// always be applied in wl_data_offer.dnd_finished.
2283    /// 
2284    /// Clients can trigger cursor surface changes from this point, so
2285    /// they reflect the current action.
2286    Action {
2287        /// action selected by the compositor
2288        dnd_action: crate::wl_data_device_manager::DndAction,
2289    },
2290}
2291
2292impl MessageType for Event {
2293    fn log(&self, this: ObjectId) -> String {
2294        match *self {
2295            Event::Target {
2296                ref mime_type,
2297            } => {
2298                format!("wl_data_source@{:?}::target(mime_type: {:?})", this, mime_type)
2299            }
2300            Event::Send {
2301                ref mime_type,
2302                ref fd,
2303            } => {
2304                format!("wl_data_source@{:?}::send(mime_type: {:?}, fd: <handle>)", this, mime_type)
2305            }
2306            Event::Cancelled {
2307            } => {
2308                format!("wl_data_source@{:?}::cancelled()", this)
2309            }
2310            Event::DndDropPerformed {
2311            } => {
2312                format!("wl_data_source@{:?}::dnd_drop_performed()", this)
2313            }
2314            Event::DndFinished {
2315            } => {
2316                format!("wl_data_source@{:?}::dnd_finished()", this)
2317            }
2318            Event::Action {
2319                ref dnd_action,
2320            } => {
2321                format!("wl_data_source@{:?}::action(dnd_action: {:?})", this, dnd_action)
2322            }
2323        }
2324    }
2325    fn message_name(&self) -> &'static std::ffi::CStr{
2326        match *self {
2327            Event::Target { .. } => c"wl_data_source::target",
2328            Event::Send { .. } => c"wl_data_source::send",
2329            Event::Cancelled { .. } => c"wl_data_source::cancelled",
2330            Event::DndDropPerformed { .. } => c"wl_data_source::dnd_drop_performed",
2331            Event::DndFinished { .. } => c"wl_data_source::dnd_finished",
2332            Event::Action { .. } => c"wl_data_source::action",
2333        }
2334    }
2335}
2336impl IntoMessage for Event {
2337    type Error = EncodeError;
2338    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
2339        let mut header = MessageHeader {
2340            sender: id,
2341            opcode: 0,
2342            length: 0,
2343        };
2344        let mut msg = Message::new();
2345        msg.write_header(&header)?;
2346        match self {
2347        Event::Target {
2348            mime_type,
2349        } => {
2350            msg.write_arg(Arg::String(mime_type))?;
2351            header.opcode = 0;
2352        },
2353        Event::Send {
2354            mime_type,
2355            fd,
2356        } => {
2357            msg.write_arg(Arg::String(mime_type))?;
2358            msg.write_arg(Arg::Handle(fd))?;
2359            header.opcode = 1;
2360        },
2361        Event::Cancelled {
2362        } => {
2363            header.opcode = 2;
2364        },
2365        Event::DndDropPerformed {
2366        } => {
2367            header.opcode = 3;
2368        },
2369        Event::DndFinished {
2370        } => {
2371            header.opcode = 4;
2372        },
2373        Event::Action {
2374            dnd_action,
2375        } => {
2376            msg.write_arg(Arg::Uint(dnd_action.bits()))?;
2377            header.opcode = 5;
2378        },
2379        }
2380        header.length = msg.bytes().len() as u16;
2381        msg.rewind();
2382        msg.write_header(&header)?;
2383        Ok(msg)
2384    }
2385}
2386impl FromArgs for Request {
2387    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
2388        match op {
2389        0 /* offer */ => {
2390            let mut iter = args.into_iter();
2391            Ok(Request::Offer {
2392                mime_type: iter.next()
2393                                             .ok_or(DecodeError::InsufficientArgs)?
2394                                             .as_string()?,
2395
2396            })
2397        },
2398        1 /* destroy */ => {
2399            let mut iter = args.into_iter();
2400            Ok(Request::Destroy {
2401
2402            })
2403        },
2404        2 /* set_actions */ => {
2405            let mut iter = args.into_iter();
2406            Ok(Request::SetActions {
2407                dnd_actions: iter.next()
2408                                             .ok_or(DecodeError::InsufficientArgs)?
2409                                             .as_uint().map(|i| match crate::wl_data_device_manager::DndAction::from_bits(i) {
2410                                      Some(e) => Enum::Recognized(e),
2411                                      None => Enum::Unrecognized(i),
2412                                 })?,
2413
2414            })
2415        },
2416        _ => {
2417            Err(DecodeError::InvalidOpcode(op).into())
2418        },
2419        }
2420    }
2421}
2422#[derive(Copy, Clone, Debug, Eq, PartialEq)]
2423#[repr(u32)]
2424pub enum Error {
2425    /// action mask contains invalid values,
2426    InvalidActionMask = 0,
2427    /// source doesn't accept this request,
2428    InvalidSource = 1,
2429}
2430
2431impl Error {
2432    pub fn from_bits(v: u32) -> Option<Self> {
2433        match v {
2434        0 => Some(Error::InvalidActionMask),
2435        1 => Some(Error::InvalidSource),
2436        _ => None,
2437        }
2438    }
2439
2440    pub fn bits(&self) -> u32 {
2441        *self as u32
2442    }
2443}
2444impl Into<Arg> for Error {
2445    fn into(self) -> Arg {
2446        Arg::Uint(self.bits())
2447    }
2448}
2449} // mod wl_data_source
2450
2451pub use crate::wl_data_source::WlDataSource;
2452pub use crate::wl_data_source::Request as WlDataSourceRequest;
2453pub use crate::wl_data_source::Event as WlDataSourceEvent;
2454pub mod wl_data_device {
2455use super::*;
2456
2457/// data transfer device
2458///
2459/// There is one wl_data_device per seat which can be obtained
2460/// from the global wl_data_device_manager singleton.
2461/// 
2462/// A wl_data_device provides access to inter-client data transfer
2463/// mechanisms such as copy-and-paste and drag-and-drop.
2464#[derive(Debug)]
2465pub struct WlDataDevice;
2466
2467impl Interface for WlDataDevice {
2468    const NAME: &'static str = "wl_data_device";
2469    const VERSION: u32 = 3;
2470    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
2471        // start_drag
2472        MessageSpec(&[
2473            ArgKind::Object,
2474            ArgKind::Object,
2475            ArgKind::Object,
2476            ArgKind::Uint,
2477        ]),
2478        // set_selection
2479        MessageSpec(&[
2480            ArgKind::Object,
2481            ArgKind::Uint,
2482        ]),
2483        // release
2484        MessageSpec(&[
2485        ]),
2486    ]);
2487    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
2488        // data_offer
2489        MessageSpec(&[
2490            ArgKind::NewId,
2491        ]),
2492        // enter
2493        MessageSpec(&[
2494            ArgKind::Uint,
2495            ArgKind::Object,
2496            ArgKind::Fixed,
2497            ArgKind::Fixed,
2498            ArgKind::Object,
2499        ]),
2500        // leave
2501        MessageSpec(&[
2502        ]),
2503        // motion
2504        MessageSpec(&[
2505            ArgKind::Uint,
2506            ArgKind::Fixed,
2507            ArgKind::Fixed,
2508        ]),
2509        // drop
2510        MessageSpec(&[
2511        ]),
2512        // selection
2513        MessageSpec(&[
2514            ArgKind::Object,
2515        ]),
2516    ]);
2517    type Incoming = Request;
2518    type Outgoing = Event;
2519}
2520
2521#[derive(Debug)]
2522pub enum Request {
2523
2524    /// start drag-and-drop operation
2525    ///
2526    /// This request asks the compositor to start a drag-and-drop
2527    /// operation on behalf of the client.
2528    /// 
2529    /// The source argument is the data source that provides the data
2530    /// for the eventual data transfer. If source is NULL, enter, leave
2531    /// and motion events are sent only to the client that initiated the
2532    /// drag and the client is expected to handle the data passing
2533    /// internally.
2534    /// 
2535    /// The origin surface is the surface where the drag originates and
2536    /// the client must have an active implicit grab that matches the
2537    /// serial.
2538    /// 
2539    /// The icon surface is an optional (can be NULL) surface that
2540    /// provides an icon to be moved around with the cursor.  Initially,
2541    /// the top-left corner of the icon surface is placed at the cursor
2542    /// hotspot, but subsequent wl_surface.attach request can move the
2543    /// relative position. Attach requests must be confirmed with
2544    /// wl_surface.commit as usual. The icon surface is given the role of
2545    /// a drag-and-drop icon. If the icon surface already has another role,
2546    /// it raises a protocol error.
2547    /// 
2548    /// The current and pending input regions of the icon wl_surface are
2549    /// cleared, and wl_surface.set_input_region is ignored until the
2550    /// wl_surface is no longer used as the icon surface. When the use
2551    /// as an icon ends, the current and pending input regions become
2552    /// undefined, and the wl_surface is unmapped.
2553    StartDrag {
2554        /// data source for the eventual transfer
2555        source: ObjectId,
2556        /// surface where the drag originates
2557        origin: ObjectId,
2558        /// drag-and-drop icon surface
2559        icon: ObjectId,
2560        /// serial number of the implicit grab on the origin
2561        serial: u32,
2562    },
2563
2564    /// copy data to the selection
2565    ///
2566    /// This request asks the compositor to set the selection
2567    /// to the data from the source on behalf of the client.
2568    /// 
2569    /// To unset the selection, set the source to NULL.
2570    SetSelection {
2571        /// data source for the selection
2572        source: ObjectId,
2573        /// serial number of the event that triggered this request
2574        serial: u32,
2575    },
2576
2577    /// destroy data device
2578    ///
2579    /// This request destroys the data device.
2580    Release,
2581}
2582
2583impl MessageType for Request {
2584    fn log(&self, this: ObjectId) -> String {
2585        match *self {
2586            Request::StartDrag {
2587                ref source,
2588                ref origin,
2589                ref icon,
2590                ref serial,
2591            } => {
2592                format!("wl_data_device@{:?}::start_drag(source: {:?}, origin: {:?}, icon: {:?}, serial: {:?})", this, source, origin, icon, serial)
2593            }
2594            Request::SetSelection {
2595                ref source,
2596                ref serial,
2597            } => {
2598                format!("wl_data_device@{:?}::set_selection(source: {:?}, serial: {:?})", this, source, serial)
2599            }
2600            Request::Release {
2601            } => {
2602                format!("wl_data_device@{:?}::release()", this)
2603            }
2604        }
2605    }
2606    fn message_name(&self) -> &'static std::ffi::CStr{
2607        match *self {
2608            Request::StartDrag { .. } => c"wl_data_device::start_drag",
2609            Request::SetSelection { .. } => c"wl_data_device::set_selection",
2610            Request::Release { .. } => c"wl_data_device::release",
2611        }
2612    }
2613}
2614#[derive(Debug)]
2615pub enum Event {
2616
2617    /// introduce a new wl_data_offer
2618    ///
2619    /// The data_offer event introduces a new wl_data_offer object,
2620    /// which will subsequently be used in either the
2621    /// data_device.enter event (for drag-and-drop) or the
2622    /// data_device.selection event (for selections).  Immediately
2623    /// following the data_device_data_offer event, the new data_offer
2624    /// object will send out data_offer.offer events to describe the
2625    /// mime types it offers.
2626    DataOffer {
2627        /// the new data_offer object
2628        id: NewId,
2629    },
2630
2631    /// initiate drag-and-drop session
2632    ///
2633    /// This event is sent when an active drag-and-drop pointer enters
2634    /// a surface owned by the client.  The position of the pointer at
2635    /// enter time is provided by the x and y arguments, in surface-local
2636    /// coordinates.
2637    Enter {
2638        /// serial number of the enter event
2639        serial: u32,
2640        /// client surface entered
2641        surface: ObjectId,
2642        /// surface-local x coordinate
2643        x: Fixed,
2644        /// surface-local y coordinate
2645        y: Fixed,
2646        /// source data_offer object
2647        id: ObjectId,
2648    },
2649
2650    /// end drag-and-drop session
2651    ///
2652    /// This event is sent when the drag-and-drop pointer leaves the
2653    /// surface and the session ends.  The client must destroy the
2654    /// wl_data_offer introduced at enter time at this point.
2655    Leave,
2656
2657    /// drag-and-drop session motion
2658    ///
2659    /// This event is sent when the drag-and-drop pointer moves within
2660    /// the currently focused surface. The new position of the pointer
2661    /// is provided by the x and y arguments, in surface-local
2662    /// coordinates.
2663    Motion {
2664        /// timestamp with millisecond granularity
2665        time: u32,
2666        /// surface-local x coordinate
2667        x: Fixed,
2668        /// surface-local y coordinate
2669        y: Fixed,
2670    },
2671
2672    /// end drag-and-drop session successfully
2673    ///
2674    /// The event is sent when a drag-and-drop operation is ended
2675    /// because the implicit grab is removed.
2676    /// 
2677    /// The drag-and-drop destination is expected to honor the last action
2678    /// received through wl_data_offer.action, if the resulting action is
2679    /// "copy" or "move", the destination can still perform
2680    /// wl_data_offer.receive requests, and is expected to end all
2681    /// transfers with a wl_data_offer.finish request.
2682    /// 
2683    /// If the resulting action is "ask", the action will not be considered
2684    /// final. The drag-and-drop destination is expected to perform one last
2685    /// wl_data_offer.set_actions request, or wl_data_offer.destroy in order
2686    /// to cancel the operation.
2687    Drop,
2688
2689    /// advertise new selection
2690    ///
2691    /// The selection event is sent out to notify the client of a new
2692    /// wl_data_offer for the selection for this device.  The
2693    /// data_device.data_offer and the data_offer.offer events are
2694    /// sent out immediately before this event to introduce the data
2695    /// offer object.  The selection event is sent to a client
2696    /// immediately before receiving keyboard focus and when a new
2697    /// selection is set while the client has keyboard focus.  The
2698    /// data_offer is valid until a new data_offer or NULL is received
2699    /// or until the client loses keyboard focus.  The client must
2700    /// destroy the previous selection data_offer, if any, upon receiving
2701    /// this event.
2702    Selection {
2703        /// selection data_offer object
2704        id: ObjectId,
2705    },
2706}
2707
2708impl MessageType for Event {
2709    fn log(&self, this: ObjectId) -> String {
2710        match *self {
2711            Event::DataOffer {
2712                ref id,
2713            } => {
2714                format!("wl_data_device@{:?}::data_offer(id: {:?})", this, id)
2715            }
2716            Event::Enter {
2717                ref serial,
2718                ref surface,
2719                ref x,
2720                ref y,
2721                ref id,
2722            } => {
2723                format!("wl_data_device@{:?}::enter(serial: {:?}, surface: {:?}, x: {:?}, y: {:?}, id: {:?})", this, serial, surface, x, y, id)
2724            }
2725            Event::Leave {
2726            } => {
2727                format!("wl_data_device@{:?}::leave()", this)
2728            }
2729            Event::Motion {
2730                ref time,
2731                ref x,
2732                ref y,
2733            } => {
2734                format!("wl_data_device@{:?}::motion(time: {:?}, x: {:?}, y: {:?})", this, time, x, y)
2735            }
2736            Event::Drop {
2737            } => {
2738                format!("wl_data_device@{:?}::drop()", this)
2739            }
2740            Event::Selection {
2741                ref id,
2742            } => {
2743                format!("wl_data_device@{:?}::selection(id: {:?})", this, id)
2744            }
2745        }
2746    }
2747    fn message_name(&self) -> &'static std::ffi::CStr{
2748        match *self {
2749            Event::DataOffer { .. } => c"wl_data_device::data_offer",
2750            Event::Enter { .. } => c"wl_data_device::enter",
2751            Event::Leave { .. } => c"wl_data_device::leave",
2752            Event::Motion { .. } => c"wl_data_device::motion",
2753            Event::Drop { .. } => c"wl_data_device::drop",
2754            Event::Selection { .. } => c"wl_data_device::selection",
2755        }
2756    }
2757}
2758impl IntoMessage for Event {
2759    type Error = EncodeError;
2760    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
2761        let mut header = MessageHeader {
2762            sender: id,
2763            opcode: 0,
2764            length: 0,
2765        };
2766        let mut msg = Message::new();
2767        msg.write_header(&header)?;
2768        match self {
2769        Event::DataOffer {
2770            id,
2771        } => {
2772            msg.write_arg(Arg::NewId(id))?;
2773            header.opcode = 0;
2774        },
2775        Event::Enter {
2776            serial,
2777            surface,
2778            x,
2779            y,
2780            id,
2781        } => {
2782            msg.write_arg(Arg::Uint(serial))?;
2783            msg.write_arg(Arg::Object(surface))?;
2784            msg.write_arg(Arg::Fixed(x))?;
2785            msg.write_arg(Arg::Fixed(y))?;
2786            msg.write_arg(Arg::Object(id))?;
2787            header.opcode = 1;
2788        },
2789        Event::Leave {
2790        } => {
2791            header.opcode = 2;
2792        },
2793        Event::Motion {
2794            time,
2795            x,
2796            y,
2797        } => {
2798            msg.write_arg(Arg::Uint(time))?;
2799            msg.write_arg(Arg::Fixed(x))?;
2800            msg.write_arg(Arg::Fixed(y))?;
2801            header.opcode = 3;
2802        },
2803        Event::Drop {
2804        } => {
2805            header.opcode = 4;
2806        },
2807        Event::Selection {
2808            id,
2809        } => {
2810            msg.write_arg(Arg::Object(id))?;
2811            header.opcode = 5;
2812        },
2813        }
2814        header.length = msg.bytes().len() as u16;
2815        msg.rewind();
2816        msg.write_header(&header)?;
2817        Ok(msg)
2818    }
2819}
2820impl FromArgs for Request {
2821    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
2822        match op {
2823        0 /* start_drag */ => {
2824            let mut iter = args.into_iter();
2825            Ok(Request::StartDrag {
2826                source: iter.next()
2827                                             .ok_or(DecodeError::InsufficientArgs)?
2828                                             .as_object()?,
2829                origin: iter.next()
2830                                             .ok_or(DecodeError::InsufficientArgs)?
2831                                             .as_object()?,
2832                icon: iter.next()
2833                                             .ok_or(DecodeError::InsufficientArgs)?
2834                                             .as_object()?,
2835                serial: iter.next()
2836                                             .ok_or(DecodeError::InsufficientArgs)?
2837                                             .as_uint()?,
2838
2839            })
2840        },
2841        1 /* set_selection */ => {
2842            let mut iter = args.into_iter();
2843            Ok(Request::SetSelection {
2844                source: iter.next()
2845                                             .ok_or(DecodeError::InsufficientArgs)?
2846                                             .as_object()?,
2847                serial: iter.next()
2848                                             .ok_or(DecodeError::InsufficientArgs)?
2849                                             .as_uint()?,
2850
2851            })
2852        },
2853        2 /* release */ => {
2854            let mut iter = args.into_iter();
2855            Ok(Request::Release {
2856
2857            })
2858        },
2859        _ => {
2860            Err(DecodeError::InvalidOpcode(op).into())
2861        },
2862        }
2863    }
2864}
2865#[derive(Copy, Clone, Debug, Eq, PartialEq)]
2866#[repr(u32)]
2867pub enum Error {
2868    /// given wl_surface has another role,
2869    Role = 0,
2870}
2871
2872impl Error {
2873    pub fn from_bits(v: u32) -> Option<Self> {
2874        match v {
2875        0 => Some(Error::Role),
2876        _ => None,
2877        }
2878    }
2879
2880    pub fn bits(&self) -> u32 {
2881        *self as u32
2882    }
2883}
2884impl Into<Arg> for Error {
2885    fn into(self) -> Arg {
2886        Arg::Uint(self.bits())
2887    }
2888}
2889} // mod wl_data_device
2890
2891pub use crate::wl_data_device::WlDataDevice;
2892pub use crate::wl_data_device::Request as WlDataDeviceRequest;
2893pub use crate::wl_data_device::Event as WlDataDeviceEvent;
2894pub mod wl_data_device_manager {
2895use super::*;
2896
2897/// data transfer interface
2898///
2899/// The wl_data_device_manager is a singleton global object that
2900/// provides access to inter-client data transfer mechanisms such as
2901/// copy-and-paste and drag-and-drop.  These mechanisms are tied to
2902/// a wl_seat and this interface lets a client get a wl_data_device
2903/// corresponding to a wl_seat.
2904/// 
2905/// Depending on the version bound, the objects created from the bound
2906/// wl_data_device_manager object will have different requirements for
2907/// functioning properly. See wl_data_source.set_actions,
2908/// wl_data_offer.accept and wl_data_offer.finish for details.
2909#[derive(Debug)]
2910pub struct WlDataDeviceManager;
2911
2912impl Interface for WlDataDeviceManager {
2913    const NAME: &'static str = "wl_data_device_manager";
2914    const VERSION: u32 = 3;
2915    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
2916        // create_data_source
2917        MessageSpec(&[
2918            ArgKind::NewId,
2919        ]),
2920        // get_data_device
2921        MessageSpec(&[
2922            ArgKind::NewId,
2923            ArgKind::Object,
2924        ]),
2925    ]);
2926    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
2927    ]);
2928    type Incoming = Request;
2929    type Outgoing = Event;
2930}
2931
2932#[derive(Debug)]
2933pub enum Request {
2934
2935    /// create a new data source
2936    ///
2937    /// Create a new data source.
2938    CreateDataSource {
2939        /// data source to create
2940        id: NewObject<WlDataSource>,
2941    },
2942
2943    /// create a new data device
2944    ///
2945    /// Create a new data device for a given seat.
2946    GetDataDevice {
2947        /// data device to create
2948        id: NewObject<WlDataDevice>,
2949        /// seat associated with the data device
2950        seat: ObjectId,
2951    },
2952}
2953
2954impl MessageType for Request {
2955    fn log(&self, this: ObjectId) -> String {
2956        match *self {
2957            Request::CreateDataSource {
2958                ref id,
2959            } => {
2960                format!("wl_data_device_manager@{:?}::create_data_source(id: {:?})", this, id)
2961            }
2962            Request::GetDataDevice {
2963                ref id,
2964                ref seat,
2965            } => {
2966                format!("wl_data_device_manager@{:?}::get_data_device(id: {:?}, seat: {:?})", this, id, seat)
2967            }
2968        }
2969    }
2970    fn message_name(&self) -> &'static std::ffi::CStr{
2971        match *self {
2972            Request::CreateDataSource { .. } => c"wl_data_device_manager::create_data_source",
2973            Request::GetDataDevice { .. } => c"wl_data_device_manager::get_data_device",
2974        }
2975    }
2976}
2977#[derive(Debug)]
2978pub enum Event {
2979}
2980
2981impl MessageType for Event {
2982    fn log(&self, this: ObjectId) -> String {
2983        match *self {
2984        }
2985    }
2986    fn message_name(&self) -> &'static std::ffi::CStr{
2987        match *self {
2988        }
2989    }
2990}
2991impl IntoMessage for Event {
2992    type Error = EncodeError;
2993    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
2994        let mut header = MessageHeader {
2995            sender: id,
2996            opcode: 0,
2997            length: 0,
2998        };
2999        let mut msg = Message::new();
3000        msg.write_header(&header)?;
3001        match self {
3002        }
3003        header.length = msg.bytes().len() as u16;
3004        msg.rewind();
3005        msg.write_header(&header)?;
3006        Ok(msg)
3007    }
3008}
3009impl FromArgs for Request {
3010    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
3011        match op {
3012        0 /* create_data_source */ => {
3013            let mut iter = args.into_iter();
3014            Ok(Request::CreateDataSource {
3015                id: iter.next()
3016                                             .ok_or(DecodeError::InsufficientArgs)?
3017                                             .as_new_id()?.into(),
3018
3019            })
3020        },
3021        1 /* get_data_device */ => {
3022            let mut iter = args.into_iter();
3023            Ok(Request::GetDataDevice {
3024                id: iter.next()
3025                                             .ok_or(DecodeError::InsufficientArgs)?
3026                                             .as_new_id()?.into(),
3027                seat: iter.next()
3028                                             .ok_or(DecodeError::InsufficientArgs)?
3029                                             .as_object()?,
3030
3031            })
3032        },
3033        _ => {
3034            Err(DecodeError::InvalidOpcode(op).into())
3035        },
3036        }
3037    }
3038}
3039::bitflags::bitflags! {
3040
3041    /// drag and drop actions
3042    ///
3043    /// This is a bitmask of the available/preferred actions in a
3044    /// drag-and-drop operation.
3045    /// 
3046    /// In the compositor, the selected action is a result of matching the
3047    /// actions offered by the source and destination sides.  "action" events
3048    /// with a "none" action will be sent to both source and destination if
3049    /// there is no match. All further checks will effectively happen on
3050    /// (source actions ∩ destination actions).
3051    /// 
3052    /// In addition, compositors may also pick different actions in
3053    /// reaction to key modifiers being pressed. One common design that
3054    /// is used in major toolkits (and the behavior recommended for
3055    /// compositors) is:
3056    /// 
3057    /// - If no modifiers are pressed, the first match (in bit order)
3058    /// will be used.
3059    /// - Pressing Shift selects "move", if enabled in the mask.
3060    /// - Pressing Control selects "copy", if enabled in the mask.
3061    /// 
3062    /// Behavior beyond that is considered implementation-dependent.
3063    /// Compositors may for example bind other modifiers (like Alt/Meta)
3064    /// or drags initiated with other buttons than BTN_LEFT to specific
3065    /// actions (e.g. "ask").
3066    #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
3067    pub struct DndAction: u32 {
3068        /// no action,
3069        const None = 0;
3070        /// copy action,
3071        const Copy = 1;
3072        /// move action,
3073        const Move = 2;
3074        /// ask action,
3075        const Ask = 4;
3076    }
3077}
3078impl Into<Arg> for DndAction {
3079    fn into(self) -> Arg {
3080        Arg::Uint(self.bits())
3081    }
3082}
3083} // mod wl_data_device_manager
3084
3085pub use crate::wl_data_device_manager::WlDataDeviceManager;
3086pub use crate::wl_data_device_manager::Request as WlDataDeviceManagerRequest;
3087pub use crate::wl_data_device_manager::Event as WlDataDeviceManagerEvent;
3088pub mod wl_shell {
3089use super::*;
3090
3091/// create desktop-style surfaces
3092///
3093/// This interface is implemented by servers that provide
3094/// desktop-style user interfaces.
3095/// 
3096/// It allows clients to associate a wl_shell_surface with
3097/// a basic surface.
3098/// 
3099/// Note! This protocol is deprecated and not intended for production use.
3100/// For desktop-style user interfaces, use xdg_shell.
3101#[derive(Debug)]
3102pub struct WlShell;
3103
3104impl Interface for WlShell {
3105    const NAME: &'static str = "wl_shell";
3106    const VERSION: u32 = 1;
3107    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
3108        // get_shell_surface
3109        MessageSpec(&[
3110            ArgKind::NewId,
3111            ArgKind::Object,
3112        ]),
3113    ]);
3114    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
3115    ]);
3116    type Incoming = Request;
3117    type Outgoing = Event;
3118}
3119
3120#[derive(Debug)]
3121pub enum Request {
3122
3123    /// create a shell surface from a surface
3124    ///
3125    /// Create a shell surface for an existing surface. This gives
3126    /// the wl_surface the role of a shell surface. If the wl_surface
3127    /// already has another role, it raises a protocol error.
3128    /// 
3129    /// Only one shell surface can be associated with a given surface.
3130    GetShellSurface {
3131        /// shell surface to create
3132        id: NewObject<WlShellSurface>,
3133        /// surface to be given the shell surface role
3134        surface: ObjectId,
3135    },
3136}
3137
3138impl MessageType for Request {
3139    fn log(&self, this: ObjectId) -> String {
3140        match *self {
3141            Request::GetShellSurface {
3142                ref id,
3143                ref surface,
3144            } => {
3145                format!("wl_shell@{:?}::get_shell_surface(id: {:?}, surface: {:?})", this, id, surface)
3146            }
3147        }
3148    }
3149    fn message_name(&self) -> &'static std::ffi::CStr{
3150        match *self {
3151            Request::GetShellSurface { .. } => c"wl_shell::get_shell_surface",
3152        }
3153    }
3154}
3155#[derive(Debug)]
3156pub enum Event {
3157}
3158
3159impl MessageType for Event {
3160    fn log(&self, this: ObjectId) -> String {
3161        match *self {
3162        }
3163    }
3164    fn message_name(&self) -> &'static std::ffi::CStr{
3165        match *self {
3166        }
3167    }
3168}
3169impl IntoMessage for Event {
3170    type Error = EncodeError;
3171    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
3172        let mut header = MessageHeader {
3173            sender: id,
3174            opcode: 0,
3175            length: 0,
3176        };
3177        let mut msg = Message::new();
3178        msg.write_header(&header)?;
3179        match self {
3180        }
3181        header.length = msg.bytes().len() as u16;
3182        msg.rewind();
3183        msg.write_header(&header)?;
3184        Ok(msg)
3185    }
3186}
3187impl FromArgs for Request {
3188    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
3189        match op {
3190        0 /* get_shell_surface */ => {
3191            let mut iter = args.into_iter();
3192            Ok(Request::GetShellSurface {
3193                id: iter.next()
3194                                             .ok_or(DecodeError::InsufficientArgs)?
3195                                             .as_new_id()?.into(),
3196                surface: iter.next()
3197                                             .ok_or(DecodeError::InsufficientArgs)?
3198                                             .as_object()?,
3199
3200            })
3201        },
3202        _ => {
3203            Err(DecodeError::InvalidOpcode(op).into())
3204        },
3205        }
3206    }
3207}
3208#[derive(Copy, Clone, Debug, Eq, PartialEq)]
3209#[repr(u32)]
3210pub enum Error {
3211    /// given wl_surface has another role,
3212    Role = 0,
3213}
3214
3215impl Error {
3216    pub fn from_bits(v: u32) -> Option<Self> {
3217        match v {
3218        0 => Some(Error::Role),
3219        _ => None,
3220        }
3221    }
3222
3223    pub fn bits(&self) -> u32 {
3224        *self as u32
3225    }
3226}
3227impl Into<Arg> for Error {
3228    fn into(self) -> Arg {
3229        Arg::Uint(self.bits())
3230    }
3231}
3232} // mod wl_shell
3233
3234pub use crate::wl_shell::WlShell;
3235pub use crate::wl_shell::Request as WlShellRequest;
3236pub use crate::wl_shell::Event as WlShellEvent;
3237pub mod wl_shell_surface {
3238use super::*;
3239
3240/// desktop-style metadata interface
3241///
3242/// An interface that may be implemented by a wl_surface, for
3243/// implementations that provide a desktop-style user interface.
3244/// 
3245/// It provides requests to treat surfaces like toplevel, fullscreen
3246/// or popup windows, move, resize or maximize them, associate
3247/// metadata like title and class, etc.
3248/// 
3249/// On the server side the object is automatically destroyed when
3250/// the related wl_surface is destroyed. On the client side,
3251/// wl_shell_surface_destroy() must be called before destroying
3252/// the wl_surface object.
3253#[derive(Debug)]
3254pub struct WlShellSurface;
3255
3256impl Interface for WlShellSurface {
3257    const NAME: &'static str = "wl_shell_surface";
3258    const VERSION: u32 = 1;
3259    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
3260        // pong
3261        MessageSpec(&[
3262            ArgKind::Uint,
3263        ]),
3264        // move
3265        MessageSpec(&[
3266            ArgKind::Object,
3267            ArgKind::Uint,
3268        ]),
3269        // resize
3270        MessageSpec(&[
3271            ArgKind::Object,
3272            ArgKind::Uint,
3273            ArgKind::Uint,
3274        ]),
3275        // set_toplevel
3276        MessageSpec(&[
3277        ]),
3278        // set_transient
3279        MessageSpec(&[
3280            ArgKind::Object,
3281            ArgKind::Int,
3282            ArgKind::Int,
3283            ArgKind::Uint,
3284        ]),
3285        // set_fullscreen
3286        MessageSpec(&[
3287            ArgKind::Uint,
3288            ArgKind::Uint,
3289            ArgKind::Object,
3290        ]),
3291        // set_popup
3292        MessageSpec(&[
3293            ArgKind::Object,
3294            ArgKind::Uint,
3295            ArgKind::Object,
3296            ArgKind::Int,
3297            ArgKind::Int,
3298            ArgKind::Uint,
3299        ]),
3300        // set_maximized
3301        MessageSpec(&[
3302            ArgKind::Object,
3303        ]),
3304        // set_title
3305        MessageSpec(&[
3306            ArgKind::String,
3307        ]),
3308        // set_class
3309        MessageSpec(&[
3310            ArgKind::String,
3311        ]),
3312    ]);
3313    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
3314        // ping
3315        MessageSpec(&[
3316            ArgKind::Uint,
3317        ]),
3318        // configure
3319        MessageSpec(&[
3320            ArgKind::Uint,
3321            ArgKind::Int,
3322            ArgKind::Int,
3323        ]),
3324        // popup_done
3325        MessageSpec(&[
3326        ]),
3327    ]);
3328    type Incoming = Request;
3329    type Outgoing = Event;
3330}
3331
3332#[derive(Debug)]
3333pub enum Request {
3334
3335    /// respond to a ping event
3336    ///
3337    /// A client must respond to a ping event with a pong request or
3338    /// the client may be deemed unresponsive.
3339    Pong {
3340        /// serial number of the ping event
3341        serial: u32,
3342    },
3343
3344    /// start an interactive move
3345    ///
3346    /// Start a pointer-driven move of the surface.
3347    /// 
3348    /// This request must be used in response to a button press event.
3349    /// The server may ignore move requests depending on the state of
3350    /// the surface (e.g. fullscreen or maximized).
3351    Move {
3352        /// seat whose pointer is used
3353        seat: ObjectId,
3354        /// serial number of the implicit grab on the pointer
3355        serial: u32,
3356    },
3357
3358    /// start an interactive resize
3359    ///
3360    /// Start a pointer-driven resizing of the surface.
3361    /// 
3362    /// This request must be used in response to a button press event.
3363    /// The server may ignore resize requests depending on the state of
3364    /// the surface (e.g. fullscreen or maximized).
3365    Resize {
3366        /// seat whose pointer is used
3367        seat: ObjectId,
3368        /// serial number of the implicit grab on the pointer
3369        serial: u32,
3370        /// which edge or corner is being dragged
3371        edges: Enum<Resize>,
3372    },
3373
3374    /// make the surface a toplevel surface
3375    ///
3376    /// Map the surface as a toplevel surface.
3377    /// 
3378    /// A toplevel surface is not fullscreen, maximized or transient.
3379    SetToplevel,
3380
3381    /// make the surface a transient surface
3382    ///
3383    /// Map the surface relative to an existing surface.
3384    /// 
3385    /// The x and y arguments specify the location of the upper left
3386    /// corner of the surface relative to the upper left corner of the
3387    /// parent surface, in surface-local coordinates.
3388    /// 
3389    /// The flags argument controls details of the transient behaviour.
3390    SetTransient {
3391        /// parent surface
3392        parent: ObjectId,
3393        /// surface-local x coordinate
3394        x: i32,
3395        /// surface-local y coordinate
3396        y: i32,
3397        /// transient surface behavior
3398        flags: Enum<Transient>,
3399    },
3400
3401    /// make the surface a fullscreen surface
3402    ///
3403    /// Map the surface as a fullscreen surface.
3404    /// 
3405    /// If an output parameter is given then the surface will be made
3406    /// fullscreen on that output. If the client does not specify the
3407    /// output then the compositor will apply its policy - usually
3408    /// choosing the output on which the surface has the biggest surface
3409    /// area.
3410    /// 
3411    /// The client may specify a method to resolve a size conflict
3412    /// between the output size and the surface size - this is provided
3413    /// through the method parameter.
3414    /// 
3415    /// The framerate parameter is used only when the method is set
3416    /// to "driver", to indicate the preferred framerate. A value of 0
3417    /// indicates that the client does not care about framerate.  The
3418    /// framerate is specified in mHz, that is framerate of 60000 is 60Hz.
3419    /// 
3420    /// A method of "scale" or "driver" implies a scaling operation of
3421    /// the surface, either via a direct scaling operation or a change of
3422    /// the output mode. This will override any kind of output scaling, so
3423    /// that mapping a surface with a buffer size equal to the mode can
3424    /// fill the screen independent of buffer_scale.
3425    /// 
3426    /// A method of "fill" means we don't scale up the buffer, however
3427    /// any output scale is applied. This means that you may run into
3428    /// an edge case where the application maps a buffer with the same
3429    /// size of the output mode but buffer_scale 1 (thus making a
3430    /// surface larger than the output). In this case it is allowed to
3431    /// downscale the results to fit the screen.
3432    /// 
3433    /// The compositor must reply to this request with a configure event
3434    /// with the dimensions for the output on which the surface will
3435    /// be made fullscreen.
3436    SetFullscreen {
3437        /// method for resolving size conflict
3438        method: Enum<FullscreenMethod>,
3439        /// framerate in mHz
3440        framerate: u32,
3441        /// output on which the surface is to be fullscreen
3442        output: ObjectId,
3443    },
3444
3445    /// make the surface a popup surface
3446    ///
3447    /// Map the surface as a popup.
3448    /// 
3449    /// A popup surface is a transient surface with an added pointer
3450    /// grab.
3451    /// 
3452    /// An existing implicit grab will be changed to owner-events mode,
3453    /// and the popup grab will continue after the implicit grab ends
3454    /// (i.e. releasing the mouse button does not cause the popup to
3455    /// be unmapped).
3456    /// 
3457    /// The popup grab continues until the window is destroyed or a
3458    /// mouse button is pressed in any other client's window. A click
3459    /// in any of the client's surfaces is reported as normal, however,
3460    /// clicks in other clients' surfaces will be discarded and trigger
3461    /// the callback.
3462    /// 
3463    /// The x and y arguments specify the location of the upper left
3464    /// corner of the surface relative to the upper left corner of the
3465    /// parent surface, in surface-local coordinates.
3466    SetPopup {
3467        /// seat whose pointer is used
3468        seat: ObjectId,
3469        /// serial number of the implicit grab on the pointer
3470        serial: u32,
3471        /// parent surface
3472        parent: ObjectId,
3473        /// surface-local x coordinate
3474        x: i32,
3475        /// surface-local y coordinate
3476        y: i32,
3477        /// transient surface behavior
3478        flags: Enum<Transient>,
3479    },
3480
3481    /// make the surface a maximized surface
3482    ///
3483    /// Map the surface as a maximized surface.
3484    /// 
3485    /// If an output parameter is given then the surface will be
3486    /// maximized on that output. If the client does not specify the
3487    /// output then the compositor will apply its policy - usually
3488    /// choosing the output on which the surface has the biggest surface
3489    /// area.
3490    /// 
3491    /// The compositor will reply with a configure event telling
3492    /// the expected new surface size. The operation is completed
3493    /// on the next buffer attach to this surface.
3494    /// 
3495    /// A maximized surface typically fills the entire output it is
3496    /// bound to, except for desktop elements such as panels. This is
3497    /// the main difference between a maximized shell surface and a
3498    /// fullscreen shell surface.
3499    /// 
3500    /// The details depend on the compositor implementation.
3501    SetMaximized {
3502        /// output on which the surface is to be maximized
3503        output: ObjectId,
3504    },
3505
3506    /// set surface title
3507    ///
3508    /// Set a short title for the surface.
3509    /// 
3510    /// This string may be used to identify the surface in a task bar,
3511    /// window list, or other user interface elements provided by the
3512    /// compositor.
3513    /// 
3514    /// The string must be encoded in UTF-8.
3515    SetTitle {
3516        /// surface title
3517        title: String,
3518    },
3519
3520    /// set surface class
3521    ///
3522    /// Set a class for the surface.
3523    /// 
3524    /// The surface class identifies the general class of applications
3525    /// to which the surface belongs. A common convention is to use the
3526    /// file name (or the full path if it is a non-standard location) of
3527    /// the application's .desktop file as the class.
3528    SetClass {
3529        /// surface class
3530        class_: String,
3531    },
3532}
3533
3534impl MessageType for Request {
3535    fn log(&self, this: ObjectId) -> String {
3536        match *self {
3537            Request::Pong {
3538                ref serial,
3539            } => {
3540                format!("wl_shell_surface@{:?}::pong(serial: {:?})", this, serial)
3541            }
3542            Request::Move {
3543                ref seat,
3544                ref serial,
3545            } => {
3546                format!("wl_shell_surface@{:?}::move(seat: {:?}, serial: {:?})", this, seat, serial)
3547            }
3548            Request::Resize {
3549                ref seat,
3550                ref serial,
3551                ref edges,
3552            } => {
3553                format!("wl_shell_surface@{:?}::resize(seat: {:?}, serial: {:?}, edges: {:?})", this, seat, serial, edges)
3554            }
3555            Request::SetToplevel {
3556            } => {
3557                format!("wl_shell_surface@{:?}::set_toplevel()", this)
3558            }
3559            Request::SetTransient {
3560                ref parent,
3561                ref x,
3562                ref y,
3563                ref flags,
3564            } => {
3565                format!("wl_shell_surface@{:?}::set_transient(parent: {:?}, x: {:?}, y: {:?}, flags: {:?})", this, parent, x, y, flags)
3566            }
3567            Request::SetFullscreen {
3568                ref method,
3569                ref framerate,
3570                ref output,
3571            } => {
3572                format!("wl_shell_surface@{:?}::set_fullscreen(method: {:?}, framerate: {:?}, output: {:?})", this, method, framerate, output)
3573            }
3574            Request::SetPopup {
3575                ref seat,
3576                ref serial,
3577                ref parent,
3578                ref x,
3579                ref y,
3580                ref flags,
3581            } => {
3582                format!("wl_shell_surface@{:?}::set_popup(seat: {:?}, serial: {:?}, parent: {:?}, x: {:?}, y: {:?}, flags: {:?})", this, seat, serial, parent, x, y, flags)
3583            }
3584            Request::SetMaximized {
3585                ref output,
3586            } => {
3587                format!("wl_shell_surface@{:?}::set_maximized(output: {:?})", this, output)
3588            }
3589            Request::SetTitle {
3590                ref title,
3591            } => {
3592                format!("wl_shell_surface@{:?}::set_title(title: {:?})", this, title)
3593            }
3594            Request::SetClass {
3595                ref class_,
3596            } => {
3597                format!("wl_shell_surface@{:?}::set_class(class_: {:?})", this, class_)
3598            }
3599        }
3600    }
3601    fn message_name(&self) -> &'static std::ffi::CStr{
3602        match *self {
3603            Request::Pong { .. } => c"wl_shell_surface::pong",
3604            Request::Move { .. } => c"wl_shell_surface::move",
3605            Request::Resize { .. } => c"wl_shell_surface::resize",
3606            Request::SetToplevel { .. } => c"wl_shell_surface::set_toplevel",
3607            Request::SetTransient { .. } => c"wl_shell_surface::set_transient",
3608            Request::SetFullscreen { .. } => c"wl_shell_surface::set_fullscreen",
3609            Request::SetPopup { .. } => c"wl_shell_surface::set_popup",
3610            Request::SetMaximized { .. } => c"wl_shell_surface::set_maximized",
3611            Request::SetTitle { .. } => c"wl_shell_surface::set_title",
3612            Request::SetClass { .. } => c"wl_shell_surface::set_class",
3613        }
3614    }
3615}
3616#[derive(Debug)]
3617pub enum Event {
3618
3619    /// ping client
3620    ///
3621    /// Ping a client to check if it is receiving events and sending
3622    /// requests. A client is expected to reply with a pong request.
3623    Ping {
3624        /// serial number of the ping
3625        serial: u32,
3626    },
3627
3628    /// suggest resize
3629    ///
3630    /// The configure event asks the client to resize its surface.
3631    /// 
3632    /// The size is a hint, in the sense that the client is free to
3633    /// ignore it if it doesn't resize, pick a smaller size (to
3634    /// satisfy aspect ratio or resize in steps of NxM pixels).
3635    /// 
3636    /// The edges parameter provides a hint about how the surface
3637    /// was resized. The client may use this information to decide
3638    /// how to adjust its content to the new size (e.g. a scrolling
3639    /// area might adjust its content position to leave the viewable
3640    /// content unmoved).
3641    /// 
3642    /// The client is free to dismiss all but the last configure
3643    /// event it received.
3644    /// 
3645    /// The width and height arguments specify the size of the window
3646    /// in surface-local coordinates.
3647    Configure {
3648        /// how the surface was resized
3649        edges: Resize,
3650        /// new width of the surface
3651        width: i32,
3652        /// new height of the surface
3653        height: i32,
3654    },
3655
3656    /// popup interaction is done
3657    ///
3658    /// The popup_done event is sent out when a popup grab is broken,
3659    /// that is, when the user clicks a surface that doesn't belong
3660    /// to the client owning the popup surface.
3661    PopupDone,
3662}
3663
3664impl MessageType for Event {
3665    fn log(&self, this: ObjectId) -> String {
3666        match *self {
3667            Event::Ping {
3668                ref serial,
3669            } => {
3670                format!("wl_shell_surface@{:?}::ping(serial: {:?})", this, serial)
3671            }
3672            Event::Configure {
3673                ref edges,
3674                ref width,
3675                ref height,
3676            } => {
3677                format!("wl_shell_surface@{:?}::configure(edges: {:?}, width: {:?}, height: {:?})", this, edges, width, height)
3678            }
3679            Event::PopupDone {
3680            } => {
3681                format!("wl_shell_surface@{:?}::popup_done()", this)
3682            }
3683        }
3684    }
3685    fn message_name(&self) -> &'static std::ffi::CStr{
3686        match *self {
3687            Event::Ping { .. } => c"wl_shell_surface::ping",
3688            Event::Configure { .. } => c"wl_shell_surface::configure",
3689            Event::PopupDone { .. } => c"wl_shell_surface::popup_done",
3690        }
3691    }
3692}
3693impl IntoMessage for Event {
3694    type Error = EncodeError;
3695    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
3696        let mut header = MessageHeader {
3697            sender: id,
3698            opcode: 0,
3699            length: 0,
3700        };
3701        let mut msg = Message::new();
3702        msg.write_header(&header)?;
3703        match self {
3704        Event::Ping {
3705            serial,
3706        } => {
3707            msg.write_arg(Arg::Uint(serial))?;
3708            header.opcode = 0;
3709        },
3710        Event::Configure {
3711            edges,
3712            width,
3713            height,
3714        } => {
3715            msg.write_arg(Arg::Uint(edges.bits()))?;
3716            msg.write_arg(Arg::Int(width))?;
3717            msg.write_arg(Arg::Int(height))?;
3718            header.opcode = 1;
3719        },
3720        Event::PopupDone {
3721        } => {
3722            header.opcode = 2;
3723        },
3724        }
3725        header.length = msg.bytes().len() as u16;
3726        msg.rewind();
3727        msg.write_header(&header)?;
3728        Ok(msg)
3729    }
3730}
3731impl FromArgs for Request {
3732    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
3733        match op {
3734        0 /* pong */ => {
3735            let mut iter = args.into_iter();
3736            Ok(Request::Pong {
3737                serial: iter.next()
3738                                             .ok_or(DecodeError::InsufficientArgs)?
3739                                             .as_uint()?,
3740
3741            })
3742        },
3743        1 /* move */ => {
3744            let mut iter = args.into_iter();
3745            Ok(Request::Move {
3746                seat: iter.next()
3747                                             .ok_or(DecodeError::InsufficientArgs)?
3748                                             .as_object()?,
3749                serial: iter.next()
3750                                             .ok_or(DecodeError::InsufficientArgs)?
3751                                             .as_uint()?,
3752
3753            })
3754        },
3755        2 /* resize */ => {
3756            let mut iter = args.into_iter();
3757            Ok(Request::Resize {
3758                seat: iter.next()
3759                                             .ok_or(DecodeError::InsufficientArgs)?
3760                                             .as_object()?,
3761                serial: iter.next()
3762                                             .ok_or(DecodeError::InsufficientArgs)?
3763                                             .as_uint()?,
3764                edges: iter.next()
3765                                             .ok_or(DecodeError::InsufficientArgs)?
3766                                             .as_uint().map(|i| match Resize::from_bits(i) {
3767                                      Some(e) => Enum::Recognized(e),
3768                                      None => Enum::Unrecognized(i),
3769                                 })?,
3770
3771            })
3772        },
3773        3 /* set_toplevel */ => {
3774            let mut iter = args.into_iter();
3775            Ok(Request::SetToplevel {
3776
3777            })
3778        },
3779        4 /* set_transient */ => {
3780            let mut iter = args.into_iter();
3781            Ok(Request::SetTransient {
3782                parent: iter.next()
3783                                             .ok_or(DecodeError::InsufficientArgs)?
3784                                             .as_object()?,
3785                x: iter.next()
3786                                             .ok_or(DecodeError::InsufficientArgs)?
3787                                             .as_int()?,
3788                y: iter.next()
3789                                             .ok_or(DecodeError::InsufficientArgs)?
3790                                             .as_int()?,
3791                flags: iter.next()
3792                                             .ok_or(DecodeError::InsufficientArgs)?
3793                                             .as_uint().map(|i| match Transient::from_bits(i) {
3794                                      Some(e) => Enum::Recognized(e),
3795                                      None => Enum::Unrecognized(i),
3796                                 })?,
3797
3798            })
3799        },
3800        5 /* set_fullscreen */ => {
3801            let mut iter = args.into_iter();
3802            Ok(Request::SetFullscreen {
3803                method: iter.next()
3804                                             .ok_or(DecodeError::InsufficientArgs)?
3805                                             .as_uint().map(|i| match FullscreenMethod::from_bits(i) {
3806                                      Some(e) => Enum::Recognized(e),
3807                                      None => Enum::Unrecognized(i),
3808                                 })?,
3809                framerate: iter.next()
3810                                             .ok_or(DecodeError::InsufficientArgs)?
3811                                             .as_uint()?,
3812                output: iter.next()
3813                                             .ok_or(DecodeError::InsufficientArgs)?
3814                                             .as_object()?,
3815
3816            })
3817        },
3818        6 /* set_popup */ => {
3819            let mut iter = args.into_iter();
3820            Ok(Request::SetPopup {
3821                seat: iter.next()
3822                                             .ok_or(DecodeError::InsufficientArgs)?
3823                                             .as_object()?,
3824                serial: iter.next()
3825                                             .ok_or(DecodeError::InsufficientArgs)?
3826                                             .as_uint()?,
3827                parent: iter.next()
3828                                             .ok_or(DecodeError::InsufficientArgs)?
3829                                             .as_object()?,
3830                x: iter.next()
3831                                             .ok_or(DecodeError::InsufficientArgs)?
3832                                             .as_int()?,
3833                y: iter.next()
3834                                             .ok_or(DecodeError::InsufficientArgs)?
3835                                             .as_int()?,
3836                flags: iter.next()
3837                                             .ok_or(DecodeError::InsufficientArgs)?
3838                                             .as_uint().map(|i| match Transient::from_bits(i) {
3839                                      Some(e) => Enum::Recognized(e),
3840                                      None => Enum::Unrecognized(i),
3841                                 })?,
3842
3843            })
3844        },
3845        7 /* set_maximized */ => {
3846            let mut iter = args.into_iter();
3847            Ok(Request::SetMaximized {
3848                output: iter.next()
3849                                             .ok_or(DecodeError::InsufficientArgs)?
3850                                             .as_object()?,
3851
3852            })
3853        },
3854        8 /* set_title */ => {
3855            let mut iter = args.into_iter();
3856            Ok(Request::SetTitle {
3857                title: iter.next()
3858                                             .ok_or(DecodeError::InsufficientArgs)?
3859                                             .as_string()?,
3860
3861            })
3862        },
3863        9 /* set_class */ => {
3864            let mut iter = args.into_iter();
3865            Ok(Request::SetClass {
3866                class_: iter.next()
3867                                             .ok_or(DecodeError::InsufficientArgs)?
3868                                             .as_string()?,
3869
3870            })
3871        },
3872        _ => {
3873            Err(DecodeError::InvalidOpcode(op).into())
3874        },
3875        }
3876    }
3877}
3878::bitflags::bitflags! {
3879
3880    /// edge values for resizing
3881    ///
3882    /// These values are used to indicate which edge of a surface
3883    /// is being dragged in a resize operation. The server may
3884    /// use this information to adapt its behavior, e.g. choose
3885    /// an appropriate cursor image.
3886    #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
3887    pub struct Resize: u32 {
3888        /// no edge,
3889        const None = 0;
3890        /// top edge,
3891        const Top = 1;
3892        /// bottom edge,
3893        const Bottom = 2;
3894        /// left edge,
3895        const Left = 4;
3896        /// top and left edges,
3897        const TopLeft = 5;
3898        /// bottom and left edges,
3899        const BottomLeft = 6;
3900        /// right edge,
3901        const Right = 8;
3902        /// top and right edges,
3903        const TopRight = 9;
3904        /// bottom and right edges,
3905        const BottomRight = 10;
3906    }
3907}
3908impl Into<Arg> for Resize {
3909    fn into(self) -> Arg {
3910        Arg::Uint(self.bits())
3911    }
3912}
3913::bitflags::bitflags! {
3914
3915    /// details of transient behaviour
3916    ///
3917    /// These flags specify details of the expected behaviour
3918    /// of transient surfaces. Used in the set_transient request.
3919    #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
3920    pub struct Transient: u32 {
3921        /// do not set keyboard focus,
3922        const Inactive = 1;
3923    }
3924}
3925impl Into<Arg> for Transient {
3926    fn into(self) -> Arg {
3927        Arg::Uint(self.bits())
3928    }
3929}
3930
3931/// different method to set the surface fullscreen
3932///
3933/// Hints to indicate to the compositor how to deal with a conflict
3934/// between the dimensions of the surface and the dimensions of the
3935/// output. The compositor is free to ignore this parameter.
3936#[derive(Copy, Clone, Debug, Eq, PartialEq)]
3937#[repr(u32)]
3938pub enum FullscreenMethod {
3939    /// no preference, apply default policy,
3940    Default = 0,
3941    /// scale, preserve the surface's aspect ratio and center on output,
3942    Scale = 1,
3943    /// switch output mode to the smallest mode that can fit the surface, add black borders to compensate size mismatch,
3944    Driver = 2,
3945    /// no upscaling, center on output and add black borders to compensate size mismatch,
3946    Fill = 3,
3947}
3948
3949impl FullscreenMethod {
3950    pub fn from_bits(v: u32) -> Option<Self> {
3951        match v {
3952        0 => Some(FullscreenMethod::Default),
3953        1 => Some(FullscreenMethod::Scale),
3954        2 => Some(FullscreenMethod::Driver),
3955        3 => Some(FullscreenMethod::Fill),
3956        _ => None,
3957        }
3958    }
3959
3960    pub fn bits(&self) -> u32 {
3961        *self as u32
3962    }
3963}
3964impl Into<Arg> for FullscreenMethod {
3965    fn into(self) -> Arg {
3966        Arg::Uint(self.bits())
3967    }
3968}
3969} // mod wl_shell_surface
3970
3971pub use crate::wl_shell_surface::WlShellSurface;
3972pub use crate::wl_shell_surface::Request as WlShellSurfaceRequest;
3973pub use crate::wl_shell_surface::Event as WlShellSurfaceEvent;
3974pub mod wl_surface {
3975use super::*;
3976
3977/// an onscreen surface
3978///
3979/// A surface is a rectangular area that may be displayed on zero
3980/// or more outputs, and shown any number of times at the compositor's
3981/// discretion. They can present wl_buffers, receive user input, and
3982/// define a local coordinate system.
3983/// 
3984/// The size of a surface (and relative positions on it) is described
3985/// in surface-local coordinates, which may differ from the buffer
3986/// coordinates of the pixel content, in case a buffer_transform
3987/// or a buffer_scale is used.
3988/// 
3989/// A surface without a "role" is fairly useless: a compositor does
3990/// not know where, when or how to present it. The role is the
3991/// purpose of a wl_surface. Examples of roles are a cursor for a
3992/// pointer (as set by wl_pointer.set_cursor), a drag icon
3993/// (wl_data_device.start_drag), a sub-surface
3994/// (wl_subcompositor.get_subsurface), and a window as defined by a
3995/// shell protocol (e.g. wl_shell.get_shell_surface).
3996/// 
3997/// A surface can have only one role at a time. Initially a
3998/// wl_surface does not have a role. Once a wl_surface is given a
3999/// role, it is set permanently for the whole lifetime of the
4000/// wl_surface object. Giving the current role again is allowed,
4001/// unless explicitly forbidden by the relevant interface
4002/// specification.
4003/// 
4004/// Surface roles are given by requests in other interfaces such as
4005/// wl_pointer.set_cursor. The request should explicitly mention
4006/// that this request gives a role to a wl_surface. Often, this
4007/// request also creates a new protocol object that represents the
4008/// role and adds additional functionality to wl_surface. When a
4009/// client wants to destroy a wl_surface, they must destroy this 'role
4010/// object' before the wl_surface.
4011/// 
4012/// Destroying the role object does not remove the role from the
4013/// wl_surface, but it may stop the wl_surface from "playing the role".
4014/// For instance, if a wl_subsurface object is destroyed, the wl_surface
4015/// it was created for will be unmapped and forget its position and
4016/// z-order. It is allowed to create a wl_subsurface for the same
4017/// wl_surface again, but it is not allowed to use the wl_surface as
4018/// a cursor (cursor is a different role than sub-surface, and role
4019/// switching is not allowed).
4020#[derive(Debug)]
4021pub struct WlSurface;
4022
4023impl Interface for WlSurface {
4024    const NAME: &'static str = "wl_surface";
4025    const VERSION: u32 = 4;
4026    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
4027        // destroy
4028        MessageSpec(&[
4029        ]),
4030        // attach
4031        MessageSpec(&[
4032            ArgKind::Object,
4033            ArgKind::Int,
4034            ArgKind::Int,
4035        ]),
4036        // damage
4037        MessageSpec(&[
4038            ArgKind::Int,
4039            ArgKind::Int,
4040            ArgKind::Int,
4041            ArgKind::Int,
4042        ]),
4043        // frame
4044        MessageSpec(&[
4045            ArgKind::NewId,
4046        ]),
4047        // set_opaque_region
4048        MessageSpec(&[
4049            ArgKind::Object,
4050        ]),
4051        // set_input_region
4052        MessageSpec(&[
4053            ArgKind::Object,
4054        ]),
4055        // commit
4056        MessageSpec(&[
4057        ]),
4058        // set_buffer_transform
4059        MessageSpec(&[
4060            ArgKind::Uint,
4061        ]),
4062        // set_buffer_scale
4063        MessageSpec(&[
4064            ArgKind::Int,
4065        ]),
4066        // damage_buffer
4067        MessageSpec(&[
4068            ArgKind::Int,
4069            ArgKind::Int,
4070            ArgKind::Int,
4071            ArgKind::Int,
4072        ]),
4073    ]);
4074    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
4075        // enter
4076        MessageSpec(&[
4077            ArgKind::Object,
4078        ]),
4079        // leave
4080        MessageSpec(&[
4081            ArgKind::Object,
4082        ]),
4083    ]);
4084    type Incoming = Request;
4085    type Outgoing = Event;
4086}
4087
4088#[derive(Debug)]
4089pub enum Request {
4090
4091    /// delete surface
4092    ///
4093    /// Deletes the surface and invalidates its object ID.
4094    Destroy,
4095
4096    /// set the surface contents
4097    ///
4098    /// Set a buffer as the content of this surface.
4099    /// 
4100    /// The new size of the surface is calculated based on the buffer
4101    /// size transformed by the inverse buffer_transform and the
4102    /// inverse buffer_scale. This means that at commit time the supplied
4103    /// buffer size must be an integer multiple of the buffer_scale. If
4104    /// that's not the case, an invalid_size error is sent.
4105    /// 
4106    /// The x and y arguments specify the location of the new pending
4107    /// buffer's upper left corner, relative to the current buffer's upper
4108    /// left corner, in surface-local coordinates. In other words, the
4109    /// x and y, combined with the new surface size define in which
4110    /// directions the surface's size changes.
4111    /// 
4112    /// Surface contents are double-buffered state, see wl_surface.commit.
4113    /// 
4114    /// The initial surface contents are void; there is no content.
4115    /// wl_surface.attach assigns the given wl_buffer as the pending
4116    /// wl_buffer. wl_surface.commit makes the pending wl_buffer the new
4117    /// surface contents, and the size of the surface becomes the size
4118    /// calculated from the wl_buffer, as described above. After commit,
4119    /// there is no pending buffer until the next attach.
4120    /// 
4121    /// Committing a pending wl_buffer allows the compositor to read the
4122    /// pixels in the wl_buffer. The compositor may access the pixels at
4123    /// any time after the wl_surface.commit request. When the compositor
4124    /// will not access the pixels anymore, it will send the
4125    /// wl_buffer.release event. Only after receiving wl_buffer.release,
4126    /// the client may reuse the wl_buffer. A wl_buffer that has been
4127    /// attached and then replaced by another attach instead of committed
4128    /// will not receive a release event, and is not used by the
4129    /// compositor.
4130    /// 
4131    /// If a pending wl_buffer has been committed to more than one wl_surface,
4132    /// the delivery of wl_buffer.release events becomes undefined. A well
4133    /// behaved client should not rely on wl_buffer.release events in this
4134    /// case. Alternatively, a client could create multiple wl_buffer objects
4135    /// from the same backing storage or use wp_linux_buffer_release.
4136    /// 
4137    /// Destroying the wl_buffer after wl_buffer.release does not change
4138    /// the surface contents. However, if the client destroys the
4139    /// wl_buffer before receiving the wl_buffer.release event, the surface
4140    /// contents become undefined immediately.
4141    /// 
4142    /// If wl_surface.attach is sent with a NULL wl_buffer, the
4143    /// following wl_surface.commit will remove the surface content.
4144    Attach {
4145        /// buffer of surface contents
4146        buffer: ObjectId,
4147        /// surface-local x coordinate
4148        x: i32,
4149        /// surface-local y coordinate
4150        y: i32,
4151    },
4152
4153    /// mark part of the surface damaged
4154    ///
4155    /// This request is used to describe the regions where the pending
4156    /// buffer is different from the current surface contents, and where
4157    /// the surface therefore needs to be repainted. The compositor
4158    /// ignores the parts of the damage that fall outside of the surface.
4159    /// 
4160    /// Damage is double-buffered state, see wl_surface.commit.
4161    /// 
4162    /// The damage rectangle is specified in surface-local coordinates,
4163    /// where x and y specify the upper left corner of the damage rectangle.
4164    /// 
4165    /// The initial value for pending damage is empty: no damage.
4166    /// wl_surface.damage adds pending damage: the new pending damage
4167    /// is the union of old pending damage and the given rectangle.
4168    /// 
4169    /// wl_surface.commit assigns pending damage as the current damage,
4170    /// and clears pending damage. The server will clear the current
4171    /// damage as it repaints the surface.
4172    /// 
4173    /// Note! New clients should not use this request. Instead damage can be
4174    /// posted with wl_surface.damage_buffer which uses buffer coordinates
4175    /// instead of surface coordinates.
4176    Damage {
4177        /// surface-local x coordinate
4178        x: i32,
4179        /// surface-local y coordinate
4180        y: i32,
4181        /// width of damage rectangle
4182        width: i32,
4183        /// height of damage rectangle
4184        height: i32,
4185    },
4186
4187    /// request a frame throttling hint
4188    ///
4189    /// Request a notification when it is a good time to start drawing a new
4190    /// frame, by creating a frame callback. This is useful for throttling
4191    /// redrawing operations, and driving animations.
4192    /// 
4193    /// When a client is animating on a wl_surface, it can use the 'frame'
4194    /// request to get notified when it is a good time to draw and commit the
4195    /// next frame of animation. If the client commits an update earlier than
4196    /// that, it is likely that some updates will not make it to the display,
4197    /// and the client is wasting resources by drawing too often.
4198    /// 
4199    /// The frame request will take effect on the next wl_surface.commit.
4200    /// The notification will only be posted for one frame unless
4201    /// requested again. For a wl_surface, the notifications are posted in
4202    /// the order the frame requests were committed.
4203    /// 
4204    /// The server must send the notifications so that a client
4205    /// will not send excessive updates, while still allowing
4206    /// the highest possible update rate for clients that wait for the reply
4207    /// before drawing again. The server should give some time for the client
4208    /// to draw and commit after sending the frame callback events to let it
4209    /// hit the next output refresh.
4210    /// 
4211    /// A server should avoid signaling the frame callbacks if the
4212    /// surface is not visible in any way, e.g. the surface is off-screen,
4213    /// or completely obscured by other opaque surfaces.
4214    /// 
4215    /// The object returned by this request will be destroyed by the
4216    /// compositor after the callback is fired and as such the client must not
4217    /// attempt to use it after that point.
4218    /// 
4219    /// The callback_data passed in the callback is the current time, in
4220    /// milliseconds, with an undefined base.
4221    Frame {
4222        /// callback object for the frame request
4223        callback: NewObject<WlCallback>,
4224    },
4225
4226    /// set opaque region
4227    ///
4228    /// This request sets the region of the surface that contains
4229    /// opaque content.
4230    /// 
4231    /// The opaque region is an optimization hint for the compositor
4232    /// that lets it optimize the redrawing of content behind opaque
4233    /// regions.  Setting an opaque region is not required for correct
4234    /// behaviour, but marking transparent content as opaque will result
4235    /// in repaint artifacts.
4236    /// 
4237    /// The opaque region is specified in surface-local coordinates.
4238    /// 
4239    /// The compositor ignores the parts of the opaque region that fall
4240    /// outside of the surface.
4241    /// 
4242    /// Opaque region is double-buffered state, see wl_surface.commit.
4243    /// 
4244    /// wl_surface.set_opaque_region changes the pending opaque region.
4245    /// wl_surface.commit copies the pending region to the current region.
4246    /// Otherwise, the pending and current regions are never changed.
4247    /// 
4248    /// The initial value for an opaque region is empty. Setting the pending
4249    /// opaque region has copy semantics, and the wl_region object can be
4250    /// destroyed immediately. A NULL wl_region causes the pending opaque
4251    /// region to be set to empty.
4252    SetOpaqueRegion {
4253        /// opaque region of the surface
4254        region: ObjectId,
4255    },
4256
4257    /// set input region
4258    ///
4259    /// This request sets the region of the surface that can receive
4260    /// pointer and touch events.
4261    /// 
4262    /// Input events happening outside of this region will try the next
4263    /// surface in the server surface stack. The compositor ignores the
4264    /// parts of the input region that fall outside of the surface.
4265    /// 
4266    /// The input region is specified in surface-local coordinates.
4267    /// 
4268    /// Input region is double-buffered state, see wl_surface.commit.
4269    /// 
4270    /// wl_surface.set_input_region changes the pending input region.
4271    /// wl_surface.commit copies the pending region to the current region.
4272    /// Otherwise the pending and current regions are never changed,
4273    /// except cursor and icon surfaces are special cases, see
4274    /// wl_pointer.set_cursor and wl_data_device.start_drag.
4275    /// 
4276    /// The initial value for an input region is infinite. That means the
4277    /// whole surface will accept input. Setting the pending input region
4278    /// has copy semantics, and the wl_region object can be destroyed
4279    /// immediately. A NULL wl_region causes the input region to be set
4280    /// to infinite.
4281    SetInputRegion {
4282        /// input region of the surface
4283        region: ObjectId,
4284    },
4285
4286    /// commit pending surface state
4287    ///
4288    /// Surface state (input, opaque, and damage regions, attached buffers,
4289    /// etc.) is double-buffered. Protocol requests modify the pending state,
4290    /// as opposed to the current state in use by the compositor. A commit
4291    /// request atomically applies all pending state, replacing the current
4292    /// state. After commit, the new pending state is as documented for each
4293    /// related request.
4294    /// 
4295    /// On commit, a pending wl_buffer is applied first, and all other state
4296    /// second. This means that all coordinates in double-buffered state are
4297    /// relative to the new wl_buffer coming into use, except for
4298    /// wl_surface.attach itself. If there is no pending wl_buffer, the
4299    /// coordinates are relative to the current surface contents.
4300    /// 
4301    /// All requests that need a commit to become effective are documented
4302    /// to affect double-buffered state.
4303    /// 
4304    /// Other interfaces may add further double-buffered surface state.
4305    Commit,
4306
4307    /// sets the buffer transformation
4308    ///
4309    /// This request sets an optional transformation on how the compositor
4310    /// interprets the contents of the buffer attached to the surface. The
4311    /// accepted values for the transform parameter are the values for
4312    /// wl_output.transform.
4313    /// 
4314    /// Buffer transform is double-buffered state, see wl_surface.commit.
4315    /// 
4316    /// A newly created surface has its buffer transformation set to normal.
4317    /// 
4318    /// wl_surface.set_buffer_transform changes the pending buffer
4319    /// transformation. wl_surface.commit copies the pending buffer
4320    /// transformation to the current one. Otherwise, the pending and current
4321    /// values are never changed.
4322    /// 
4323    /// The purpose of this request is to allow clients to render content
4324    /// according to the output transform, thus permitting the compositor to
4325    /// use certain optimizations even if the display is rotated. Using
4326    /// hardware overlays and scanning out a client buffer for fullscreen
4327    /// surfaces are examples of such optimizations. Those optimizations are
4328    /// highly dependent on the compositor implementation, so the use of this
4329    /// request should be considered on a case-by-case basis.
4330    /// 
4331    /// Note that if the transform value includes 90 or 270 degree rotation,
4332    /// the width of the buffer will become the surface height and the height
4333    /// of the buffer will become the surface width.
4334    /// 
4335    /// If transform is not one of the values from the
4336    /// wl_output.transform enum the invalid_transform protocol error
4337    /// is raised.
4338    SetBufferTransform {
4339        /// transform for interpreting buffer contents
4340        transform: Enum<crate::wl_output::Transform>,
4341    },
4342
4343    /// sets the buffer scaling factor
4344    ///
4345    /// This request sets an optional scaling factor on how the compositor
4346    /// interprets the contents of the buffer attached to the window.
4347    /// 
4348    /// Buffer scale is double-buffered state, see wl_surface.commit.
4349    /// 
4350    /// A newly created surface has its buffer scale set to 1.
4351    /// 
4352    /// wl_surface.set_buffer_scale changes the pending buffer scale.
4353    /// wl_surface.commit copies the pending buffer scale to the current one.
4354    /// Otherwise, the pending and current values are never changed.
4355    /// 
4356    /// The purpose of this request is to allow clients to supply higher
4357    /// resolution buffer data for use on high resolution outputs. It is
4358    /// intended that you pick the same buffer scale as the scale of the
4359    /// output that the surface is displayed on. This means the compositor
4360    /// can avoid scaling when rendering the surface on that output.
4361    /// 
4362    /// Note that if the scale is larger than 1, then you have to attach
4363    /// a buffer that is larger (by a factor of scale in each dimension)
4364    /// than the desired surface size.
4365    /// 
4366    /// If scale is not positive the invalid_scale protocol error is
4367    /// raised.
4368    SetBufferScale {
4369        /// positive scale for interpreting buffer contents
4370        scale: i32,
4371    },
4372
4373    /// mark part of the surface damaged using buffer coordinates
4374    ///
4375    /// This request is used to describe the regions where the pending
4376    /// buffer is different from the current surface contents, and where
4377    /// the surface therefore needs to be repainted. The compositor
4378    /// ignores the parts of the damage that fall outside of the surface.
4379    /// 
4380    /// Damage is double-buffered state, see wl_surface.commit.
4381    /// 
4382    /// The damage rectangle is specified in buffer coordinates,
4383    /// where x and y specify the upper left corner of the damage rectangle.
4384    /// 
4385    /// The initial value for pending damage is empty: no damage.
4386    /// wl_surface.damage_buffer adds pending damage: the new pending
4387    /// damage is the union of old pending damage and the given rectangle.
4388    /// 
4389    /// wl_surface.commit assigns pending damage as the current damage,
4390    /// and clears pending damage. The server will clear the current
4391    /// damage as it repaints the surface.
4392    /// 
4393    /// This request differs from wl_surface.damage in only one way - it
4394    /// takes damage in buffer coordinates instead of surface-local
4395    /// coordinates. While this generally is more intuitive than surface
4396    /// coordinates, it is especially desirable when using wp_viewport
4397    /// or when a drawing library (like EGL) is unaware of buffer scale
4398    /// and buffer transform.
4399    /// 
4400    /// Note: Because buffer transformation changes and damage requests may
4401    /// be interleaved in the protocol stream, it is impossible to determine
4402    /// the actual mapping between surface and buffer damage until
4403    /// wl_surface.commit time. Therefore, compositors wishing to take both
4404    /// kinds of damage into account will have to accumulate damage from the
4405    /// two requests separately and only transform from one to the other
4406    /// after receiving the wl_surface.commit.
4407    DamageBuffer {
4408        /// buffer-local x coordinate
4409        x: i32,
4410        /// buffer-local y coordinate
4411        y: i32,
4412        /// width of damage rectangle
4413        width: i32,
4414        /// height of damage rectangle
4415        height: i32,
4416    },
4417}
4418
4419impl MessageType for Request {
4420    fn log(&self, this: ObjectId) -> String {
4421        match *self {
4422            Request::Destroy {
4423            } => {
4424                format!("wl_surface@{:?}::destroy()", this)
4425            }
4426            Request::Attach {
4427                ref buffer,
4428                ref x,
4429                ref y,
4430            } => {
4431                format!("wl_surface@{:?}::attach(buffer: {:?}, x: {:?}, y: {:?})", this, buffer, x, y)
4432            }
4433            Request::Damage {
4434                ref x,
4435                ref y,
4436                ref width,
4437                ref height,
4438            } => {
4439                format!("wl_surface@{:?}::damage(x: {:?}, y: {:?}, width: {:?}, height: {:?})", this, x, y, width, height)
4440            }
4441            Request::Frame {
4442                ref callback,
4443            } => {
4444                format!("wl_surface@{:?}::frame(callback: {:?})", this, callback)
4445            }
4446            Request::SetOpaqueRegion {
4447                ref region,
4448            } => {
4449                format!("wl_surface@{:?}::set_opaque_region(region: {:?})", this, region)
4450            }
4451            Request::SetInputRegion {
4452                ref region,
4453            } => {
4454                format!("wl_surface@{:?}::set_input_region(region: {:?})", this, region)
4455            }
4456            Request::Commit {
4457            } => {
4458                format!("wl_surface@{:?}::commit()", this)
4459            }
4460            Request::SetBufferTransform {
4461                ref transform,
4462            } => {
4463                format!("wl_surface@{:?}::set_buffer_transform(transform: {:?})", this, transform)
4464            }
4465            Request::SetBufferScale {
4466                ref scale,
4467            } => {
4468                format!("wl_surface@{:?}::set_buffer_scale(scale: {:?})", this, scale)
4469            }
4470            Request::DamageBuffer {
4471                ref x,
4472                ref y,
4473                ref width,
4474                ref height,
4475            } => {
4476                format!("wl_surface@{:?}::damage_buffer(x: {:?}, y: {:?}, width: {:?}, height: {:?})", this, x, y, width, height)
4477            }
4478        }
4479    }
4480    fn message_name(&self) -> &'static std::ffi::CStr{
4481        match *self {
4482            Request::Destroy { .. } => c"wl_surface::destroy",
4483            Request::Attach { .. } => c"wl_surface::attach",
4484            Request::Damage { .. } => c"wl_surface::damage",
4485            Request::Frame { .. } => c"wl_surface::frame",
4486            Request::SetOpaqueRegion { .. } => c"wl_surface::set_opaque_region",
4487            Request::SetInputRegion { .. } => c"wl_surface::set_input_region",
4488            Request::Commit { .. } => c"wl_surface::commit",
4489            Request::SetBufferTransform { .. } => c"wl_surface::set_buffer_transform",
4490            Request::SetBufferScale { .. } => c"wl_surface::set_buffer_scale",
4491            Request::DamageBuffer { .. } => c"wl_surface::damage_buffer",
4492        }
4493    }
4494}
4495#[derive(Debug)]
4496pub enum Event {
4497
4498    /// surface enters an output
4499    ///
4500    /// This is emitted whenever a surface's creation, movement, or resizing
4501    /// results in some part of it being within the scanout region of an
4502    /// output.
4503    /// 
4504    /// Note that a surface may be overlapping with zero or more outputs.
4505    Enter {
4506        /// output entered by the surface
4507        output: ObjectId,
4508    },
4509
4510    /// surface leaves an output
4511    ///
4512    /// This is emitted whenever a surface's creation, movement, or resizing
4513    /// results in it no longer having any part of it within the scanout region
4514    /// of an output.
4515    Leave {
4516        /// output left by the surface
4517        output: ObjectId,
4518    },
4519}
4520
4521impl MessageType for Event {
4522    fn log(&self, this: ObjectId) -> String {
4523        match *self {
4524            Event::Enter {
4525                ref output,
4526            } => {
4527                format!("wl_surface@{:?}::enter(output: {:?})", this, output)
4528            }
4529            Event::Leave {
4530                ref output,
4531            } => {
4532                format!("wl_surface@{:?}::leave(output: {:?})", this, output)
4533            }
4534        }
4535    }
4536    fn message_name(&self) -> &'static std::ffi::CStr{
4537        match *self {
4538            Event::Enter { .. } => c"wl_surface::enter",
4539            Event::Leave { .. } => c"wl_surface::leave",
4540        }
4541    }
4542}
4543impl IntoMessage for Event {
4544    type Error = EncodeError;
4545    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
4546        let mut header = MessageHeader {
4547            sender: id,
4548            opcode: 0,
4549            length: 0,
4550        };
4551        let mut msg = Message::new();
4552        msg.write_header(&header)?;
4553        match self {
4554        Event::Enter {
4555            output,
4556        } => {
4557            msg.write_arg(Arg::Object(output))?;
4558            header.opcode = 0;
4559        },
4560        Event::Leave {
4561            output,
4562        } => {
4563            msg.write_arg(Arg::Object(output))?;
4564            header.opcode = 1;
4565        },
4566        }
4567        header.length = msg.bytes().len() as u16;
4568        msg.rewind();
4569        msg.write_header(&header)?;
4570        Ok(msg)
4571    }
4572}
4573impl FromArgs for Request {
4574    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
4575        match op {
4576        0 /* destroy */ => {
4577            let mut iter = args.into_iter();
4578            Ok(Request::Destroy {
4579
4580            })
4581        },
4582        1 /* attach */ => {
4583            let mut iter = args.into_iter();
4584            Ok(Request::Attach {
4585                buffer: iter.next()
4586                                             .ok_or(DecodeError::InsufficientArgs)?
4587                                             .as_object()?,
4588                x: iter.next()
4589                                             .ok_or(DecodeError::InsufficientArgs)?
4590                                             .as_int()?,
4591                y: iter.next()
4592                                             .ok_or(DecodeError::InsufficientArgs)?
4593                                             .as_int()?,
4594
4595            })
4596        },
4597        2 /* damage */ => {
4598            let mut iter = args.into_iter();
4599            Ok(Request::Damage {
4600                x: iter.next()
4601                                             .ok_or(DecodeError::InsufficientArgs)?
4602                                             .as_int()?,
4603                y: iter.next()
4604                                             .ok_or(DecodeError::InsufficientArgs)?
4605                                             .as_int()?,
4606                width: iter.next()
4607                                             .ok_or(DecodeError::InsufficientArgs)?
4608                                             .as_int()?,
4609                height: iter.next()
4610                                             .ok_or(DecodeError::InsufficientArgs)?
4611                                             .as_int()?,
4612
4613            })
4614        },
4615        3 /* frame */ => {
4616            let mut iter = args.into_iter();
4617            Ok(Request::Frame {
4618                callback: iter.next()
4619                                             .ok_or(DecodeError::InsufficientArgs)?
4620                                             .as_new_id()?.into(),
4621
4622            })
4623        },
4624        4 /* set_opaque_region */ => {
4625            let mut iter = args.into_iter();
4626            Ok(Request::SetOpaqueRegion {
4627                region: iter.next()
4628                                             .ok_or(DecodeError::InsufficientArgs)?
4629                                             .as_object()?,
4630
4631            })
4632        },
4633        5 /* set_input_region */ => {
4634            let mut iter = args.into_iter();
4635            Ok(Request::SetInputRegion {
4636                region: iter.next()
4637                                             .ok_or(DecodeError::InsufficientArgs)?
4638                                             .as_object()?,
4639
4640            })
4641        },
4642        6 /* commit */ => {
4643            let mut iter = args.into_iter();
4644            Ok(Request::Commit {
4645
4646            })
4647        },
4648        7 /* set_buffer_transform */ => {
4649            let mut iter = args.into_iter();
4650            Ok(Request::SetBufferTransform {
4651                transform: iter.next()
4652                                             .ok_or(DecodeError::InsufficientArgs)?
4653                                             .as_uint().map(|i| match crate::wl_output::Transform::from_bits(i) {
4654                                      Some(e) => Enum::Recognized(e),
4655                                      None => Enum::Unrecognized(i),
4656                                 })?,
4657
4658            })
4659        },
4660        8 /* set_buffer_scale */ => {
4661            let mut iter = args.into_iter();
4662            Ok(Request::SetBufferScale {
4663                scale: iter.next()
4664                                             .ok_or(DecodeError::InsufficientArgs)?
4665                                             .as_int()?,
4666
4667            })
4668        },
4669        9 /* damage_buffer */ => {
4670            let mut iter = args.into_iter();
4671            Ok(Request::DamageBuffer {
4672                x: iter.next()
4673                                             .ok_or(DecodeError::InsufficientArgs)?
4674                                             .as_int()?,
4675                y: iter.next()
4676                                             .ok_or(DecodeError::InsufficientArgs)?
4677                                             .as_int()?,
4678                width: iter.next()
4679                                             .ok_or(DecodeError::InsufficientArgs)?
4680                                             .as_int()?,
4681                height: iter.next()
4682                                             .ok_or(DecodeError::InsufficientArgs)?
4683                                             .as_int()?,
4684
4685            })
4686        },
4687        _ => {
4688            Err(DecodeError::InvalidOpcode(op).into())
4689        },
4690        }
4691    }
4692}
4693
4694/// wl_surface error values
4695///
4696/// These errors can be emitted in response to wl_surface requests.
4697#[derive(Copy, Clone, Debug, Eq, PartialEq)]
4698#[repr(u32)]
4699pub enum Error {
4700    /// buffer scale value is invalid,
4701    InvalidScale = 0,
4702    /// buffer transform value is invalid,
4703    InvalidTransform = 1,
4704    /// buffer size is invalid,
4705    InvalidSize = 2,
4706}
4707
4708impl Error {
4709    pub fn from_bits(v: u32) -> Option<Self> {
4710        match v {
4711        0 => Some(Error::InvalidScale),
4712        1 => Some(Error::InvalidTransform),
4713        2 => Some(Error::InvalidSize),
4714        _ => None,
4715        }
4716    }
4717
4718    pub fn bits(&self) -> u32 {
4719        *self as u32
4720    }
4721}
4722impl Into<Arg> for Error {
4723    fn into(self) -> Arg {
4724        Arg::Uint(self.bits())
4725    }
4726}
4727} // mod wl_surface
4728
4729pub use crate::wl_surface::WlSurface;
4730pub use crate::wl_surface::Request as WlSurfaceRequest;
4731pub use crate::wl_surface::Event as WlSurfaceEvent;
4732pub mod wl_seat {
4733use super::*;
4734
4735/// group of input devices
4736///
4737/// A seat is a group of keyboards, pointer and touch devices. This
4738/// object is published as a global during start up, or when such a
4739/// device is hot plugged.  A seat typically has a pointer and
4740/// maintains a keyboard focus and a pointer focus.
4741#[derive(Debug)]
4742pub struct WlSeat;
4743
4744impl Interface for WlSeat {
4745    const NAME: &'static str = "wl_seat";
4746    const VERSION: u32 = 7;
4747    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
4748        // get_pointer
4749        MessageSpec(&[
4750            ArgKind::NewId,
4751        ]),
4752        // get_keyboard
4753        MessageSpec(&[
4754            ArgKind::NewId,
4755        ]),
4756        // get_touch
4757        MessageSpec(&[
4758            ArgKind::NewId,
4759        ]),
4760        // release
4761        MessageSpec(&[
4762        ]),
4763    ]);
4764    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
4765        // capabilities
4766        MessageSpec(&[
4767            ArgKind::Uint,
4768        ]),
4769        // name
4770        MessageSpec(&[
4771            ArgKind::String,
4772        ]),
4773    ]);
4774    type Incoming = Request;
4775    type Outgoing = Event;
4776}
4777
4778#[derive(Debug)]
4779pub enum Request {
4780
4781    /// return pointer object
4782    ///
4783    /// The ID provided will be initialized to the wl_pointer interface
4784    /// for this seat.
4785    /// 
4786    /// This request only takes effect if the seat has the pointer
4787    /// capability, or has had the pointer capability in the past.
4788    /// It is a protocol violation to issue this request on a seat that has
4789    /// never had the pointer capability. The missing_capability error will
4790    /// be sent in this case.
4791    GetPointer {
4792        /// seat pointer
4793        id: NewObject<WlPointer>,
4794    },
4795
4796    /// return keyboard object
4797    ///
4798    /// The ID provided will be initialized to the wl_keyboard interface
4799    /// for this seat.
4800    /// 
4801    /// This request only takes effect if the seat has the keyboard
4802    /// capability, or has had the keyboard capability in the past.
4803    /// It is a protocol violation to issue this request on a seat that has
4804    /// never had the keyboard capability. The missing_capability error will
4805    /// be sent in this case.
4806    GetKeyboard {
4807        /// seat keyboard
4808        id: NewObject<WlKeyboard>,
4809    },
4810
4811    /// return touch object
4812    ///
4813    /// The ID provided will be initialized to the wl_touch interface
4814    /// for this seat.
4815    /// 
4816    /// This request only takes effect if the seat has the touch
4817    /// capability, or has had the touch capability in the past.
4818    /// It is a protocol violation to issue this request on a seat that has
4819    /// never had the touch capability. The missing_capability error will
4820    /// be sent in this case.
4821    GetTouch {
4822        /// seat touch interface
4823        id: NewObject<WlTouch>,
4824    },
4825
4826    /// release the seat object
4827    ///
4828    /// Using this request a client can tell the server that it is not going to
4829    /// use the seat object anymore.
4830    Release,
4831}
4832
4833impl MessageType for Request {
4834    fn log(&self, this: ObjectId) -> String {
4835        match *self {
4836            Request::GetPointer {
4837                ref id,
4838            } => {
4839                format!("wl_seat@{:?}::get_pointer(id: {:?})", this, id)
4840            }
4841            Request::GetKeyboard {
4842                ref id,
4843            } => {
4844                format!("wl_seat@{:?}::get_keyboard(id: {:?})", this, id)
4845            }
4846            Request::GetTouch {
4847                ref id,
4848            } => {
4849                format!("wl_seat@{:?}::get_touch(id: {:?})", this, id)
4850            }
4851            Request::Release {
4852            } => {
4853                format!("wl_seat@{:?}::release()", this)
4854            }
4855        }
4856    }
4857    fn message_name(&self) -> &'static std::ffi::CStr{
4858        match *self {
4859            Request::GetPointer { .. } => c"wl_seat::get_pointer",
4860            Request::GetKeyboard { .. } => c"wl_seat::get_keyboard",
4861            Request::GetTouch { .. } => c"wl_seat::get_touch",
4862            Request::Release { .. } => c"wl_seat::release",
4863        }
4864    }
4865}
4866#[derive(Debug)]
4867pub enum Event {
4868
4869    /// seat capabilities changed
4870    ///
4871    /// This is emitted whenever a seat gains or loses the pointer,
4872    /// keyboard or touch capabilities.  The argument is a capability
4873    /// enum containing the complete set of capabilities this seat has.
4874    /// 
4875    /// When the pointer capability is added, a client may create a
4876    /// wl_pointer object using the wl_seat.get_pointer request. This object
4877    /// will receive pointer events until the capability is removed in the
4878    /// future.
4879    /// 
4880    /// When the pointer capability is removed, a client should destroy the
4881    /// wl_pointer objects associated with the seat where the capability was
4882    /// removed, using the wl_pointer.release request. No further pointer
4883    /// events will be received on these objects.
4884    /// 
4885    /// In some compositors, if a seat regains the pointer capability and a
4886    /// client has a previously obtained wl_pointer object of version 4 or
4887    /// less, that object may start sending pointer events again. This
4888    /// behavior is considered a misinterpretation of the intended behavior
4889    /// and must not be relied upon by the client. wl_pointer objects of
4890    /// version 5 or later must not send events if created before the most
4891    /// recent event notifying the client of an added pointer capability.
4892    /// 
4893    /// The above behavior also applies to wl_keyboard and wl_touch with the
4894    /// keyboard and touch capabilities, respectively.
4895    Capabilities {
4896        /// capabilities of the seat
4897        capabilities: Capability,
4898    },
4899
4900    /// unique identifier for this seat
4901    ///
4902    /// In a multiseat configuration this can be used by the client to help
4903    /// identify which physical devices the seat represents. Based on
4904    /// the seat configuration used by the compositor.
4905    Name {
4906        /// seat identifier
4907        name: String,
4908    },
4909}
4910
4911impl MessageType for Event {
4912    fn log(&self, this: ObjectId) -> String {
4913        match *self {
4914            Event::Capabilities {
4915                ref capabilities,
4916            } => {
4917                format!("wl_seat@{:?}::capabilities(capabilities: {:?})", this, capabilities)
4918            }
4919            Event::Name {
4920                ref name,
4921            } => {
4922                format!("wl_seat@{:?}::name(name: {:?})", this, name)
4923            }
4924        }
4925    }
4926    fn message_name(&self) -> &'static std::ffi::CStr{
4927        match *self {
4928            Event::Capabilities { .. } => c"wl_seat::capabilities",
4929            Event::Name { .. } => c"wl_seat::name",
4930        }
4931    }
4932}
4933impl IntoMessage for Event {
4934    type Error = EncodeError;
4935    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
4936        let mut header = MessageHeader {
4937            sender: id,
4938            opcode: 0,
4939            length: 0,
4940        };
4941        let mut msg = Message::new();
4942        msg.write_header(&header)?;
4943        match self {
4944        Event::Capabilities {
4945            capabilities,
4946        } => {
4947            msg.write_arg(Arg::Uint(capabilities.bits()))?;
4948            header.opcode = 0;
4949        },
4950        Event::Name {
4951            name,
4952        } => {
4953            msg.write_arg(Arg::String(name))?;
4954            header.opcode = 1;
4955        },
4956        }
4957        header.length = msg.bytes().len() as u16;
4958        msg.rewind();
4959        msg.write_header(&header)?;
4960        Ok(msg)
4961    }
4962}
4963impl FromArgs for Request {
4964    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
4965        match op {
4966        0 /* get_pointer */ => {
4967            let mut iter = args.into_iter();
4968            Ok(Request::GetPointer {
4969                id: iter.next()
4970                                             .ok_or(DecodeError::InsufficientArgs)?
4971                                             .as_new_id()?.into(),
4972
4973            })
4974        },
4975        1 /* get_keyboard */ => {
4976            let mut iter = args.into_iter();
4977            Ok(Request::GetKeyboard {
4978                id: iter.next()
4979                                             .ok_or(DecodeError::InsufficientArgs)?
4980                                             .as_new_id()?.into(),
4981
4982            })
4983        },
4984        2 /* get_touch */ => {
4985            let mut iter = args.into_iter();
4986            Ok(Request::GetTouch {
4987                id: iter.next()
4988                                             .ok_or(DecodeError::InsufficientArgs)?
4989                                             .as_new_id()?.into(),
4990
4991            })
4992        },
4993        3 /* release */ => {
4994            let mut iter = args.into_iter();
4995            Ok(Request::Release {
4996
4997            })
4998        },
4999        _ => {
5000            Err(DecodeError::InvalidOpcode(op).into())
5001        },
5002        }
5003    }
5004}
5005::bitflags::bitflags! {
5006
5007    /// seat capability bitmask
5008    ///
5009    /// This is a bitmask of capabilities this seat has; if a member is
5010    /// set, then it is present on the seat.
5011    #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
5012    pub struct Capability: u32 {
5013        /// the seat has pointer devices,
5014        const Pointer = 1;
5015        /// the seat has one or more keyboards,
5016        const Keyboard = 2;
5017        /// the seat has touch devices,
5018        const Touch = 4;
5019    }
5020}
5021impl Into<Arg> for Capability {
5022    fn into(self) -> Arg {
5023        Arg::Uint(self.bits())
5024    }
5025}
5026
5027/// wl_seat error values
5028///
5029/// These errors can be emitted in response to wl_seat requests.
5030#[derive(Copy, Clone, Debug, Eq, PartialEq)]
5031#[repr(u32)]
5032pub enum Error {
5033    /// get_pointer, get_keyboard or get_touch called on seat without the matching capability,
5034    MissingCapability = 0,
5035}
5036
5037impl Error {
5038    pub fn from_bits(v: u32) -> Option<Self> {
5039        match v {
5040        0 => Some(Error::MissingCapability),
5041        _ => None,
5042        }
5043    }
5044
5045    pub fn bits(&self) -> u32 {
5046        *self as u32
5047    }
5048}
5049impl Into<Arg> for Error {
5050    fn into(self) -> Arg {
5051        Arg::Uint(self.bits())
5052    }
5053}
5054} // mod wl_seat
5055
5056pub use crate::wl_seat::WlSeat;
5057pub use crate::wl_seat::Request as WlSeatRequest;
5058pub use crate::wl_seat::Event as WlSeatEvent;
5059pub mod wl_pointer {
5060use super::*;
5061
5062/// pointer input device
5063///
5064/// The wl_pointer interface represents one or more input devices,
5065/// such as mice, which control the pointer location and pointer_focus
5066/// of a seat.
5067/// 
5068/// The wl_pointer interface generates motion, enter and leave
5069/// events for the surfaces that the pointer is located over,
5070/// and button and axis events for button presses, button releases
5071/// and scrolling.
5072#[derive(Debug)]
5073pub struct WlPointer;
5074
5075impl Interface for WlPointer {
5076    const NAME: &'static str = "wl_pointer";
5077    const VERSION: u32 = 7;
5078    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
5079        // set_cursor
5080        MessageSpec(&[
5081            ArgKind::Uint,
5082            ArgKind::Object,
5083            ArgKind::Int,
5084            ArgKind::Int,
5085        ]),
5086        // release
5087        MessageSpec(&[
5088        ]),
5089    ]);
5090    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
5091        // enter
5092        MessageSpec(&[
5093            ArgKind::Uint,
5094            ArgKind::Object,
5095            ArgKind::Fixed,
5096            ArgKind::Fixed,
5097        ]),
5098        // leave
5099        MessageSpec(&[
5100            ArgKind::Uint,
5101            ArgKind::Object,
5102        ]),
5103        // motion
5104        MessageSpec(&[
5105            ArgKind::Uint,
5106            ArgKind::Fixed,
5107            ArgKind::Fixed,
5108        ]),
5109        // button
5110        MessageSpec(&[
5111            ArgKind::Uint,
5112            ArgKind::Uint,
5113            ArgKind::Uint,
5114            ArgKind::Uint,
5115        ]),
5116        // axis
5117        MessageSpec(&[
5118            ArgKind::Uint,
5119            ArgKind::Uint,
5120            ArgKind::Fixed,
5121        ]),
5122        // frame
5123        MessageSpec(&[
5124        ]),
5125        // axis_source
5126        MessageSpec(&[
5127            ArgKind::Uint,
5128        ]),
5129        // axis_stop
5130        MessageSpec(&[
5131            ArgKind::Uint,
5132            ArgKind::Uint,
5133        ]),
5134        // axis_discrete
5135        MessageSpec(&[
5136            ArgKind::Uint,
5137            ArgKind::Int,
5138        ]),
5139    ]);
5140    type Incoming = Request;
5141    type Outgoing = Event;
5142}
5143
5144#[derive(Debug)]
5145pub enum Request {
5146
5147    /// set the pointer surface
5148    ///
5149    /// Set the pointer surface, i.e., the surface that contains the
5150    /// pointer image (cursor). This request gives the surface the role
5151    /// of a cursor. If the surface already has another role, it raises
5152    /// a protocol error.
5153    /// 
5154    /// The cursor actually changes only if the pointer
5155    /// focus for this device is one of the requesting client's surfaces
5156    /// or the surface parameter is the current pointer surface. If
5157    /// there was a previous surface set with this request it is
5158    /// replaced. If surface is NULL, the pointer image is hidden.
5159    /// 
5160    /// The parameters hotspot_x and hotspot_y define the position of
5161    /// the pointer surface relative to the pointer location. Its
5162    /// top-left corner is always at (x, y) - (hotspot_x, hotspot_y),
5163    /// where (x, y) are the coordinates of the pointer location, in
5164    /// surface-local coordinates.
5165    /// 
5166    /// On surface.attach requests to the pointer surface, hotspot_x
5167    /// and hotspot_y are decremented by the x and y parameters
5168    /// passed to the request. Attach must be confirmed by
5169    /// wl_surface.commit as usual.
5170    /// 
5171    /// The hotspot can also be updated by passing the currently set
5172    /// pointer surface to this request with new values for hotspot_x
5173    /// and hotspot_y.
5174    /// 
5175    /// The current and pending input regions of the wl_surface are
5176    /// cleared, and wl_surface.set_input_region is ignored until the
5177    /// wl_surface is no longer used as the cursor. When the use as a
5178    /// cursor ends, the current and pending input regions become
5179    /// undefined, and the wl_surface is unmapped.
5180    SetCursor {
5181        /// serial number of the enter event
5182        serial: u32,
5183        /// pointer surface
5184        surface: ObjectId,
5185        /// surface-local x coordinate
5186        hotspot_x: i32,
5187        /// surface-local y coordinate
5188        hotspot_y: i32,
5189    },
5190
5191    /// release the pointer object
5192    ///
5193    /// Using this request a client can tell the server that it is not going to
5194    /// use the pointer object anymore.
5195    /// 
5196    /// This request destroys the pointer proxy object, so clients must not call
5197    /// wl_pointer_destroy() after using this request.
5198    Release,
5199}
5200
5201impl MessageType for Request {
5202    fn log(&self, this: ObjectId) -> String {
5203        match *self {
5204            Request::SetCursor {
5205                ref serial,
5206                ref surface,
5207                ref hotspot_x,
5208                ref hotspot_y,
5209            } => {
5210                format!("wl_pointer@{:?}::set_cursor(serial: {:?}, surface: {:?}, hotspot_x: {:?}, hotspot_y: {:?})", this, serial, surface, hotspot_x, hotspot_y)
5211            }
5212            Request::Release {
5213            } => {
5214                format!("wl_pointer@{:?}::release()", this)
5215            }
5216        }
5217    }
5218    fn message_name(&self) -> &'static std::ffi::CStr{
5219        match *self {
5220            Request::SetCursor { .. } => c"wl_pointer::set_cursor",
5221            Request::Release { .. } => c"wl_pointer::release",
5222        }
5223    }
5224}
5225#[derive(Debug)]
5226pub enum Event {
5227
5228    /// enter event
5229    ///
5230    /// Notification that this seat's pointer is focused on a certain
5231    /// surface.
5232    /// 
5233    /// When a seat's focus enters a surface, the pointer image
5234    /// is undefined and a client should respond to this event by setting
5235    /// an appropriate pointer image with the set_cursor request.
5236    Enter {
5237        /// serial number of the enter event
5238        serial: u32,
5239        /// surface entered by the pointer
5240        surface: ObjectId,
5241        /// surface-local x coordinate
5242        surface_x: Fixed,
5243        /// surface-local y coordinate
5244        surface_y: Fixed,
5245    },
5246
5247    /// leave event
5248    ///
5249    /// Notification that this seat's pointer is no longer focused on
5250    /// a certain surface.
5251    /// 
5252    /// The leave notification is sent before the enter notification
5253    /// for the new focus.
5254    Leave {
5255        /// serial number of the leave event
5256        serial: u32,
5257        /// surface left by the pointer
5258        surface: ObjectId,
5259    },
5260
5261    /// pointer motion event
5262    ///
5263    /// Notification of pointer location change. The arguments
5264    /// surface_x and surface_y are the location relative to the
5265    /// focused surface.
5266    Motion {
5267        /// timestamp with millisecond granularity
5268        time: u32,
5269        /// surface-local x coordinate
5270        surface_x: Fixed,
5271        /// surface-local y coordinate
5272        surface_y: Fixed,
5273    },
5274
5275    /// pointer button event
5276    ///
5277    /// Mouse button click and release notifications.
5278    /// 
5279    /// The location of the click is given by the last motion or
5280    /// enter event.
5281    /// The time argument is a timestamp with millisecond
5282    /// granularity, with an undefined base.
5283    /// 
5284    /// The button is a button code as defined in the Linux kernel's
5285    /// linux/input-event-codes.h header file, e.g. BTN_LEFT.
5286    /// 
5287    /// Any 16-bit button code value is reserved for future additions to the
5288    /// kernel's event code list. All other button codes above 0xFFFF are
5289    /// currently undefined but may be used in future versions of this
5290    /// protocol.
5291    Button {
5292        /// serial number of the button event
5293        serial: u32,
5294        /// timestamp with millisecond granularity
5295        time: u32,
5296        /// button that produced the event
5297        button: u32,
5298        /// physical state of the button
5299        state: ButtonState,
5300    },
5301
5302    /// axis event
5303    ///
5304    /// Scroll and other axis notifications.
5305    /// 
5306    /// For scroll events (vertical and horizontal scroll axes), the
5307    /// value parameter is the length of a vector along the specified
5308    /// axis in a coordinate space identical to those of motion events,
5309    /// representing a relative movement along the specified axis.
5310    /// 
5311    /// For devices that support movements non-parallel to axes multiple
5312    /// axis events will be emitted.
5313    /// 
5314    /// When applicable, for example for touch pads, the server can
5315    /// choose to emit scroll events where the motion vector is
5316    /// equivalent to a motion event vector.
5317    /// 
5318    /// When applicable, a client can transform its content relative to the
5319    /// scroll distance.
5320    Axis {
5321        /// timestamp with millisecond granularity
5322        time: u32,
5323        /// axis type
5324        axis: Axis,
5325        /// length of vector in surface-local coordinate space
5326        value: Fixed,
5327    },
5328
5329    /// end of a pointer event sequence
5330    ///
5331    /// Indicates the end of a set of events that logically belong together.
5332    /// A client is expected to accumulate the data in all events within the
5333    /// frame before proceeding.
5334    /// 
5335    /// All wl_pointer events before a wl_pointer.frame event belong
5336    /// logically together. For example, in a diagonal scroll motion the
5337    /// compositor will send an optional wl_pointer.axis_source event, two
5338    /// wl_pointer.axis events (horizontal and vertical) and finally a
5339    /// wl_pointer.frame event. The client may use this information to
5340    /// calculate a diagonal vector for scrolling.
5341    /// 
5342    /// When multiple wl_pointer.axis events occur within the same frame,
5343    /// the motion vector is the combined motion of all events.
5344    /// When a wl_pointer.axis and a wl_pointer.axis_stop event occur within
5345    /// the same frame, this indicates that axis movement in one axis has
5346    /// stopped but continues in the other axis.
5347    /// When multiple wl_pointer.axis_stop events occur within the same
5348    /// frame, this indicates that these axes stopped in the same instance.
5349    /// 
5350    /// A wl_pointer.frame event is sent for every logical event group,
5351    /// even if the group only contains a single wl_pointer event.
5352    /// Specifically, a client may get a sequence: motion, frame, button,
5353    /// frame, axis, frame, axis_stop, frame.
5354    /// 
5355    /// The wl_pointer.enter and wl_pointer.leave events are logical events
5356    /// generated by the compositor and not the hardware. These events are
5357    /// also grouped by a wl_pointer.frame. When a pointer moves from one
5358    /// surface to another, a compositor should group the
5359    /// wl_pointer.leave event within the same wl_pointer.frame.
5360    /// However, a client must not rely on wl_pointer.leave and
5361    /// wl_pointer.enter being in the same wl_pointer.frame.
5362    /// Compositor-specific policies may require the wl_pointer.leave and
5363    /// wl_pointer.enter event being split across multiple wl_pointer.frame
5364    /// groups.
5365    Frame,
5366
5367    /// axis source event
5368    ///
5369    /// Source information for scroll and other axes.
5370    /// 
5371    /// This event does not occur on its own. It is sent before a
5372    /// wl_pointer.frame event and carries the source information for
5373    /// all events within that frame.
5374    /// 
5375    /// The source specifies how this event was generated. If the source is
5376    /// wl_pointer.axis_source.finger, a wl_pointer.axis_stop event will be
5377    /// sent when the user lifts the finger off the device.
5378    /// 
5379    /// If the source is wl_pointer.axis_source.wheel,
5380    /// wl_pointer.axis_source.wheel_tilt or
5381    /// wl_pointer.axis_source.continuous, a wl_pointer.axis_stop event may
5382    /// or may not be sent. Whether a compositor sends an axis_stop event
5383    /// for these sources is hardware-specific and implementation-dependent;
5384    /// clients must not rely on receiving an axis_stop event for these
5385    /// scroll sources and should treat scroll sequences from these scroll
5386    /// sources as unterminated by default.
5387    /// 
5388    /// This event is optional. If the source is unknown for a particular
5389    /// axis event sequence, no event is sent.
5390    /// Only one wl_pointer.axis_source event is permitted per frame.
5391    /// 
5392    /// The order of wl_pointer.axis_discrete and wl_pointer.axis_source is
5393    /// not guaranteed.
5394    AxisSource {
5395        /// source of the axis event
5396        axis_source: AxisSource,
5397    },
5398
5399    /// axis stop event
5400    ///
5401    /// Stop notification for scroll and other axes.
5402    /// 
5403    /// For some wl_pointer.axis_source types, a wl_pointer.axis_stop event
5404    /// is sent to notify a client that the axis sequence has terminated.
5405    /// This enables the client to implement kinetic scrolling.
5406    /// See the wl_pointer.axis_source documentation for information on when
5407    /// this event may be generated.
5408    /// 
5409    /// Any wl_pointer.axis events with the same axis_source after this
5410    /// event should be considered as the start of a new axis motion.
5411    /// 
5412    /// The timestamp is to be interpreted identical to the timestamp in the
5413    /// wl_pointer.axis event. The timestamp value may be the same as a
5414    /// preceding wl_pointer.axis event.
5415    AxisStop {
5416        /// timestamp with millisecond granularity
5417        time: u32,
5418        /// the axis stopped with this event
5419        axis: Axis,
5420    },
5421
5422    /// axis click event
5423    ///
5424    /// Discrete step information for scroll and other axes.
5425    /// 
5426    /// This event carries the axis value of the wl_pointer.axis event in
5427    /// discrete steps (e.g. mouse wheel clicks).
5428    /// 
5429    /// This event does not occur on its own, it is coupled with a
5430    /// wl_pointer.axis event that represents this axis value on a
5431    /// continuous scale. The protocol guarantees that each axis_discrete
5432    /// event is always followed by exactly one axis event with the same
5433    /// axis number within the same wl_pointer.frame. Note that the protocol
5434    /// allows for other events to occur between the axis_discrete and
5435    /// its coupled axis event, including other axis_discrete or axis
5436    /// events.
5437    /// 
5438    /// This event is optional; continuous scrolling devices
5439    /// like two-finger scrolling on touchpads do not have discrete
5440    /// steps and do not generate this event.
5441    /// 
5442    /// The discrete value carries the directional information. e.g. a value
5443    /// of -2 is two steps towards the negative direction of this axis.
5444    /// 
5445    /// The axis number is identical to the axis number in the associated
5446    /// axis event.
5447    /// 
5448    /// The order of wl_pointer.axis_discrete and wl_pointer.axis_source is
5449    /// not guaranteed.
5450    AxisDiscrete {
5451        /// axis type
5452        axis: Axis,
5453        /// number of steps
5454        discrete: i32,
5455    },
5456}
5457
5458impl MessageType for Event {
5459    fn log(&self, this: ObjectId) -> String {
5460        match *self {
5461            Event::Enter {
5462                ref serial,
5463                ref surface,
5464                ref surface_x,
5465                ref surface_y,
5466            } => {
5467                format!("wl_pointer@{:?}::enter(serial: {:?}, surface: {:?}, surface_x: {:?}, surface_y: {:?})", this, serial, surface, surface_x, surface_y)
5468            }
5469            Event::Leave {
5470                ref serial,
5471                ref surface,
5472            } => {
5473                format!("wl_pointer@{:?}::leave(serial: {:?}, surface: {:?})", this, serial, surface)
5474            }
5475            Event::Motion {
5476                ref time,
5477                ref surface_x,
5478                ref surface_y,
5479            } => {
5480                format!("wl_pointer@{:?}::motion(time: {:?}, surface_x: {:?}, surface_y: {:?})", this, time, surface_x, surface_y)
5481            }
5482            Event::Button {
5483                ref serial,
5484                ref time,
5485                ref button,
5486                ref state,
5487            } => {
5488                format!("wl_pointer@{:?}::button(serial: {:?}, time: {:?}, button: {:?}, state: {:?})", this, serial, time, button, state)
5489            }
5490            Event::Axis {
5491                ref time,
5492                ref axis,
5493                ref value,
5494            } => {
5495                format!("wl_pointer@{:?}::axis(time: {:?}, axis: {:?}, value: {:?})", this, time, axis, value)
5496            }
5497            Event::Frame {
5498            } => {
5499                format!("wl_pointer@{:?}::frame()", this)
5500            }
5501            Event::AxisSource {
5502                ref axis_source,
5503            } => {
5504                format!("wl_pointer@{:?}::axis_source(axis_source: {:?})", this, axis_source)
5505            }
5506            Event::AxisStop {
5507                ref time,
5508                ref axis,
5509            } => {
5510                format!("wl_pointer@{:?}::axis_stop(time: {:?}, axis: {:?})", this, time, axis)
5511            }
5512            Event::AxisDiscrete {
5513                ref axis,
5514                ref discrete,
5515            } => {
5516                format!("wl_pointer@{:?}::axis_discrete(axis: {:?}, discrete: {:?})", this, axis, discrete)
5517            }
5518        }
5519    }
5520    fn message_name(&self) -> &'static std::ffi::CStr{
5521        match *self {
5522            Event::Enter { .. } => c"wl_pointer::enter",
5523            Event::Leave { .. } => c"wl_pointer::leave",
5524            Event::Motion { .. } => c"wl_pointer::motion",
5525            Event::Button { .. } => c"wl_pointer::button",
5526            Event::Axis { .. } => c"wl_pointer::axis",
5527            Event::Frame { .. } => c"wl_pointer::frame",
5528            Event::AxisSource { .. } => c"wl_pointer::axis_source",
5529            Event::AxisStop { .. } => c"wl_pointer::axis_stop",
5530            Event::AxisDiscrete { .. } => c"wl_pointer::axis_discrete",
5531        }
5532    }
5533}
5534impl IntoMessage for Event {
5535    type Error = EncodeError;
5536    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
5537        let mut header = MessageHeader {
5538            sender: id,
5539            opcode: 0,
5540            length: 0,
5541        };
5542        let mut msg = Message::new();
5543        msg.write_header(&header)?;
5544        match self {
5545        Event::Enter {
5546            serial,
5547            surface,
5548            surface_x,
5549            surface_y,
5550        } => {
5551            msg.write_arg(Arg::Uint(serial))?;
5552            msg.write_arg(Arg::Object(surface))?;
5553            msg.write_arg(Arg::Fixed(surface_x))?;
5554            msg.write_arg(Arg::Fixed(surface_y))?;
5555            header.opcode = 0;
5556        },
5557        Event::Leave {
5558            serial,
5559            surface,
5560        } => {
5561            msg.write_arg(Arg::Uint(serial))?;
5562            msg.write_arg(Arg::Object(surface))?;
5563            header.opcode = 1;
5564        },
5565        Event::Motion {
5566            time,
5567            surface_x,
5568            surface_y,
5569        } => {
5570            msg.write_arg(Arg::Uint(time))?;
5571            msg.write_arg(Arg::Fixed(surface_x))?;
5572            msg.write_arg(Arg::Fixed(surface_y))?;
5573            header.opcode = 2;
5574        },
5575        Event::Button {
5576            serial,
5577            time,
5578            button,
5579            state,
5580        } => {
5581            msg.write_arg(Arg::Uint(serial))?;
5582            msg.write_arg(Arg::Uint(time))?;
5583            msg.write_arg(Arg::Uint(button))?;
5584            msg.write_arg(Arg::Uint(state.bits()))?;
5585            header.opcode = 3;
5586        },
5587        Event::Axis {
5588            time,
5589            axis,
5590            value,
5591        } => {
5592            msg.write_arg(Arg::Uint(time))?;
5593            msg.write_arg(Arg::Uint(axis.bits()))?;
5594            msg.write_arg(Arg::Fixed(value))?;
5595            header.opcode = 4;
5596        },
5597        Event::Frame {
5598        } => {
5599            header.opcode = 5;
5600        },
5601        Event::AxisSource {
5602            axis_source,
5603        } => {
5604            msg.write_arg(Arg::Uint(axis_source.bits()))?;
5605            header.opcode = 6;
5606        },
5607        Event::AxisStop {
5608            time,
5609            axis,
5610        } => {
5611            msg.write_arg(Arg::Uint(time))?;
5612            msg.write_arg(Arg::Uint(axis.bits()))?;
5613            header.opcode = 7;
5614        },
5615        Event::AxisDiscrete {
5616            axis,
5617            discrete,
5618        } => {
5619            msg.write_arg(Arg::Uint(axis.bits()))?;
5620            msg.write_arg(Arg::Int(discrete))?;
5621            header.opcode = 8;
5622        },
5623        }
5624        header.length = msg.bytes().len() as u16;
5625        msg.rewind();
5626        msg.write_header(&header)?;
5627        Ok(msg)
5628    }
5629}
5630impl FromArgs for Request {
5631    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
5632        match op {
5633        0 /* set_cursor */ => {
5634            let mut iter = args.into_iter();
5635            Ok(Request::SetCursor {
5636                serial: iter.next()
5637                                             .ok_or(DecodeError::InsufficientArgs)?
5638                                             .as_uint()?,
5639                surface: iter.next()
5640                                             .ok_or(DecodeError::InsufficientArgs)?
5641                                             .as_object()?,
5642                hotspot_x: iter.next()
5643                                             .ok_or(DecodeError::InsufficientArgs)?
5644                                             .as_int()?,
5645                hotspot_y: iter.next()
5646                                             .ok_or(DecodeError::InsufficientArgs)?
5647                                             .as_int()?,
5648
5649            })
5650        },
5651        1 /* release */ => {
5652            let mut iter = args.into_iter();
5653            Ok(Request::Release {
5654
5655            })
5656        },
5657        _ => {
5658            Err(DecodeError::InvalidOpcode(op).into())
5659        },
5660        }
5661    }
5662}
5663#[derive(Copy, Clone, Debug, Eq, PartialEq)]
5664#[repr(u32)]
5665pub enum Error {
5666    /// given wl_surface has another role,
5667    Role = 0,
5668}
5669
5670impl Error {
5671    pub fn from_bits(v: u32) -> Option<Self> {
5672        match v {
5673        0 => Some(Error::Role),
5674        _ => None,
5675        }
5676    }
5677
5678    pub fn bits(&self) -> u32 {
5679        *self as u32
5680    }
5681}
5682impl Into<Arg> for Error {
5683    fn into(self) -> Arg {
5684        Arg::Uint(self.bits())
5685    }
5686}
5687
5688/// physical button state
5689///
5690/// Describes the physical state of a button that produced the button
5691/// event.
5692#[derive(Copy, Clone, Debug, Eq, PartialEq)]
5693#[repr(u32)]
5694pub enum ButtonState {
5695    /// the button is not pressed,
5696    Released = 0,
5697    /// the button is pressed,
5698    Pressed = 1,
5699}
5700
5701impl ButtonState {
5702    pub fn from_bits(v: u32) -> Option<Self> {
5703        match v {
5704        0 => Some(ButtonState::Released),
5705        1 => Some(ButtonState::Pressed),
5706        _ => None,
5707        }
5708    }
5709
5710    pub fn bits(&self) -> u32 {
5711        *self as u32
5712    }
5713}
5714impl Into<Arg> for ButtonState {
5715    fn into(self) -> Arg {
5716        Arg::Uint(self.bits())
5717    }
5718}
5719
5720/// axis types
5721///
5722/// Describes the axis types of scroll events.
5723#[derive(Copy, Clone, Debug, Eq, PartialEq)]
5724#[repr(u32)]
5725pub enum Axis {
5726    /// vertical axis,
5727    VerticalScroll = 0,
5728    /// horizontal axis,
5729    HorizontalScroll = 1,
5730}
5731
5732impl Axis {
5733    pub fn from_bits(v: u32) -> Option<Self> {
5734        match v {
5735        0 => Some(Axis::VerticalScroll),
5736        1 => Some(Axis::HorizontalScroll),
5737        _ => None,
5738        }
5739    }
5740
5741    pub fn bits(&self) -> u32 {
5742        *self as u32
5743    }
5744}
5745impl Into<Arg> for Axis {
5746    fn into(self) -> Arg {
5747        Arg::Uint(self.bits())
5748    }
5749}
5750
5751/// axis source types
5752///
5753/// Describes the source types for axis events. This indicates to the
5754/// client how an axis event was physically generated; a client may
5755/// adjust the user interface accordingly. For example, scroll events
5756/// from a "finger" source may be in a smooth coordinate space with
5757/// kinetic scrolling whereas a "wheel" source may be in discrete steps
5758/// of a number of lines.
5759/// 
5760/// The "continuous" axis source is a device generating events in a
5761/// continuous coordinate space, but using something other than a
5762/// finger. One example for this source is button-based scrolling where
5763/// the vertical motion of a device is converted to scroll events while
5764/// a button is held down.
5765/// 
5766/// The "wheel tilt" axis source indicates that the actual device is a
5767/// wheel but the scroll event is not caused by a rotation but a
5768/// (usually sideways) tilt of the wheel.
5769#[derive(Copy, Clone, Debug, Eq, PartialEq)]
5770#[repr(u32)]
5771pub enum AxisSource {
5772    /// a physical wheel rotation,
5773    Wheel = 0,
5774    /// finger on a touch surface,
5775    Finger = 1,
5776    /// continuous coordinate space,
5777    Continuous = 2,
5778    /// a physical wheel tilt,
5779    WheelTilt = 3,
5780}
5781
5782impl AxisSource {
5783    pub fn from_bits(v: u32) -> Option<Self> {
5784        match v {
5785        0 => Some(AxisSource::Wheel),
5786        1 => Some(AxisSource::Finger),
5787        2 => Some(AxisSource::Continuous),
5788        3 => Some(AxisSource::WheelTilt),
5789        _ => None,
5790        }
5791    }
5792
5793    pub fn bits(&self) -> u32 {
5794        *self as u32
5795    }
5796}
5797impl Into<Arg> for AxisSource {
5798    fn into(self) -> Arg {
5799        Arg::Uint(self.bits())
5800    }
5801}
5802} // mod wl_pointer
5803
5804pub use crate::wl_pointer::WlPointer;
5805pub use crate::wl_pointer::Request as WlPointerRequest;
5806pub use crate::wl_pointer::Event as WlPointerEvent;
5807pub mod wl_keyboard {
5808use super::*;
5809
5810/// keyboard input device
5811///
5812/// The wl_keyboard interface represents one or more keyboards
5813/// associated with a seat.
5814#[derive(Debug)]
5815pub struct WlKeyboard;
5816
5817impl Interface for WlKeyboard {
5818    const NAME: &'static str = "wl_keyboard";
5819    const VERSION: u32 = 7;
5820    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
5821        // release
5822        MessageSpec(&[
5823        ]),
5824    ]);
5825    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
5826        // keymap
5827        MessageSpec(&[
5828            ArgKind::Uint,
5829            ArgKind::Handle,
5830            ArgKind::Uint,
5831        ]),
5832        // enter
5833        MessageSpec(&[
5834            ArgKind::Uint,
5835            ArgKind::Object,
5836            ArgKind::Array,
5837        ]),
5838        // leave
5839        MessageSpec(&[
5840            ArgKind::Uint,
5841            ArgKind::Object,
5842        ]),
5843        // key
5844        MessageSpec(&[
5845            ArgKind::Uint,
5846            ArgKind::Uint,
5847            ArgKind::Uint,
5848            ArgKind::Uint,
5849        ]),
5850        // modifiers
5851        MessageSpec(&[
5852            ArgKind::Uint,
5853            ArgKind::Uint,
5854            ArgKind::Uint,
5855            ArgKind::Uint,
5856            ArgKind::Uint,
5857        ]),
5858        // repeat_info
5859        MessageSpec(&[
5860            ArgKind::Int,
5861            ArgKind::Int,
5862        ]),
5863    ]);
5864    type Incoming = Request;
5865    type Outgoing = Event;
5866}
5867
5868#[derive(Debug)]
5869pub enum Request {
5870
5871    /// release the keyboard object
5872    ///
5873    Release,
5874}
5875
5876impl MessageType for Request {
5877    fn log(&self, this: ObjectId) -> String {
5878        match *self {
5879            Request::Release {
5880            } => {
5881                format!("wl_keyboard@{:?}::release()", this)
5882            }
5883        }
5884    }
5885    fn message_name(&self) -> &'static std::ffi::CStr{
5886        match *self {
5887            Request::Release { .. } => c"wl_keyboard::release",
5888        }
5889    }
5890}
5891#[derive(Debug)]
5892pub enum Event {
5893
5894    /// keyboard mapping
5895    ///
5896    /// This event provides a file descriptor to the client which can be
5897    /// memory-mapped to provide a keyboard mapping description.
5898    /// 
5899    /// From version 7 onwards, the fd must be mapped with MAP_PRIVATE by
5900    /// the recipient, as MAP_SHARED may fail.
5901    Keymap {
5902        /// keymap format
5903        format: KeymapFormat,
5904        /// keymap file descriptor
5905        fd: zx::Handle,
5906        /// keymap size, in bytes
5907        size: u32,
5908    },
5909
5910    /// enter event
5911    ///
5912    /// Notification that this seat's keyboard focus is on a certain
5913    /// surface.
5914    /// 
5915    /// The compositor must send the wl_keyboard.modifiers event after this
5916    /// event.
5917    Enter {
5918        /// serial number of the enter event
5919        serial: u32,
5920        /// surface gaining keyboard focus
5921        surface: ObjectId,
5922        /// the currently pressed keys
5923        keys: Array,
5924    },
5925
5926    /// leave event
5927    ///
5928    /// Notification that this seat's keyboard focus is no longer on
5929    /// a certain surface.
5930    /// 
5931    /// The leave notification is sent before the enter notification
5932    /// for the new focus.
5933    /// 
5934    /// After this event client must assume that all keys, including modifiers,
5935    /// are lifted and also it must stop key repeating if there's some going on.
5936    Leave {
5937        /// serial number of the leave event
5938        serial: u32,
5939        /// surface that lost keyboard focus
5940        surface: ObjectId,
5941    },
5942
5943    /// key event
5944    ///
5945    /// A key was pressed or released.
5946    /// The time argument is a timestamp with millisecond
5947    /// granularity, with an undefined base.
5948    /// 
5949    /// The key is a platform-specific key code that can be interpreted
5950    /// by feeding it to the keyboard mapping (see the keymap event).
5951    /// 
5952    /// If this event produces a change in modifiers, then the resulting
5953    /// wl_keyboard.modifiers event must be sent after this event.
5954    Key {
5955        /// serial number of the key event
5956        serial: u32,
5957        /// timestamp with millisecond granularity
5958        time: u32,
5959        /// key that produced the event
5960        key: u32,
5961        /// physical state of the key
5962        state: KeyState,
5963    },
5964
5965    /// modifier and group state
5966    ///
5967    /// Notifies clients that the modifier and/or group state has
5968    /// changed, and it should update its local state.
5969    Modifiers {
5970        /// serial number of the modifiers event
5971        serial: u32,
5972        /// depressed modifiers
5973        mods_depressed: u32,
5974        /// latched modifiers
5975        mods_latched: u32,
5976        /// locked modifiers
5977        mods_locked: u32,
5978        /// keyboard layout
5979        group: u32,
5980    },
5981
5982    /// repeat rate and delay
5983    ///
5984    /// Informs the client about the keyboard's repeat rate and delay.
5985    /// 
5986    /// This event is sent as soon as the wl_keyboard object has been created,
5987    /// and is guaranteed to be received by the client before any key press
5988    /// event.
5989    /// 
5990    /// Negative values for either rate or delay are illegal. A rate of zero
5991    /// will disable any repeating (regardless of the value of delay).
5992    /// 
5993    /// This event can be sent later on as well with a new value if necessary,
5994    /// so clients should continue listening for the event past the creation
5995    /// of wl_keyboard.
5996    RepeatInfo {
5997        /// the rate of repeating keys in characters per second
5998        rate: i32,
5999        /// delay in milliseconds since key down until repeating starts
6000        delay: i32,
6001    },
6002}
6003
6004impl MessageType for Event {
6005    fn log(&self, this: ObjectId) -> String {
6006        match *self {
6007            Event::Keymap {
6008                ref format,
6009                ref fd,
6010                ref size,
6011            } => {
6012                format!("wl_keyboard@{:?}::keymap(format: {:?}, fd: <handle>, size: {:?})", this, format, size)
6013            }
6014            Event::Enter {
6015                ref serial,
6016                ref surface,
6017                ref keys,
6018            } => {
6019                format!("wl_keyboard@{:?}::enter(serial: {:?}, surface: {:?}, keys: Array[{}])", this, serial, surface, keys.len())
6020            }
6021            Event::Leave {
6022                ref serial,
6023                ref surface,
6024            } => {
6025                format!("wl_keyboard@{:?}::leave(serial: {:?}, surface: {:?})", this, serial, surface)
6026            }
6027            Event::Key {
6028                ref serial,
6029                ref time,
6030                ref key,
6031                ref state,
6032            } => {
6033                format!("wl_keyboard@{:?}::key(serial: {:?}, time: {:?}, key: {:?}, state: {:?})", this, serial, time, key, state)
6034            }
6035            Event::Modifiers {
6036                ref serial,
6037                ref mods_depressed,
6038                ref mods_latched,
6039                ref mods_locked,
6040                ref group,
6041            } => {
6042                format!("wl_keyboard@{:?}::modifiers(serial: {:?}, mods_depressed: {:?}, mods_latched: {:?}, mods_locked: {:?}, group: {:?})", this, serial, mods_depressed, mods_latched, mods_locked, group)
6043            }
6044            Event::RepeatInfo {
6045                ref rate,
6046                ref delay,
6047            } => {
6048                format!("wl_keyboard@{:?}::repeat_info(rate: {:?}, delay: {:?})", this, rate, delay)
6049            }
6050        }
6051    }
6052    fn message_name(&self) -> &'static std::ffi::CStr{
6053        match *self {
6054            Event::Keymap { .. } => c"wl_keyboard::keymap",
6055            Event::Enter { .. } => c"wl_keyboard::enter",
6056            Event::Leave { .. } => c"wl_keyboard::leave",
6057            Event::Key { .. } => c"wl_keyboard::key",
6058            Event::Modifiers { .. } => c"wl_keyboard::modifiers",
6059            Event::RepeatInfo { .. } => c"wl_keyboard::repeat_info",
6060        }
6061    }
6062}
6063impl IntoMessage for Event {
6064    type Error = EncodeError;
6065    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
6066        let mut header = MessageHeader {
6067            sender: id,
6068            opcode: 0,
6069            length: 0,
6070        };
6071        let mut msg = Message::new();
6072        msg.write_header(&header)?;
6073        match self {
6074        Event::Keymap {
6075            format,
6076            fd,
6077            size,
6078        } => {
6079            msg.write_arg(Arg::Uint(format.bits()))?;
6080            msg.write_arg(Arg::Handle(fd))?;
6081            msg.write_arg(Arg::Uint(size))?;
6082            header.opcode = 0;
6083        },
6084        Event::Enter {
6085            serial,
6086            surface,
6087            keys,
6088        } => {
6089            msg.write_arg(Arg::Uint(serial))?;
6090            msg.write_arg(Arg::Object(surface))?;
6091            msg.write_arg(Arg::Array(keys))?;
6092            header.opcode = 1;
6093        },
6094        Event::Leave {
6095            serial,
6096            surface,
6097        } => {
6098            msg.write_arg(Arg::Uint(serial))?;
6099            msg.write_arg(Arg::Object(surface))?;
6100            header.opcode = 2;
6101        },
6102        Event::Key {
6103            serial,
6104            time,
6105            key,
6106            state,
6107        } => {
6108            msg.write_arg(Arg::Uint(serial))?;
6109            msg.write_arg(Arg::Uint(time))?;
6110            msg.write_arg(Arg::Uint(key))?;
6111            msg.write_arg(Arg::Uint(state.bits()))?;
6112            header.opcode = 3;
6113        },
6114        Event::Modifiers {
6115            serial,
6116            mods_depressed,
6117            mods_latched,
6118            mods_locked,
6119            group,
6120        } => {
6121            msg.write_arg(Arg::Uint(serial))?;
6122            msg.write_arg(Arg::Uint(mods_depressed))?;
6123            msg.write_arg(Arg::Uint(mods_latched))?;
6124            msg.write_arg(Arg::Uint(mods_locked))?;
6125            msg.write_arg(Arg::Uint(group))?;
6126            header.opcode = 4;
6127        },
6128        Event::RepeatInfo {
6129            rate,
6130            delay,
6131        } => {
6132            msg.write_arg(Arg::Int(rate))?;
6133            msg.write_arg(Arg::Int(delay))?;
6134            header.opcode = 5;
6135        },
6136        }
6137        header.length = msg.bytes().len() as u16;
6138        msg.rewind();
6139        msg.write_header(&header)?;
6140        Ok(msg)
6141    }
6142}
6143impl FromArgs for Request {
6144    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
6145        match op {
6146        0 /* release */ => {
6147            let mut iter = args.into_iter();
6148            Ok(Request::Release {
6149
6150            })
6151        },
6152        _ => {
6153            Err(DecodeError::InvalidOpcode(op).into())
6154        },
6155        }
6156    }
6157}
6158
6159/// keyboard mapping format
6160///
6161/// This specifies the format of the keymap provided to the
6162/// client with the wl_keyboard.keymap event.
6163#[derive(Copy, Clone, Debug, Eq, PartialEq)]
6164#[repr(u32)]
6165pub enum KeymapFormat {
6166    /// no keymap; client must understand how to interpret the raw keycode,
6167    NoKeymap = 0,
6168    /// libxkbcommon compatible; to determine the xkb keycode, clients must add 8 to the key event keycode,
6169    XkbV1 = 1,
6170}
6171
6172impl KeymapFormat {
6173    pub fn from_bits(v: u32) -> Option<Self> {
6174        match v {
6175        0 => Some(KeymapFormat::NoKeymap),
6176        1 => Some(KeymapFormat::XkbV1),
6177        _ => None,
6178        }
6179    }
6180
6181    pub fn bits(&self) -> u32 {
6182        *self as u32
6183    }
6184}
6185impl Into<Arg> for KeymapFormat {
6186    fn into(self) -> Arg {
6187        Arg::Uint(self.bits())
6188    }
6189}
6190
6191/// physical key state
6192///
6193/// Describes the physical state of a key that produced the key event.
6194#[derive(Copy, Clone, Debug, Eq, PartialEq)]
6195#[repr(u32)]
6196pub enum KeyState {
6197    /// key is not pressed,
6198    Released = 0,
6199    /// key is pressed,
6200    Pressed = 1,
6201}
6202
6203impl KeyState {
6204    pub fn from_bits(v: u32) -> Option<Self> {
6205        match v {
6206        0 => Some(KeyState::Released),
6207        1 => Some(KeyState::Pressed),
6208        _ => None,
6209        }
6210    }
6211
6212    pub fn bits(&self) -> u32 {
6213        *self as u32
6214    }
6215}
6216impl Into<Arg> for KeyState {
6217    fn into(self) -> Arg {
6218        Arg::Uint(self.bits())
6219    }
6220}
6221} // mod wl_keyboard
6222
6223pub use crate::wl_keyboard::WlKeyboard;
6224pub use crate::wl_keyboard::Request as WlKeyboardRequest;
6225pub use crate::wl_keyboard::Event as WlKeyboardEvent;
6226pub mod wl_touch {
6227use super::*;
6228
6229/// touchscreen input device
6230///
6231/// The wl_touch interface represents a touchscreen
6232/// associated with a seat.
6233/// 
6234/// Touch interactions can consist of one or more contacts.
6235/// For each contact, a series of events is generated, starting
6236/// with a down event, followed by zero or more motion events,
6237/// and ending with an up event. Events relating to the same
6238/// contact point can be identified by the ID of the sequence.
6239#[derive(Debug)]
6240pub struct WlTouch;
6241
6242impl Interface for WlTouch {
6243    const NAME: &'static str = "wl_touch";
6244    const VERSION: u32 = 7;
6245    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
6246        // release
6247        MessageSpec(&[
6248        ]),
6249    ]);
6250    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
6251        // down
6252        MessageSpec(&[
6253            ArgKind::Uint,
6254            ArgKind::Uint,
6255            ArgKind::Object,
6256            ArgKind::Int,
6257            ArgKind::Fixed,
6258            ArgKind::Fixed,
6259        ]),
6260        // up
6261        MessageSpec(&[
6262            ArgKind::Uint,
6263            ArgKind::Uint,
6264            ArgKind::Int,
6265        ]),
6266        // motion
6267        MessageSpec(&[
6268            ArgKind::Uint,
6269            ArgKind::Int,
6270            ArgKind::Fixed,
6271            ArgKind::Fixed,
6272        ]),
6273        // frame
6274        MessageSpec(&[
6275        ]),
6276        // cancel
6277        MessageSpec(&[
6278        ]),
6279        // shape
6280        MessageSpec(&[
6281            ArgKind::Int,
6282            ArgKind::Fixed,
6283            ArgKind::Fixed,
6284        ]),
6285        // orientation
6286        MessageSpec(&[
6287            ArgKind::Int,
6288            ArgKind::Fixed,
6289        ]),
6290    ]);
6291    type Incoming = Request;
6292    type Outgoing = Event;
6293}
6294
6295#[derive(Debug)]
6296pub enum Request {
6297
6298    /// release the touch object
6299    ///
6300    Release,
6301}
6302
6303impl MessageType for Request {
6304    fn log(&self, this: ObjectId) -> String {
6305        match *self {
6306            Request::Release {
6307            } => {
6308                format!("wl_touch@{:?}::release()", this)
6309            }
6310        }
6311    }
6312    fn message_name(&self) -> &'static std::ffi::CStr{
6313        match *self {
6314            Request::Release { .. } => c"wl_touch::release",
6315        }
6316    }
6317}
6318#[derive(Debug)]
6319pub enum Event {
6320
6321    /// touch down event and beginning of a touch sequence
6322    ///
6323    /// A new touch point has appeared on the surface. This touch point is
6324    /// assigned a unique ID. Future events from this touch point reference
6325    /// this ID. The ID ceases to be valid after a touch up event and may be
6326    /// reused in the future.
6327    Down {
6328        /// serial number of the touch down event
6329        serial: u32,
6330        /// timestamp with millisecond granularity
6331        time: u32,
6332        /// surface touched
6333        surface: ObjectId,
6334        /// the unique ID of this touch point
6335        id: i32,
6336        /// surface-local x coordinate
6337        x: Fixed,
6338        /// surface-local y coordinate
6339        y: Fixed,
6340    },
6341
6342    /// end of a touch event sequence
6343    ///
6344    /// The touch point has disappeared. No further events will be sent for
6345    /// this touch point and the touch point's ID is released and may be
6346    /// reused in a future touch down event.
6347    Up {
6348        /// serial number of the touch up event
6349        serial: u32,
6350        /// timestamp with millisecond granularity
6351        time: u32,
6352        /// the unique ID of this touch point
6353        id: i32,
6354    },
6355
6356    /// update of touch point coordinates
6357    ///
6358    /// A touch point has changed coordinates.
6359    Motion {
6360        /// timestamp with millisecond granularity
6361        time: u32,
6362        /// the unique ID of this touch point
6363        id: i32,
6364        /// surface-local x coordinate
6365        x: Fixed,
6366        /// surface-local y coordinate
6367        y: Fixed,
6368    },
6369
6370    /// end of touch frame event
6371    ///
6372    /// Indicates the end of a set of events that logically belong together.
6373    /// A client is expected to accumulate the data in all events within the
6374    /// frame before proceeding.
6375    /// 
6376    /// A wl_touch.frame terminates at least one event but otherwise no
6377    /// guarantee is provided about the set of events within a frame. A client
6378    /// must assume that any state not updated in a frame is unchanged from the
6379    /// previously known state.
6380    Frame,
6381
6382    /// touch session cancelled
6383    ///
6384    /// Sent if the compositor decides the touch stream is a global
6385    /// gesture. No further events are sent to the clients from that
6386    /// particular gesture. Touch cancellation applies to all touch points
6387    /// currently active on this client's surface. The client is
6388    /// responsible for finalizing the touch points, future touch points on
6389    /// this surface may reuse the touch point ID.
6390    Cancel,
6391
6392    /// update shape of touch point
6393    ///
6394    /// Sent when a touchpoint has changed its shape.
6395    /// 
6396    /// This event does not occur on its own. It is sent before a
6397    /// wl_touch.frame event and carries the new shape information for
6398    /// any previously reported, or new touch points of that frame.
6399    /// 
6400    /// Other events describing the touch point such as wl_touch.down,
6401    /// wl_touch.motion or wl_touch.orientation may be sent within the
6402    /// same wl_touch.frame. A client should treat these events as a single
6403    /// logical touch point update. The order of wl_touch.shape,
6404    /// wl_touch.orientation and wl_touch.motion is not guaranteed.
6405    /// A wl_touch.down event is guaranteed to occur before the first
6406    /// wl_touch.shape event for this touch ID but both events may occur within
6407    /// the same wl_touch.frame.
6408    /// 
6409    /// A touchpoint shape is approximated by an ellipse through the major and
6410    /// minor axis length. The major axis length describes the longer diameter
6411    /// of the ellipse, while the minor axis length describes the shorter
6412    /// diameter. Major and minor are orthogonal and both are specified in
6413    /// surface-local coordinates. The center of the ellipse is always at the
6414    /// touchpoint location as reported by wl_touch.down or wl_touch.move.
6415    /// 
6416    /// This event is only sent by the compositor if the touch device supports
6417    /// shape reports. The client has to make reasonable assumptions about the
6418    /// shape if it did not receive this event.
6419    Shape {
6420        /// the unique ID of this touch point
6421        id: i32,
6422        /// length of the major axis in surface-local coordinates
6423        major: Fixed,
6424        /// length of the minor axis in surface-local coordinates
6425        minor: Fixed,
6426    },
6427
6428    /// update orientation of touch point
6429    ///
6430    /// Sent when a touchpoint has changed its orientation.
6431    /// 
6432    /// This event does not occur on its own. It is sent before a
6433    /// wl_touch.frame event and carries the new shape information for
6434    /// any previously reported, or new touch points of that frame.
6435    /// 
6436    /// Other events describing the touch point such as wl_touch.down,
6437    /// wl_touch.motion or wl_touch.shape may be sent within the
6438    /// same wl_touch.frame. A client should treat these events as a single
6439    /// logical touch point update. The order of wl_touch.shape,
6440    /// wl_touch.orientation and wl_touch.motion is not guaranteed.
6441    /// A wl_touch.down event is guaranteed to occur before the first
6442    /// wl_touch.orientation event for this touch ID but both events may occur
6443    /// within the same wl_touch.frame.
6444    /// 
6445    /// The orientation describes the clockwise angle of a touchpoint's major
6446    /// axis to the positive surface y-axis and is normalized to the -180 to
6447    /// +180 degree range. The granularity of orientation depends on the touch
6448    /// device, some devices only support binary rotation values between 0 and
6449    /// 90 degrees.
6450    /// 
6451    /// This event is only sent by the compositor if the touch device supports
6452    /// orientation reports.
6453    Orientation {
6454        /// the unique ID of this touch point
6455        id: i32,
6456        /// angle between major axis and positive surface y-axis in degrees
6457        orientation: Fixed,
6458    },
6459}
6460
6461impl MessageType for Event {
6462    fn log(&self, this: ObjectId) -> String {
6463        match *self {
6464            Event::Down {
6465                ref serial,
6466                ref time,
6467                ref surface,
6468                ref id,
6469                ref x,
6470                ref y,
6471            } => {
6472                format!("wl_touch@{:?}::down(serial: {:?}, time: {:?}, surface: {:?}, id: {:?}, x: {:?}, y: {:?})", this, serial, time, surface, id, x, y)
6473            }
6474            Event::Up {
6475                ref serial,
6476                ref time,
6477                ref id,
6478            } => {
6479                format!("wl_touch@{:?}::up(serial: {:?}, time: {:?}, id: {:?})", this, serial, time, id)
6480            }
6481            Event::Motion {
6482                ref time,
6483                ref id,
6484                ref x,
6485                ref y,
6486            } => {
6487                format!("wl_touch@{:?}::motion(time: {:?}, id: {:?}, x: {:?}, y: {:?})", this, time, id, x, y)
6488            }
6489            Event::Frame {
6490            } => {
6491                format!("wl_touch@{:?}::frame()", this)
6492            }
6493            Event::Cancel {
6494            } => {
6495                format!("wl_touch@{:?}::cancel()", this)
6496            }
6497            Event::Shape {
6498                ref id,
6499                ref major,
6500                ref minor,
6501            } => {
6502                format!("wl_touch@{:?}::shape(id: {:?}, major: {:?}, minor: {:?})", this, id, major, minor)
6503            }
6504            Event::Orientation {
6505                ref id,
6506                ref orientation,
6507            } => {
6508                format!("wl_touch@{:?}::orientation(id: {:?}, orientation: {:?})", this, id, orientation)
6509            }
6510        }
6511    }
6512    fn message_name(&self) -> &'static std::ffi::CStr{
6513        match *self {
6514            Event::Down { .. } => c"wl_touch::down",
6515            Event::Up { .. } => c"wl_touch::up",
6516            Event::Motion { .. } => c"wl_touch::motion",
6517            Event::Frame { .. } => c"wl_touch::frame",
6518            Event::Cancel { .. } => c"wl_touch::cancel",
6519            Event::Shape { .. } => c"wl_touch::shape",
6520            Event::Orientation { .. } => c"wl_touch::orientation",
6521        }
6522    }
6523}
6524impl IntoMessage for Event {
6525    type Error = EncodeError;
6526    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
6527        let mut header = MessageHeader {
6528            sender: id,
6529            opcode: 0,
6530            length: 0,
6531        };
6532        let mut msg = Message::new();
6533        msg.write_header(&header)?;
6534        match self {
6535        Event::Down {
6536            serial,
6537            time,
6538            surface,
6539            id,
6540            x,
6541            y,
6542        } => {
6543            msg.write_arg(Arg::Uint(serial))?;
6544            msg.write_arg(Arg::Uint(time))?;
6545            msg.write_arg(Arg::Object(surface))?;
6546            msg.write_arg(Arg::Int(id))?;
6547            msg.write_arg(Arg::Fixed(x))?;
6548            msg.write_arg(Arg::Fixed(y))?;
6549            header.opcode = 0;
6550        },
6551        Event::Up {
6552            serial,
6553            time,
6554            id,
6555        } => {
6556            msg.write_arg(Arg::Uint(serial))?;
6557            msg.write_arg(Arg::Uint(time))?;
6558            msg.write_arg(Arg::Int(id))?;
6559            header.opcode = 1;
6560        },
6561        Event::Motion {
6562            time,
6563            id,
6564            x,
6565            y,
6566        } => {
6567            msg.write_arg(Arg::Uint(time))?;
6568            msg.write_arg(Arg::Int(id))?;
6569            msg.write_arg(Arg::Fixed(x))?;
6570            msg.write_arg(Arg::Fixed(y))?;
6571            header.opcode = 2;
6572        },
6573        Event::Frame {
6574        } => {
6575            header.opcode = 3;
6576        },
6577        Event::Cancel {
6578        } => {
6579            header.opcode = 4;
6580        },
6581        Event::Shape {
6582            id,
6583            major,
6584            minor,
6585        } => {
6586            msg.write_arg(Arg::Int(id))?;
6587            msg.write_arg(Arg::Fixed(major))?;
6588            msg.write_arg(Arg::Fixed(minor))?;
6589            header.opcode = 5;
6590        },
6591        Event::Orientation {
6592            id,
6593            orientation,
6594        } => {
6595            msg.write_arg(Arg::Int(id))?;
6596            msg.write_arg(Arg::Fixed(orientation))?;
6597            header.opcode = 6;
6598        },
6599        }
6600        header.length = msg.bytes().len() as u16;
6601        msg.rewind();
6602        msg.write_header(&header)?;
6603        Ok(msg)
6604    }
6605}
6606impl FromArgs for Request {
6607    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
6608        match op {
6609        0 /* release */ => {
6610            let mut iter = args.into_iter();
6611            Ok(Request::Release {
6612
6613            })
6614        },
6615        _ => {
6616            Err(DecodeError::InvalidOpcode(op).into())
6617        },
6618        }
6619    }
6620}
6621} // mod wl_touch
6622
6623pub use crate::wl_touch::WlTouch;
6624pub use crate::wl_touch::Request as WlTouchRequest;
6625pub use crate::wl_touch::Event as WlTouchEvent;
6626pub mod wl_output {
6627use super::*;
6628
6629/// compositor output region
6630///
6631/// An output describes part of the compositor geometry.  The
6632/// compositor works in the 'compositor coordinate system' and an
6633/// output corresponds to a rectangular area in that space that is
6634/// actually visible.  This typically corresponds to a monitor that
6635/// displays part of the compositor space.  This object is published
6636/// as global during start up, or when a monitor is hotplugged.
6637#[derive(Debug)]
6638pub struct WlOutput;
6639
6640impl Interface for WlOutput {
6641    const NAME: &'static str = "wl_output";
6642    const VERSION: u32 = 3;
6643    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
6644        // release
6645        MessageSpec(&[
6646        ]),
6647    ]);
6648    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
6649        // geometry
6650        MessageSpec(&[
6651            ArgKind::Int,
6652            ArgKind::Int,
6653            ArgKind::Int,
6654            ArgKind::Int,
6655            ArgKind::Uint,
6656            ArgKind::String,
6657            ArgKind::String,
6658            ArgKind::Uint,
6659        ]),
6660        // mode
6661        MessageSpec(&[
6662            ArgKind::Uint,
6663            ArgKind::Int,
6664            ArgKind::Int,
6665            ArgKind::Int,
6666        ]),
6667        // done
6668        MessageSpec(&[
6669        ]),
6670        // scale
6671        MessageSpec(&[
6672            ArgKind::Int,
6673        ]),
6674    ]);
6675    type Incoming = Request;
6676    type Outgoing = Event;
6677}
6678
6679#[derive(Debug)]
6680pub enum Request {
6681
6682    /// release the output object
6683    ///
6684    /// Using this request a client can tell the server that it is not going to
6685    /// use the output object anymore.
6686    Release,
6687}
6688
6689impl MessageType for Request {
6690    fn log(&self, this: ObjectId) -> String {
6691        match *self {
6692            Request::Release {
6693            } => {
6694                format!("wl_output@{:?}::release()", this)
6695            }
6696        }
6697    }
6698    fn message_name(&self) -> &'static std::ffi::CStr{
6699        match *self {
6700            Request::Release { .. } => c"wl_output::release",
6701        }
6702    }
6703}
6704#[derive(Debug)]
6705pub enum Event {
6706
6707    /// properties of the output
6708    ///
6709    /// The geometry event describes geometric properties of the output.
6710    /// The event is sent when binding to the output object and whenever
6711    /// any of the properties change.
6712    /// 
6713    /// The physical size can be set to zero if it doesn't make sense for this
6714    /// output (e.g. for projectors or virtual outputs).
6715    /// 
6716    /// Note: wl_output only advertises partial information about the output
6717    /// position and identification. Some compositors, for instance those not
6718    /// implementing a desktop-style output layout or those exposing virtual
6719    /// outputs, might fake this information. Instead of using x and y, clients
6720    /// should use xdg_output.logical_position. Instead of using make and model,
6721    /// clients should use xdg_output.name and xdg_output.description.
6722    Geometry {
6723        /// x position within the global compositor space
6724        x: i32,
6725        /// y position within the global compositor space
6726        y: i32,
6727        /// width in millimeters of the output
6728        physical_width: i32,
6729        /// height in millimeters of the output
6730        physical_height: i32,
6731        /// subpixel orientation of the output
6732        subpixel: Subpixel,
6733        /// textual description of the manufacturer
6734        make: String,
6735        /// textual description of the model
6736        model: String,
6737        /// transform that maps framebuffer to output
6738        transform: Transform,
6739    },
6740
6741    /// advertise available modes for the output
6742    ///
6743    /// The mode event describes an available mode for the output.
6744    /// 
6745    /// The event is sent when binding to the output object and there
6746    /// will always be one mode, the current mode.  The event is sent
6747    /// again if an output changes mode, for the mode that is now
6748    /// current.  In other words, the current mode is always the last
6749    /// mode that was received with the current flag set.
6750    /// 
6751    /// The size of a mode is given in physical hardware units of
6752    /// the output device. This is not necessarily the same as
6753    /// the output size in the global compositor space. For instance,
6754    /// the output may be scaled, as described in wl_output.scale,
6755    /// or transformed, as described in wl_output.transform. Clients
6756    /// willing to retrieve the output size in the global compositor
6757    /// space should use xdg_output.logical_size instead.
6758    /// 
6759    /// The vertical refresh rate can be set to zero if it doesn't make
6760    /// sense for this output (e.g. for virtual outputs).
6761    /// 
6762    /// Clients should not use the refresh rate to schedule frames. Instead,
6763    /// they should use the wl_surface.frame event or the presentation-time
6764    /// protocol.
6765    /// 
6766    /// Note: this information is not always meaningful for all outputs. Some
6767    /// compositors, such as those exposing virtual outputs, might fake the
6768    /// refresh rate or the size.
6769    Mode {
6770        /// bitfield of mode flags
6771        flags: Mode,
6772        /// width of the mode in hardware units
6773        width: i32,
6774        /// height of the mode in hardware units
6775        height: i32,
6776        /// vertical refresh rate in mHz
6777        refresh: i32,
6778    },
6779
6780    /// sent all information about output
6781    ///
6782    /// This event is sent after all other properties have been
6783    /// sent after binding to the output object and after any
6784    /// other property changes done after that. This allows
6785    /// changes to the output properties to be seen as
6786    /// atomic, even if they happen via multiple events.
6787    Done,
6788
6789    /// output scaling properties
6790    ///
6791    /// This event contains scaling geometry information
6792    /// that is not in the geometry event. It may be sent after
6793    /// binding the output object or if the output scale changes
6794    /// later. If it is not sent, the client should assume a
6795    /// scale of 1.
6796    /// 
6797    /// A scale larger than 1 means that the compositor will
6798    /// automatically scale surface buffers by this amount
6799    /// when rendering. This is used for very high resolution
6800    /// displays where applications rendering at the native
6801    /// resolution would be too small to be legible.
6802    /// 
6803    /// It is intended that scaling aware clients track the
6804    /// current output of a surface, and if it is on a scaled
6805    /// output it should use wl_surface.set_buffer_scale with
6806    /// the scale of the output. That way the compositor can
6807    /// avoid scaling the surface, and the client can supply
6808    /// a higher detail image.
6809    Scale {
6810        /// scaling factor of output
6811        factor: i32,
6812    },
6813}
6814
6815impl MessageType for Event {
6816    fn log(&self, this: ObjectId) -> String {
6817        match *self {
6818            Event::Geometry {
6819                ref x,
6820                ref y,
6821                ref physical_width,
6822                ref physical_height,
6823                ref subpixel,
6824                ref make,
6825                ref model,
6826                ref transform,
6827            } => {
6828                format!("wl_output@{:?}::geometry(x: {:?}, y: {:?}, physical_width: {:?}, physical_height: {:?}, subpixel: {:?}, make: {:?}, model: {:?}, transform: {:?})", this, x, y, physical_width, physical_height, subpixel, make, model, transform)
6829            }
6830            Event::Mode {
6831                ref flags,
6832                ref width,
6833                ref height,
6834                ref refresh,
6835            } => {
6836                format!("wl_output@{:?}::mode(flags: {:?}, width: {:?}, height: {:?}, refresh: {:?})", this, flags, width, height, refresh)
6837            }
6838            Event::Done {
6839            } => {
6840                format!("wl_output@{:?}::done()", this)
6841            }
6842            Event::Scale {
6843                ref factor,
6844            } => {
6845                format!("wl_output@{:?}::scale(factor: {:?})", this, factor)
6846            }
6847        }
6848    }
6849    fn message_name(&self) -> &'static std::ffi::CStr{
6850        match *self {
6851            Event::Geometry { .. } => c"wl_output::geometry",
6852            Event::Mode { .. } => c"wl_output::mode",
6853            Event::Done { .. } => c"wl_output::done",
6854            Event::Scale { .. } => c"wl_output::scale",
6855        }
6856    }
6857}
6858impl IntoMessage for Event {
6859    type Error = EncodeError;
6860    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
6861        let mut header = MessageHeader {
6862            sender: id,
6863            opcode: 0,
6864            length: 0,
6865        };
6866        let mut msg = Message::new();
6867        msg.write_header(&header)?;
6868        match self {
6869        Event::Geometry {
6870            x,
6871            y,
6872            physical_width,
6873            physical_height,
6874            subpixel,
6875            make,
6876            model,
6877            transform,
6878        } => {
6879            msg.write_arg(Arg::Int(x))?;
6880            msg.write_arg(Arg::Int(y))?;
6881            msg.write_arg(Arg::Int(physical_width))?;
6882            msg.write_arg(Arg::Int(physical_height))?;
6883            msg.write_arg(Arg::Uint(subpixel.bits()))?;
6884            msg.write_arg(Arg::String(make))?;
6885            msg.write_arg(Arg::String(model))?;
6886            msg.write_arg(Arg::Uint(transform.bits()))?;
6887            header.opcode = 0;
6888        },
6889        Event::Mode {
6890            flags,
6891            width,
6892            height,
6893            refresh,
6894        } => {
6895            msg.write_arg(Arg::Uint(flags.bits()))?;
6896            msg.write_arg(Arg::Int(width))?;
6897            msg.write_arg(Arg::Int(height))?;
6898            msg.write_arg(Arg::Int(refresh))?;
6899            header.opcode = 1;
6900        },
6901        Event::Done {
6902        } => {
6903            header.opcode = 2;
6904        },
6905        Event::Scale {
6906            factor,
6907        } => {
6908            msg.write_arg(Arg::Int(factor))?;
6909            header.opcode = 3;
6910        },
6911        }
6912        header.length = msg.bytes().len() as u16;
6913        msg.rewind();
6914        msg.write_header(&header)?;
6915        Ok(msg)
6916    }
6917}
6918impl FromArgs for Request {
6919    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
6920        match op {
6921        0 /* release */ => {
6922            let mut iter = args.into_iter();
6923            Ok(Request::Release {
6924
6925            })
6926        },
6927        _ => {
6928            Err(DecodeError::InvalidOpcode(op).into())
6929        },
6930        }
6931    }
6932}
6933
6934/// subpixel geometry information
6935///
6936/// This enumeration describes how the physical
6937/// pixels on an output are laid out.
6938#[derive(Copy, Clone, Debug, Eq, PartialEq)]
6939#[repr(u32)]
6940pub enum Subpixel {
6941    /// unknown geometry,
6942    Unknown = 0,
6943    /// no geometry,
6944    None = 1,
6945    /// horizontal RGB,
6946    HorizontalRgb = 2,
6947    /// horizontal BGR,
6948    HorizontalBgr = 3,
6949    /// vertical RGB,
6950    VerticalRgb = 4,
6951    /// vertical BGR,
6952    VerticalBgr = 5,
6953}
6954
6955impl Subpixel {
6956    pub fn from_bits(v: u32) -> Option<Self> {
6957        match v {
6958        0 => Some(Subpixel::Unknown),
6959        1 => Some(Subpixel::None),
6960        2 => Some(Subpixel::HorizontalRgb),
6961        3 => Some(Subpixel::HorizontalBgr),
6962        4 => Some(Subpixel::VerticalRgb),
6963        5 => Some(Subpixel::VerticalBgr),
6964        _ => None,
6965        }
6966    }
6967
6968    pub fn bits(&self) -> u32 {
6969        *self as u32
6970    }
6971}
6972impl Into<Arg> for Subpixel {
6973    fn into(self) -> Arg {
6974        Arg::Uint(self.bits())
6975    }
6976}
6977
6978/// transform from framebuffer to output
6979///
6980/// This describes the transform that a compositor will apply to a
6981/// surface to compensate for the rotation or mirroring of an
6982/// output device.
6983/// 
6984/// The flipped values correspond to an initial flip around a
6985/// vertical axis followed by rotation.
6986/// 
6987/// The purpose is mainly to allow clients to render accordingly and
6988/// tell the compositor, so that for fullscreen surfaces, the
6989/// compositor will still be able to scan out directly from client
6990/// surfaces.
6991#[derive(Copy, Clone, Debug, Eq, PartialEq)]
6992#[repr(u32)]
6993pub enum Transform {
6994    /// no transform,
6995    Normal = 0,
6996    /// 90 degrees counter-clockwise,
6997    _90 = 1,
6998    /// 180 degrees counter-clockwise,
6999    _180 = 2,
7000    /// 270 degrees counter-clockwise,
7001    _270 = 3,
7002    /// 180 degree flip around a vertical axis,
7003    Flipped = 4,
7004    /// flip and rotate 90 degrees counter-clockwise,
7005    Flipped90 = 5,
7006    /// flip and rotate 180 degrees counter-clockwise,
7007    Flipped180 = 6,
7008    /// flip and rotate 270 degrees counter-clockwise,
7009    Flipped270 = 7,
7010}
7011
7012impl Transform {
7013    pub fn from_bits(v: u32) -> Option<Self> {
7014        match v {
7015        0 => Some(Transform::Normal),
7016        1 => Some(Transform::_90),
7017        2 => Some(Transform::_180),
7018        3 => Some(Transform::_270),
7019        4 => Some(Transform::Flipped),
7020        5 => Some(Transform::Flipped90),
7021        6 => Some(Transform::Flipped180),
7022        7 => Some(Transform::Flipped270),
7023        _ => None,
7024        }
7025    }
7026
7027    pub fn bits(&self) -> u32 {
7028        *self as u32
7029    }
7030}
7031impl Into<Arg> for Transform {
7032    fn into(self) -> Arg {
7033        Arg::Uint(self.bits())
7034    }
7035}
7036::bitflags::bitflags! {
7037
7038    /// mode information
7039    ///
7040    /// These flags describe properties of an output mode.
7041    /// They are used in the flags bitfield of the mode event.
7042    #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
7043    pub struct Mode: u32 {
7044        /// indicates this is the current mode,
7045        const Current = 1;
7046        /// indicates this is the preferred mode,
7047        const Preferred = 2;
7048    }
7049}
7050impl Into<Arg> for Mode {
7051    fn into(self) -> Arg {
7052        Arg::Uint(self.bits())
7053    }
7054}
7055} // mod wl_output
7056
7057pub use crate::wl_output::WlOutput;
7058pub use crate::wl_output::Request as WlOutputRequest;
7059pub use crate::wl_output::Event as WlOutputEvent;
7060pub mod wl_region {
7061use super::*;
7062
7063/// region interface
7064///
7065/// A region object describes an area.
7066/// 
7067/// Region objects are used to describe the opaque and input
7068/// regions of a surface.
7069#[derive(Debug)]
7070pub struct WlRegion;
7071
7072impl Interface for WlRegion {
7073    const NAME: &'static str = "wl_region";
7074    const VERSION: u32 = 1;
7075    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
7076        // destroy
7077        MessageSpec(&[
7078        ]),
7079        // add
7080        MessageSpec(&[
7081            ArgKind::Int,
7082            ArgKind::Int,
7083            ArgKind::Int,
7084            ArgKind::Int,
7085        ]),
7086        // subtract
7087        MessageSpec(&[
7088            ArgKind::Int,
7089            ArgKind::Int,
7090            ArgKind::Int,
7091            ArgKind::Int,
7092        ]),
7093    ]);
7094    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
7095    ]);
7096    type Incoming = Request;
7097    type Outgoing = Event;
7098}
7099
7100#[derive(Debug)]
7101pub enum Request {
7102
7103    /// destroy region
7104    ///
7105    /// Destroy the region.  This will invalidate the object ID.
7106    Destroy,
7107
7108    /// add rectangle to region
7109    ///
7110    /// Add the specified rectangle to the region.
7111    Add {
7112        /// region-local x coordinate
7113        x: i32,
7114        /// region-local y coordinate
7115        y: i32,
7116        /// rectangle width
7117        width: i32,
7118        /// rectangle height
7119        height: i32,
7120    },
7121
7122    /// subtract rectangle from region
7123    ///
7124    /// Subtract the specified rectangle from the region.
7125    Subtract {
7126        /// region-local x coordinate
7127        x: i32,
7128        /// region-local y coordinate
7129        y: i32,
7130        /// rectangle width
7131        width: i32,
7132        /// rectangle height
7133        height: i32,
7134    },
7135}
7136
7137impl MessageType for Request {
7138    fn log(&self, this: ObjectId) -> String {
7139        match *self {
7140            Request::Destroy {
7141            } => {
7142                format!("wl_region@{:?}::destroy()", this)
7143            }
7144            Request::Add {
7145                ref x,
7146                ref y,
7147                ref width,
7148                ref height,
7149            } => {
7150                format!("wl_region@{:?}::add(x: {:?}, y: {:?}, width: {:?}, height: {:?})", this, x, y, width, height)
7151            }
7152            Request::Subtract {
7153                ref x,
7154                ref y,
7155                ref width,
7156                ref height,
7157            } => {
7158                format!("wl_region@{:?}::subtract(x: {:?}, y: {:?}, width: {:?}, height: {:?})", this, x, y, width, height)
7159            }
7160        }
7161    }
7162    fn message_name(&self) -> &'static std::ffi::CStr{
7163        match *self {
7164            Request::Destroy { .. } => c"wl_region::destroy",
7165            Request::Add { .. } => c"wl_region::add",
7166            Request::Subtract { .. } => c"wl_region::subtract",
7167        }
7168    }
7169}
7170#[derive(Debug)]
7171pub enum Event {
7172}
7173
7174impl MessageType for Event {
7175    fn log(&self, this: ObjectId) -> String {
7176        match *self {
7177        }
7178    }
7179    fn message_name(&self) -> &'static std::ffi::CStr{
7180        match *self {
7181        }
7182    }
7183}
7184impl IntoMessage for Event {
7185    type Error = EncodeError;
7186    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
7187        let mut header = MessageHeader {
7188            sender: id,
7189            opcode: 0,
7190            length: 0,
7191        };
7192        let mut msg = Message::new();
7193        msg.write_header(&header)?;
7194        match self {
7195        }
7196        header.length = msg.bytes().len() as u16;
7197        msg.rewind();
7198        msg.write_header(&header)?;
7199        Ok(msg)
7200    }
7201}
7202impl FromArgs for Request {
7203    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
7204        match op {
7205        0 /* destroy */ => {
7206            let mut iter = args.into_iter();
7207            Ok(Request::Destroy {
7208
7209            })
7210        },
7211        1 /* add */ => {
7212            let mut iter = args.into_iter();
7213            Ok(Request::Add {
7214                x: iter.next()
7215                                             .ok_or(DecodeError::InsufficientArgs)?
7216                                             .as_int()?,
7217                y: iter.next()
7218                                             .ok_or(DecodeError::InsufficientArgs)?
7219                                             .as_int()?,
7220                width: iter.next()
7221                                             .ok_or(DecodeError::InsufficientArgs)?
7222                                             .as_int()?,
7223                height: iter.next()
7224                                             .ok_or(DecodeError::InsufficientArgs)?
7225                                             .as_int()?,
7226
7227            })
7228        },
7229        2 /* subtract */ => {
7230            let mut iter = args.into_iter();
7231            Ok(Request::Subtract {
7232                x: iter.next()
7233                                             .ok_or(DecodeError::InsufficientArgs)?
7234                                             .as_int()?,
7235                y: iter.next()
7236                                             .ok_or(DecodeError::InsufficientArgs)?
7237                                             .as_int()?,
7238                width: iter.next()
7239                                             .ok_or(DecodeError::InsufficientArgs)?
7240                                             .as_int()?,
7241                height: iter.next()
7242                                             .ok_or(DecodeError::InsufficientArgs)?
7243                                             .as_int()?,
7244
7245            })
7246        },
7247        _ => {
7248            Err(DecodeError::InvalidOpcode(op).into())
7249        },
7250        }
7251    }
7252}
7253} // mod wl_region
7254
7255pub use crate::wl_region::WlRegion;
7256pub use crate::wl_region::Request as WlRegionRequest;
7257pub use crate::wl_region::Event as WlRegionEvent;
7258pub mod wl_subcompositor {
7259use super::*;
7260
7261/// sub-surface compositing
7262///
7263/// The global interface exposing sub-surface compositing capabilities.
7264/// A wl_surface, that has sub-surfaces associated, is called the
7265/// parent surface. Sub-surfaces can be arbitrarily nested and create
7266/// a tree of sub-surfaces.
7267/// 
7268/// The root surface in a tree of sub-surfaces is the main
7269/// surface. The main surface cannot be a sub-surface, because
7270/// sub-surfaces must always have a parent.
7271/// 
7272/// A main surface with its sub-surfaces forms a (compound) window.
7273/// For window management purposes, this set of wl_surface objects is
7274/// to be considered as a single window, and it should also behave as
7275/// such.
7276/// 
7277/// The aim of sub-surfaces is to offload some of the compositing work
7278/// within a window from clients to the compositor. A prime example is
7279/// a video player with decorations and video in separate wl_surface
7280/// objects. This should allow the compositor to pass YUV video buffer
7281/// processing to dedicated overlay hardware when possible.
7282#[derive(Debug)]
7283pub struct WlSubcompositor;
7284
7285impl Interface for WlSubcompositor {
7286    const NAME: &'static str = "wl_subcompositor";
7287    const VERSION: u32 = 1;
7288    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
7289        // destroy
7290        MessageSpec(&[
7291        ]),
7292        // get_subsurface
7293        MessageSpec(&[
7294            ArgKind::NewId,
7295            ArgKind::Object,
7296            ArgKind::Object,
7297        ]),
7298    ]);
7299    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
7300    ]);
7301    type Incoming = Request;
7302    type Outgoing = Event;
7303}
7304
7305#[derive(Debug)]
7306pub enum Request {
7307
7308    /// unbind from the subcompositor interface
7309    ///
7310    /// Informs the server that the client will not be using this
7311    /// protocol object anymore. This does not affect any other
7312    /// objects, wl_subsurface objects included.
7313    Destroy,
7314
7315    /// give a surface the role sub-surface
7316    ///
7317    /// Create a sub-surface interface for the given surface, and
7318    /// associate it with the given parent surface. This turns a
7319    /// plain wl_surface into a sub-surface.
7320    /// 
7321    /// The to-be sub-surface must not already have another role, and it
7322    /// must not have an existing wl_subsurface object. Otherwise a protocol
7323    /// error is raised.
7324    /// 
7325    /// Adding sub-surfaces to a parent is a double-buffered operation on the
7326    /// parent (see wl_surface.commit). The effect of adding a sub-surface
7327    /// becomes visible on the next time the state of the parent surface is
7328    /// applied.
7329    /// 
7330    /// This request modifies the behaviour of wl_surface.commit request on
7331    /// the sub-surface, see the documentation on wl_subsurface interface.
7332    GetSubsurface {
7333        /// the new sub-surface object ID
7334        id: NewObject<WlSubsurface>,
7335        /// the surface to be turned into a sub-surface
7336        surface: ObjectId,
7337        /// the parent surface
7338        parent: ObjectId,
7339    },
7340}
7341
7342impl MessageType for Request {
7343    fn log(&self, this: ObjectId) -> String {
7344        match *self {
7345            Request::Destroy {
7346            } => {
7347                format!("wl_subcompositor@{:?}::destroy()", this)
7348            }
7349            Request::GetSubsurface {
7350                ref id,
7351                ref surface,
7352                ref parent,
7353            } => {
7354                format!("wl_subcompositor@{:?}::get_subsurface(id: {:?}, surface: {:?}, parent: {:?})", this, id, surface, parent)
7355            }
7356        }
7357    }
7358    fn message_name(&self) -> &'static std::ffi::CStr{
7359        match *self {
7360            Request::Destroy { .. } => c"wl_subcompositor::destroy",
7361            Request::GetSubsurface { .. } => c"wl_subcompositor::get_subsurface",
7362        }
7363    }
7364}
7365#[derive(Debug)]
7366pub enum Event {
7367}
7368
7369impl MessageType for Event {
7370    fn log(&self, this: ObjectId) -> String {
7371        match *self {
7372        }
7373    }
7374    fn message_name(&self) -> &'static std::ffi::CStr{
7375        match *self {
7376        }
7377    }
7378}
7379impl IntoMessage for Event {
7380    type Error = EncodeError;
7381    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
7382        let mut header = MessageHeader {
7383            sender: id,
7384            opcode: 0,
7385            length: 0,
7386        };
7387        let mut msg = Message::new();
7388        msg.write_header(&header)?;
7389        match self {
7390        }
7391        header.length = msg.bytes().len() as u16;
7392        msg.rewind();
7393        msg.write_header(&header)?;
7394        Ok(msg)
7395    }
7396}
7397impl FromArgs for Request {
7398    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
7399        match op {
7400        0 /* destroy */ => {
7401            let mut iter = args.into_iter();
7402            Ok(Request::Destroy {
7403
7404            })
7405        },
7406        1 /* get_subsurface */ => {
7407            let mut iter = args.into_iter();
7408            Ok(Request::GetSubsurface {
7409                id: iter.next()
7410                                             .ok_or(DecodeError::InsufficientArgs)?
7411                                             .as_new_id()?.into(),
7412                surface: iter.next()
7413                                             .ok_or(DecodeError::InsufficientArgs)?
7414                                             .as_object()?,
7415                parent: iter.next()
7416                                             .ok_or(DecodeError::InsufficientArgs)?
7417                                             .as_object()?,
7418
7419            })
7420        },
7421        _ => {
7422            Err(DecodeError::InvalidOpcode(op).into())
7423        },
7424        }
7425    }
7426}
7427#[derive(Copy, Clone, Debug, Eq, PartialEq)]
7428#[repr(u32)]
7429pub enum Error {
7430    /// the to-be sub-surface is invalid,
7431    BadSurface = 0,
7432}
7433
7434impl Error {
7435    pub fn from_bits(v: u32) -> Option<Self> {
7436        match v {
7437        0 => Some(Error::BadSurface),
7438        _ => None,
7439        }
7440    }
7441
7442    pub fn bits(&self) -> u32 {
7443        *self as u32
7444    }
7445}
7446impl Into<Arg> for Error {
7447    fn into(self) -> Arg {
7448        Arg::Uint(self.bits())
7449    }
7450}
7451} // mod wl_subcompositor
7452
7453pub use crate::wl_subcompositor::WlSubcompositor;
7454pub use crate::wl_subcompositor::Request as WlSubcompositorRequest;
7455pub use crate::wl_subcompositor::Event as WlSubcompositorEvent;
7456pub mod wl_subsurface {
7457use super::*;
7458
7459/// sub-surface interface to a wl_surface
7460///
7461/// An additional interface to a wl_surface object, which has been
7462/// made a sub-surface. A sub-surface has one parent surface. A
7463/// sub-surface's size and position are not limited to that of the parent.
7464/// Particularly, a sub-surface is not automatically clipped to its
7465/// parent's area.
7466/// 
7467/// A sub-surface becomes mapped, when a non-NULL wl_buffer is applied
7468/// and the parent surface is mapped. The order of which one happens
7469/// first is irrelevant. A sub-surface is hidden if the parent becomes
7470/// hidden, or if a NULL wl_buffer is applied. These rules apply
7471/// recursively through the tree of surfaces.
7472/// 
7473/// The behaviour of a wl_surface.commit request on a sub-surface
7474/// depends on the sub-surface's mode. The possible modes are
7475/// synchronized and desynchronized, see methods
7476/// wl_subsurface.set_sync and wl_subsurface.set_desync. Synchronized
7477/// mode caches the wl_surface state to be applied when the parent's
7478/// state gets applied, and desynchronized mode applies the pending
7479/// wl_surface state directly. A sub-surface is initially in the
7480/// synchronized mode.
7481/// 
7482/// Sub-surfaces also have another kind of state, which is managed by
7483/// wl_subsurface requests, as opposed to wl_surface requests. This
7484/// state includes the sub-surface position relative to the parent
7485/// surface (wl_subsurface.set_position), and the stacking order of
7486/// the parent and its sub-surfaces (wl_subsurface.place_above and
7487/// .place_below). This state is applied when the parent surface's
7488/// wl_surface state is applied, regardless of the sub-surface's mode.
7489/// As the exception, set_sync and set_desync are effective immediately.
7490/// 
7491/// The main surface can be thought to be always in desynchronized mode,
7492/// since it does not have a parent in the sub-surfaces sense.
7493/// 
7494/// Even if a sub-surface is in desynchronized mode, it will behave as
7495/// in synchronized mode, if its parent surface behaves as in
7496/// synchronized mode. This rule is applied recursively throughout the
7497/// tree of surfaces. This means, that one can set a sub-surface into
7498/// synchronized mode, and then assume that all its child and grand-child
7499/// sub-surfaces are synchronized, too, without explicitly setting them.
7500/// 
7501/// If the wl_surface associated with the wl_subsurface is destroyed, the
7502/// wl_subsurface object becomes inert. Note, that destroying either object
7503/// takes effect immediately. If you need to synchronize the removal
7504/// of a sub-surface to the parent surface update, unmap the sub-surface
7505/// first by attaching a NULL wl_buffer, update parent, and then destroy
7506/// the sub-surface.
7507/// 
7508/// If the parent wl_surface object is destroyed, the sub-surface is
7509/// unmapped.
7510#[derive(Debug)]
7511pub struct WlSubsurface;
7512
7513impl Interface for WlSubsurface {
7514    const NAME: &'static str = "wl_subsurface";
7515    const VERSION: u32 = 1;
7516    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
7517        // destroy
7518        MessageSpec(&[
7519        ]),
7520        // set_position
7521        MessageSpec(&[
7522            ArgKind::Int,
7523            ArgKind::Int,
7524        ]),
7525        // place_above
7526        MessageSpec(&[
7527            ArgKind::Object,
7528        ]),
7529        // place_below
7530        MessageSpec(&[
7531            ArgKind::Object,
7532        ]),
7533        // set_sync
7534        MessageSpec(&[
7535        ]),
7536        // set_desync
7537        MessageSpec(&[
7538        ]),
7539    ]);
7540    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
7541    ]);
7542    type Incoming = Request;
7543    type Outgoing = Event;
7544}
7545
7546#[derive(Debug)]
7547pub enum Request {
7548
7549    /// remove sub-surface interface
7550    ///
7551    /// The sub-surface interface is removed from the wl_surface object
7552    /// that was turned into a sub-surface with a
7553    /// wl_subcompositor.get_subsurface request. The wl_surface's association
7554    /// to the parent is deleted, and the wl_surface loses its role as
7555    /// a sub-surface. The wl_surface is unmapped immediately.
7556    Destroy,
7557
7558    /// reposition the sub-surface
7559    ///
7560    /// This schedules a sub-surface position change.
7561    /// The sub-surface will be moved so that its origin (top left
7562    /// corner pixel) will be at the location x, y of the parent surface
7563    /// coordinate system. The coordinates are not restricted to the parent
7564    /// surface area. Negative values are allowed.
7565    /// 
7566    /// The scheduled coordinates will take effect whenever the state of the
7567    /// parent surface is applied. When this happens depends on whether the
7568    /// parent surface is in synchronized mode or not. See
7569    /// wl_subsurface.set_sync and wl_subsurface.set_desync for details.
7570    /// 
7571    /// If more than one set_position request is invoked by the client before
7572    /// the commit of the parent surface, the position of a new request always
7573    /// replaces the scheduled position from any previous request.
7574    /// 
7575    /// The initial position is 0, 0.
7576    SetPosition {
7577        /// x coordinate in the parent surface
7578        x: i32,
7579        /// y coordinate in the parent surface
7580        y: i32,
7581    },
7582
7583    /// restack the sub-surface
7584    ///
7585    /// This sub-surface is taken from the stack, and put back just
7586    /// above the reference surface, changing the z-order of the sub-surfaces.
7587    /// The reference surface must be one of the sibling surfaces, or the
7588    /// parent surface. Using any other surface, including this sub-surface,
7589    /// will cause a protocol error.
7590    /// 
7591    /// The z-order is double-buffered. Requests are handled in order and
7592    /// applied immediately to a pending state. The final pending state is
7593    /// copied to the active state the next time the state of the parent
7594    /// surface is applied. When this happens depends on whether the parent
7595    /// surface is in synchronized mode or not. See wl_subsurface.set_sync and
7596    /// wl_subsurface.set_desync for details.
7597    /// 
7598    /// A new sub-surface is initially added as the top-most in the stack
7599    /// of its siblings and parent.
7600    PlaceAbove {
7601        /// the reference surface
7602        sibling: ObjectId,
7603    },
7604
7605    /// restack the sub-surface
7606    ///
7607    /// The sub-surface is placed just below the reference surface.
7608    /// See wl_subsurface.place_above.
7609    PlaceBelow {
7610        /// the reference surface
7611        sibling: ObjectId,
7612    },
7613
7614    /// set sub-surface to synchronized mode
7615    ///
7616    /// Change the commit behaviour of the sub-surface to synchronized
7617    /// mode, also described as the parent dependent mode.
7618    /// 
7619    /// In synchronized mode, wl_surface.commit on a sub-surface will
7620    /// accumulate the committed state in a cache, but the state will
7621    /// not be applied and hence will not change the compositor output.
7622    /// The cached state is applied to the sub-surface immediately after
7623    /// the parent surface's state is applied. This ensures atomic
7624    /// updates of the parent and all its synchronized sub-surfaces.
7625    /// Applying the cached state will invalidate the cache, so further
7626    /// parent surface commits do not (re-)apply old state.
7627    /// 
7628    /// See wl_subsurface for the recursive effect of this mode.
7629    SetSync,
7630
7631    /// set sub-surface to desynchronized mode
7632    ///
7633    /// Change the commit behaviour of the sub-surface to desynchronized
7634    /// mode, also described as independent or freely running mode.
7635    /// 
7636    /// In desynchronized mode, wl_surface.commit on a sub-surface will
7637    /// apply the pending state directly, without caching, as happens
7638    /// normally with a wl_surface. Calling wl_surface.commit on the
7639    /// parent surface has no effect on the sub-surface's wl_surface
7640    /// state. This mode allows a sub-surface to be updated on its own.
7641    /// 
7642    /// If cached state exists when wl_surface.commit is called in
7643    /// desynchronized mode, the pending state is added to the cached
7644    /// state, and applied as a whole. This invalidates the cache.
7645    /// 
7646    /// Note: even if a sub-surface is set to desynchronized, a parent
7647    /// sub-surface may override it to behave as synchronized. For details,
7648    /// see wl_subsurface.
7649    /// 
7650    /// If a surface's parent surface behaves as desynchronized, then
7651    /// the cached state is applied on set_desync.
7652    SetDesync,
7653}
7654
7655impl MessageType for Request {
7656    fn log(&self, this: ObjectId) -> String {
7657        match *self {
7658            Request::Destroy {
7659            } => {
7660                format!("wl_subsurface@{:?}::destroy()", this)
7661            }
7662            Request::SetPosition {
7663                ref x,
7664                ref y,
7665            } => {
7666                format!("wl_subsurface@{:?}::set_position(x: {:?}, y: {:?})", this, x, y)
7667            }
7668            Request::PlaceAbove {
7669                ref sibling,
7670            } => {
7671                format!("wl_subsurface@{:?}::place_above(sibling: {:?})", this, sibling)
7672            }
7673            Request::PlaceBelow {
7674                ref sibling,
7675            } => {
7676                format!("wl_subsurface@{:?}::place_below(sibling: {:?})", this, sibling)
7677            }
7678            Request::SetSync {
7679            } => {
7680                format!("wl_subsurface@{:?}::set_sync()", this)
7681            }
7682            Request::SetDesync {
7683            } => {
7684                format!("wl_subsurface@{:?}::set_desync()", this)
7685            }
7686        }
7687    }
7688    fn message_name(&self) -> &'static std::ffi::CStr{
7689        match *self {
7690            Request::Destroy { .. } => c"wl_subsurface::destroy",
7691            Request::SetPosition { .. } => c"wl_subsurface::set_position",
7692            Request::PlaceAbove { .. } => c"wl_subsurface::place_above",
7693            Request::PlaceBelow { .. } => c"wl_subsurface::place_below",
7694            Request::SetSync { .. } => c"wl_subsurface::set_sync",
7695            Request::SetDesync { .. } => c"wl_subsurface::set_desync",
7696        }
7697    }
7698}
7699#[derive(Debug)]
7700pub enum Event {
7701}
7702
7703impl MessageType for Event {
7704    fn log(&self, this: ObjectId) -> String {
7705        match *self {
7706        }
7707    }
7708    fn message_name(&self) -> &'static std::ffi::CStr{
7709        match *self {
7710        }
7711    }
7712}
7713impl IntoMessage for Event {
7714    type Error = EncodeError;
7715    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
7716        let mut header = MessageHeader {
7717            sender: id,
7718            opcode: 0,
7719            length: 0,
7720        };
7721        let mut msg = Message::new();
7722        msg.write_header(&header)?;
7723        match self {
7724        }
7725        header.length = msg.bytes().len() as u16;
7726        msg.rewind();
7727        msg.write_header(&header)?;
7728        Ok(msg)
7729    }
7730}
7731impl FromArgs for Request {
7732    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
7733        match op {
7734        0 /* destroy */ => {
7735            let mut iter = args.into_iter();
7736            Ok(Request::Destroy {
7737
7738            })
7739        },
7740        1 /* set_position */ => {
7741            let mut iter = args.into_iter();
7742            Ok(Request::SetPosition {
7743                x: iter.next()
7744                                             .ok_or(DecodeError::InsufficientArgs)?
7745                                             .as_int()?,
7746                y: iter.next()
7747                                             .ok_or(DecodeError::InsufficientArgs)?
7748                                             .as_int()?,
7749
7750            })
7751        },
7752        2 /* place_above */ => {
7753            let mut iter = args.into_iter();
7754            Ok(Request::PlaceAbove {
7755                sibling: iter.next()
7756                                             .ok_or(DecodeError::InsufficientArgs)?
7757                                             .as_object()?,
7758
7759            })
7760        },
7761        3 /* place_below */ => {
7762            let mut iter = args.into_iter();
7763            Ok(Request::PlaceBelow {
7764                sibling: iter.next()
7765                                             .ok_or(DecodeError::InsufficientArgs)?
7766                                             .as_object()?,
7767
7768            })
7769        },
7770        4 /* set_sync */ => {
7771            let mut iter = args.into_iter();
7772            Ok(Request::SetSync {
7773
7774            })
7775        },
7776        5 /* set_desync */ => {
7777            let mut iter = args.into_iter();
7778            Ok(Request::SetDesync {
7779
7780            })
7781        },
7782        _ => {
7783            Err(DecodeError::InvalidOpcode(op).into())
7784        },
7785        }
7786    }
7787}
7788#[derive(Copy, Clone, Debug, Eq, PartialEq)]
7789#[repr(u32)]
7790pub enum Error {
7791    /// wl_surface is not a sibling or the parent,
7792    BadSurface = 0,
7793}
7794
7795impl Error {
7796    pub fn from_bits(v: u32) -> Option<Self> {
7797        match v {
7798        0 => Some(Error::BadSurface),
7799        _ => None,
7800        }
7801    }
7802
7803    pub fn bits(&self) -> u32 {
7804        *self as u32
7805    }
7806}
7807impl Into<Arg> for Error {
7808    fn into(self) -> Arg {
7809        Arg::Uint(self.bits())
7810    }
7811}
7812} // mod wl_subsurface
7813
7814pub use crate::wl_subsurface::WlSubsurface;
7815pub use crate::wl_subsurface::Request as WlSubsurfaceRequest;
7816pub use crate::wl_subsurface::Event as WlSubsurfaceEvent;