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