zwp_pointer_constraints_v1_client_protocol/zwp_pointer_constraints_v1_client_protocol.rs
1// GENERATED FILE -- DO NOT EDIT
2//
3// Copyright © 2014 Jonas Ådahl
4// Copyright © 2015 Red Hat Inc.
5//
6// Permission is hereby granted, free of charge, to any person obtaining a
7// copy of this software and associated documentation files (the "Software"),
8// to deal in the Software without restriction, including without limitation
9// the rights to use, copy, modify, merge, publish, distribute, sublicense,
10// and/or sell copies of the Software, and to permit persons to whom the
11// Software is furnished to do so, subject to the following conditions:
12//
13// The above copyright notice and this permission notice (including the next
14// paragraph) shall be included in all copies or substantial portions of the
15// Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE.
24
25#![allow(warnings)]
26#![allow(clippy::all)]
27use anyhow;
28#[allow(unused_imports)]
29use fuchsia_wayland_core::{Array, Enum, Fixed, NewId, NewObject};
30use fuchsia_wayland_core::{ArgKind, Arg, FromArgs, IntoMessage, Message,
31 MessageGroupSpec, MessageHeader, MessageSpec, MessageType,
32 ObjectId, EncodeError, DecodeError, Interface};
33
34#[allow(unused_imports)]
35use wayland_client_protocol::*;
36pub mod zwp_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 = Event;
84 type Outgoing = Request;
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: NewId,
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: 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: NewId,
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: 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 Request {
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 Request::Destroy {
237 } => {
238 header.opcode = 0;
239 },
240 Request::LockPointer {
241 id,
242 surface,
243 pointer,
244 region,
245 lifetime,
246 } => {
247 msg.write_arg(Arg::NewId(id))?;
248 msg.write_arg(Arg::Object(surface))?;
249 msg.write_arg(Arg::Object(pointer))?;
250 msg.write_arg(Arg::Object(region))?;
251 msg.write_arg(Arg::Uint(lifetime.bits()))?;
252 header.opcode = 1;
253 },
254 Request::ConfinePointer {
255 id,
256 surface,
257 pointer,
258 region,
259 lifetime,
260 } => {
261 msg.write_arg(Arg::NewId(id))?;
262 msg.write_arg(Arg::Object(surface))?;
263 msg.write_arg(Arg::Object(pointer))?;
264 msg.write_arg(Arg::Object(region))?;
265 msg.write_arg(Arg::Uint(lifetime.bits()))?;
266 header.opcode = 2;
267 },
268 }
269 header.length = msg.bytes().len() as u16;
270 msg.rewind();
271 msg.write_header(&header)?;
272 Ok(msg)
273 }
274}
275impl FromArgs for Event {
276 fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
277 match op {
278 _ => {
279 Err(DecodeError::InvalidOpcode(op).into())
280 },
281 }
282 }
283}
284
285/// wp_pointer_constraints error values
286///
287/// These errors can be emitted in response to wp_pointer_constraints
288/// requests.
289#[derive(Copy, Clone, Debug, Eq, PartialEq)]
290#[repr(u32)]
291pub enum Error {
292 /// pointer constraint already requested on that surface,
293 AlreadyConstrained = 1,
294}
295
296impl Error {
297 pub fn from_bits(v: u32) -> Option<Self> {
298 match v {
299 1 => Some(Error::AlreadyConstrained),
300 _ => None,
301 }
302 }
303
304 pub fn bits(&self) -> u32 {
305 *self as u32
306 }
307}
308impl Into<Arg> for Error {
309 fn into(self) -> Arg {
310 Arg::Uint(self.bits())
311 }
312}
313
314/// constraint lifetime
315///
316/// These values represent different lifetime semantics. They are passed
317/// as arguments to the factory requests to specify how the constraint
318/// lifetimes should be managed.
319#[derive(Copy, Clone, Debug, Eq, PartialEq)]
320#[repr(u32)]
321pub enum Lifetime {
322 Oneshot = 1,
323 Persistent = 2,
324}
325
326impl Lifetime {
327 pub fn from_bits(v: u32) -> Option<Self> {
328 match v {
329 1 => Some(Lifetime::Oneshot),
330 2 => Some(Lifetime::Persistent),
331 _ => None,
332 }
333 }
334
335 pub fn bits(&self) -> u32 {
336 *self as u32
337 }
338}
339impl Into<Arg> for Lifetime {
340 fn into(self) -> Arg {
341 Arg::Uint(self.bits())
342 }
343}
344} // mod zwp_pointer_constraints_v1
345
346pub use crate::zwp_pointer_constraints_v1::ZwpPointerConstraintsV1;
347pub use crate::zwp_pointer_constraints_v1::Request as ZwpPointerConstraintsV1Request;
348pub use crate::zwp_pointer_constraints_v1::Event as ZwpPointerConstraintsV1Event;
349pub mod zwp_locked_pointer_v1 {
350use super::*;
351
352/// receive relative pointer motion events
353///
354/// The wp_locked_pointer interface represents a locked pointer state.
355///
356/// While the lock of this object is active, the wl_pointer objects of the
357/// associated seat will not emit any wl_pointer.motion events.
358///
359/// This object will send the event 'locked' when the lock is activated.
360/// Whenever the lock is activated, it is guaranteed that the locked surface
361/// will already have received pointer focus and that the pointer will be
362/// within the region passed to the request creating this object.
363///
364/// To unlock the pointer, send the destroy request. This will also destroy
365/// the wp_locked_pointer object.
366///
367/// If the compositor decides to unlock the pointer the unlocked event is
368/// sent. See wp_locked_pointer.unlock for details.
369///
370/// When unlocking, the compositor may warp the cursor position to the set
371/// cursor position hint. If it does, it will not result in any relative
372/// motion events emitted via wp_relative_pointer.
373///
374/// If the surface the lock was requested on is destroyed and the lock is not
375/// yet activated, the wp_locked_pointer object is now defunct and must be
376/// destroyed.
377#[derive(Debug)]
378pub struct ZwpLockedPointerV1;
379
380impl Interface for ZwpLockedPointerV1 {
381 const NAME: &'static str = "zwp_locked_pointer_v1";
382 const VERSION: u32 = 1;
383 const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
384 // destroy
385 MessageSpec(&[
386 ]),
387 // set_cursor_position_hint
388 MessageSpec(&[
389 ArgKind::Fixed,
390 ArgKind::Fixed,
391 ]),
392 // set_region
393 MessageSpec(&[
394 ArgKind::Object,
395 ]),
396 ]);
397 const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
398 // locked
399 MessageSpec(&[
400 ]),
401 // unlocked
402 MessageSpec(&[
403 ]),
404 ]);
405 type Incoming = Event;
406 type Outgoing = Request;
407}
408
409#[derive(Debug)]
410pub enum Request {
411
412 /// destroy the locked pointer object
413 ///
414 /// Destroy the locked pointer object. If applicable, the compositor will
415 /// unlock the pointer.
416 Destroy,
417
418 /// set the pointer cursor position hint
419 ///
420 /// Set the cursor position hint relative to the top left corner of the
421 /// surface.
422 ///
423 /// If the client is drawing its own cursor, it should update the position
424 /// hint to the position of its own cursor. A compositor may use this
425 /// information to warp the pointer upon unlock in order to avoid pointer
426 /// jumps.
427 ///
428 /// The cursor position hint is double buffered. The new hint will only take
429 /// effect when the associated surface gets it pending state applied. See
430 /// wl_surface.commit for details.
431 SetCursorPositionHint {
432 /// surface-local x coordinate
433 surface_x: Fixed,
434 /// surface-local y coordinate
435 surface_y: Fixed,
436 },
437
438 /// set a new lock region
439 ///
440 /// Set a new region used to lock the pointer.
441 ///
442 /// The new lock region is double-buffered. The new lock region will
443 /// only take effect when the associated surface gets its pending state
444 /// applied. See wl_surface.commit for details.
445 ///
446 /// For details about the lock region, see wp_locked_pointer.
447 SetRegion {
448 /// region of surface
449 region: ObjectId,
450 },
451}
452
453impl MessageType for Request {
454 fn log(&self, this: ObjectId) -> String {
455 match *self {
456 Request::Destroy {
457 } => {
458 format!("zwp_locked_pointer_v1@{:?}::destroy()", this)
459 }
460 Request::SetCursorPositionHint {
461 ref surface_x,
462 ref surface_y,
463 } => {
464 format!("zwp_locked_pointer_v1@{:?}::set_cursor_position_hint(surface_x: {:?}, surface_y: {:?})", this, surface_x, surface_y)
465 }
466 Request::SetRegion {
467 ref region,
468 } => {
469 format!("zwp_locked_pointer_v1@{:?}::set_region(region: {:?})", this, region)
470 }
471 }
472 }
473 fn message_name(&self) -> &'static std::ffi::CStr{
474 match *self {
475 Request::Destroy { .. } => c"zwp_locked_pointer_v1::destroy",
476 Request::SetCursorPositionHint { .. } => c"zwp_locked_pointer_v1::set_cursor_position_hint",
477 Request::SetRegion { .. } => c"zwp_locked_pointer_v1::set_region",
478 }
479 }
480}
481#[derive(Debug)]
482pub enum Event {
483
484 /// lock activation event
485 ///
486 /// Notification that the pointer lock of the seat's pointer is activated.
487 Locked,
488
489 /// lock deactivation event
490 ///
491 /// Notification that the pointer lock of the seat's pointer is no longer
492 /// active. If this is a oneshot pointer lock (see
493 /// wp_pointer_constraints.lifetime) this object is now defunct and should
494 /// be destroyed. If this is a persistent pointer lock (see
495 /// wp_pointer_constraints.lifetime) this pointer lock may again
496 /// reactivate in the future.
497 Unlocked,
498}
499
500impl MessageType for Event {
501 fn log(&self, this: ObjectId) -> String {
502 match *self {
503 Event::Locked {
504 } => {
505 format!("zwp_locked_pointer_v1@{:?}::locked()", this)
506 }
507 Event::Unlocked {
508 } => {
509 format!("zwp_locked_pointer_v1@{:?}::unlocked()", this)
510 }
511 }
512 }
513 fn message_name(&self) -> &'static std::ffi::CStr{
514 match *self {
515 Event::Locked { .. } => c"zwp_locked_pointer_v1::locked",
516 Event::Unlocked { .. } => c"zwp_locked_pointer_v1::unlocked",
517 }
518 }
519}
520impl IntoMessage for Request {
521 type Error = EncodeError;
522 fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
523 let mut header = MessageHeader {
524 sender: id,
525 opcode: 0,
526 length: 0,
527 };
528 let mut msg = Message::new();
529 msg.write_header(&header)?;
530 match self {
531 Request::Destroy {
532 } => {
533 header.opcode = 0;
534 },
535 Request::SetCursorPositionHint {
536 surface_x,
537 surface_y,
538 } => {
539 msg.write_arg(Arg::Fixed(surface_x))?;
540 msg.write_arg(Arg::Fixed(surface_y))?;
541 header.opcode = 1;
542 },
543 Request::SetRegion {
544 region,
545 } => {
546 msg.write_arg(Arg::Object(region))?;
547 header.opcode = 2;
548 },
549 }
550 header.length = msg.bytes().len() as u16;
551 msg.rewind();
552 msg.write_header(&header)?;
553 Ok(msg)
554 }
555}
556impl FromArgs for Event {
557 fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
558 match op {
559 0 /* locked */ => {
560 let mut iter = args.into_iter();
561 Ok(Event::Locked {
562
563 })
564 },
565 1 /* unlocked */ => {
566 let mut iter = args.into_iter();
567 Ok(Event::Unlocked {
568
569 })
570 },
571 _ => {
572 Err(DecodeError::InvalidOpcode(op).into())
573 },
574 }
575 }
576}
577} // mod zwp_locked_pointer_v1
578
579pub use crate::zwp_locked_pointer_v1::ZwpLockedPointerV1;
580pub use crate::zwp_locked_pointer_v1::Request as ZwpLockedPointerV1Request;
581pub use crate::zwp_locked_pointer_v1::Event as ZwpLockedPointerV1Event;
582pub mod zwp_confined_pointer_v1 {
583use super::*;
584
585/// confined pointer object
586///
587/// The wp_confined_pointer interface represents a confined pointer state.
588///
589/// This object will send the event 'confined' when the confinement is
590/// activated. Whenever the confinement is activated, it is guaranteed that
591/// the surface the pointer is confined to will already have received pointer
592/// focus and that the pointer will be within the region passed to the request
593/// creating this object. It is up to the compositor to decide whether this
594/// requires some user interaction and if the pointer will warp to within the
595/// passed region if outside.
596///
597/// To unconfine the pointer, send the destroy request. This will also destroy
598/// the wp_confined_pointer object.
599///
600/// If the compositor decides to unconfine the pointer the unconfined event is
601/// sent. The wp_confined_pointer object is at this point defunct and should
602/// be destroyed.
603#[derive(Debug)]
604pub struct ZwpConfinedPointerV1;
605
606impl Interface for ZwpConfinedPointerV1 {
607 const NAME: &'static str = "zwp_confined_pointer_v1";
608 const VERSION: u32 = 1;
609 const REQUESTS: MessageGroupSpec = MessageGroupSpec(&[
610 // destroy
611 MessageSpec(&[
612 ]),
613 // set_region
614 MessageSpec(&[
615 ArgKind::Object,
616 ]),
617 ]);
618 const EVENTS: MessageGroupSpec = MessageGroupSpec(&[
619 // confined
620 MessageSpec(&[
621 ]),
622 // unconfined
623 MessageSpec(&[
624 ]),
625 ]);
626 type Incoming = Event;
627 type Outgoing = Request;
628}
629
630#[derive(Debug)]
631pub enum Request {
632
633 /// destroy the confined pointer object
634 ///
635 /// Destroy the confined pointer object. If applicable, the compositor will
636 /// unconfine the pointer.
637 Destroy,
638
639 /// set a new confine region
640 ///
641 /// Set a new region used to confine the pointer.
642 ///
643 /// The new confine region is double-buffered. The new confine region will
644 /// only take effect when the associated surface gets its pending state
645 /// applied. See wl_surface.commit for details.
646 ///
647 /// If the confinement is active when the new confinement region is applied
648 /// and the pointer ends up outside of newly applied region, the pointer may
649 /// warped to a position within the new confinement region. If warped, a
650 /// wl_pointer.motion event will be emitted, but no
651 /// wp_relative_pointer.relative_motion event.
652 ///
653 /// The compositor may also, instead of using the new region, unconfine the
654 /// pointer.
655 ///
656 /// For details about the confine region, see wp_confined_pointer.
657 SetRegion {
658 /// region of surface
659 region: ObjectId,
660 },
661}
662
663impl MessageType for Request {
664 fn log(&self, this: ObjectId) -> String {
665 match *self {
666 Request::Destroy {
667 } => {
668 format!("zwp_confined_pointer_v1@{:?}::destroy()", this)
669 }
670 Request::SetRegion {
671 ref region,
672 } => {
673 format!("zwp_confined_pointer_v1@{:?}::set_region(region: {:?})", this, region)
674 }
675 }
676 }
677 fn message_name(&self) -> &'static std::ffi::CStr{
678 match *self {
679 Request::Destroy { .. } => c"zwp_confined_pointer_v1::destroy",
680 Request::SetRegion { .. } => c"zwp_confined_pointer_v1::set_region",
681 }
682 }
683}
684#[derive(Debug)]
685pub enum Event {
686
687 /// pointer confined
688 ///
689 /// Notification that the pointer confinement of the seat's pointer is
690 /// activated.
691 Confined,
692
693 /// pointer unconfined
694 ///
695 /// Notification that the pointer confinement of the seat's pointer is no
696 /// longer active. If this is a oneshot pointer confinement (see
697 /// wp_pointer_constraints.lifetime) this object is now defunct and should
698 /// be destroyed. If this is a persistent pointer confinement (see
699 /// wp_pointer_constraints.lifetime) this pointer confinement may again
700 /// reactivate in the future.
701 Unconfined,
702}
703
704impl MessageType for Event {
705 fn log(&self, this: ObjectId) -> String {
706 match *self {
707 Event::Confined {
708 } => {
709 format!("zwp_confined_pointer_v1@{:?}::confined()", this)
710 }
711 Event::Unconfined {
712 } => {
713 format!("zwp_confined_pointer_v1@{:?}::unconfined()", this)
714 }
715 }
716 }
717 fn message_name(&self) -> &'static std::ffi::CStr{
718 match *self {
719 Event::Confined { .. } => c"zwp_confined_pointer_v1::confined",
720 Event::Unconfined { .. } => c"zwp_confined_pointer_v1::unconfined",
721 }
722 }
723}
724impl IntoMessage for Request {
725 type Error = EncodeError;
726 fn into_message(self, id: u32) -> Result<Message, <Self as IntoMessage>::Error> {
727 let mut header = MessageHeader {
728 sender: id,
729 opcode: 0,
730 length: 0,
731 };
732 let mut msg = Message::new();
733 msg.write_header(&header)?;
734 match self {
735 Request::Destroy {
736 } => {
737 header.opcode = 0;
738 },
739 Request::SetRegion {
740 region,
741 } => {
742 msg.write_arg(Arg::Object(region))?;
743 header.opcode = 1;
744 },
745 }
746 header.length = msg.bytes().len() as u16;
747 msg.rewind();
748 msg.write_header(&header)?;
749 Ok(msg)
750 }
751}
752impl FromArgs for Event {
753 fn from_args(op: u16, mut args: Vec<Arg>) -> Result<Self, anyhow::Error> {
754 match op {
755 0 /* confined */ => {
756 let mut iter = args.into_iter();
757 Ok(Event::Confined {
758
759 })
760 },
761 1 /* unconfined */ => {
762 let mut iter = args.into_iter();
763 Ok(Event::Unconfined {
764
765 })
766 },
767 _ => {
768 Err(DecodeError::InvalidOpcode(op).into())
769 },
770 }
771 }
772}
773} // mod zwp_confined_pointer_v1
774
775pub use crate::zwp_confined_pointer_v1::ZwpConfinedPointerV1;
776pub use crate::zwp_confined_pointer_v1::Request as ZwpConfinedPointerV1Request;
777pub use crate::zwp_confined_pointer_v1::Event as ZwpConfinedPointerV1Event;