zwp_pointer_constraints_v1_server_protocol/
zwp_pointer_constraints_v1_server_protocol.rs

1// GENERATED FILE -- DO NOT EDIT
2//
3// Copyright © 2014      Jonas Ådahl
4// Copyright © 2015      Red Hat Inc.
5// 
6// Permission is hereby granted, free of charge, to any person obtaining a
7// copy of this software and associated documentation files (the "Software"),
8// to deal in the Software without restriction, including without limitation
9// the rights to use, copy, modify, merge, publish, distribute, sublicense,
10// and/or sell copies of the Software, and to permit persons to whom the
11// Software is furnished to do so, subject to the following conditions:
12// 
13// The above copyright notice and this permission notice (including the next
14// paragraph) shall be included in all copies or substantial portions of the
15// Software.
16// 
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE.
24
25#![allow(warnings)]
26#![allow(clippy::all)]
27use anyhow;
28#[allow(unused_imports)]
29use fuchsia_wayland_core::{Array, Enum, Fixed, NewId, NewObject};
30use fuchsia_wayland_core::{ArgKind, Arg, FromArgs, IntoMessage, Message,
31                            MessageGroupSpec, MessageHeader, MessageSpec, MessageType,
32                            ObjectId, EncodeError, DecodeError, Interface};
33
34#[allow(unused_imports)]
35use wayland_server_protocol::*;
36pub mod zwp_pointer_constraints_v1 {
37use super::*;
38
39/// constrain the movement of a pointer
40///
41/// The global interface exposing pointer constraining functionality. It
42/// exposes two requests: lock_pointer for locking the pointer to its
43/// position, and confine_pointer for locking the pointer to a region.
44/// 
45/// The lock_pointer and confine_pointer requests create the objects
46/// wp_locked_pointer and wp_confined_pointer respectively, and the client can
47/// use these objects to interact with the lock.
48/// 
49/// For any surface, only one lock or confinement may be active across all
50/// wl_pointer objects of the same seat. If a lock or confinement is requested
51/// when another lock or confinement is active or requested on the same surface
52/// and with any of the wl_pointer objects of the same seat, an
53/// 'already_constrained' error will be raised.
54#[derive(Debug)]
55pub struct ZwpPointerConstraintsV1;
56
57impl Interface for ZwpPointerConstraintsV1 {
58    const NAME: &'static str = "zwp_pointer_constraints_v1";
59    const VERSION: u32 = 1;
60    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
61        // destroy
62        MessageSpec(&[
63        ]),
64        // lock_pointer
65        MessageSpec(&[
66            ArgKind::NewId,
67            ArgKind::Object,
68            ArgKind::Object,
69            ArgKind::Object,
70            ArgKind::Uint,
71        ]),
72        // confine_pointer
73        MessageSpec(&[
74            ArgKind::NewId,
75            ArgKind::Object,
76            ArgKind::Object,
77            ArgKind::Object,
78            ArgKind::Uint,
79        ]),
80    ]);
81    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
82    ]);
83    type Incoming = Request;
84    type Outgoing = Event;
85}
86
87#[derive(Debug)]
88pub enum Request {
89
90    /// destroy the pointer constraints manager object
91    ///
92    /// Used by the client to notify the server that it will no longer use this
93    /// pointer constraints object.
94    Destroy,
95
96    /// lock pointer to a position
97    ///
98    /// The lock_pointer request lets the client request to disable movements of
99    /// the virtual pointer (i.e. the cursor), effectively locking the pointer
100    /// to a position. This request may not take effect immediately; in the
101    /// future, when the compositor deems implementation-specific constraints
102    /// are satisfied, the pointer lock will be activated and the compositor
103    /// sends a locked event.
104    /// 
105    /// The protocol provides no guarantee that the constraints are ever
106    /// satisfied, and does not require the compositor to send an error if the
107    /// constraints cannot ever be satisfied. It is thus possible to request a
108    /// lock that will never activate.
109    /// 
110    /// There may not be another pointer constraint of any kind requested or
111    /// active on the surface for any of the wl_pointer objects of the seat of
112    /// the passed pointer when requesting a lock. If there is, an error will be
113    /// raised. See general pointer lock documentation for more details.
114    /// 
115    /// The intersection of the region passed with this request and the input
116    /// region of the surface is used to determine where the pointer must be
117    /// in order for the lock to activate. It is up to the compositor whether to
118    /// warp the pointer or require some kind of user interaction for the lock
119    /// to activate. If the region is null the surface input region is used.
120    /// 
121    /// A surface may receive pointer focus without the lock being activated.
122    /// 
123    /// The request creates a new object wp_locked_pointer which is used to
124    /// interact with the lock as well as receive updates about its state. See
125    /// the the description of wp_locked_pointer for further information.
126    /// 
127    /// Note that while a pointer is locked, the wl_pointer objects of the
128    /// corresponding seat will not emit any wl_pointer.motion events, but
129    /// relative motion events will still be emitted via wp_relative_pointer
130    /// objects of the same seat. wl_pointer.axis and wl_pointer.button events
131    /// are unaffected.
132    LockPointer {
133        id: NewObject<ZwpLockedPointerV1>,
134        /// surface to lock pointer to
135        surface: ObjectId,
136        /// the pointer that should be locked
137        pointer: ObjectId,
138        /// region of surface
139        region: ObjectId,
140        /// lock lifetime
141        lifetime: Enum<Lifetime>,
142    },
143
144    /// confine pointer to a region
145    ///
146    /// The confine_pointer request lets the client request to confine the
147    /// pointer cursor to a given region. This request may not take effect
148    /// immediately; in the future, when the compositor deems implementation-
149    /// specific constraints are satisfied, the pointer confinement will be
150    /// activated and the compositor sends a confined event.
151    /// 
152    /// The intersection of the region passed with this request and the input
153    /// region of the surface is used to determine where the pointer must be
154    /// in order for the confinement to activate. It is up to the compositor
155    /// whether to warp the pointer or require some kind of user interaction for
156    /// the confinement to activate. If the region is null the surface input
157    /// region is used.
158    /// 
159    /// The request will create a new object wp_confined_pointer which is used
160    /// to interact with the confinement as well as receive updates about its
161    /// state. See the the description of wp_confined_pointer for further
162    /// information.
163    ConfinePointer {
164        id: NewObject<ZwpConfinedPointerV1>,
165        /// surface to lock pointer to
166        surface: ObjectId,
167        /// the pointer that should be confined
168        pointer: ObjectId,
169        /// region of surface
170        region: ObjectId,
171        /// confinement lifetime
172        lifetime: Enum<Lifetime>,
173    },
174}
175
176impl MessageType for Request {
177    fn log(&self, this: ObjectId) -> String {
178        match *self {
179            Request::Destroy {
180            } => {
181                format!("zwp_pointer_constraints_v1@{:?}::destroy()", this)
182            }
183            Request::LockPointer {
184                ref id,
185                ref surface,
186                ref pointer,
187                ref region,
188                ref lifetime,
189            } => {
190                format!("zwp_pointer_constraints_v1@{:?}::lock_pointer(id: {:?}, surface: {:?}, pointer: {:?}, region: {:?}, lifetime: {:?})", this, id, surface, pointer, region, lifetime)
191            }
192            Request::ConfinePointer {
193                ref id,
194                ref surface,
195                ref pointer,
196                ref region,
197                ref lifetime,
198            } => {
199                format!("zwp_pointer_constraints_v1@{:?}::confine_pointer(id: {:?}, surface: {:?}, pointer: {:?}, region: {:?}, lifetime: {:?})", this, id, surface, pointer, region, lifetime)
200            }
201        }
202    }
203    fn message_name(&self) -> &'static std::ffi::CStr{
204        match *self {
205            Request::Destroy { .. } => c"zwp_pointer_constraints_v1::destroy",
206            Request::LockPointer { .. } => c"zwp_pointer_constraints_v1::lock_pointer",
207            Request::ConfinePointer { .. } => c"zwp_pointer_constraints_v1::confine_pointer",
208        }
209    }
210}
211#[derive(Debug)]
212pub enum Event {
213}
214
215impl MessageType for Event {
216    fn log(&self, this: ObjectId) -> String {
217        match *self {
218        }
219    }
220    fn message_name(&self) -> &'static std::ffi::CStr{
221        match *self {
222        }
223    }
224}
225impl IntoMessage for Event {
226    type Error = EncodeError;
227    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
228        let mut header = MessageHeader {
229            sender: id,
230            opcode: 0,
231            length: 0,
232        };
233        let mut msg = Message::new();
234        msg.write_header(&header)?;
235        match self {
236        }
237        header.length = msg.bytes().len() as u16;
238        msg.rewind();
239        msg.write_header(&header)?;
240        Ok(msg)
241    }
242}
243impl FromArgs for Request {
244    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
245        match op {
246        0 /* destroy */ => {
247            let mut iter = args.into_iter();
248            Ok(Request::Destroy {
249
250            })
251        },
252        1 /* lock_pointer */ => {
253            let mut iter = args.into_iter();
254            Ok(Request::LockPointer {
255                id: iter.next()
256                                             .ok_or(DecodeError::InsufficientArgs)?
257                                             .as_new_id()?.into(),
258                surface: iter.next()
259                                             .ok_or(DecodeError::InsufficientArgs)?
260                                             .as_object()?,
261                pointer: iter.next()
262                                             .ok_or(DecodeError::InsufficientArgs)?
263                                             .as_object()?,
264                region: iter.next()
265                                             .ok_or(DecodeError::InsufficientArgs)?
266                                             .as_object()?,
267                lifetime: iter.next()
268                                             .ok_or(DecodeError::InsufficientArgs)?
269                                             .as_uint().map(|i| match Lifetime::from_bits(i) {
270                                      Some(e) => Enum::Recognized(e),
271                                      None => Enum::Unrecognized(i),
272                                 })?,
273
274            })
275        },
276        2 /* confine_pointer */ => {
277            let mut iter = args.into_iter();
278            Ok(Request::ConfinePointer {
279                id: iter.next()
280                                             .ok_or(DecodeError::InsufficientArgs)?
281                                             .as_new_id()?.into(),
282                surface: iter.next()
283                                             .ok_or(DecodeError::InsufficientArgs)?
284                                             .as_object()?,
285                pointer: iter.next()
286                                             .ok_or(DecodeError::InsufficientArgs)?
287                                             .as_object()?,
288                region: iter.next()
289                                             .ok_or(DecodeError::InsufficientArgs)?
290                                             .as_object()?,
291                lifetime: iter.next()
292                                             .ok_or(DecodeError::InsufficientArgs)?
293                                             .as_uint().map(|i| match Lifetime::from_bits(i) {
294                                      Some(e) => Enum::Recognized(e),
295                                      None => Enum::Unrecognized(i),
296                                 })?,
297
298            })
299        },
300        _ => {
301            Err(DecodeError::InvalidOpcode(op).into())
302        },
303        }
304    }
305}
306
307/// wp_pointer_constraints error values
308///
309/// These errors can be emitted in response to wp_pointer_constraints
310/// requests.
311#[derive(Copy, Clone, Debug, Eq, PartialEq)]
312#[repr(u32)]
313pub enum Error {
314    /// pointer constraint already requested on that surface,
315    AlreadyConstrained = 1,
316}
317
318impl Error {
319    pub fn from_bits(v: u32) -> Option<Self> {
320        match v {
321        1 => Some(Error::AlreadyConstrained),
322        _ => None,
323        }
324    }
325
326    pub fn bits(&self) -> u32 {
327        *self as u32
328    }
329}
330impl Into<Arg> for Error {
331    fn into(self) -> Arg {
332        Arg::Uint(self.bits())
333    }
334}
335
336/// constraint lifetime
337///
338/// These values represent different lifetime semantics. They are passed
339/// as arguments to the factory requests to specify how the constraint
340/// lifetimes should be managed.
341#[derive(Copy, Clone, Debug, Eq, PartialEq)]
342#[repr(u32)]
343pub enum Lifetime {
344    Oneshot = 1,
345    Persistent = 2,
346}
347
348impl Lifetime {
349    pub fn from_bits(v: u32) -> Option<Self> {
350        match v {
351        1 => Some(Lifetime::Oneshot),
352        2 => Some(Lifetime::Persistent),
353        _ => None,
354        }
355    }
356
357    pub fn bits(&self) -> u32 {
358        *self as u32
359    }
360}
361impl Into<Arg> for Lifetime {
362    fn into(self) -> Arg {
363        Arg::Uint(self.bits())
364    }
365}
366} // mod zwp_pointer_constraints_v1
367
368pub use crate::zwp_pointer_constraints_v1::ZwpPointerConstraintsV1;
369pub use crate::zwp_pointer_constraints_v1::Request as ZwpPointerConstraintsV1Request;
370pub use crate::zwp_pointer_constraints_v1::Event as ZwpPointerConstraintsV1Event;
371pub mod zwp_locked_pointer_v1 {
372use super::*;
373
374/// receive relative pointer motion events
375///
376/// The wp_locked_pointer interface represents a locked pointer state.
377/// 
378/// While the lock of this object is active, the wl_pointer objects of the
379/// associated seat will not emit any wl_pointer.motion events.
380/// 
381/// This object will send the event 'locked' when the lock is activated.
382/// Whenever the lock is activated, it is guaranteed that the locked surface
383/// will already have received pointer focus and that the pointer will be
384/// within the region passed to the request creating this object.
385/// 
386/// To unlock the pointer, send the destroy request. This will also destroy
387/// the wp_locked_pointer object.
388/// 
389/// If the compositor decides to unlock the pointer the unlocked event is
390/// sent. See wp_locked_pointer.unlock for details.
391/// 
392/// When unlocking, the compositor may warp the cursor position to the set
393/// cursor position hint. If it does, it will not result in any relative
394/// motion events emitted via wp_relative_pointer.
395/// 
396/// If the surface the lock was requested on is destroyed and the lock is not
397/// yet activated, the wp_locked_pointer object is now defunct and must be
398/// destroyed.
399#[derive(Debug)]
400pub struct ZwpLockedPointerV1;
401
402impl Interface for ZwpLockedPointerV1 {
403    const NAME: &'static str = "zwp_locked_pointer_v1";
404    const VERSION: u32 = 1;
405    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
406        // destroy
407        MessageSpec(&[
408        ]),
409        // set_cursor_position_hint
410        MessageSpec(&[
411            ArgKind::Fixed,
412            ArgKind::Fixed,
413        ]),
414        // set_region
415        MessageSpec(&[
416            ArgKind::Object,
417        ]),
418    ]);
419    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
420        // locked
421        MessageSpec(&[
422        ]),
423        // unlocked
424        MessageSpec(&[
425        ]),
426    ]);
427    type Incoming = Request;
428    type Outgoing = Event;
429}
430
431#[derive(Debug)]
432pub enum Request {
433
434    /// destroy the locked pointer object
435    ///
436    /// Destroy the locked pointer object. If applicable, the compositor will
437    /// unlock the pointer.
438    Destroy,
439
440    /// set the pointer cursor position hint
441    ///
442    /// Set the cursor position hint relative to the top left corner of the
443    /// surface.
444    /// 
445    /// If the client is drawing its own cursor, it should update the position
446    /// hint to the position of its own cursor. A compositor may use this
447    /// information to warp the pointer upon unlock in order to avoid pointer
448    /// jumps.
449    /// 
450    /// The cursor position hint is double buffered. The new hint will only take
451    /// effect when the associated surface gets it pending state applied. See
452    /// wl_surface.commit for details.
453    SetCursorPositionHint {
454        /// surface-local x coordinate
455        surface_x: Fixed,
456        /// surface-local y coordinate
457        surface_y: Fixed,
458    },
459
460    /// set a new lock region
461    ///
462    /// Set a new region used to lock the pointer.
463    /// 
464    /// The new lock region is double-buffered. The new lock region will
465    /// only take effect when the associated surface gets its pending state
466    /// applied. See wl_surface.commit for details.
467    /// 
468    /// For details about the lock region, see wp_locked_pointer.
469    SetRegion {
470        /// region of surface
471        region: ObjectId,
472    },
473}
474
475impl MessageType for Request {
476    fn log(&self, this: ObjectId) -> String {
477        match *self {
478            Request::Destroy {
479            } => {
480                format!("zwp_locked_pointer_v1@{:?}::destroy()", this)
481            }
482            Request::SetCursorPositionHint {
483                ref surface_x,
484                ref surface_y,
485            } => {
486                format!("zwp_locked_pointer_v1@{:?}::set_cursor_position_hint(surface_x: {:?}, surface_y: {:?})", this, surface_x, surface_y)
487            }
488            Request::SetRegion {
489                ref region,
490            } => {
491                format!("zwp_locked_pointer_v1@{:?}::set_region(region: {:?})", this, region)
492            }
493        }
494    }
495    fn message_name(&self) -> &'static std::ffi::CStr{
496        match *self {
497            Request::Destroy { .. } => c"zwp_locked_pointer_v1::destroy",
498            Request::SetCursorPositionHint { .. } => c"zwp_locked_pointer_v1::set_cursor_position_hint",
499            Request::SetRegion { .. } => c"zwp_locked_pointer_v1::set_region",
500        }
501    }
502}
503#[derive(Debug)]
504pub enum Event {
505
506    /// lock activation event
507    ///
508    /// Notification that the pointer lock of the seat's pointer is activated.
509    Locked,
510
511    /// lock deactivation event
512    ///
513    /// Notification that the pointer lock of the seat's pointer is no longer
514    /// active. If this is a oneshot pointer lock (see
515    /// wp_pointer_constraints.lifetime) this object is now defunct and should
516    /// be destroyed. If this is a persistent pointer lock (see
517    /// wp_pointer_constraints.lifetime) this pointer lock may again
518    /// reactivate in the future.
519    Unlocked,
520}
521
522impl MessageType for Event {
523    fn log(&self, this: ObjectId) -> String {
524        match *self {
525            Event::Locked {
526            } => {
527                format!("zwp_locked_pointer_v1@{:?}::locked()", this)
528            }
529            Event::Unlocked {
530            } => {
531                format!("zwp_locked_pointer_v1@{:?}::unlocked()", this)
532            }
533        }
534    }
535    fn message_name(&self) -> &'static std::ffi::CStr{
536        match *self {
537            Event::Locked { .. } => c"zwp_locked_pointer_v1::locked",
538            Event::Unlocked { .. } => c"zwp_locked_pointer_v1::unlocked",
539        }
540    }
541}
542impl IntoMessage for Event {
543    type Error = EncodeError;
544    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
545        let mut header = MessageHeader {
546            sender: id,
547            opcode: 0,
548            length: 0,
549        };
550        let mut msg = Message::new();
551        msg.write_header(&header)?;
552        match self {
553        Event::Locked {
554        } => {
555            header.opcode = 0;
556        },
557        Event::Unlocked {
558        } => {
559            header.opcode = 1;
560        },
561        }
562        header.length = msg.bytes().len() as u16;
563        msg.rewind();
564        msg.write_header(&header)?;
565        Ok(msg)
566    }
567}
568impl FromArgs for Request {
569    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
570        match op {
571        0 /* destroy */ => {
572            let mut iter = args.into_iter();
573            Ok(Request::Destroy {
574
575            })
576        },
577        1 /* set_cursor_position_hint */ => {
578            let mut iter = args.into_iter();
579            Ok(Request::SetCursorPositionHint {
580                surface_x: iter.next()
581                                             .ok_or(DecodeError::InsufficientArgs)?
582                                             .as_fixed()?.into(),
583                surface_y: iter.next()
584                                             .ok_or(DecodeError::InsufficientArgs)?
585                                             .as_fixed()?.into(),
586
587            })
588        },
589        2 /* set_region */ => {
590            let mut iter = args.into_iter();
591            Ok(Request::SetRegion {
592                region: iter.next()
593                                             .ok_or(DecodeError::InsufficientArgs)?
594                                             .as_object()?,
595
596            })
597        },
598        _ => {
599            Err(DecodeError::InvalidOpcode(op).into())
600        },
601        }
602    }
603}
604} // mod zwp_locked_pointer_v1
605
606pub use crate::zwp_locked_pointer_v1::ZwpLockedPointerV1;
607pub use crate::zwp_locked_pointer_v1::Request as ZwpLockedPointerV1Request;
608pub use crate::zwp_locked_pointer_v1::Event as ZwpLockedPointerV1Event;
609pub mod zwp_confined_pointer_v1 {
610use super::*;
611
612/// confined pointer object
613///
614/// The wp_confined_pointer interface represents a confined pointer state.
615/// 
616/// This object will send the event 'confined' when the confinement is
617/// activated. Whenever the confinement is activated, it is guaranteed that
618/// the surface the pointer is confined to will already have received pointer
619/// focus and that the pointer will be within the region passed to the request
620/// creating this object. It is up to the compositor to decide whether this
621/// requires some user interaction and if the pointer will warp to within the
622/// passed region if outside.
623/// 
624/// To unconfine the pointer, send the destroy request. This will also destroy
625/// the wp_confined_pointer object.
626/// 
627/// If the compositor decides to unconfine the pointer the unconfined event is
628/// sent. The wp_confined_pointer object is at this point defunct and should
629/// be destroyed.
630#[derive(Debug)]
631pub struct ZwpConfinedPointerV1;
632
633impl Interface for ZwpConfinedPointerV1 {
634    const NAME: &'static str = "zwp_confined_pointer_v1";
635    const VERSION: u32 = 1;
636    const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
637        // destroy
638        MessageSpec(&[
639        ]),
640        // set_region
641        MessageSpec(&[
642            ArgKind::Object,
643        ]),
644    ]);
645    const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
646        // confined
647        MessageSpec(&[
648        ]),
649        // unconfined
650        MessageSpec(&[
651        ]),
652    ]);
653    type Incoming = Request;
654    type Outgoing = Event;
655}
656
657#[derive(Debug)]
658pub enum Request {
659
660    /// destroy the confined pointer object
661    ///
662    /// Destroy the confined pointer object. If applicable, the compositor will
663    /// unconfine the pointer.
664    Destroy,
665
666    /// set a new confine region
667    ///
668    /// Set a new region used to confine the pointer.
669    /// 
670    /// The new confine region is double-buffered. The new confine region will
671    /// only take effect when the associated surface gets its pending state
672    /// applied. See wl_surface.commit for details.
673    /// 
674    /// If the confinement is active when the new confinement region is applied
675    /// and the pointer ends up outside of newly applied region, the pointer may
676    /// warped to a position within the new confinement region. If warped, a
677    /// wl_pointer.motion event will be emitted, but no
678    /// wp_relative_pointer.relative_motion event.
679    /// 
680    /// The compositor may also, instead of using the new region, unconfine the
681    /// pointer.
682    /// 
683    /// For details about the confine region, see wp_confined_pointer.
684    SetRegion {
685        /// region of surface
686        region: ObjectId,
687    },
688}
689
690impl MessageType for Request {
691    fn log(&self, this: ObjectId) -> String {
692        match *self {
693            Request::Destroy {
694            } => {
695                format!("zwp_confined_pointer_v1@{:?}::destroy()", this)
696            }
697            Request::SetRegion {
698                ref region,
699            } => {
700                format!("zwp_confined_pointer_v1@{:?}::set_region(region: {:?})", this, region)
701            }
702        }
703    }
704    fn message_name(&self) -> &'static std::ffi::CStr{
705        match *self {
706            Request::Destroy { .. } => c"zwp_confined_pointer_v1::destroy",
707            Request::SetRegion { .. } => c"zwp_confined_pointer_v1::set_region",
708        }
709    }
710}
711#[derive(Debug)]
712pub enum Event {
713
714    /// pointer confined
715    ///
716    /// Notification that the pointer confinement of the seat's pointer is
717    /// activated.
718    Confined,
719
720    /// pointer unconfined
721    ///
722    /// Notification that the pointer confinement of the seat's pointer is no
723    /// longer active. If this is a oneshot pointer confinement (see
724    /// wp_pointer_constraints.lifetime) this object is now defunct and should
725    /// be destroyed. If this is a persistent pointer confinement (see
726    /// wp_pointer_constraints.lifetime) this pointer confinement may again
727    /// reactivate in the future.
728    Unconfined,
729}
730
731impl MessageType for Event {
732    fn log(&self, this: ObjectId) -> String {
733        match *self {
734            Event::Confined {
735            } => {
736                format!("zwp_confined_pointer_v1@{:?}::confined()", this)
737            }
738            Event::Unconfined {
739            } => {
740                format!("zwp_confined_pointer_v1@{:?}::unconfined()", this)
741            }
742        }
743    }
744    fn message_name(&self) -> &'static std::ffi::CStr{
745        match *self {
746            Event::Confined { .. } => c"zwp_confined_pointer_v1::confined",
747            Event::Unconfined { .. } => c"zwp_confined_pointer_v1::unconfined",
748        }
749    }
750}
751impl IntoMessage for Event {
752    type Error = EncodeError;
753    fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
754        let mut header = MessageHeader {
755            sender: id,
756            opcode: 0,
757            length: 0,
758        };
759        let mut msg = Message::new();
760        msg.write_header(&header)?;
761        match self {
762        Event::Confined {
763        } => {
764            header.opcode = 0;
765        },
766        Event::Unconfined {
767        } => {
768            header.opcode = 1;
769        },
770        }
771        header.length = msg.bytes().len() as u16;
772        msg.rewind();
773        msg.write_header(&header)?;
774        Ok(msg)
775    }
776}
777impl FromArgs for Request {
778    fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
779        match op {
780        0 /* destroy */ => {
781            let mut iter = args.into_iter();
782            Ok(Request::Destroy {
783
784            })
785        },
786        1 /* set_region */ => {
787            let mut iter = args.into_iter();
788            Ok(Request::SetRegion {
789                region: iter.next()
790                                             .ok_or(DecodeError::InsufficientArgs)?
791                                             .as_object()?,
792
793            })
794        },
795        _ => {
796            Err(DecodeError::InvalidOpcode(op).into())
797        },
798        }
799    }
800}
801} // mod zwp_confined_pointer_v1
802
803pub use crate::zwp_confined_pointer_v1::ZwpConfinedPointerV1;
804pub use crate::zwp_confined_pointer_v1::Request as ZwpConfinedPointerV1Request;
805pub use crate::zwp_confined_pointer_v1::Event as ZwpConfinedPointerV1Event;