x11rb-protocol-0.13.1/.cargo_vcs_info.json0000644000000001540000000000100137120ustar { "git": { "sha1": "9e97a17f7d1d219ab5d640531e11cc3c60163a53" }, "path_in_vcs": "x11rb-protocol" }x11rb-protocol-0.13.1/Cargo.toml0000644000000040000000000000100117020ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" rust-version = "1.63" name = "x11rb-protocol" version = "0.13.1" authors = [ "Uli Schlachter ", "Eduardo Sánchez Muñoz ", "notgull ", ] description = "Rust bindings to X11" readme = "README.md" keywords = [ "xcb", "X11", ] license = "MIT OR Apache-2.0" repository = "https://github.com/psychon/x11rb" resolver = "1" [package.metadata.docs.rs] all-features = true [[bench]] name = "proto_connection" harness = false [dependencies.serde] version = "1" features = ["derive"] optional = true [dev-dependencies.criterion] version = "0.5" [features] all-extensions = [ "composite", "damage", "dbe", "dpms", "dri2", "dri3", "glx", "present", "randr", "record", "render", "res", "screensaver", "shape", "shm", "sync", "xevie", "xf86dri", "xf86vidmode", "xfixes", "xinerama", "xinput", "xkb", "xprint", "xselinux", "xtest", "xv", "xvmc", ] composite = ["xfixes"] damage = ["xfixes"] dbe = [] default = ["std"] dpms = [] dri2 = [] dri3 = [] extra-traits = [] glx = [] present = [ "randr", "xfixes", "sync", ] randr = ["render"] record = [] render = [] request-parsing = [] res = [] resource_manager = ["std"] screensaver = [] shape = [] shm = [] std = [] sync = [] xevie = [] xf86dri = [] xf86vidmode = [] xfixes = [ "render", "shape", ] xinerama = [] xinput = ["xfixes"] xkb = [] xprint = [] xselinux = [] xtest = [] xv = ["shm"] xvmc = ["xv"] x11rb-protocol-0.13.1/Cargo.toml.orig000064400000000000000000000035241046102023000153750ustar 00000000000000[package] name = "x11rb-protocol" version = "0.13.1" description = "Rust bindings to X11" authors = [ "Uli Schlachter ", "Eduardo Sánchez Muñoz ", "notgull ", ] repository = "https://github.com/psychon/x11rb" readme = "../README.md" edition = "2021" rust-version = "1.63" license = "MIT OR Apache-2.0" keywords = ["xcb", "X11"] [dependencies] serde = { version = "1", features = ["derive"], optional = true } [dev-dependencies] criterion = "0.5" [features] default = ["std"] std = [] # Enable extra traits for the X11 types extra-traits = [] # Enable parsing for requests. # # This adds a lot of extra code that isn't used in the common case. request-parsing = [] # Enable utility functions in `x11rb::resource_manager` for querying the # resource databases. resource_manager = ["std"] # Enable this feature to enable all the X11 extensions all-extensions = [ "composite", "damage", "dbe", "dpms", "dri2", "dri3", "glx", "present", "randr", "record", "render", "res", "screensaver", "shape", "shm", "sync", "xevie", "xf86dri", "xf86vidmode", "xfixes", "xinerama", "xinput", "xkb", "xprint", "xselinux", "xtest", "xv", "xvmc", ] # Features to enable individual X11 extensions composite = ["xfixes"] damage = ["xfixes"] dbe = [] dpms = [] dri2 = [] dri3 = [] glx = [] present = ["randr", "xfixes", "sync"] randr = ["render"] record = [] render = [] res = [] screensaver = [] shape = [] shm = [] sync = [] xevie = [] xf86dri = [] xf86vidmode = [] xfixes = ["render", "shape"] xinerama = [] xinput = ["xfixes"] xkb = [] xprint = [] xselinux = [] xtest = [] xv = ["shm"] xvmc = ["xv"] [package.metadata.docs.rs] all-features = true [[bench]] name = "proto_connection" harness = false x11rb-protocol-0.13.1/LICENSE-APACHE000064400000000000000000000261361046102023000144360ustar 00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. x11rb-protocol-0.13.1/LICENSE-MIT000064400000000000000000000020421046102023000141340ustar 00000000000000Copyright 2019 x11rb Contributers 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 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. x11rb-protocol-0.13.1/README.md000064400000000000000000000050561046102023000137670ustar 00000000000000# X11 rust bindings [![GitHub Actions Status](https://github.com/psychon/x11rb/workflows/CI/badge.svg)](https://github.com/psychon/x11rb/actions) [![Crate](https://img.shields.io/crates/v/x11rb.svg)](https://crates.io/crates/x11rb) [![API](https://docs.rs/x11rb/badge.svg)](https://docs.rs/x11rb) ![Minimum rustc version](https://img.shields.io/badge/rustc-1.63+-lightgray.svg) [![License](https://img.shields.io/crates/l/x11rb.svg)](https://github.com/psychon/x11rb#license) Feel free to open issues for any problems or questions you might have. A comparison with some other Rust X11 libraries is available in an [extra document](doc/comparison.md). ## Building This crate uses a code generator that is implemented in Rust. A copy of the generated code is included, so you do not need to run the generator unless you have modified the definitions or the generator itself. The code generator uses the X11 XML description from `xcb-proto`. A copy of xcb-proto that comes with the source code is used. The interaction with libxcb via `XCBConnection` requires at least libxcb 1.12. ## Crate features Most X11 extensions are feature-gated. For example, to use the shared memory extension, the `shm` feature has to be enabled. The `all-extensions` feature just enables all X11 extensions. Additionally, the `allow-unsafe-code` feature enables `XCBConnection`. This uses `libxcb` internally and allows sharing the underlying `xcb_connection_t` pointer with other code. The `cursor` feature enables X11 cursor support via the `cursor` module. This module helps with loading cursors from the current cursor theme. ## Current state The full X11 protocol is supported by this library. All extensions that are available in `xcb-proto` can be used and even [FD passing](x11rb/examples/shared_memory.rs) with the server is supported. The changelog is available in a [separate file](doc/changelog.md). ## License Licensed under either of * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0) * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT) at your option. The subdirectory xcb-proto-1.17.0 contains a vendored copy of the package of the same name. It is covered by the MIT license. See [xcb-proto-1.17.0/COPYING](xcb-proto-1.17.0/COPYING) for details. ## Contribution Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. x11rb-protocol-0.13.1/benches/proto_connection.rs000064400000000000000000000275521046102023000200540ustar 00000000000000//! Benchmark the `x11rb_protocol::Connection` type's method, at varying levels of //! capacity. use criterion::{black_box, criterion_group, criterion_main, BatchSize, Criterion}; use std::{ io::{Read, Write}, mem::{replace, size_of}, net::{TcpListener, TcpStream}, thread, }; use x11rb_protocol::{ connection::{Connection, ReplyFdKind}, protocol::xproto::{Depth, Rectangle, Screen}, x11_utils::{Serialize, TryParse}, DiscardMode, SequenceNumber, }; #[cfg(unix)] use std::os::unix::net::UnixStream; fn pow(i: i32, p: i32) -> i32 { let mut result = 1; for _ in 0..p { result *= i; } result } fn enqueue_packet_test(c: &mut Criterion) { // take the cartesian product of the following conditions: // - the packet is an event, a reply, or an error // - pending_events and pending_replies are empty, have one element, or have // many elements enum PacketType { Event, Reply, Error, } enum PacketCount { Empty, One, Many, } use PacketCount::*; use PacketType::*; let mut group = c.benchmark_group("enqueue_packet"); for packet_ty in &[Event, Reply, Error] { for packet_count in &[Empty, One, Many] { let packet_ty_desc = match packet_ty { Event => "event", Reply => "reply", Error => "error", }; let packet_count_desc = match packet_count { Empty => "no", One => "one", Many => "many", }; let name = format!( "enqueue_packet {} with {} packets", packet_ty_desc, packet_count_desc ); group.bench_function(name, |b| { // generate a valid packet with the given first byte and sequence number let mut seqno = 0u16; let mut packet = move |ind: u8| { let our_seqno = seqno + 1; seqno += 1; let mut v = vec![0; 32]; v[0] = ind; // copy our_seqno to bytes 3 and 4 v[2..4].copy_from_slice(&our_seqno.to_ne_bytes()); v }; // we need another one for make_conn let mut packet2 = packet; let queue_count = match packet_count { PacketCount::Empty => 0, PacketCount::One => 1, PacketCount::Many => pow(2, 8), }; // create a connection with the given stats let mut make_conn = || { let mut conn = Connection::new(); for _ in 0..queue_count { // push a new event conn.enqueue_packet(packet2(2)); } for _ in 0..queue_count { // push a new reply conn.enqueue_packet(packet2(1)); } conn }; let mut conn = make_conn(); let packet = packet(match packet_ty { Event => 2, Reply => 1, Error => 0, }); b.iter(move || { conn.enqueue_packet(packet.clone()); }) }); } } } fn send_and_receive_request(c: &mut Criterion) { // permutations: // - send queue is empty or very full // - receive queue is empty of very full enum SendQueue { SEmpty, SFull, } enum RecvQueue { REmpty, RFull, } use RecvQueue::*; use SendQueue::*; let mut group = c.benchmark_group("send_and_receive_request"); for send_queue in &[SEmpty, SFull] { for recv_queue in &[REmpty, RFull] { let name = format!( "send_and_receive_request (send {}, recv {})", match send_queue { SEmpty => "empty", SFull => "full", }, match recv_queue { REmpty => "empty", RFull => "full", } ); group.bench_function(name, |b| { // create a new connection let mut conn = Connection::new(); // if the send queue needs to be full, flood it with sent requests if matches!(send_queue, SFull) { for _ in 0..pow(2, 14) { conn.send_request(match recv_queue { REmpty => ReplyFdKind::NoReply, RFull => ReplyFdKind::ReplyWithoutFDs, }); } } // if the recv queue needs to be full, flood it with replies if matches!(recv_queue, RFull) { for _ in 0..pow(2, 14) { let mut packet = vec![0; 32]; packet[0] = 1; conn.enqueue_packet(packet); } } // create a new packet let mut packet = vec![0u8; 32]; packet[0] = 1; b.iter(move || { // send our request let seq = conn.send_request(ReplyFdKind::ReplyWithoutFDs).unwrap(); // truncate to a u16 let seq_trunc = seq as u16; // insert the sequence number at positions 2 and 3 packet[2..4].copy_from_slice(&seq_trunc.to_ne_bytes()); // enqueue the packet conn.enqueue_packet(black_box(replace(&mut packet, vec![0u8; 32]))); // pop the reply conn.poll_for_reply_or_error(seq) }) }); } } } fn try_parse_small_struct(c: &mut Criterion) { // xproto::Rectangle is a pointer wide on 64-bit, use that c.bench_function("try_parse an xproto::Rectangle", |b| { let packet = [0x42u8; size_of::()]; b.iter(|| Rectangle::try_parse(black_box(&packet))) }); } fn try_parse_large_struct(c: &mut Criterion) { // xproto::Screen is a significantly larger structure, use that const SCREEN_BASE_SIZE: usize = size_of::() - size_of::>() + size_of::(); const NUM_DEPTHS: usize = 3; const DEPTH_SIZE: usize = 8; const TOTAL_SIZE: usize = SCREEN_BASE_SIZE + (NUM_DEPTHS * DEPTH_SIZE); c.bench_function("try_parse an xproto::Screen", |b| { let mut packet = [0; TOTAL_SIZE]; packet[SCREEN_BASE_SIZE - 1] = NUM_DEPTHS as u8; b.iter(|| Screen::try_parse(black_box(&packet))) }); } fn serialize_struct(c: &mut Criterion) { // try the following: // - send it down a TCP socket // - send it down a Unix socket (if linux) // // this should relatively accurately tell us what kind of impact the buffering // and writing have on the serialization time // // note that send() and recv() degenerate into sendmsg() and recvmsg(), at least // on the Linux kernel end, so not using those functions should have no effect enum SocketTy { TryTcp, TryUnix, } enum StructType { Small, Large, } use SocketTy::*; use StructType::*; let mut group = c.benchmark_group("serialize_struct"); for socket_ty in &[TryTcp, TryUnix] { let mut fd: Box = match socket_ty { TryTcp => { const PORT: u16 = 41234; let listen = TcpListener::bind(("::1", PORT)).unwrap(); thread::spawn(move || { let (mut sock, _) = listen.accept().unwrap(); // read until other sock gets dropped let mut buf = [0u8; 1024]; loop { if sock.read(&mut buf).is_err() { break; } } }); let sock = TcpStream::connect(("::1", PORT)).unwrap(); Box::new(sock) } TryUnix => { #[cfg(unix)] { let (mut left, right) = UnixStream::pair().unwrap(); thread::spawn(move || { let mut buf = [0u8; 1024]; loop { if left.read(&mut buf).is_err() { break; } } }); Box::new(right) } #[cfg(not(unix))] { continue; } } }; let try_desc = match socket_ty { TryTcp => "TCP", TryUnix => "Unix", }; for struct_size in &[Small, Large] { let size_desc = match struct_size { Small => "small", Large => "large", }; let name = format!("serialize_struct {} {}", try_desc, size_desc); group.bench_function(name, |b| { b.iter(|| { let bytes = match struct_size { Small => { let rect = Rectangle::default(); black_box(rect.serialize()).to_vec() } Large => { let mut screen = Screen::default(); screen.allowed_depths.resize_with(3, Default::default); black_box(screen.serialize()) } }; // write the serialized bytes tothe output fd.write_all(&bytes).unwrap(); }) }); } } } fn discard_reply(c: &mut Criterion) { // Measure the performance of discard_reply() fn get_connection_and_seqnos() -> (Connection, Vec) { let mut conn = Connection::new(); let seqnos = (0..pow(2, 13)) .map(|_| conn.send_request(ReplyFdKind::NoReply).unwrap()) .collect(); (conn, seqnos) } let mut group = c.benchmark_group("discard_reply"); group.bench_function("discard oldest", |b| { b.iter_batched( get_connection_and_seqnos, |(mut conn, seqnos)| { conn.discard_reply(*seqnos.first().unwrap(), DiscardMode::DiscardReply) }, BatchSize::SmallInput, ); }); group.bench_function("discard newest", |b| { b.iter_batched( get_connection_and_seqnos, |(mut conn, seqnos)| { conn.discard_reply(*seqnos.last().unwrap(), DiscardMode::DiscardReply) }, BatchSize::SmallInput, ); }); group.bench_function("discard all forward", |b| { b.iter_batched( get_connection_and_seqnos, |(mut conn, seqnos)| { for seqno in seqnos { conn.discard_reply(seqno, DiscardMode::DiscardReply) } }, BatchSize::SmallInput, ); }); group.bench_function("discard all backward", |b| { b.iter_batched( get_connection_and_seqnos, |(mut conn, seqnos)| { for seqno in seqnos.into_iter().rev() { conn.discard_reply(seqno, DiscardMode::DiscardReply) } }, BatchSize::SmallInput, ); }); } criterion_group!( benches, enqueue_packet_test, send_and_receive_request, try_parse_small_struct, try_parse_large_struct, serialize_struct, discard_reply, ); criterion_main!(benches); x11rb-protocol-0.13.1/src/connect.rs000064400000000000000000000277511046102023000153040ustar 00000000000000//! Contains utilities for connection to the X11 server. use crate::errors::{ConnectError, ParseError}; use crate::protocol::xproto::{Setup, SetupAuthenticate, SetupFailed, SetupRequest}; use crate::x11_utils::{Serialize, TryParse}; #[cfg(feature = "std")] use crate::xauth::{get_auth, Family}; use alloc::{vec, vec::Vec}; use core::fmt; /// The connection handshake used to connect to the X11 server. /// /// In order to connect to the X11 server, the client must send the /// server a request containing important pieces of client data. In /// response, the server sends the client a response containing one /// of the following: /// /// - An error indicating that the setup request is malformed, or the /// setup otherwise failed. /// - A request for further authorization data. /// - The [`Setup`](protocol/xproto/struct.Setup.html) for the connection, /// which contains server-specific information and is necessary for /// the client's ability to communicate with the server. /// /// This handshake contains four relevant methods: /// /// - `new`, which creates the handshake and also returns the setup request /// to send to the server. /// - `buffer`, which returns an `&mut [u8]` containing the buffer /// which is intended to hold the bytes received from the server. /// - `advance`, which takes a `usize` indicating how many bytes /// were received from the server and advances the buffer. /// - `into_setup`, which consumes this `Connect` and returns the /// full `Setup`. /// /// # Examples /// /// Let's say you have an object `stream` which implements `Read` /// and `Write`. In addition, you already have the connection family, /// the address of the connection, and the display. You can use the `Connect` /// to establish an X11 connection like so: /// /// ```rust,no_run /// # use x11rb_protocol::connect::Connect; /// # use x11rb_protocol::xauth::Family; /// # use std::{error::Error, io::prelude::*}; /// # fn main() -> Result<(), Box> { /// # struct Stream; /// # impl Read for Stream { /// # fn read(&mut self, buf: &mut [u8]) -> std::io::Result { /// # Ok(buf.len()) /// # } /// # } /// # impl Write for Stream { /// # fn write(&mut self, buf: &[u8]) -> std::io::Result { /// # Ok(buf.len()) /// # } /// # fn flush(&mut self) -> std::io::Result<()> { /// # Ok(()) /// # } /// # } /// # let mut stream = Stream; /// let family = Family::INTERNET; /// let address = b"foobar"; /// let display = 0; /// /// let (mut connect, setup_request) = Connect::new(family, address, display)?; /// /// // send the setup request to the server /// stream.write_all(&setup_request)?; /// /// // receive the setup response from the server /// loop { /// let adv = stream.read(connect.buffer())?; /// /// // if we've completed the setup, break out of the loop /// if connect.advance(adv) { /// break; /// } /// } /// /// // get the setup used for our connection /// let setup = connect.into_setup()?; /// # Ok(()) /// # } /// ``` /// /// If, instead, `stream` implements `AsyncRead` and `AsyncWrite`, the code /// would be identical, but with `.await` after `read` and `write_all`. pub struct Connect { // input buffer buffer: Vec, // position in the buffer that has been filled advanced: usize, } const INITIAL_CAPACITY: usize = 8; // X11 interprets capital B as big endian, and lowercase l as little endian. #[cfg(target_endian = "little")] const BYTE_ORDER: u8 = b'l'; #[cfg(not(target_endian = "little"))] const BYTE_ORDER: u8 = b'B'; // protocol version const PROTOCOL_MAJOR_VERSION: u16 = 11; const PROTOCOL_MINOR_VERSION: u16 = 0; impl Connect { /// The initial state of a `Connect`. fn blank() -> Self { Self { buffer: vec![0; INITIAL_CAPACITY], advanced: 0, } } /// Create a new `Connect` from the given authorization data. /// /// This uses the provided protocol name and data to establish the connection, /// rather than the default protocol name and data found in `Xauthority`. /// /// # Example /// /// ```rust /// # use x11rb_protocol::connect::Connect; /// /// let (connect, setup_request) = Connect::with_authorization( /// b"MIT-MAGIC-COOKIE-1".to_vec(), /// b"my_secret_password".to_vec(), /// ); /// ``` pub fn with_authorization(protocol_name: Vec, protocol_data: Vec) -> (Self, Vec) { // craft the setup request let sr = SetupRequest { byte_order: BYTE_ORDER, protocol_major_version: PROTOCOL_MAJOR_VERSION, protocol_minor_version: PROTOCOL_MINOR_VERSION, authorization_protocol_name: protocol_name, authorization_protocol_data: protocol_data, }; // return it (Self::blank(), sr.serialize()) } /// Create a new `Connect` from the information necessary to connect to the X11 server. /// /// This returns the connection handshake object as well as the setup request to send to the server. #[cfg(feature = "std")] pub fn new( family: Family, address: &[u8], display: u16, ) -> Result<(Self, Vec), ConnectError> { match get_auth(family, address, display)? { Some((name, data)) => Ok(Self::with_authorization(name, data)), None => { // fall through to no authorization Ok(Self::with_authorization(Vec::new(), Vec::new())) } } } /// Returns the buffer that needs to be filled with incoming data from the server. /// /// After filling this buffer (using a method like `Read::read`), call [`Self::advance`] with /// the number of bytes read to indicate that the buffer has been filled. pub fn buffer(&mut self) -> &mut [u8] { &mut self.buffer[self.advanced..] } /// Advance the internal buffer, given the number of bytes that have been read. pub fn advance(&mut self, bytes: usize) -> bool { self.advanced += bytes; debug_assert!(self.buffer.len() >= self.advanced); // if we've read up to the initial capacity, tell how many more bytes // we need to read if self.advanced == INITIAL_CAPACITY { // remaining length is at byte range 6-7 in 4-bytes let length = u16::from_ne_bytes([self.buffer[6], self.buffer[7]]); let length = length as usize * 4; // allocate more room // use reserve_exact because this will be the final // length of the vector self.buffer.reserve_exact(length); self.buffer.resize(length + self.buffer.len(), 0); false } else { self.advanced == self.buffer.len() } } /// Returns the setup provided by the server. /// /// # Errors /// /// - If this method is called before the server returns all of the required data, /// it returns `ConnectError::NotEnoughData`. /// - If the server fails to establish the X11 connection, the `ConnectError::SetupFailed` /// variant is returned. /// - If the server failed to authenticate the user, the `ConnectError::SetupAuthenticate` /// error is returned. /// - If the server failed to parse any of the above responses, the /// `ConnectError::ParseError` error is returned. pub fn into_setup(self) -> Result { // if we aren't full yet, panic if self.advanced != self.buffer.len() { return Err(ConnectError::Incomplete { expected: self.buffer.len(), received: self.advanced, }); } // parse the setup response match self.buffer[0] { 0 => { // an error has occurred let (failed, _) = SetupFailed::try_parse(&self.buffer)?; Err(ConnectError::SetupFailed(failed)) } 1 => { // the setup is valid! let (success, _) = Setup::try_parse(&self.buffer)?; Ok(success) } 2 => { // we need further authentication let (more_auth, _) = SetupAuthenticate::try_parse(&self.buffer)?; Err(ConnectError::SetupAuthenticate(more_auth)) } _ => { // this is undefined Err(ParseError::InvalidValue.into()) } } } } impl fmt::Debug for Connect { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Connect") .field( "buffer", &format_args!("{}/{}", self.advanced, self.buffer.len()), ) .finish() } } impl TryFrom for Setup { type Error = ConnectError; fn try_from(connect: Connect) -> Result { connect.into_setup() } } #[cfg(test)] #[cfg(feature = "extra-traits")] mod tests { use super::Connect; use crate::errors::ConnectError; use crate::protocol::xproto::{ImageOrder, Setup, SetupAuthenticate, SetupFailed}; use crate::x11_utils::Serialize; use alloc::vec; fn test_setup() -> Setup { let mut s = Setup { status: 1, protocol_major_version: 11, protocol_minor_version: 0, length: 0, release_number: 0, resource_id_base: 1, resource_id_mask: 1, motion_buffer_size: 0, maximum_request_length: 0, image_byte_order: ImageOrder::LSB_FIRST, bitmap_format_bit_order: ImageOrder::LSB_FIRST, bitmap_format_scanline_unit: 32, bitmap_format_scanline_pad: 32, min_keycode: 0, max_keycode: 0, vendor: b"Testing Setup".to_vec(), pixmap_formats: vec![], roots: vec![], }; // +3 so it rounds up s.length = ((s.serialize().len() - 8 + 3) / 4) as u16; s } fn try_receive_bytes(item: &impl Serialize) -> Result { let mut connect = Connect::blank(); // feed in a setup let mut item_bytes = vec![]; item.serialize_into(&mut item_bytes); let mut i = 0; loop { i += 1; if i > 500 { panic!("too many iterations"); } // copy bytes to connect let buffer = connect.buffer(); let bytes_to_copy = std::cmp::min(item_bytes.len(), buffer.len()); buffer[..bytes_to_copy].copy_from_slice(&item_bytes[..bytes_to_copy]); // drain the bytes that we've already copied drop(item_bytes.drain(..bytes_to_copy)); // check advance if connect.advance(bytes_to_copy) { break; } } connect.into_setup() } #[test] fn test_connect_receive_setup() { let setup = test_setup(); let b = try_receive_bytes(&setup); match b { Ok(s) => assert_eq!(s, setup), Err(e) => panic!("{:?}", e), } } #[test] fn test_connect_receive_setup_authenticate() { let setup = SetupAuthenticate { status: 2, reason: b"Needs more auth.".to_vec(), }; let b = try_receive_bytes(&setup); match b { Ok(s) => panic!("{:?}", s), Err(ConnectError::SetupAuthenticate(e)) => assert_eq!(e, setup), Err(e) => panic!("{:?}", e), } } #[test] fn test_connect_receive_setup_failed() { let mut setup = SetupFailed { status: 0, protocol_major_version: 11, protocol_minor_version: 0, length: 0, reason: b"whatever".to_vec(), }; setup.length = ((setup.serialize().len() - 8) / 4) as _; let b = try_receive_bytes(&setup); match b { Ok(s) => panic!("{:?}", s), Err(ConnectError::SetupFailed(e)) => assert_eq!(e, setup), Err(e) => panic!("{:?}", e), } } } x11rb-protocol-0.13.1/src/connection/mod.rs000064400000000000000000000421311046102023000165560ustar 00000000000000//! Helper types for implementing an X11 client. use alloc::collections::VecDeque; use alloc::vec::Vec; use crate::utils::RawFdContainer; use crate::{DiscardMode, SequenceNumber}; /// A combination of a buffer and a list of file descriptors. pub type BufWithFds = crate::BufWithFds>; /// The raw bytes of an X11 event and its sequence number. pub type RawEventAndSeqNumber = crate::RawEventAndSeqNumber>; /// Information about the reply to an X11 request. #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum ReplyFdKind { /// The request does not have a reply. NoReply, /// The request has a reply and that reply does *not* contain any file descriptors. ReplyWithoutFDs, /// The request has a reply and that reply *does* contain file descriptor(s). ReplyWithFDs, } /// Information about the result of polling for a reply packet. #[derive(Debug, Clone)] pub enum PollReply { /// It is not clear yet what the result will be; try again later. TryAgain, /// There will be no reply; polling is done. NoReply, /// Here is the result of the polling; polling is done. Reply(Vec), } #[derive(Debug, Clone, Copy, Eq, PartialEq)] struct SentRequest { seqno: SequenceNumber, discard_mode: Option, has_fds: bool, } /// A pure-rust, sans-I/O implementation of the X11 protocol. /// /// This object is designed to be used in combination with an I/O backend, in /// order to keep state for the X11 protocol. #[derive(Debug)] pub struct Connection { // The sequence number of the last request that was written last_sequence_written: SequenceNumber, // Sorted(!) list with information on requests that were written, but no answer received yet. sent_requests: VecDeque, // The sequence number of the next reply that is expected to come in next_reply_expected: SequenceNumber, // The sequence number of the last reply/error/event that was read last_sequence_read: SequenceNumber, // Events that were read, but not yet returned to the API user pending_events: VecDeque<(SequenceNumber, Vec)>, // Replies that were read, but not yet returned to the API user pending_replies: VecDeque<(SequenceNumber, BufWithFds)>, // FDs that were read, but not yet assigned to any reply pending_fds: VecDeque, } impl Default for Connection { fn default() -> Self { Self::new() } } impl Connection { /// Create a new `Connection`. /// /// It is assumed that the connection was just established. This means that the next request /// that is sent will have sequence number one. pub fn new() -> Self { Connection { last_sequence_written: 0, next_reply_expected: 0, last_sequence_read: 0, sent_requests: VecDeque::new(), pending_events: VecDeque::new(), pending_replies: VecDeque::new(), pending_fds: VecDeque::new(), } } /// Send a request to the X11 server. /// /// When this returns `None`, a sync with the server is necessary. Afterwards, the caller /// should try again. pub fn send_request(&mut self, kind: ReplyFdKind) -> Option { let has_response = match kind { ReplyFdKind::NoReply => false, ReplyFdKind::ReplyWithoutFDs => true, ReplyFdKind::ReplyWithFDs => true, }; if self.next_reply_expected + SequenceNumber::from(u16::max_value()) - 1 <= self.last_sequence_written && !has_response { // The caller need to call send_sync(). Otherwise, we might not be able to reconstruct // full sequence numbers for received packets. return None; } self.last_sequence_written += 1; let seqno = self.last_sequence_written; if has_response { self.next_reply_expected = self.last_sequence_written; } let sent_request = SentRequest { seqno, discard_mode: None, has_fds: kind == ReplyFdKind::ReplyWithFDs, }; self.sent_requests.push_back(sent_request); Some(seqno) } /// Ignore the reply for a request that was previously sent. pub fn discard_reply(&mut self, seqno: SequenceNumber, mode: DiscardMode) { if let Ok(index) = self.sent_requests.binary_search_by_key(&seqno, |r| r.seqno) { self.sent_requests[index].discard_mode = Some(mode); } match mode { DiscardMode::DiscardReplyAndError => self.pending_replies.retain(|r| r.0 != seqno), DiscardMode::DiscardReply => { if let Some(index) = self.pending_replies.iter().position(|r| r.0 == seqno) { while self .pending_replies .get(index) .filter(|r| r.0 == seqno) .is_some() { if let Some((_, packet)) = self.pending_replies.remove(index) { if packet.0[0] == 0 { // This is an error self.pending_events.push_back((seqno, packet.0)); } } } } } } } // Extract the sequence number from a packet read from the X11 server. The packet must be a // reply, an event, or an error. All of these have a u16 sequence number in bytes 2 and 3... // except for KeymapNotify events. fn extract_sequence_number(&mut self, buffer: &[u8]) -> Option { use crate::protocol::xproto::KEYMAP_NOTIFY_EVENT; if buffer[0] == KEYMAP_NOTIFY_EVENT { return None; } // We get the u16 from the wire... let number = u16::from_ne_bytes([buffer[2], buffer[3]]); // ...and use our state to reconstruct the high bytes let high_bytes = self.last_sequence_read & !SequenceNumber::from(u16::max_value()); let mut full_number = SequenceNumber::from(number) | high_bytes; if full_number < self.last_sequence_read { full_number += SequenceNumber::from(u16::max_value()) + 1; } // Update our state self.last_sequence_read = full_number; if self.next_reply_expected < full_number { // This is most likely an event/error that allows us to update our sequence number // implicitly. Normally, only requests with a reply update this (in send_request()). self.next_reply_expected = full_number; } Some(full_number) } /// Add FDs that were received to the internal state. /// /// This must be called before the corresponding packets are enqueued. pub fn enqueue_fds(&mut self, fds: Vec) { self.pending_fds.extend(fds); } /// An X11 packet was received from the connection and is now enqueued into our state. /// /// Any FDs that were received must already be enqueued before this can be called. pub fn enqueue_packet(&mut self, packet: Vec) { let kind = packet[0]; // extract_sequence_number() updates our state and is thus important to call even when we // do not need the sequence number let seqno = self .extract_sequence_number(&packet) .unwrap_or(self.last_sequence_read); // Remove all entries for older requests while let Some(request) = self.sent_requests.front() { if request.seqno >= seqno { break; } let _ = self.sent_requests.pop_front(); } let request = self.sent_requests.front().filter(|r| r.seqno == seqno); if kind == 0 { // It is an error. Let's see where we have to send it to. if let Some(request) = request { match request.discard_mode { Some(DiscardMode::DiscardReplyAndError) => { /* This error should be ignored */ } Some(DiscardMode::DiscardReply) => { self.pending_events.push_back((seqno, packet)) } None => self .pending_replies .push_back((seqno, (packet, Vec::new()))), } } else { // Unexpected error, send to main loop self.pending_events.push_back((seqno, packet)); } } else if kind == 1 { let fds = if request.filter(|r| r.has_fds).is_some() { // This reply has FDs, the number of FDs is always in the second byte let num_fds = usize::from(packet[1]); // FIXME Turn this into some kind of "permanent error state" (so that // everything fails with said error) instead of using a panic (this panic will // likely poison some Mutex and produce an error state that way). assert!( num_fds <= self.pending_fds.len(), "FIXME: The server sent us too few FDs. The connection is now unusable \ since we will never be sure again which FD belongs to which reply." ); self.pending_fds.drain(..num_fds).collect() } else { Vec::new() }; // It is a reply if request.filter(|r| r.discard_mode.is_some()).is_some() { // This reply should be discarded } else { self.pending_replies.push_back((seqno, (packet, fds))); } } else { // It is an event self.pending_events.push_back((seqno, packet)); } } /// Check if the server already sent an answer to the request with the given sequence number. /// /// This function is meant to be used for requests that have a reply. Such requests always /// cause a reply or an error to be sent. pub fn poll_for_reply_or_error(&mut self, sequence: SequenceNumber) -> Option { for (index, (seqno, _packet)) in self.pending_replies.iter().enumerate() { if *seqno == sequence { return Some(self.pending_replies.remove(index).unwrap().1); } } None } /// Prepare for calling `poll_check_for_reply_or_error()`. /// /// To check if a request with a reply caused an error, one simply has to wait for the error or /// reply to be received. However, this approach does not work for requests without errors: /// Success is indicated by the absence of an error. /// /// Thus, this function returns true if a sync is necessary to ensure that a reply with a /// higher sequence number will be received. Since the X11 server handles requests in-order, /// if the reply to a later request is received, this means that the earlier request did not /// fail. pub fn prepare_check_for_reply_or_error(&mut self, sequence: SequenceNumber) -> bool { self.next_reply_expected < sequence } /// Check if the request with the given sequence number was already handled by the server. /// /// Before calling this function, you must call `prepare_check_for_reply_or_error()` with the /// sequence number. /// /// This function can be used for requests with and without a reply. pub fn poll_check_for_reply_or_error(&mut self, sequence: SequenceNumber) -> PollReply { if let Some(result) = self.poll_for_reply_or_error(sequence) { return PollReply::Reply(result.0); } if self.last_sequence_read > sequence { // We can be sure that there will be no reply/error PollReply::NoReply } else { // Hm, we cannot be sure yet. Perhaps there will still be a reply/error PollReply::TryAgain } } /// Find the reply for the request with the given sequence number. /// /// If the request caused an error, that error will be handled as an event. This means that a /// latter call to `poll_for_event()` will return it. pub fn poll_for_reply(&mut self, sequence: SequenceNumber) -> PollReply { if let Some(reply) = self.poll_for_reply_or_error(sequence) { if reply.0[0] == 0 { self.pending_events.push_back((sequence, reply.0)); PollReply::NoReply } else { PollReply::Reply(reply.0) } } else { PollReply::TryAgain } } /// Get a pending event. pub fn poll_for_event_with_sequence(&mut self) -> Option { self.pending_events .pop_front() .map(|(seqno, event)| (event, seqno)) } } #[cfg(test)] mod test { use super::{Connection, ReplyFdKind}; #[test] fn insert_sync_no_reply() { // The connection must send a sync (GetInputFocus) request every 2^16-1 requests (that do not // have a reply). Thus, this test sends more than that and tests for the sync to appear. let mut connection = Connection::new(); for num in 1..0xffff { let seqno = connection.send_request(ReplyFdKind::NoReply); assert_eq!(Some(num), seqno); } // request 0xffff should be a sync, hence the next one is 0x10000 let seqno = connection.send_request(ReplyFdKind::NoReply); assert_eq!(None, seqno); let seqno = connection.send_request(ReplyFdKind::ReplyWithoutFDs); assert_eq!(Some(0xffff), seqno); let seqno = connection.send_request(ReplyFdKind::NoReply); assert_eq!(Some(0x10000), seqno); } #[test] fn insert_no_sync_with_reply() { // Compared to the previous test, this uses ReplyFdKind::ReplyWithoutFDs, so no sync needs to // be inserted. let mut connection = Connection::new(); for num in 1..=0x10001 { let seqno = connection.send_request(ReplyFdKind::ReplyWithoutFDs); assert_eq!(Some(num), seqno); } } #[test] fn insert_no_sync_when_already_syncing() { // This test sends enough ReplyFdKind::NoReply requests that a sync becomes necessary on // the next request. Then it sends a ReplyFdKind::ReplyWithoutFDs request so that no sync is // necessary. This is a regression test: Once upon a time, an unnecessary sync was done. let mut connection = Connection::new(); for num in 1..0xffff { let seqno = connection.send_request(ReplyFdKind::NoReply); assert_eq!(Some(num), seqno); } let seqno = connection.send_request(ReplyFdKind::ReplyWithoutFDs); assert_eq!(Some(0xffff), seqno); } #[test] fn get_sync_replies() { // This sends requests with a reply with seqno 1 and 1+2^16 and then checks that their // replies are correctly mapped to the requests. let mut connection = Connection::new(); let first_reply = 1; let second_reply = 0x10001; // First, send all the requests // First request is one with a reply let seqno = connection.send_request(ReplyFdKind::ReplyWithoutFDs); assert_eq!(Some(first_reply), seqno); // Then, there should be enough requests so that the next request will end up with sequence // number 'second_reply' for num in (first_reply + 1)..(second_reply - 1) { let seqno = connection.send_request(ReplyFdKind::NoReply); assert_eq!(Some(num), seqno); } // Send one more request. This needs to be a sync request so that sequence numbers can be // reconstructed correctly. The bug that we testing was that no sync was required, so this // test handles both cases correctly. let requested_extra_sync = connection.send_request(ReplyFdKind::NoReply).is_none(); if requested_extra_sync { let _ = connection.send_request(ReplyFdKind::ReplyWithoutFDs); } let seqno = connection.send_request(ReplyFdKind::ReplyWithoutFDs); assert_eq!(Some(second_reply), seqno); // Prepare a reply packet let mut packet = [0; 32]; // It is a reply packet[0] = 1; // Set the sequence number to 1 packet[2..4].copy_from_slice(&1u16.to_ne_bytes()); // Enqueue the first reply. connection.enqueue_packet(packet.to_vec()); // Send an extra reply if the code wanted one. This extra reply allows to detect that all // replies to the first request were received (remember, there can be multiple replies to a // single request!) if requested_extra_sync { packet[2..4].copy_from_slice(&((second_reply - 1) as u16).to_ne_bytes()); connection.enqueue_packet(packet.to_vec()); } // Set the sequence number for the second reply packet[2..4].copy_from_slice(&(second_reply as u16).to_ne_bytes()); connection.enqueue_packet(packet.to_vec()); // Now check that the sequence number for the last packet was reconstructed correctly. assert!(connection.poll_for_reply_or_error(second_reply).is_some()); } } x11rb-protocol-0.13.1/src/errors.rs000064400000000000000000000172201046102023000151550ustar 00000000000000//! This module contains the current mess that is error handling. use crate::protocol::xproto::{SetupAuthenticate, SetupFailed}; pub use crate::id_allocator::IdsExhausted; use core::fmt; #[cfg(feature = "std")] use std::error::Error; /// An error occurred while parsing some data #[derive(Debug, Copy, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum ParseError { /// Not enough data was provided. InsufficientData, /// A value did not fit. /// /// This error can e.g. happen when a value that was received from the X11 server does not fit /// into an `usize`. ConversionFailed, /// The value of an expression could not be computed. /// /// As an example, the length of the data in `xproto`'s `GetPropertyReply` is described by /// `value_len * (format / 8)`. The multiplication could cause an overflow, which would be /// represented by this error. InvalidExpression, /// A value was outside of its valid range. /// /// There are two kinds of situations where this error can happen: /// /// 1. The protocol was violated and a nonsensical value was found. /// 2. The user of the API called the wrong parsing function. /// /// Examples for the first kind of error: /// /// - One of a set of values should be present (a `` in xcb-proto-speak), but none of /// the `` matched. This can e.g. happen when parsing /// [`crate::protocol::xinput::InputInfo`]. /// - Parsing a request with a length field that is too small for the request header to fit. /// /// Examples for the second kind of error: /// /// - Parsing an X11 error with `response_type != 0`. /// - Parsing an X11 reply with `response_type != 1`. /// - Parsing an X11 request with the wrong value for its `minor_opcode`. InvalidValue, /// Some file descriptors were expected, but not enough were received. MissingFileDescriptors, } #[cfg(feature = "std")] impl Error for ParseError {} impl fmt::Display for ParseError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { ParseError::InsufficientData => write!(f, "Insufficient data was provided"), ParseError::ConversionFailed => { write!(f, "A value conversion failed due to out of range data") } ParseError::InvalidExpression => write!( f, "An expression could not be computed, e.g. due to overflow" ), ParseError::InvalidValue => { write!(f, "A value could not be parsed into an enumeration") } ParseError::MissingFileDescriptors => write!(f, "Missing file descriptors"), } } } /// An error that occurred while parsing the `$DISPLAY` environment variable #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum DisplayParsingError { /// No explicit display was provided and the `$DISPLAY` environment variable is not set. DisplayNotSet, /// The given value could not be parsed. The input to parsing is provided. MalformedValue(alloc::boxed::Box), /// The value of `$DISPLAY` is not valid unicode NotUnicode, /// An unknown error occurred during display parsing. /// /// This is `XCB_CONN_CLOSED_PARSE_ERR`. Unknown, } #[cfg(feature = "std")] impl Error for DisplayParsingError {} impl fmt::Display for DisplayParsingError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { DisplayParsingError::DisplayNotSet => { write!( f, "$DISPLAY variable not set and no value was provided explicitly" ) } DisplayParsingError::MalformedValue(dpy) => { write!(f, "Failed to parse value '{}'", dpy) } DisplayParsingError::NotUnicode => { write!(f, "The value of $DISPLAY is not valid unicode") } DisplayParsingError::Unknown => { write!(f, "Unknown error while parsing a $DISPLAY address") } } } } /// An error that occurred while connecting to an X11 server #[derive(Debug)] #[non_exhaustive] pub enum ConnectError { /// An unknown error occurred. /// /// One situation were this error is used when libxcb indicates an error that does not match /// any of the defined error conditions. Thus, libxcb is violating its own API (or new error /// cases were defined, but are not yet handled by x11rb). UnknownError, /// Error while parsing some data, see `ParseError`. ParseError(ParseError), /// Out of memory. /// /// This is `XCB_CONN_CLOSED_MEM_INSUFFICIENT`. InsufficientMemory, /// Error during parsing of display string. /// /// This is `XCB_CONN_CLOSED_PARSE_ERR`. DisplayParsingError(DisplayParsingError), /// Server does not have a screen matching the display. /// /// This is `XCB_CONN_CLOSED_INVALID_SCREEN`. InvalidScreen, /// An I/O error occurred on the connection. #[cfg(feature = "std")] IoError(std::io::Error), /// Invalid ID mask provided by the server. /// /// The value of `resource_id_mask` in the `Setup` provided by the server was zero. ZeroIdMask, /// The server rejected the connection with a `SetupAuthenticate` message. SetupAuthenticate(SetupAuthenticate), /// The server rejected the connection with a `SetupFailed` message. SetupFailed(SetupFailed), /// The client did not receive enough data from the server to complete /// the handshake. Incomplete { /// The number of bytes that were expected. expected: usize, /// The number of bytes that were received. received: usize, }, } #[cfg(feature = "std")] impl Error for ConnectError {} impl fmt::Display for ConnectError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn display(f: &mut fmt::Formatter<'_>, prefix: &str, value: &[u8]) -> fmt::Result { match core::str::from_utf8(value).ok() { Some(value) => write!(f, "{}: '{}'", prefix, value), None => write!(f, "{}: {:?} [message is not utf8]", prefix, value), } } match self { ConnectError::UnknownError => write!(f, "Unknown connection error"), ConnectError::InsufficientMemory => write!(f, "Insufficient memory"), ConnectError::DisplayParsingError(err) => err.fmt(f), ConnectError::InvalidScreen => write!(f, "Invalid screen"), ConnectError::ParseError(err) => err.fmt(f), #[cfg(feature = "std")] ConnectError::IoError(err) => err.fmt(f), ConnectError::ZeroIdMask => write!(f, "XID mask was zero"), ConnectError::SetupFailed(err) => display(f, "X11 setup failed", &err.reason), ConnectError::SetupAuthenticate(err) => { display(f, "X11 authentication failed", &err.reason) } ConnectError::Incomplete { expected, received } => write!( f, "Not enough data received to complete the handshake. Expected {}, received {}", expected, received ), } } } impl From for ConnectError { fn from(err: ParseError) -> Self { ConnectError::ParseError(err) } } impl From for ConnectError { fn from(err: DisplayParsingError) -> Self { ConnectError::DisplayParsingError(err) } } #[cfg(feature = "std")] impl From for ConnectError { fn from(err: std::io::Error) -> Self { ConnectError::IoError(err) } } x11rb-protocol-0.13.1/src/id_allocator.rs000064400000000000000000000123231046102023000162740ustar 00000000000000//! A mechanism for allocating XIDs. use crate::errors::ConnectError; use crate::protocol::xc_misc::GetXIDRangeReply; #[cfg(feature = "std")] use std::error::Error; use core::fmt; /// An allocator for X11 IDs. /// /// This struct handles the client-side generation of X11 IDs. The ID allocation is based on a /// range of IDs that the server assigned us. This range is described by a base and a mask. From /// the X11 protocol reference manual: /// /// > The resource-id-mask contains a single contiguous set of bits (at least 18). The client /// > allocates resource IDs [..] by choosing a value with only some subset of these bits set and /// > ORing it with resource-id-base. #[derive(Debug, Clone, Copy)] pub struct IdAllocator { next_id: u32, max_id: u32, increment: u32, } impl IdAllocator { /// Create a new instance of an ID allocator. /// /// The arguments should be the `resource_id_base` and `resource_id_mask` values that the X11 /// server sent in a `Setup` response. pub fn new(id_base: u32, id_mask: u32) -> Result { if id_mask == 0 { return Err(ConnectError::ZeroIdMask); } // Find the right-most set bit in id_mask, e.g. for 0b110, this results in 0b010. let increment = id_mask & (1 + !id_mask); Ok(Self { next_id: id_base, max_id: id_base | id_mask, increment, }) } /// Update the available range of IDs based on a GetXIDRangeReply pub fn update_xid_range(&mut self, xidrange: &GetXIDRangeReply) -> Result<(), IdsExhausted> { let (start, count) = (xidrange.start_id, xidrange.count); // Apparently (0, 1) is how the server signals "I am out of IDs". // The second case avoids an underflow below and should never happen. if (start, count) == (0, 1) || count == 0 { return Err(IdsExhausted); } self.next_id = start; self.max_id = start + (count - 1) * self.increment; Ok(()) } /// Generate the next ID. pub fn generate_id(&mut self) -> Option { if self.next_id > self.max_id { None } else { let id = self.next_id; self.next_id += self.increment; Some(id) } } } /// The XID range has been exhausted. #[derive(Debug, Copy, Clone)] pub struct IdsExhausted; impl fmt::Display for IdsExhausted { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "XID range has been exhausted") } } #[cfg(feature = "std")] impl Error for IdsExhausted {} #[cfg(test)] mod test { use super::{GetXIDRangeReply, IdAllocator, IdsExhausted}; #[test] fn exhaustive() { let mut allocator = IdAllocator::new(0x2800, 0x1ff).unwrap(); for expected in 0x2800..=0x29ff { assert_eq!(Some(expected), allocator.generate_id()); } assert_eq!(None, allocator.generate_id()); } #[test] fn increment() { let mut allocator = IdAllocator::new(0, 0b1100).unwrap(); assert_eq!(Some(0b0000), allocator.generate_id()); assert_eq!(Some(0b0100), allocator.generate_id()); assert_eq!(Some(0b1000), allocator.generate_id()); assert_eq!(Some(0b1100), allocator.generate_id()); assert_eq!(None, allocator.generate_id()); } #[test] fn new_range() { let mut allocator = IdAllocator::new(0x420, 2).unwrap(); assert_eq!(Some(0x420), allocator.generate_id()); assert_eq!(Some(0x422), allocator.generate_id()); // At this point the range is exhausted and a GetXIDRange request needs to be sent assert_eq!(None, allocator.generate_id()); allocator .update_xid_range(&generate_get_xid_range_reply(0x13370, 3)) .unwrap(); assert_eq!(Some(0x13370), allocator.generate_id()); assert_eq!(Some(0x13372), allocator.generate_id()); assert_eq!(Some(0x13374), allocator.generate_id()); // At this point the range is exhausted and a GetXIDRange request needs to be sent assert_eq!(None, allocator.generate_id()); allocator .update_xid_range(&generate_get_xid_range_reply(0x13370, 3)) .unwrap(); assert_eq!(Some(0x13370), allocator.generate_id()); } #[test] fn invalid_new_arg() { let err = IdAllocator::new(1234, 0).unwrap_err(); if let super::ConnectError::ZeroIdMask = err { } else { panic!("Wrong error: {:?}", err); } } #[test] fn invalid_update_arg() { fn check_ids_exhausted(arg: &Result<(), IdsExhausted>) { if let Err(IdsExhausted) = arg { } else { panic!("Expected IdsExhausted, got {:?}", arg); } } let mut allocator = IdAllocator::new(0x420, 2).unwrap(); check_ids_exhausted(&allocator.update_xid_range(&generate_get_xid_range_reply(0, 1))); check_ids_exhausted(&allocator.update_xid_range(&generate_get_xid_range_reply(1, 0))); } fn generate_get_xid_range_reply(start_id: u32, count: u32) -> GetXIDRangeReply { GetXIDRangeReply { sequence: 0, length: 0, start_id, count, } } } x11rb-protocol-0.13.1/src/lib.rs000064400000000000000000000106461046102023000144140ustar 00000000000000//! X11 rust bindings. //! //! This crate provides a representation of the X11 protocol in Rust. With this protocol, raw X11 //! bytes can be parsed into a structured representation or raw bytes can be produces. //! //! This protocol does not do any I/O. If you need an X11 client library, look at //! . //! //! # Feature flags //! //! This crate uses [feature //! flags](https://doc.rust-lang.org/cargo/reference/manifest.html#the-features-section) to reduce //! the amount of compiled code. There are two kinds of feature flags available: //! //! * Feature flags for specific X11 extensions //! * Feature flags for additional functionality //! //! ## Feature flags for specific X11 extensions //! //! By default, only the core X11 protocol and some small, commonly needed X11 extensions are //! enabled. These are the `bigreq`, `ge` and `xc_misc` extensions. Further extensions need to be //! explicitly enabled via their feature flag: //! //! `composite`, `damage`, `dpms`, `dri2`, `dri3`, `glx`, `present`, `randr`, `record`, `render`, //! `res`, `screensaver`, `shape`, `shm`, `sync`, `xevie`, `xf86dri`, `xf86vidmode`, `xfixes`, //! `xinerama`, `xinput`, `xkb`, `xprint`, `xselinux`, `xtest`, `xv`, `xvmc`. //! //! If you want to take the "I do not want to think about this"-approach, you can enable the //! `all-extensions` feature to just enable, well, all extensions. //! //! ## Feature flags for additional functionality //! //! Additionally, the following flags exist: //! * `std` (enabled by default): Enable functionality needing the std library, e.g. environment //! variables or [`std::os::unix::io::OwnedFd`]. //! * `resource_manager`: Enable the code in [resource_manager] for loading and querying the //! X11 resource database. //! * `serde`: Implement [`serde::Serialize`] and [`serde::Deserialize`] for all objects. //! * `request-parsing`: Add the ability to parse X11 requests. Not normally needed. //! * `extra-traits`: Implement extra traits for types. This improves the output of the `Debug` //! impl and adds `PartialEq`, `Eq`, `PartialOrd`, `Ord`, and `Hash` where possible. // A list of lints that are only #![deny] and not the stronger #![forbid]. Each one has a comment // explaining why it gets the weaker treatment. #![deny( // Contains unreachable_code and "?" generates an #[allow] for this unused, // #[derive] generates an #[allow] for this; not part of "unused" unused_qualifications, // serde's Deserialize/Serialize impls add allows for this rust_2018_idioms, // Not everything in x11rb_protocol::protocol has doc comments missing_docs, )] #![forbid( missing_copy_implementations, missing_debug_implementations, rustdoc::private_doc_tests, //single_use_lifetimes, trivial_casts, trivial_numeric_casts, unreachable_pub, unsafe_code, unused_must_use, unused_results, clippy::cast_lossless, clippy::needless_pass_by_value, )] #![no_std] // std crate imports extern crate alloc; #[cfg(feature = "std")] extern crate std; use alloc::vec::Vec; pub mod connect; pub mod connection; #[macro_use] pub mod x11_utils; pub mod errors; pub mod id_allocator; pub mod packet_reader; pub mod parse_display; #[rustfmt::skip] #[allow(missing_docs)] pub mod protocol; #[cfg(feature = "resource_manager")] pub mod resource_manager; #[cfg(test)] mod test; mod utils; pub mod wrapper; pub mod xauth; pub use utils::RawFdContainer; // Used to avoid too-complex types. /// A combination of a buffer and a list of file descriptors. pub type BufWithFds = (B, Vec); /// Number type used for referring to things that were sent to the server in responses from the /// server. /// /// Each request sent to the X11 server is implicitly assigned a monotonically increasing sequence /// number. Replies, events, and errors contain the sequence number of the last request that the /// server received. This allows to map replies to their requests and to figure out which request /// caused an error. pub type SequenceNumber = u64; /// The raw bytes of an event and its sequence number. pub type RawEventAndSeqNumber = (B, SequenceNumber); /// Variants describing which responses to a request should be discarded. #[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum DiscardMode { /// Only discard the actual reply. Errors go to the main loop. DiscardReply, /// Ignore any kind of response that this request generates. DiscardReplyAndError, } x11rb-protocol-0.13.1/src/packet_reader.rs000064400000000000000000000210631046102023000164320ustar 00000000000000//! Collects X11 data into "packets" to be parsed by a display. use core::fmt; use core::mem::replace; use alloc::{vec, vec::Vec}; /// Minimal length of an X11 packet. const MINIMAL_PACKET_LENGTH: usize = 32; /// A wrapper around a buffer used to read X11 packets. pub struct PacketReader { /// A partially-read packet. pending_packet: Vec, /// The point at which the packet is already read. already_read: usize, } impl fmt::Debug for PacketReader { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_tuple("PacketReader") .field(&format_args!( "{}/{}", self.already_read, self.pending_packet.len() )) .finish() } } impl Default for PacketReader { fn default() -> Self { Self::new() } } impl PacketReader { /// Create a new, empty `PacketReader`. /// /// # Example /// /// ```rust /// # use x11rb_protocol::packet_reader::PacketReader; /// let reader = PacketReader::new(); /// ``` pub fn new() -> Self { Self { pending_packet: vec![0; MINIMAL_PACKET_LENGTH], already_read: 0, } } /// Get the buffer that the reader should fill with data. /// /// # Example /// /// ```rust /// # use x11rb_protocol::packet_reader::PacketReader; /// # use x11rb_protocol::protocol::xproto::{GetInputFocusReply, InputFocus, Window}; /// let mut reader = PacketReader::new(); /// let buffer: [u8; 32] = read_in_buffer(); /// /// reader.buffer().copy_from_slice(&buffer); /// /// # fn read_in_buffer() -> [u8; 32] { [0; 32] } /// ``` pub fn buffer(&mut self) -> &mut [u8] { &mut self.pending_packet[self.already_read..] } /// The remaining capacity that needs to be filled. pub fn remaining_capacity(&self) -> usize { self.pending_packet.len() - self.already_read } /// Advance this buffer by the given amount. /// /// This will return the packet that was read, if enough bytes were read in order /// to form a complete packet. pub fn advance(&mut self, amount: usize) -> Option> { self.already_read += amount; debug_assert!(self.already_read <= self.pending_packet.len()); if self.already_read == MINIMAL_PACKET_LENGTH { // we've read in the minimal packet, compute the amount of data we need to read // to form a complete packet let extra_length = extra_length(&self.pending_packet); // tell if we need to read more if extra_length > 0 { let total_length = MINIMAL_PACKET_LENGTH + extra_length; self.pending_packet.resize(total_length, 0); return None; } } else if self.already_read != self.pending_packet.len() { // we haven't read the full packet yet, return return None; } // we've read in the full packet, return it self.already_read = 0; Some(replace( &mut self.pending_packet, vec![0; MINIMAL_PACKET_LENGTH], )) } } /// Compute the length of the data we need to read, beyond the `MINIMAL_PACKET_LENGTH`. fn extra_length(buffer: &[u8]) -> usize { use crate::protocol::xproto::GE_GENERIC_EVENT; const REPLY: u8 = 1; let response_type = buffer[0]; if response_type == REPLY || response_type & 0x7f == GE_GENERIC_EVENT { let length_field = buffer[4..8].try_into().unwrap(); let length_field = u32::from_ne_bytes(length_field) as usize; 4 * length_field } else { // Fixed size packet: error or event that is not GE_GENERIC_EVENT 0 } } #[cfg(test)] mod tests { use super::PacketReader; use alloc::{vec, vec::Vec}; fn test_packets(packets: Vec>) { // Combine all packet data into one big chunk and test that the packet reader splits things let mut all_data = packets.iter().flatten().copied().collect::>(); let mut reader = PacketReader::default(); for (i, packet) in packets.into_iter().enumerate() { std::println!("Checking packet {i}"); loop { let buffer = reader.buffer(); let amount = std::cmp::min(buffer.len(), all_data.len()); buffer.copy_from_slice(&all_data[..amount]); let _ = all_data.drain(..amount); if let Some(read_packet) = reader.advance(amount) { assert_eq!(read_packet, packet); break; } } } } fn make_reply_with_length(len: usize) -> Vec { let mut packet = vec![0; len]; let len = (len - 32) / 4; // write "len" to bytes 4..8 in the packet let len_bytes = (len as u32).to_ne_bytes(); packet[4..8].copy_from_slice(&len_bytes); packet[0] = 1; packet } #[test] fn fixed_size_packet() { // packet with a fixed size let packet = vec![0; 32]; test_packets(vec![packet]); } #[test] fn variable_size_packet() { // packet with a variable size let packet = make_reply_with_length(1200); test_packets(vec![packet]); } #[test] fn test_many_fixed_size_packets() { let mut packets = vec![]; for _ in 0..100 { packets.push(vec![0; 32]); } test_packets(packets); } #[test] fn test_many_variable_size_packets() { let mut packets = vec![]; for i in 0..100 { // for maximum variation, increase packet size in a curved parabola // defined by -1/25 (x - 50)^2 + 100 let variation = ((i - 50) * (i - 50)) as f32; let variation = -1.0 / 25.0 * variation + 100.0; let variation = variation as usize; // round to a multiple of 4 let variation = variation / 4 * 4; let mut len = 1200 + variation; let mut packet = vec![0; len]; assert_eq!(0, len % 4); len = (len - 32) / 4; // write "len" to bytes 4..8 in the packet let len_bytes = (len as u32).to_ne_bytes(); packet[4..8].copy_from_slice(&len_bytes); packet[0] = 1; packets.push(packet); } test_packets(packets); } #[test] fn test_many_size_packets_mixed() { let mut packets = vec![]; for i in 0..100 { // on odds, do a varsize packet let mut len = if i & 1 == 1 { // for maximum variation, increase packet size in a curved parabola // defined by -1/25 (x - 50)^2 + 100 let variation = ((i - 50) * (i - 50)) as f32; let variation = -1.0 / 25.0 * variation + 100.0; let variation = variation as usize; // round to a multiple of 4 let variation = variation / 4 * 4; 1200 + variation } else { 32 }; assert_eq!(0, len % 4); let mut packet = vec![0; len]; len = (len - 32) / 4; // write "len" to bytes 4..8 in the packet let len_bytes = (len as u32).to_ne_bytes(); packet[4..8].copy_from_slice(&len_bytes); packet[0] = 1; packets.push(packet); } test_packets(packets); } #[test] fn test_debug_fixed_size_packet() { // The debug output includes the length of the packet of the packet and how much was // already read let mut reader = PacketReader::new(); assert_eq!(std::format!("{:?}", reader), "PacketReader(0/32)"); let _ = reader.advance(15); assert_eq!(std::format!("{:?}", reader), "PacketReader(15/32)"); let _ = reader.advance(15); assert_eq!(std::format!("{:?}", reader), "PacketReader(30/32)"); let _ = reader.advance(2); assert_eq!(std::format!("{:?}", reader), "PacketReader(0/32)"); } #[test] fn test_debug_variable_size_packet() { let packet = make_reply_with_length(1200); let mut reader = PacketReader::new(); let first_len = 32; let second_len = 3; reader.buffer()[..first_len].copy_from_slice(&packet[..first_len]); let _ = reader.advance(first_len); reader.buffer()[..second_len].copy_from_slice(&packet[..second_len]); let _ = reader.advance(second_len); assert_eq!(std::format!("{:?}", reader), "PacketReader(35/1200)"); } } x11rb-protocol-0.13.1/src/parse_display/connect_instruction.rs000064400000000000000000000053551046102023000226000ustar 00000000000000//! Provides the `ConnectInstruction` structure, which allows for a `ParsedDisplay` //! to be transformed into a server connection. use super::ParsedDisplay; use alloc::format; use alloc::string::String; use alloc::vec::Vec; /// A possible address for an X11 server. #[derive(Debug, Clone, PartialEq, Eq)] #[non_exhaustive] pub enum ConnectAddress<'a> { /// Connect to this hostname and port over TCP. Hostname(&'a str, u16), /// Connect to this Unix socket. /// /// First, the given path should be attempted in the abstract namespace. Only if that fails, /// then the named socket with the given name should be tried. Socket(String), } /// Get an iterator over all of the addresses we should target with a /// `ParsedDisplay`. pub(super) fn connect_addresses(p: &ParsedDisplay) -> impl Iterator> { const TCP_PORT_BASE: u16 = 6000; let ParsedDisplay { host, protocol, display, .. } = p; let mut targets = Vec::new(); if (protocol.is_none() || protocol.as_deref() != Some("unix")) && !host.is_empty() && host != "unix" { targets.push(ConnectAddress::Hostname(host, TCP_PORT_BASE + display)); } else { if protocol.is_none() || protocol.as_deref() == Some("unix") { let file_name = format!("/tmp/.X11-unix/X{}", display); targets.push(ConnectAddress::Socket(file_name)); } if protocol.is_none() && host.is_empty() { targets.push(ConnectAddress::Hostname( "localhost", TCP_PORT_BASE + display, )); } } targets.into_iter() } #[cfg(test)] mod tests { // make sure iterator properties are clean use super::{super::parse_display, ConnectAddress}; use alloc::{vec, vec::Vec}; #[test] fn basic_test() { let pd = parse_display(Some(":0")).unwrap(); let ci = pd.connect_instruction(); let ci = ci.collect::>(); assert_eq!( ci, vec![ ConnectAddress::Socket("/tmp/.X11-unix/X0".into()), ConnectAddress::Hostname("localhost", 6000), ] ); } #[test] fn try_over_hostname() { let pd = parse_display(Some("192.168.1.111:0")).unwrap(); let ci = pd.connect_instruction(); let ci = ci.collect::>(); assert_eq!(ci, vec![ConnectAddress::Hostname("192.168.1.111", 6000),]); } #[test] fn try_over_unix_hostname() { let pd = parse_display(Some("unix/host:0")).unwrap(); let ci = pd.connect_instruction(); let ci = ci.collect::>(); assert_eq!(ci, vec![ConnectAddress::Socket("/tmp/.X11-unix/X0".into())]); } } x11rb-protocol-0.13.1/src/parse_display/mod.rs000064400000000000000000000473231046102023000172660ustar 00000000000000//! Utilities for parsing X11 display strings. mod connect_instruction; pub use connect_instruction::ConnectAddress; use crate::errors::DisplayParsingError; use alloc::string::{String, ToString}; /// A parsed X11 display string. #[derive(Debug, Clone, PartialEq, Eq)] pub struct ParsedDisplay { /// The hostname of the computer we nned to connect to. /// /// This is an empty string if we are connecting to the /// local host. pub host: String, /// The protocol we are communicating over. /// /// This is `None` if the protocol may be determined /// automatically. pub protocol: Option, /// The index of the display we are connecting to. pub display: u16, /// The index of the screen that we are using as the /// default screen. pub screen: u16, } impl ParsedDisplay { /// Get an iterator over `ConnectAddress`es from this parsed display for connecting /// to the server. pub fn connect_instruction(&self) -> impl Iterator> { connect_instruction::connect_addresses(self) } } /// Parse an X11 display string. /// /// If `dpy_name` is `None`, the display is parsed from the environment variable `DISPLAY`. /// /// This function is only available when the `std` feature is enabled. #[cfg(feature = "std")] pub fn parse_display(dpy_name: Option<&str>) -> Result { fn file_exists(path: &str) -> bool { std::path::Path::new(path).exists() } match dpy_name { Some(dpy_name) => parse_display_with_file_exists_callback(dpy_name, file_exists), // If no dpy name was provided, use the env var. If no env var exists, return an error. None => match std::env::var("DISPLAY") { Ok(dpy_name) => parse_display_with_file_exists_callback(&dpy_name, file_exists), Err(std::env::VarError::NotPresent) => Err(DisplayParsingError::DisplayNotSet), Err(std::env::VarError::NotUnicode(_)) => Err(DisplayParsingError::NotUnicode), }, } } /// Parse an X11 display string. /// /// If `dpy_name` is `None`, the display is parsed from the environment variable `DISPLAY`. /// /// The parameter `file_exists` is called to check whether a given string refers to an existing /// file. This function does not need to check the file type. pub fn parse_display_with_file_exists_callback( dpy_name: &str, file_exists: impl Fn(&str) -> bool, ) -> Result { let malformed = || DisplayParsingError::MalformedValue(dpy_name.to_string().into()); let map_malformed = |_| malformed(); if dpy_name.starts_with('/') { return parse_display_direct_path(dpy_name, file_exists); } if let Some(remaining) = dpy_name.strip_prefix("unix:") { return parse_display_direct_path(remaining, file_exists); } // Everything up to the last '/' is the protocol. This part is optional. let (protocol, remaining) = if let Some(pos) = dpy_name.rfind('/') { (Some(&dpy_name[..pos]), &dpy_name[pos + 1..]) } else { (None, dpy_name) }; // Everything up to the last ':' is the host. This part is required. let pos = remaining.rfind(':').ok_or_else(malformed)?; let (host, remaining) = (&remaining[..pos], &remaining[pos + 1..]); // The remaining part is display.screen. The display is required and the screen optional. let (display, screen) = match remaining.find('.') { Some(pos) => (&remaining[..pos], &remaining[pos + 1..]), None => (remaining, "0"), }; // Parse the display and screen number let (display, screen) = ( display.parse().map_err(map_malformed)?, screen.parse().map_err(map_malformed)?, ); let host = host.to_string(); let protocol = protocol.map(|p| p.to_string()); Ok(ParsedDisplay { host, protocol, display, screen, }) } // Check for "launchd mode" where we get the full path to a unix socket fn parse_display_direct_path( dpy_name: &str, file_exists: impl Fn(&str) -> bool, ) -> Result { if file_exists(dpy_name) { return Ok(ParsedDisplay { host: dpy_name.to_string(), protocol: Some("unix".to_string()), display: 0, screen: 0, }); } // Optionally, a screen number may be appended as ".n". if let Some((path, screen)) = dpy_name.rsplit_once('.') { if file_exists(path) { return Ok(ParsedDisplay { host: path.to_string(), protocol: Some("unix".to_string()), display: 0, screen: screen.parse().map_err(|_| { DisplayParsingError::MalformedValue(dpy_name.to_string().into()) })?, }); } } Err(DisplayParsingError::MalformedValue( dpy_name.to_string().into(), )) } #[cfg(test)] mod test { use super::{ parse_display, parse_display_with_file_exists_callback, DisplayParsingError, ParsedDisplay, }; use alloc::string::ToString; use core::cell::RefCell; fn do_parse_display(input: &str) -> Result { std::env::set_var("DISPLAY", input); let result1 = parse_display(None); std::env::remove_var("DISPLAY"); let result2 = parse_display(Some(input)); assert_eq!(result1, result2); result1 } // The tests modify environment variables. This is process-global. Thus, the tests in this // module cannot be run concurrently. We achieve this by having only a single test functions // that calls all other functions. #[test] fn test_parsing() { test_missing_input(); xcb_good_cases(); xcb_bad_cases(); own_good_cases(); own_bad_cases(); } fn test_missing_input() { std::env::remove_var("DISPLAY"); assert_eq!(parse_display(None), Err(DisplayParsingError::DisplayNotSet)); } fn own_good_cases() { // The XCB test suite does not test protocol parsing for (input, output) in &[ ( "foo/bar:1", ParsedDisplay { host: "bar".to_string(), protocol: Some("foo".to_string()), display: 1, screen: 0, }, ), ( "foo/bar:1.2", ParsedDisplay { host: "bar".to_string(), protocol: Some("foo".to_string()), display: 1, screen: 2, }, ), ( "a:b/c/foo:bar:1.2", ParsedDisplay { host: "foo:bar".to_string(), protocol: Some("a:b/c".to_string()), display: 1, screen: 2, }, ), ] { assert_eq!( do_parse_display(input).as_ref(), Ok(output), "Failed parsing correctly: {}", input ); } } fn own_bad_cases() { let non_existing_file = concat!(env!("CARGO_MANIFEST_DIR"), "/this_file_does_not_exist"); assert_eq!( do_parse_display(non_existing_file), Err(DisplayParsingError::MalformedValue( non_existing_file.to_string().into() )), "Unexpectedly parsed: {}", non_existing_file ); } // Based on libxcb's test suite; (C) 2001-2006 Bart Massey, Jamey Sharp, and Josh Triplett fn xcb_good_cases() { // The libxcb code creates a temporary file. We can just use a known-to-exist file. let existing_file = concat!(env!("CARGO_MANIFEST_DIR"), "/Cargo.toml"); for (input, output) in &[ // unix in "launchd mode" ( existing_file, ParsedDisplay { host: existing_file.to_string(), protocol: Some("unix".to_string()), display: 0, screen: 0, }, ), ( &alloc::format!("unix:{existing_file}"), ParsedDisplay { host: existing_file.to_string(), protocol: Some("unix".to_string()), display: 0, screen: 0, }, ), ( &alloc::format!("unix:{existing_file}.1"), ParsedDisplay { host: existing_file.to_string(), protocol: Some("unix".to_string()), display: 0, screen: 1, }, ), ( &alloc::format!("{existing_file}.1"), ParsedDisplay { host: existing_file.to_string(), protocol: Some("unix".to_string()), display: 0, screen: 1, }, ), // unix ( ":0", ParsedDisplay { host: "".to_string(), protocol: None, display: 0, screen: 0, }, ), ( ":1", ParsedDisplay { host: "".to_string(), protocol: None, display: 1, screen: 0, }, ), ( ":0.1", ParsedDisplay { host: "".to_string(), protocol: None, display: 0, screen: 1, }, ), // ip ( "x.org:0", ParsedDisplay { host: "x.org".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "expo:0", ParsedDisplay { host: "expo".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "bigmachine:1", ParsedDisplay { host: "bigmachine".to_string(), protocol: None, display: 1, screen: 0, }, ), ( "hydra:0.1", ParsedDisplay { host: "hydra".to_string(), protocol: None, display: 0, screen: 1, }, ), // ipv4 ( "198.112.45.11:0", ParsedDisplay { host: "198.112.45.11".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "198.112.45.11:0.1", ParsedDisplay { host: "198.112.45.11".to_string(), protocol: None, display: 0, screen: 1, }, ), // ipv6 ( ":::0", ParsedDisplay { host: "::".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "1:::0", ParsedDisplay { host: "1::".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "::1:0", ParsedDisplay { host: "::1".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "::1:0.1", ParsedDisplay { host: "::1".to_string(), protocol: None, display: 0, screen: 1, }, ), ( "::127.0.0.1:0", ParsedDisplay { host: "::127.0.0.1".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "::ffff:127.0.0.1:0", ParsedDisplay { host: "::ffff:127.0.0.1".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "2002:83fc:3052::1:0", ParsedDisplay { host: "2002:83fc:3052::1".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "2002:83fc:3052::1:0.1", ParsedDisplay { host: "2002:83fc:3052::1".to_string(), protocol: None, display: 0, screen: 1, }, ), ( "[::]:0", ParsedDisplay { host: "[::]".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "[1::]:0", ParsedDisplay { host: "[1::]".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "[::1]:0", ParsedDisplay { host: "[::1]".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "[::1]:0.1", ParsedDisplay { host: "[::1]".to_string(), protocol: None, display: 0, screen: 1, }, ), ( "[::127.0.0.1]:0", ParsedDisplay { host: "[::127.0.0.1]".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "[2002:83fc:d052::1]:0", ParsedDisplay { host: "[2002:83fc:d052::1]".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "[2002:83fc:d052::1]:0.1", ParsedDisplay { host: "[2002:83fc:d052::1]".to_string(), protocol: None, display: 0, screen: 1, }, ), // decnet ( "myws::0", ParsedDisplay { host: "myws:".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "big::0", ParsedDisplay { host: "big:".to_string(), protocol: None, display: 0, screen: 0, }, ), ( "hydra::0.1", ParsedDisplay { host: "hydra:".to_string(), protocol: None, display: 0, screen: 1, }, ), ] { assert_eq!( do_parse_display(input).as_ref(), Ok(output), "Failed parsing correctly: {}", input ); } } // Based on libxcb's test suite; (C) 2001-2006 Bart Massey, Jamey Sharp, and Josh Triplett fn xcb_bad_cases() { for input in &[ "", ":", "::", ":::", ":.", ":a", ":a.", ":0.", ":.a", ":.0", ":0.a", ":0.0.", "127.0.0.1", "127.0.0.1:", "127.0.0.1::", "::127.0.0.1", "::127.0.0.1:", "::127.0.0.1::", "::ffff:127.0.0.1", "::ffff:127.0.0.1:", "::ffff:127.0.0.1::", "localhost", "localhost:", "localhost::", ] { assert_eq!( do_parse_display(input), Err(DisplayParsingError::MalformedValue( input.to_string().into() )), "Unexpectedly parsed: {}", input ); } } fn make_unix_path(host: &str, screen: u16) -> Result { Ok(ParsedDisplay { host: host.to_string(), protocol: Some("unix".to_string()), display: 0, screen, }) } #[test] fn test_file_exists_callback_direct_path() { fn run_test(display: &str, expected_path: &str) { let called = RefCell::new(0); let callback = |path: &_| { assert_eq!(path, expected_path); let mut called = called.borrow_mut(); assert_eq!(*called, 0); *called += 1; true }; let result = parse_display_with_file_exists_callback(display, callback); assert_eq!(*called.borrow(), 1); assert_eq!(result, make_unix_path(expected_path, 0)); } run_test("/path/to/file", "/path/to/file"); run_test("/path/to/file.123", "/path/to/file.123"); run_test("unix:whatever", "whatever"); run_test("unix:whatever.123", "whatever.123"); } #[test] fn test_file_exists_callback_direct_path_with_screen() { fn run_test(display: &str, expected_path: &str) { let called = RefCell::new(0); let callback = |path: &_| { let mut called = called.borrow_mut(); *called += 1; match *called { 1 => { assert_eq!(path, alloc::format!("{expected_path}.42")); false } 2 => { assert_eq!(path, expected_path); true } _ => panic!("Unexpected call count {}", *called), } }; let result = parse_display_with_file_exists_callback(display, callback); assert_eq!(*called.borrow(), 2); assert_eq!(result, make_unix_path(expected_path, 42)); } run_test("/path/to/file.42", "/path/to/file"); run_test("unix:whatever.42", "whatever"); } #[test] fn test_file_exists_callback_not_called_without_path() { let callback = |path: &str| unreachable!("Called with {path}"); let result = parse_display_with_file_exists_callback("foo/bar:1.2", callback); assert_eq!( result, Ok(ParsedDisplay { host: "bar".to_string(), protocol: Some("foo".to_string()), display: 1, screen: 2, },) ); } } x11rb-protocol-0.13.1/src/protocol/bigreq.rs000064400000000000000000000135171046102023000167600ustar 00000000000000// This file contains generated code. Do not edit directly. // To regenerate this, run 'make'. //! Bindings to the `BigRequests` X11 extension. #![allow(clippy::too_many_arguments)] // The code generator is simpler if it can always use conversions #![allow(clippy::useless_conversion)] #[allow(unused_imports)] use alloc::borrow::Cow; #[allow(unused_imports)] use core::convert::TryInto; use alloc::vec; use alloc::vec::Vec; use core::convert::TryFrom; use crate::errors::ParseError; #[allow(unused_imports)] use crate::x11_utils::TryIntoUSize; use crate::BufWithFds; #[allow(unused_imports)] use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; #[allow(unused_imports)] use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; /// The X11 name of the extension for QueryExtension pub const X11_EXTENSION_NAME: &str = "BIG-REQUESTS"; /// The version number of this extension that this client library supports. /// /// This constant contains the version number of this extension that is supported /// by this build of x11rb. For most things, it does not make sense to use this /// information. If you need to send a `QueryVersion`, it is recommended to instead /// send the maximum version of the extension that you need. pub const X11_XML_VERSION: (u32, u32) = (0, 0); /// Opcode for the Enable request pub const ENABLE_REQUEST: u8 = 0; /// Enable the BIG-REQUESTS extension. /// /// This enables the BIG-REQUESTS extension, which allows for requests larger than /// 262140 bytes in length. When enabled, if the 16-bit length field is zero, it /// is immediately followed by a 32-bit length field specifying the length of the /// request in 4-byte units. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct EnableRequest; impl_debug_if_no_extra_traits!(EnableRequest, "EnableRequest"); impl EnableRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let mut request0 = vec![ major_opcode, ENABLE_REQUEST, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != ENABLE_REQUEST { return Err(ParseError::InvalidValue); } let _ = value; Ok(EnableRequest ) } } impl Request for EnableRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for EnableRequest { type Reply = EnableReply; } /// # Fields /// /// * `maximum_request_length` - The maximum length of requests supported by the server, in 4-byte units. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct EnableReply { pub sequence: u16, pub length: u32, pub maximum_request_length: u32, } impl_debug_if_no_extra_traits!(EnableReply, "EnableReply"); impl TryParse for EnableReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (maximum_request_length, remaining) = u32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = EnableReply { sequence, length, maximum_request_length }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for EnableReply { type Bytes = [u8; 12]; fn serialize(&self) -> [u8; 12] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let maximum_request_length_bytes = self.maximum_request_length.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], maximum_request_length_bytes[0], maximum_request_length_bytes[1], maximum_request_length_bytes[2], maximum_request_length_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(12); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.maximum_request_length.serialize_into(bytes); } } x11rb-protocol-0.13.1/src/protocol/composite.rs000064400000000000000000001032571046102023000175120ustar 00000000000000// This file contains generated code. Do not edit directly. // To regenerate this, run 'make'. //! Bindings to the `Composite` X11 extension. #![allow(clippy::too_many_arguments)] // The code generator is simpler if it can always use conversions #![allow(clippy::useless_conversion)] #[allow(unused_imports)] use alloc::borrow::Cow; #[allow(unused_imports)] use core::convert::TryInto; use alloc::vec; use alloc::vec::Vec; use core::convert::TryFrom; use crate::errors::ParseError; #[allow(unused_imports)] use crate::x11_utils::TryIntoUSize; use crate::BufWithFds; #[allow(unused_imports)] use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; #[allow(unused_imports)] use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; #[allow(unused_imports)] use super::xfixes; #[allow(unused_imports)] use super::xproto; /// The X11 name of the extension for QueryExtension pub const X11_EXTENSION_NAME: &str = "Composite"; /// The version number of this extension that this client library supports. /// /// This constant contains the version number of this extension that is supported /// by this build of x11rb. For most things, it does not make sense to use this /// information. If you need to send a `QueryVersion`, it is recommended to instead /// send the maximum version of the extension that you need. pub const X11_XML_VERSION: (u32, u32) = (0, 4); #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Redirect(u8); impl Redirect { pub const AUTOMATIC: Self = Self(0); pub const MANUAL: Self = Self(1); } impl From for u8 { #[inline] fn from(input: Redirect) -> Self { input.0 } } impl From for Option { #[inline] fn from(input: Redirect) -> Self { Some(input.0) } } impl From for u16 { #[inline] fn from(input: Redirect) -> Self { u16::from(input.0) } } impl From for Option { #[inline] fn from(input: Redirect) -> Self { Some(u16::from(input.0)) } } impl From for u32 { #[inline] fn from(input: Redirect) -> Self { u32::from(input.0) } } impl From for Option { #[inline] fn from(input: Redirect) -> Self { Some(u32::from(input.0)) } } impl From for Redirect { #[inline] fn from(value: u8) -> Self { Self(value) } } impl core::fmt::Debug for Redirect { fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let variants = [ (Self::AUTOMATIC.0.into(), "AUTOMATIC", "Automatic"), (Self::MANUAL.0.into(), "MANUAL", "Manual"), ]; pretty_print_enum(fmt, self.0.into(), &variants) } } /// Opcode for the QueryVersion request pub const QUERY_VERSION_REQUEST: u8 = 0; /// Negotiate the version of Composite. /// /// This negotiates the version of the Composite extension. It must be precede all /// other requests using Composite. Failure to do so will cause a BadRequest error. /// /// # Fields /// /// * `client_major_version` - The major version supported by the client. /// * `client_minor_version` - The minor version supported by the client. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryVersionRequest { pub client_major_version: u32, pub client_minor_version: u32, } impl_debug_if_no_extra_traits!(QueryVersionRequest, "QueryVersionRequest"); impl QueryVersionRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let client_major_version_bytes = self.client_major_version.serialize(); let client_minor_version_bytes = self.client_minor_version.serialize(); let mut request0 = vec![ major_opcode, QUERY_VERSION_REQUEST, 0, 0, client_major_version_bytes[0], client_major_version_bytes[1], client_major_version_bytes[2], client_major_version_bytes[3], client_minor_version_bytes[0], client_minor_version_bytes[1], client_minor_version_bytes[2], client_minor_version_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != QUERY_VERSION_REQUEST { return Err(ParseError::InvalidValue); } let (client_major_version, remaining) = u32::try_parse(value)?; let (client_minor_version, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(QueryVersionRequest { client_major_version, client_minor_version, }) } } impl Request for QueryVersionRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for QueryVersionRequest { type Reply = QueryVersionReply; } /// The negotiated version of Composite. /// /// This indicates the version of Composite chosen by the server. It will always be /// less than or equal to the version offered by the client. /// /// # Fields /// /// * `major_version` - The major version chosen by the server. /// * `minor_version` - The minor version chosen by the server. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryVersionReply { pub sequence: u16, pub length: u32, pub major_version: u32, pub minor_version: u32, } impl_debug_if_no_extra_traits!(QueryVersionReply, "QueryVersionReply"); impl TryParse for QueryVersionReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (major_version, remaining) = u32::try_parse(remaining)?; let (minor_version, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = QueryVersionReply { sequence, length, major_version, minor_version }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for QueryVersionReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let major_version_bytes = self.major_version.serialize(); let minor_version_bytes = self.minor_version.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], major_version_bytes[0], major_version_bytes[1], major_version_bytes[2], major_version_bytes[3], minor_version_bytes[0], minor_version_bytes[1], minor_version_bytes[2], minor_version_bytes[3], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.major_version.serialize_into(bytes); self.minor_version.serialize_into(bytes); bytes.extend_from_slice(&[0; 16]); } } /// Opcode for the RedirectWindow request pub const REDIRECT_WINDOW_REQUEST: u8 = 1; /// Redirect the hierarchy starting at "window" to off-screen storage.. /// /// The hierarchy starting at 'window' is directed to off-screen /// storage. When all clients enabling redirection terminate, /// the redirection will automatically be disabled. /// /// The root window may not be redirected. Doing so results in a Match /// error. /// /// # Fields /// /// * `window` - The root of the hierarchy to redirect to off-screen storage. /// * `update` - Whether contents are automatically mirrored to the parent window. If one client /// already specifies an update type of Manual, any attempt by another to specify a /// mode of Manual so will result in an Access error. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct RedirectWindowRequest { pub window: xproto::Window, pub update: Redirect, } impl_debug_if_no_extra_traits!(RedirectWindowRequest, "RedirectWindowRequest"); impl RedirectWindowRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let window_bytes = self.window.serialize(); let update_bytes = u8::from(self.update).serialize(); let mut request0 = vec![ major_opcode, REDIRECT_WINDOW_REQUEST, 0, 0, window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], update_bytes[0], 0, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != REDIRECT_WINDOW_REQUEST { return Err(ParseError::InvalidValue); } let (window, remaining) = xproto::Window::try_parse(value)?; let (update, remaining) = u8::try_parse(remaining)?; let update = update.into(); let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?; let _ = remaining; Ok(RedirectWindowRequest { window, update, }) } } impl Request for RedirectWindowRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for RedirectWindowRequest { } /// Opcode for the RedirectSubwindows request pub const REDIRECT_SUBWINDOWS_REQUEST: u8 = 2; /// Redirect all current and future children of ‘window’. /// /// Hierarchies starting at all current and future children of window /// will be redirected as in RedirectWindow. If update is Manual, /// then painting of the window background during window manipulation /// and ClearArea requests is inhibited. /// /// # Fields /// /// * `window` - The root of the hierarchy to redirect to off-screen storage. /// * `update` - Whether contents are automatically mirrored to the parent window. If one client /// already specifies an update type of Manual, any attempt by another to specify a /// mode of Manual so will result in an Access error. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct RedirectSubwindowsRequest { pub window: xproto::Window, pub update: Redirect, } impl_debug_if_no_extra_traits!(RedirectSubwindowsRequest, "RedirectSubwindowsRequest"); impl RedirectSubwindowsRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let window_bytes = self.window.serialize(); let update_bytes = u8::from(self.update).serialize(); let mut request0 = vec![ major_opcode, REDIRECT_SUBWINDOWS_REQUEST, 0, 0, window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], update_bytes[0], 0, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != REDIRECT_SUBWINDOWS_REQUEST { return Err(ParseError::InvalidValue); } let (window, remaining) = xproto::Window::try_parse(value)?; let (update, remaining) = u8::try_parse(remaining)?; let update = update.into(); let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?; let _ = remaining; Ok(RedirectSubwindowsRequest { window, update, }) } } impl Request for RedirectSubwindowsRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for RedirectSubwindowsRequest { } /// Opcode for the UnredirectWindow request pub const UNREDIRECT_WINDOW_REQUEST: u8 = 3; /// Terminate redirection of the specified window.. /// /// Redirection of the specified window will be terminated. This cannot be /// used if the window was redirected with RedirectSubwindows. /// /// # Fields /// /// * `window` - The window to terminate redirection of. Must be redirected by the /// current client, or a Value error results. /// * `update` - The update type passed to RedirectWindows. If this does not match the /// previously requested update type, a Value error results. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UnredirectWindowRequest { pub window: xproto::Window, pub update: Redirect, } impl_debug_if_no_extra_traits!(UnredirectWindowRequest, "UnredirectWindowRequest"); impl UnredirectWindowRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let window_bytes = self.window.serialize(); let update_bytes = u8::from(self.update).serialize(); let mut request0 = vec![ major_opcode, UNREDIRECT_WINDOW_REQUEST, 0, 0, window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], update_bytes[0], 0, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != UNREDIRECT_WINDOW_REQUEST { return Err(ParseError::InvalidValue); } let (window, remaining) = xproto::Window::try_parse(value)?; let (update, remaining) = u8::try_parse(remaining)?; let update = update.into(); let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?; let _ = remaining; Ok(UnredirectWindowRequest { window, update, }) } } impl Request for UnredirectWindowRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for UnredirectWindowRequest { } /// Opcode for the UnredirectSubwindows request pub const UNREDIRECT_SUBWINDOWS_REQUEST: u8 = 4; /// Terminate redirection of the specified window’s children. /// /// Redirection of all children of window will be terminated. /// /// # Fields /// /// * `window` - The window to terminate redirection of. Must have previously been /// selected for sub-redirection by the current client, or a Value error /// results. /// * `update` - The update type passed to RedirectSubWindows. If this does not match /// the previously requested update type, a Value error results. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UnredirectSubwindowsRequest { pub window: xproto::Window, pub update: Redirect, } impl_debug_if_no_extra_traits!(UnredirectSubwindowsRequest, "UnredirectSubwindowsRequest"); impl UnredirectSubwindowsRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let window_bytes = self.window.serialize(); let update_bytes = u8::from(self.update).serialize(); let mut request0 = vec![ major_opcode, UNREDIRECT_SUBWINDOWS_REQUEST, 0, 0, window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], update_bytes[0], 0, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != UNREDIRECT_SUBWINDOWS_REQUEST { return Err(ParseError::InvalidValue); } let (window, remaining) = xproto::Window::try_parse(value)?; let (update, remaining) = u8::try_parse(remaining)?; let update = update.into(); let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?; let _ = remaining; Ok(UnredirectSubwindowsRequest { window, update, }) } } impl Request for UnredirectSubwindowsRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for UnredirectSubwindowsRequest { } /// Opcode for the CreateRegionFromBorderClip request pub const CREATE_REGION_FROM_BORDER_CLIP_REQUEST: u8 = 5; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateRegionFromBorderClipRequest { pub region: xfixes::Region, pub window: xproto::Window, } impl_debug_if_no_extra_traits!(CreateRegionFromBorderClipRequest, "CreateRegionFromBorderClipRequest"); impl CreateRegionFromBorderClipRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let region_bytes = self.region.serialize(); let window_bytes = self.window.serialize(); let mut request0 = vec![ major_opcode, CREATE_REGION_FROM_BORDER_CLIP_REQUEST, 0, 0, region_bytes[0], region_bytes[1], region_bytes[2], region_bytes[3], window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != CREATE_REGION_FROM_BORDER_CLIP_REQUEST { return Err(ParseError::InvalidValue); } let (region, remaining) = xfixes::Region::try_parse(value)?; let (window, remaining) = xproto::Window::try_parse(remaining)?; let _ = remaining; Ok(CreateRegionFromBorderClipRequest { region, window, }) } } impl Request for CreateRegionFromBorderClipRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for CreateRegionFromBorderClipRequest { } /// Opcode for the NameWindowPixmap request pub const NAME_WINDOW_PIXMAP_REQUEST: u8 = 6; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct NameWindowPixmapRequest { pub window: xproto::Window, pub pixmap: xproto::Pixmap, } impl_debug_if_no_extra_traits!(NameWindowPixmapRequest, "NameWindowPixmapRequest"); impl NameWindowPixmapRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let window_bytes = self.window.serialize(); let pixmap_bytes = self.pixmap.serialize(); let mut request0 = vec![ major_opcode, NAME_WINDOW_PIXMAP_REQUEST, 0, 0, window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], pixmap_bytes[0], pixmap_bytes[1], pixmap_bytes[2], pixmap_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != NAME_WINDOW_PIXMAP_REQUEST { return Err(ParseError::InvalidValue); } let (window, remaining) = xproto::Window::try_parse(value)?; let (pixmap, remaining) = xproto::Pixmap::try_parse(remaining)?; let _ = remaining; Ok(NameWindowPixmapRequest { window, pixmap, }) } } impl Request for NameWindowPixmapRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for NameWindowPixmapRequest { } /// Opcode for the GetOverlayWindow request pub const GET_OVERLAY_WINDOW_REQUEST: u8 = 7; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetOverlayWindowRequest { pub window: xproto::Window, } impl_debug_if_no_extra_traits!(GetOverlayWindowRequest, "GetOverlayWindowRequest"); impl GetOverlayWindowRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let window_bytes = self.window.serialize(); let mut request0 = vec![ major_opcode, GET_OVERLAY_WINDOW_REQUEST, 0, 0, window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_OVERLAY_WINDOW_REQUEST { return Err(ParseError::InvalidValue); } let (window, remaining) = xproto::Window::try_parse(value)?; let _ = remaining; Ok(GetOverlayWindowRequest { window, }) } } impl Request for GetOverlayWindowRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetOverlayWindowRequest { type Reply = GetOverlayWindowReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetOverlayWindowReply { pub sequence: u16, pub length: u32, pub overlay_win: xproto::Window, } impl_debug_if_no_extra_traits!(GetOverlayWindowReply, "GetOverlayWindowReply"); impl TryParse for GetOverlayWindowReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (overlay_win, remaining) = xproto::Window::try_parse(remaining)?; let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetOverlayWindowReply { sequence, length, overlay_win }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetOverlayWindowReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let overlay_win_bytes = self.overlay_win.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], overlay_win_bytes[0], overlay_win_bytes[1], overlay_win_bytes[2], overlay_win_bytes[3], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.overlay_win.serialize_into(bytes); bytes.extend_from_slice(&[0; 20]); } } /// Opcode for the ReleaseOverlayWindow request pub const RELEASE_OVERLAY_WINDOW_REQUEST: u8 = 8; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ReleaseOverlayWindowRequest { pub window: xproto::Window, } impl_debug_if_no_extra_traits!(ReleaseOverlayWindowRequest, "ReleaseOverlayWindowRequest"); impl ReleaseOverlayWindowRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let window_bytes = self.window.serialize(); let mut request0 = vec![ major_opcode, RELEASE_OVERLAY_WINDOW_REQUEST, 0, 0, window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != RELEASE_OVERLAY_WINDOW_REQUEST { return Err(ParseError::InvalidValue); } let (window, remaining) = xproto::Window::try_parse(value)?; let _ = remaining; Ok(ReleaseOverlayWindowRequest { window, }) } } impl Request for ReleaseOverlayWindowRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for ReleaseOverlayWindowRequest { } x11rb-protocol-0.13.1/src/protocol/damage.rs000064400000000000000000000671111046102023000167240ustar 00000000000000// This file contains generated code. Do not edit directly. // To regenerate this, run 'make'. //! Bindings to the `Damage` X11 extension. #![allow(clippy::too_many_arguments)] // The code generator is simpler if it can always use conversions #![allow(clippy::useless_conversion)] #[allow(unused_imports)] use alloc::borrow::Cow; #[allow(unused_imports)] use core::convert::TryInto; use alloc::vec; use alloc::vec::Vec; use core::convert::TryFrom; use crate::errors::ParseError; #[allow(unused_imports)] use crate::x11_utils::TryIntoUSize; use crate::BufWithFds; #[allow(unused_imports)] use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; #[allow(unused_imports)] use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; #[allow(unused_imports)] use super::xfixes; #[allow(unused_imports)] use super::xproto; /// The X11 name of the extension for QueryExtension pub const X11_EXTENSION_NAME: &str = "DAMAGE"; /// The version number of this extension that this client library supports. /// /// This constant contains the version number of this extension that is supported /// by this build of x11rb. For most things, it does not make sense to use this /// information. If you need to send a `QueryVersion`, it is recommended to instead /// send the maximum version of the extension that you need. pub const X11_XML_VERSION: (u32, u32) = (1, 1); pub type Damage = u32; #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ReportLevel(u8); impl ReportLevel { pub const RAW_RECTANGLES: Self = Self(0); pub const DELTA_RECTANGLES: Self = Self(1); pub const BOUNDING_BOX: Self = Self(2); pub const NON_EMPTY: Self = Self(3); } impl From for u8 { #[inline] fn from(input: ReportLevel) -> Self { input.0 } } impl From for Option { #[inline] fn from(input: ReportLevel) -> Self { Some(input.0) } } impl From for u16 { #[inline] fn from(input: ReportLevel) -> Self { u16::from(input.0) } } impl From for Option { #[inline] fn from(input: ReportLevel) -> Self { Some(u16::from(input.0)) } } impl From for u32 { #[inline] fn from(input: ReportLevel) -> Self { u32::from(input.0) } } impl From for Option { #[inline] fn from(input: ReportLevel) -> Self { Some(u32::from(input.0)) } } impl From for ReportLevel { #[inline] fn from(value: u8) -> Self { Self(value) } } impl core::fmt::Debug for ReportLevel { fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let variants = [ (Self::RAW_RECTANGLES.0.into(), "RAW_RECTANGLES", "RawRectangles"), (Self::DELTA_RECTANGLES.0.into(), "DELTA_RECTANGLES", "DeltaRectangles"), (Self::BOUNDING_BOX.0.into(), "BOUNDING_BOX", "BoundingBox"), (Self::NON_EMPTY.0.into(), "NON_EMPTY", "NonEmpty"), ]; pretty_print_enum(fmt, self.0.into(), &variants) } } /// Opcode for the BadDamage error pub const BAD_DAMAGE_ERROR: u8 = 0; /// Opcode for the QueryVersion request pub const QUERY_VERSION_REQUEST: u8 = 0; /// Negotiate the version of the DAMAGE extension. /// /// This negotiates the version of the DAMAGE extension. It must precede any other /// request using the DAMAGE extension. Failure to do so will cause a BadRequest /// error for those requests. /// /// # Fields /// /// * `client_major_version` - The major version supported by the client. /// * `client_minor_version` - The minor version supported by the client. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryVersionRequest { pub client_major_version: u32, pub client_minor_version: u32, } impl_debug_if_no_extra_traits!(QueryVersionRequest, "QueryVersionRequest"); impl QueryVersionRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let client_major_version_bytes = self.client_major_version.serialize(); let client_minor_version_bytes = self.client_minor_version.serialize(); let mut request0 = vec![ major_opcode, QUERY_VERSION_REQUEST, 0, 0, client_major_version_bytes[0], client_major_version_bytes[1], client_major_version_bytes[2], client_major_version_bytes[3], client_minor_version_bytes[0], client_minor_version_bytes[1], client_minor_version_bytes[2], client_minor_version_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != QUERY_VERSION_REQUEST { return Err(ParseError::InvalidValue); } let (client_major_version, remaining) = u32::try_parse(value)?; let (client_minor_version, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(QueryVersionRequest { client_major_version, client_minor_version, }) } } impl Request for QueryVersionRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for QueryVersionRequest { type Reply = QueryVersionReply; } /// The negotiated version of the DAMAGE extension. /// /// This indicates the version of the DAMAGE extension chosen by the server. /// It will always be less than or equal to the version offered by the client. /// /// # Fields /// /// * `major_version` - The major version chosen by the server. /// * `minor_version` - The minor version chosen by the server. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryVersionReply { pub sequence: u16, pub length: u32, pub major_version: u32, pub minor_version: u32, } impl_debug_if_no_extra_traits!(QueryVersionReply, "QueryVersionReply"); impl TryParse for QueryVersionReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (major_version, remaining) = u32::try_parse(remaining)?; let (minor_version, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = QueryVersionReply { sequence, length, major_version, minor_version }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for QueryVersionReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let major_version_bytes = self.major_version.serialize(); let minor_version_bytes = self.minor_version.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], major_version_bytes[0], major_version_bytes[1], major_version_bytes[2], major_version_bytes[3], minor_version_bytes[0], minor_version_bytes[1], minor_version_bytes[2], minor_version_bytes[3], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.major_version.serialize_into(bytes); self.minor_version.serialize_into(bytes); bytes.extend_from_slice(&[0; 16]); } } /// Opcode for the Create request pub const CREATE_REQUEST: u8 = 1; /// Creates a Damage object to monitor changes to a drawable.. /// /// This creates a Damage object to monitor changes to a drawable, and specifies /// the level of detail to be reported for changes. /// /// We call changes made to pixel contents of windows and pixmaps 'damage' /// throughout this extension. /// /// Damage accumulates as drawing occurs in the drawable. Each drawing operation /// 'damages' one or more rectangular areas within the drawable. The rectangles /// are guaranteed to include the set of pixels modified by each operation, but /// may include significantly more than just those pixels. The desire is for /// the damage to strike a balance between the number of rectangles reported and /// the extraneous area included. A reasonable goal is for each primitive /// object drawn (line, string, rectangle) to be represented as a single /// rectangle and for the damage area of the operation to be the union of these /// rectangles. /// /// The DAMAGE extension allows applications to either receive the raw /// rectangles as a stream of events, or to have them partially processed within /// the X server to reduce the amount of data transmitted as well as reduce the /// processing latency once the repaint operation has started. /// /// The Damage object holds any accumulated damage region and reflects the /// relationship between the drawable selected for damage notification and the /// drawable for which damage is tracked. /// /// # Fields /// /// * `damage` - The ID with which you will refer to the new Damage object, created by /// `xcb_generate_id`. /// * `drawable` - The ID of the drawable to be monitored. /// * `level` - The level of detail to be provided in Damage events. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateRequest { pub damage: Damage, pub drawable: xproto::Drawable, pub level: ReportLevel, } impl_debug_if_no_extra_traits!(CreateRequest, "CreateRequest"); impl CreateRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let damage_bytes = self.damage.serialize(); let drawable_bytes = self.drawable.serialize(); let level_bytes = u8::from(self.level).serialize(); let mut request0 = vec![ major_opcode, CREATE_REQUEST, 0, 0, damage_bytes[0], damage_bytes[1], damage_bytes[2], damage_bytes[3], drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], level_bytes[0], 0, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != CREATE_REQUEST { return Err(ParseError::InvalidValue); } let (damage, remaining) = Damage::try_parse(value)?; let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?; let (level, remaining) = u8::try_parse(remaining)?; let level = level.into(); let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?; let _ = remaining; Ok(CreateRequest { damage, drawable, level, }) } } impl Request for CreateRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for CreateRequest { } /// Opcode for the Destroy request pub const DESTROY_REQUEST: u8 = 2; /// Destroys a previously created Damage object.. /// /// This destroys a Damage object and requests the X server stop reporting /// the changes it was tracking. /// /// # Fields /// /// * `damage` - The ID you provided to `xcb_create_damage`. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DestroyRequest { pub damage: Damage, } impl_debug_if_no_extra_traits!(DestroyRequest, "DestroyRequest"); impl DestroyRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let damage_bytes = self.damage.serialize(); let mut request0 = vec![ major_opcode, DESTROY_REQUEST, 0, 0, damage_bytes[0], damage_bytes[1], damage_bytes[2], damage_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != DESTROY_REQUEST { return Err(ParseError::InvalidValue); } let (damage, remaining) = Damage::try_parse(value)?; let _ = remaining; Ok(DestroyRequest { damage, }) } } impl Request for DestroyRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for DestroyRequest { } /// Opcode for the Subtract request pub const SUBTRACT_REQUEST: u8 = 3; /// Remove regions from a previously created Damage object.. /// /// This updates the regions of damage recorded in a a Damage object. /// See /// for details. /// /// # Fields /// /// * `damage` - The ID you provided to `xcb_create_damage`. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SubtractRequest { pub damage: Damage, pub repair: xfixes::Region, pub parts: xfixes::Region, } impl_debug_if_no_extra_traits!(SubtractRequest, "SubtractRequest"); impl SubtractRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let damage_bytes = self.damage.serialize(); let repair_bytes = self.repair.serialize(); let parts_bytes = self.parts.serialize(); let mut request0 = vec![ major_opcode, SUBTRACT_REQUEST, 0, 0, damage_bytes[0], damage_bytes[1], damage_bytes[2], damage_bytes[3], repair_bytes[0], repair_bytes[1], repair_bytes[2], repair_bytes[3], parts_bytes[0], parts_bytes[1], parts_bytes[2], parts_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != SUBTRACT_REQUEST { return Err(ParseError::InvalidValue); } let (damage, remaining) = Damage::try_parse(value)?; let (repair, remaining) = xfixes::Region::try_parse(remaining)?; let (parts, remaining) = xfixes::Region::try_parse(remaining)?; let _ = remaining; Ok(SubtractRequest { damage, repair, parts, }) } } impl Request for SubtractRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for SubtractRequest { } /// Opcode for the Add request pub const ADD_REQUEST: u8 = 4; /// Add a region to a previously created Damage object.. /// /// This updates the regions of damage recorded in a a Damage object. /// See /// for details. /// /// # Fields /// /// * `damage` - The ID you provided to `xcb_create_damage`. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AddRequest { pub drawable: xproto::Drawable, pub region: xfixes::Region, } impl_debug_if_no_extra_traits!(AddRequest, "AddRequest"); impl AddRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let region_bytes = self.region.serialize(); let mut request0 = vec![ major_opcode, ADD_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], region_bytes[0], region_bytes[1], region_bytes[2], region_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != ADD_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = xproto::Drawable::try_parse(value)?; let (region, remaining) = xfixes::Region::try_parse(remaining)?; let _ = remaining; Ok(AddRequest { drawable, region, }) } } impl Request for AddRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for AddRequest { } /// Opcode for the Notify event pub const NOTIFY_EVENT: u8 = 0; /// the contents of the monitored drawable have changed. /// /// # Fields /// /// * `level` - The level of the damage being reported. /// If the 0x80 bit is set, indicates there are subsequent Damage events /// being delivered immediately as part of a larger Damage region. /// * `drawable` - The drawable for which damage is being reported. /// * `damage` - The Damage object being used to track the damage. /// * `timestamp` - Time when the event was generated (in milliseconds). /// * `area` - Damaged area of the drawable. /// * `geometry` - Total area of the drawable. /// /// # See /// /// * `Create`: request #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct NotifyEvent { pub response_type: u8, pub level: ReportLevel, pub sequence: u16, pub drawable: xproto::Drawable, pub damage: Damage, pub timestamp: xproto::Timestamp, pub area: xproto::Rectangle, pub geometry: xproto::Rectangle, } impl_debug_if_no_extra_traits!(NotifyEvent, "NotifyEvent"); impl TryParse for NotifyEvent { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let (level, remaining) = u8::try_parse(remaining)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?; let (damage, remaining) = Damage::try_parse(remaining)?; let (timestamp, remaining) = xproto::Timestamp::try_parse(remaining)?; let (area, remaining) = xproto::Rectangle::try_parse(remaining)?; let (geometry, remaining) = xproto::Rectangle::try_parse(remaining)?; let level = level.into(); let result = NotifyEvent { response_type, level, sequence, drawable, damage, timestamp, area, geometry }; let _ = remaining; let remaining = initial_value.get(32..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for NotifyEvent { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = self.response_type.serialize(); let level_bytes = u8::from(self.level).serialize(); let sequence_bytes = self.sequence.serialize(); let drawable_bytes = self.drawable.serialize(); let damage_bytes = self.damage.serialize(); let timestamp_bytes = self.timestamp.serialize(); let area_bytes = self.area.serialize(); let geometry_bytes = self.geometry.serialize(); [ response_type_bytes[0], level_bytes[0], sequence_bytes[0], sequence_bytes[1], drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], damage_bytes[0], damage_bytes[1], damage_bytes[2], damage_bytes[3], timestamp_bytes[0], timestamp_bytes[1], timestamp_bytes[2], timestamp_bytes[3], area_bytes[0], area_bytes[1], area_bytes[2], area_bytes[3], area_bytes[4], area_bytes[5], area_bytes[6], area_bytes[7], geometry_bytes[0], geometry_bytes[1], geometry_bytes[2], geometry_bytes[3], geometry_bytes[4], geometry_bytes[5], geometry_bytes[6], geometry_bytes[7], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); self.response_type.serialize_into(bytes); u8::from(self.level).serialize_into(bytes); self.sequence.serialize_into(bytes); self.drawable.serialize_into(bytes); self.damage.serialize_into(bytes); self.timestamp.serialize_into(bytes); self.area.serialize_into(bytes); self.geometry.serialize_into(bytes); } } impl From<&NotifyEvent> for [u8; 32] { fn from(input: &NotifyEvent) -> Self { let response_type_bytes = input.response_type.serialize(); let level_bytes = u8::from(input.level).serialize(); let sequence_bytes = input.sequence.serialize(); let drawable_bytes = input.drawable.serialize(); let damage_bytes = input.damage.serialize(); let timestamp_bytes = input.timestamp.serialize(); let area_bytes = input.area.serialize(); let geometry_bytes = input.geometry.serialize(); [ response_type_bytes[0], level_bytes[0], sequence_bytes[0], sequence_bytes[1], drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], damage_bytes[0], damage_bytes[1], damage_bytes[2], damage_bytes[3], timestamp_bytes[0], timestamp_bytes[1], timestamp_bytes[2], timestamp_bytes[3], area_bytes[0], area_bytes[1], area_bytes[2], area_bytes[3], area_bytes[4], area_bytes[5], area_bytes[6], area_bytes[7], geometry_bytes[0], geometry_bytes[1], geometry_bytes[2], geometry_bytes[3], geometry_bytes[4], geometry_bytes[5], geometry_bytes[6], geometry_bytes[7], ] } } impl From for [u8; 32] { fn from(input: NotifyEvent) -> Self { Self::from(&input) } } x11rb-protocol-0.13.1/src/protocol/dbe.rs000064400000000000000000001167171046102023000162470ustar 00000000000000// This file contains generated code. Do not edit directly. // To regenerate this, run 'make'. //! Bindings to the `Dbe` X11 extension. #![allow(clippy::too_many_arguments)] // The code generator is simpler if it can always use conversions #![allow(clippy::useless_conversion)] #[allow(unused_imports)] use alloc::borrow::Cow; #[allow(unused_imports)] use core::convert::TryInto; use alloc::vec; use alloc::vec::Vec; use core::convert::TryFrom; use crate::errors::ParseError; #[allow(unused_imports)] use crate::x11_utils::TryIntoUSize; use crate::BufWithFds; #[allow(unused_imports)] use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; #[allow(unused_imports)] use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; #[allow(unused_imports)] use super::xproto; /// The X11 name of the extension for QueryExtension pub const X11_EXTENSION_NAME: &str = "DOUBLE-BUFFER"; /// The version number of this extension that this client library supports. /// /// This constant contains the version number of this extension that is supported /// by this build of x11rb. For most things, it does not make sense to use this /// information. If you need to send a `QueryVersion`, it is recommended to instead /// send the maximum version of the extension that you need. pub const X11_XML_VERSION: (u32, u32) = (1, 0); pub type BackBuffer = xproto::Drawable; /// Specifies what to do with the front buffer after it is swapped with the back buffer. /// /// # Fields /// /// * `Undefined` - Discard the buffer. The buffer may be reallocated and end up with random VRAM content. /// * `Background` - Erase with window background. /// * `Untouched` - Leave untouched. /// * `Copied` - Copy the newly displayed front buffer. #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SwapAction(u8); impl SwapAction { pub const UNDEFINED: Self = Self(0); pub const BACKGROUND: Self = Self(1); pub const UNTOUCHED: Self = Self(2); pub const COPIED: Self = Self(3); } impl From for u8 { #[inline] fn from(input: SwapAction) -> Self { input.0 } } impl From for Option { #[inline] fn from(input: SwapAction) -> Self { Some(input.0) } } impl From for u16 { #[inline] fn from(input: SwapAction) -> Self { u16::from(input.0) } } impl From for Option { #[inline] fn from(input: SwapAction) -> Self { Some(u16::from(input.0)) } } impl From for u32 { #[inline] fn from(input: SwapAction) -> Self { u32::from(input.0) } } impl From for Option { #[inline] fn from(input: SwapAction) -> Self { Some(u32::from(input.0)) } } impl From for SwapAction { #[inline] fn from(value: u8) -> Self { Self(value) } } impl core::fmt::Debug for SwapAction { fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let variants = [ (Self::UNDEFINED.0.into(), "UNDEFINED", "Undefined"), (Self::BACKGROUND.0.into(), "BACKGROUND", "Background"), (Self::UNTOUCHED.0.into(), "UNTOUCHED", "Untouched"), (Self::COPIED.0.into(), "COPIED", "Copied"), ]; pretty_print_enum(fmt, self.0.into(), &variants) } } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SwapInfo { pub window: xproto::Window, pub swap_action: SwapAction, } impl_debug_if_no_extra_traits!(SwapInfo, "SwapInfo"); impl TryParse for SwapInfo { fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> { let (window, remaining) = xproto::Window::try_parse(remaining)?; let (swap_action, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?; let swap_action = swap_action.into(); let result = SwapInfo { window, swap_action }; Ok((result, remaining)) } } impl Serialize for SwapInfo { type Bytes = [u8; 8]; fn serialize(&self) -> [u8; 8] { let window_bytes = self.window.serialize(); let swap_action_bytes = u8::from(self.swap_action).serialize(); [ window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], swap_action_bytes[0], 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(8); self.window.serialize_into(bytes); u8::from(self.swap_action).serialize_into(bytes); bytes.extend_from_slice(&[0; 3]); } } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct BufferAttributes { pub window: xproto::Window, } impl_debug_if_no_extra_traits!(BufferAttributes, "BufferAttributes"); impl TryParse for BufferAttributes { fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> { let (window, remaining) = xproto::Window::try_parse(remaining)?; let result = BufferAttributes { window }; Ok((result, remaining)) } } impl Serialize for BufferAttributes { type Bytes = [u8; 4]; fn serialize(&self) -> [u8; 4] { let window_bytes = self.window.serialize(); [ window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(4); self.window.serialize_into(bytes); } } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct VisualInfo { pub visual_id: xproto::Visualid, pub depth: u8, pub perf_level: u8, } impl_debug_if_no_extra_traits!(VisualInfo, "VisualInfo"); impl TryParse for VisualInfo { fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> { let (visual_id, remaining) = xproto::Visualid::try_parse(remaining)?; let (depth, remaining) = u8::try_parse(remaining)?; let (perf_level, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(2..).ok_or(ParseError::InsufficientData)?; let result = VisualInfo { visual_id, depth, perf_level }; Ok((result, remaining)) } } impl Serialize for VisualInfo { type Bytes = [u8; 8]; fn serialize(&self) -> [u8; 8] { let visual_id_bytes = self.visual_id.serialize(); let depth_bytes = self.depth.serialize(); let perf_level_bytes = self.perf_level.serialize(); [ visual_id_bytes[0], visual_id_bytes[1], visual_id_bytes[2], visual_id_bytes[3], depth_bytes[0], perf_level_bytes[0], 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(8); self.visual_id.serialize_into(bytes); self.depth.serialize_into(bytes); self.perf_level.serialize_into(bytes); bytes.extend_from_slice(&[0; 2]); } } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct VisualInfos { pub infos: Vec, } impl_debug_if_no_extra_traits!(VisualInfos, "VisualInfos"); impl TryParse for VisualInfos { fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> { let (n_infos, remaining) = u32::try_parse(remaining)?; let (infos, remaining) = crate::x11_utils::parse_list::(remaining, n_infos.try_to_usize()?)?; let result = VisualInfos { infos }; Ok((result, remaining)) } } impl Serialize for VisualInfos { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { let n_infos = u32::try_from(self.infos.len()).expect("`infos` has too many elements"); n_infos.serialize_into(bytes); self.infos.serialize_into(bytes); } } impl VisualInfos { /// Get the value of the `n_infos` field. /// /// The `n_infos` field is used as the length field of the `infos` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n_infos(&self) -> u32 { self.infos.len() .try_into().unwrap() } } /// Opcode for the BadBuffer error pub const BAD_BUFFER_ERROR: u8 = 0; /// Opcode for the QueryVersion request pub const QUERY_VERSION_REQUEST: u8 = 0; /// Queries the version of this extension. /// /// Queries the version of this extension. You must do this before using any functionality it provides. /// /// # Fields /// /// * `major_version` - The major version of the extension. Check that it is compatible with the XCB_DBE_MAJOR_VERSION that your code is compiled with. /// * `minor_version` - The minor version of the extension. Check that it is compatible with the XCB_DBE_MINOR_VERSION that your code is compiled with. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryVersionRequest { pub major_version: u8, pub minor_version: u8, } impl_debug_if_no_extra_traits!(QueryVersionRequest, "QueryVersionRequest"); impl QueryVersionRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let major_version_bytes = self.major_version.serialize(); let minor_version_bytes = self.minor_version.serialize(); let mut request0 = vec![ major_opcode, QUERY_VERSION_REQUEST, 0, 0, major_version_bytes[0], minor_version_bytes[0], 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != QUERY_VERSION_REQUEST { return Err(ParseError::InvalidValue); } let (major_version, remaining) = u8::try_parse(value)?; let (minor_version, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(2..).ok_or(ParseError::InsufficientData)?; let _ = remaining; Ok(QueryVersionRequest { major_version, minor_version, }) } } impl Request for QueryVersionRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for QueryVersionRequest { type Reply = QueryVersionReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryVersionReply { pub sequence: u16, pub length: u32, pub major_version: u8, pub minor_version: u8, } impl_debug_if_no_extra_traits!(QueryVersionReply, "QueryVersionReply"); impl TryParse for QueryVersionReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (major_version, remaining) = u8::try_parse(remaining)?; let (minor_version, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(22..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = QueryVersionReply { sequence, length, major_version, minor_version }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for QueryVersionReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let major_version_bytes = self.major_version.serialize(); let minor_version_bytes = self.minor_version.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], major_version_bytes[0], minor_version_bytes[0], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.major_version.serialize_into(bytes); self.minor_version.serialize_into(bytes); bytes.extend_from_slice(&[0; 22]); } } /// Opcode for the AllocateBackBuffer request pub const ALLOCATE_BACK_BUFFER_REQUEST: u8 = 1; /// Allocates a back buffer. /// /// Associates `buffer` with the back buffer of `window`. Multiple ids may be associated with the back buffer, which is created by the first allocate call and destroyed by the last deallocate. /// /// # Fields /// /// * `window` - The window to which to add the back buffer. /// * `buffer` - The buffer id to associate with the back buffer. /// * `swap_action` - The swap action most likely to be used to present this back buffer. This is only a hint, and does not preclude the use of other swap actions. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AllocateBackBufferRequest { pub window: xproto::Window, pub buffer: BackBuffer, pub swap_action: u8, } impl_debug_if_no_extra_traits!(AllocateBackBufferRequest, "AllocateBackBufferRequest"); impl AllocateBackBufferRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let window_bytes = self.window.serialize(); let buffer_bytes = self.buffer.serialize(); let swap_action_bytes = self.swap_action.serialize(); let mut request0 = vec![ major_opcode, ALLOCATE_BACK_BUFFER_REQUEST, 0, 0, window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], buffer_bytes[0], buffer_bytes[1], buffer_bytes[2], buffer_bytes[3], swap_action_bytes[0], 0, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != ALLOCATE_BACK_BUFFER_REQUEST { return Err(ParseError::InvalidValue); } let (window, remaining) = xproto::Window::try_parse(value)?; let (buffer, remaining) = BackBuffer::try_parse(remaining)?; let (swap_action, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?; let _ = remaining; Ok(AllocateBackBufferRequest { window, buffer, swap_action, }) } } impl Request for AllocateBackBufferRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for AllocateBackBufferRequest { } /// Opcode for the DeallocateBackBuffer request pub const DEALLOCATE_BACK_BUFFER_REQUEST: u8 = 2; /// Deallocates a back buffer. /// /// Deallocates the given `buffer`. If `buffer` is an invalid id, a `BadBuffer` error is returned. Because a window may have allocated multiple back buffer ids, the back buffer itself is not deleted until all these ids are deallocated by this call. /// /// # Fields /// /// * `buffer` - The back buffer to deallocate. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DeallocateBackBufferRequest { pub buffer: BackBuffer, } impl_debug_if_no_extra_traits!(DeallocateBackBufferRequest, "DeallocateBackBufferRequest"); impl DeallocateBackBufferRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let buffer_bytes = self.buffer.serialize(); let mut request0 = vec![ major_opcode, DEALLOCATE_BACK_BUFFER_REQUEST, 0, 0, buffer_bytes[0], buffer_bytes[1], buffer_bytes[2], buffer_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != DEALLOCATE_BACK_BUFFER_REQUEST { return Err(ParseError::InvalidValue); } let (buffer, remaining) = BackBuffer::try_parse(value)?; let _ = remaining; Ok(DeallocateBackBufferRequest { buffer, }) } } impl Request for DeallocateBackBufferRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for DeallocateBackBufferRequest { } /// Opcode for the SwapBuffers request pub const SWAP_BUFFERS_REQUEST: u8 = 3; /// Swaps front and back buffers. /// /// Swaps the front and back buffers on the specified windows. The front and back buffers retain their ids, so that the window id continues to refer to the front buffer, while the back buffer id created by this extension continues to refer to the back buffer. Back buffer contents is moved to the front buffer. Back buffer contents after the operation depends on the given swap action. The optimal swap action depends on how each frame is rendered. For example, if the buffer is cleared and fully overwritten on every frame, the "untouched" action, which throws away the buffer contents, would provide the best performance. To eliminate visual artifacts, the swap will occure during the monitor VSync, if the X server supports detecting it. /// /// # Fields /// /// * `actions` - List of windows on which to swap buffers. #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SwapBuffersRequest<'input> { pub actions: Cow<'input, [SwapInfo]>, } impl_debug_if_no_extra_traits!(SwapBuffersRequest<'_>, "SwapBuffersRequest"); impl<'input> SwapBuffersRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let n_actions = u32::try_from(self.actions.len()).expect("`actions` has too many elements"); let n_actions_bytes = n_actions.serialize(); let mut request0 = vec![ major_opcode, SWAP_BUFFERS_REQUEST, 0, 0, n_actions_bytes[0], n_actions_bytes[1], n_actions_bytes[2], n_actions_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let actions_bytes = self.actions.serialize(); let length_so_far = length_so_far + actions_bytes.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), actions_bytes.into(), padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != SWAP_BUFFERS_REQUEST { return Err(ParseError::InvalidValue); } let (n_actions, remaining) = u32::try_parse(value)?; let (actions, remaining) = crate::x11_utils::parse_list::(remaining, n_actions.try_to_usize()?)?; let _ = remaining; Ok(SwapBuffersRequest { actions: Cow::Owned(actions), }) } /// Clone all borrowed data in this SwapBuffersRequest. pub fn into_owned(self) -> SwapBuffersRequest<'static> { SwapBuffersRequest { actions: Cow::Owned(self.actions.into_owned()), } } } impl<'input> Request for SwapBuffersRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::VoidRequest for SwapBuffersRequest<'input> { } /// Opcode for the BeginIdiom request pub const BEGIN_IDIOM_REQUEST: u8 = 4; /// Begins a logical swap block. /// /// Creates a block of operations intended to occur together. This may be needed if window presentation requires changing buffers unknown to this extension, such as depth or stencil buffers. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct BeginIdiomRequest; impl_debug_if_no_extra_traits!(BeginIdiomRequest, "BeginIdiomRequest"); impl BeginIdiomRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let mut request0 = vec![ major_opcode, BEGIN_IDIOM_REQUEST, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != BEGIN_IDIOM_REQUEST { return Err(ParseError::InvalidValue); } let _ = value; Ok(BeginIdiomRequest ) } } impl Request for BeginIdiomRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for BeginIdiomRequest { } /// Opcode for the EndIdiom request pub const END_IDIOM_REQUEST: u8 = 5; /// Ends a logical swap block. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct EndIdiomRequest; impl_debug_if_no_extra_traits!(EndIdiomRequest, "EndIdiomRequest"); impl EndIdiomRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let mut request0 = vec![ major_opcode, END_IDIOM_REQUEST, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != END_IDIOM_REQUEST { return Err(ParseError::InvalidValue); } let _ = value; Ok(EndIdiomRequest ) } } impl Request for EndIdiomRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for EndIdiomRequest { } /// Opcode for the GetVisualInfo request pub const GET_VISUAL_INFO_REQUEST: u8 = 6; /// Requests visuals that support double buffering. #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetVisualInfoRequest<'input> { pub drawables: Cow<'input, [xproto::Drawable]>, } impl_debug_if_no_extra_traits!(GetVisualInfoRequest<'_>, "GetVisualInfoRequest"); impl<'input> GetVisualInfoRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let n_drawables = u32::try_from(self.drawables.len()).expect("`drawables` has too many elements"); let n_drawables_bytes = n_drawables.serialize(); let mut request0 = vec![ major_opcode, GET_VISUAL_INFO_REQUEST, 0, 0, n_drawables_bytes[0], n_drawables_bytes[1], n_drawables_bytes[2], n_drawables_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let drawables_bytes = self.drawables.serialize(); let length_so_far = length_so_far + drawables_bytes.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), drawables_bytes.into(), padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != GET_VISUAL_INFO_REQUEST { return Err(ParseError::InvalidValue); } let (n_drawables, remaining) = u32::try_parse(value)?; let (drawables, remaining) = crate::x11_utils::parse_list::(remaining, n_drawables.try_to_usize()?)?; let _ = remaining; Ok(GetVisualInfoRequest { drawables: Cow::Owned(drawables), }) } /// Clone all borrowed data in this GetVisualInfoRequest. pub fn into_owned(self) -> GetVisualInfoRequest<'static> { GetVisualInfoRequest { drawables: Cow::Owned(self.drawables.into_owned()), } } } impl<'input> Request for GetVisualInfoRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::ReplyRequest for GetVisualInfoRequest<'input> { type Reply = GetVisualInfoReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetVisualInfoReply { pub sequence: u16, pub length: u32, pub supported_visuals: Vec, } impl_debug_if_no_extra_traits!(GetVisualInfoReply, "GetVisualInfoReply"); impl TryParse for GetVisualInfoReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (n_supported_visuals, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?; let (supported_visuals, remaining) = crate::x11_utils::parse_list::(remaining, n_supported_visuals.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetVisualInfoReply { sequence, length, supported_visuals }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetVisualInfoReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); let n_supported_visuals = u32::try_from(self.supported_visuals.len()).expect("`supported_visuals` has too many elements"); n_supported_visuals.serialize_into(bytes); bytes.extend_from_slice(&[0; 20]); self.supported_visuals.serialize_into(bytes); } } impl GetVisualInfoReply { /// Get the value of the `n_supported_visuals` field. /// /// The `n_supported_visuals` field is used as the length field of the `supported_visuals` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n_supported_visuals(&self) -> u32 { self.supported_visuals.len() .try_into().unwrap() } } /// Opcode for the GetBackBufferAttributes request pub const GET_BACK_BUFFER_ATTRIBUTES_REQUEST: u8 = 7; /// Gets back buffer attributes. /// /// Returns the attributes of the specified `buffer`. /// /// # Fields /// /// * `buffer` - The back buffer to query. /// * `attributes` - The attributes of `buffer`. #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetBackBufferAttributesRequest { pub buffer: BackBuffer, } impl_debug_if_no_extra_traits!(GetBackBufferAttributesRequest, "GetBackBufferAttributesRequest"); impl GetBackBufferAttributesRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let buffer_bytes = self.buffer.serialize(); let mut request0 = vec![ major_opcode, GET_BACK_BUFFER_ATTRIBUTES_REQUEST, 0, 0, buffer_bytes[0], buffer_bytes[1], buffer_bytes[2], buffer_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_BACK_BUFFER_ATTRIBUTES_REQUEST { return Err(ParseError::InvalidValue); } let (buffer, remaining) = BackBuffer::try_parse(value)?; let _ = remaining; Ok(GetBackBufferAttributesRequest { buffer, }) } } impl Request for GetBackBufferAttributesRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetBackBufferAttributesRequest { type Reply = GetBackBufferAttributesReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetBackBufferAttributesReply { pub sequence: u16, pub length: u32, pub attributes: BufferAttributes, } impl_debug_if_no_extra_traits!(GetBackBufferAttributesReply, "GetBackBufferAttributesReply"); impl TryParse for GetBackBufferAttributesReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (attributes, remaining) = BufferAttributes::try_parse(remaining)?; let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetBackBufferAttributesReply { sequence, length, attributes }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetBackBufferAttributesReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let attributes_bytes = self.attributes.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], attributes_bytes[0], attributes_bytes[1], attributes_bytes[2], attributes_bytes[3], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.attributes.serialize_into(bytes); bytes.extend_from_slice(&[0; 20]); } } x11rb-protocol-0.13.1/src/protocol/dpms.rs000064400000000000000000001122141046102023000164440ustar 00000000000000// This file contains generated code. Do not edit directly. // To regenerate this, run 'make'. //! Bindings to the `DPMS` X11 extension. #![allow(clippy::too_many_arguments)] // The code generator is simpler if it can always use conversions #![allow(clippy::useless_conversion)] #[allow(unused_imports)] use alloc::borrow::Cow; #[allow(unused_imports)] use core::convert::TryInto; use alloc::vec; use alloc::vec::Vec; use core::convert::TryFrom; use crate::errors::ParseError; #[allow(unused_imports)] use crate::x11_utils::TryIntoUSize; use crate::BufWithFds; #[allow(unused_imports)] use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; #[allow(unused_imports)] use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; #[allow(unused_imports)] use super::xproto; /// The X11 name of the extension for QueryExtension pub const X11_EXTENSION_NAME: &str = "DPMS"; /// The version number of this extension that this client library supports. /// /// This constant contains the version number of this extension that is supported /// by this build of x11rb. For most things, it does not make sense to use this /// information. If you need to send a `QueryVersion`, it is recommended to instead /// send the maximum version of the extension that you need. pub const X11_XML_VERSION: (u32, u32) = (1, 2); /// Opcode for the GetVersion request pub const GET_VERSION_REQUEST: u8 = 0; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetVersionRequest { pub client_major_version: u16, pub client_minor_version: u16, } impl_debug_if_no_extra_traits!(GetVersionRequest, "GetVersionRequest"); impl GetVersionRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let client_major_version_bytes = self.client_major_version.serialize(); let client_minor_version_bytes = self.client_minor_version.serialize(); let mut request0 = vec![ major_opcode, GET_VERSION_REQUEST, 0, 0, client_major_version_bytes[0], client_major_version_bytes[1], client_minor_version_bytes[0], client_minor_version_bytes[1], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_VERSION_REQUEST { return Err(ParseError::InvalidValue); } let (client_major_version, remaining) = u16::try_parse(value)?; let (client_minor_version, remaining) = u16::try_parse(remaining)?; let _ = remaining; Ok(GetVersionRequest { client_major_version, client_minor_version, }) } } impl Request for GetVersionRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetVersionRequest { type Reply = GetVersionReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetVersionReply { pub sequence: u16, pub length: u32, pub server_major_version: u16, pub server_minor_version: u16, } impl_debug_if_no_extra_traits!(GetVersionReply, "GetVersionReply"); impl TryParse for GetVersionReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (server_major_version, remaining) = u16::try_parse(remaining)?; let (server_minor_version, remaining) = u16::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetVersionReply { sequence, length, server_major_version, server_minor_version }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetVersionReply { type Bytes = [u8; 12]; fn serialize(&self) -> [u8; 12] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let server_major_version_bytes = self.server_major_version.serialize(); let server_minor_version_bytes = self.server_minor_version.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], server_major_version_bytes[0], server_major_version_bytes[1], server_minor_version_bytes[0], server_minor_version_bytes[1], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(12); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.server_major_version.serialize_into(bytes); self.server_minor_version.serialize_into(bytes); } } /// Opcode for the Capable request pub const CAPABLE_REQUEST: u8 = 1; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CapableRequest; impl_debug_if_no_extra_traits!(CapableRequest, "CapableRequest"); impl CapableRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let mut request0 = vec![ major_opcode, CAPABLE_REQUEST, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != CAPABLE_REQUEST { return Err(ParseError::InvalidValue); } let _ = value; Ok(CapableRequest ) } } impl Request for CapableRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for CapableRequest { type Reply = CapableReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CapableReply { pub sequence: u16, pub length: u32, pub capable: bool, } impl_debug_if_no_extra_traits!(CapableReply, "CapableReply"); impl TryParse for CapableReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (capable, remaining) = bool::try_parse(remaining)?; let remaining = remaining.get(23..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = CapableReply { sequence, length, capable }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for CapableReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let capable_bytes = self.capable.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], capable_bytes[0], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.capable.serialize_into(bytes); bytes.extend_from_slice(&[0; 23]); } } /// Opcode for the GetTimeouts request pub const GET_TIMEOUTS_REQUEST: u8 = 2; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTimeoutsRequest; impl_debug_if_no_extra_traits!(GetTimeoutsRequest, "GetTimeoutsRequest"); impl GetTimeoutsRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let mut request0 = vec![ major_opcode, GET_TIMEOUTS_REQUEST, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_TIMEOUTS_REQUEST { return Err(ParseError::InvalidValue); } let _ = value; Ok(GetTimeoutsRequest ) } } impl Request for GetTimeoutsRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetTimeoutsRequest { type Reply = GetTimeoutsReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTimeoutsReply { pub sequence: u16, pub length: u32, pub standby_timeout: u16, pub suspend_timeout: u16, pub off_timeout: u16, } impl_debug_if_no_extra_traits!(GetTimeoutsReply, "GetTimeoutsReply"); impl TryParse for GetTimeoutsReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (standby_timeout, remaining) = u16::try_parse(remaining)?; let (suspend_timeout, remaining) = u16::try_parse(remaining)?; let (off_timeout, remaining) = u16::try_parse(remaining)?; let remaining = remaining.get(18..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetTimeoutsReply { sequence, length, standby_timeout, suspend_timeout, off_timeout }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetTimeoutsReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let standby_timeout_bytes = self.standby_timeout.serialize(); let suspend_timeout_bytes = self.suspend_timeout.serialize(); let off_timeout_bytes = self.off_timeout.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], standby_timeout_bytes[0], standby_timeout_bytes[1], suspend_timeout_bytes[0], suspend_timeout_bytes[1], off_timeout_bytes[0], off_timeout_bytes[1], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.standby_timeout.serialize_into(bytes); self.suspend_timeout.serialize_into(bytes); self.off_timeout.serialize_into(bytes); bytes.extend_from_slice(&[0; 18]); } } /// Opcode for the SetTimeouts request pub const SET_TIMEOUTS_REQUEST: u8 = 3; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetTimeoutsRequest { pub standby_timeout: u16, pub suspend_timeout: u16, pub off_timeout: u16, } impl_debug_if_no_extra_traits!(SetTimeoutsRequest, "SetTimeoutsRequest"); impl SetTimeoutsRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let standby_timeout_bytes = self.standby_timeout.serialize(); let suspend_timeout_bytes = self.suspend_timeout.serialize(); let off_timeout_bytes = self.off_timeout.serialize(); let mut request0 = vec![ major_opcode, SET_TIMEOUTS_REQUEST, 0, 0, standby_timeout_bytes[0], standby_timeout_bytes[1], suspend_timeout_bytes[0], suspend_timeout_bytes[1], off_timeout_bytes[0], off_timeout_bytes[1], 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != SET_TIMEOUTS_REQUEST { return Err(ParseError::InvalidValue); } let (standby_timeout, remaining) = u16::try_parse(value)?; let (suspend_timeout, remaining) = u16::try_parse(remaining)?; let (off_timeout, remaining) = u16::try_parse(remaining)?; let _ = remaining; Ok(SetTimeoutsRequest { standby_timeout, suspend_timeout, off_timeout, }) } } impl Request for SetTimeoutsRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for SetTimeoutsRequest { } /// Opcode for the Enable request pub const ENABLE_REQUEST: u8 = 4; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct EnableRequest; impl_debug_if_no_extra_traits!(EnableRequest, "EnableRequest"); impl EnableRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let mut request0 = vec![ major_opcode, ENABLE_REQUEST, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != ENABLE_REQUEST { return Err(ParseError::InvalidValue); } let _ = value; Ok(EnableRequest ) } } impl Request for EnableRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for EnableRequest { } /// Opcode for the Disable request pub const DISABLE_REQUEST: u8 = 5; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DisableRequest; impl_debug_if_no_extra_traits!(DisableRequest, "DisableRequest"); impl DisableRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let mut request0 = vec![ major_opcode, DISABLE_REQUEST, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != DISABLE_REQUEST { return Err(ParseError::InvalidValue); } let _ = value; Ok(DisableRequest ) } } impl Request for DisableRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for DisableRequest { } #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DPMSMode(u16); impl DPMSMode { pub const ON: Self = Self(0); pub const STANDBY: Self = Self(1); pub const SUSPEND: Self = Self(2); pub const OFF: Self = Self(3); } impl From for u16 { #[inline] fn from(input: DPMSMode) -> Self { input.0 } } impl From for Option { #[inline] fn from(input: DPMSMode) -> Self { Some(input.0) } } impl From for u32 { #[inline] fn from(input: DPMSMode) -> Self { u32::from(input.0) } } impl From for Option { #[inline] fn from(input: DPMSMode) -> Self { Some(u32::from(input.0)) } } impl From for DPMSMode { #[inline] fn from(value: u8) -> Self { Self(value.into()) } } impl From for DPMSMode { #[inline] fn from(value: u16) -> Self { Self(value) } } impl core::fmt::Debug for DPMSMode { fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let variants = [ (Self::ON.0.into(), "ON", "On"), (Self::STANDBY.0.into(), "STANDBY", "Standby"), (Self::SUSPEND.0.into(), "SUSPEND", "Suspend"), (Self::OFF.0.into(), "OFF", "Off"), ]; pretty_print_enum(fmt, self.0.into(), &variants) } } /// Opcode for the ForceLevel request pub const FORCE_LEVEL_REQUEST: u8 = 6; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ForceLevelRequest { pub power_level: DPMSMode, } impl_debug_if_no_extra_traits!(ForceLevelRequest, "ForceLevelRequest"); impl ForceLevelRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let power_level_bytes = u16::from(self.power_level).serialize(); let mut request0 = vec![ major_opcode, FORCE_LEVEL_REQUEST, 0, 0, power_level_bytes[0], power_level_bytes[1], 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != FORCE_LEVEL_REQUEST { return Err(ParseError::InvalidValue); } let (power_level, remaining) = u16::try_parse(value)?; let power_level = power_level.into(); let _ = remaining; Ok(ForceLevelRequest { power_level, }) } } impl Request for ForceLevelRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for ForceLevelRequest { } /// Opcode for the Info request pub const INFO_REQUEST: u8 = 7; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InfoRequest; impl_debug_if_no_extra_traits!(InfoRequest, "InfoRequest"); impl InfoRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let mut request0 = vec![ major_opcode, INFO_REQUEST, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != INFO_REQUEST { return Err(ParseError::InvalidValue); } let _ = value; Ok(InfoRequest ) } } impl Request for InfoRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for InfoRequest { type Reply = InfoReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InfoReply { pub sequence: u16, pub length: u32, pub power_level: DPMSMode, pub state: bool, } impl_debug_if_no_extra_traits!(InfoReply, "InfoReply"); impl TryParse for InfoReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (power_level, remaining) = u16::try_parse(remaining)?; let (state, remaining) = bool::try_parse(remaining)?; let remaining = remaining.get(21..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let power_level = power_level.into(); let result = InfoReply { sequence, length, power_level, state }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for InfoReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let power_level_bytes = u16::from(self.power_level).serialize(); let state_bytes = self.state.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], power_level_bytes[0], power_level_bytes[1], state_bytes[0], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); u16::from(self.power_level).serialize_into(bytes); self.state.serialize_into(bytes); bytes.extend_from_slice(&[0; 21]); } } #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct EventMask(u32); impl EventMask { pub const INFO_NOTIFY: Self = Self(1 << 0); } impl From for u32 { #[inline] fn from(input: EventMask) -> Self { input.0 } } impl From for Option { #[inline] fn from(input: EventMask) -> Self { Some(input.0) } } impl From for EventMask { #[inline] fn from(value: u8) -> Self { Self(value.into()) } } impl From for EventMask { #[inline] fn from(value: u16) -> Self { Self(value.into()) } } impl From for EventMask { #[inline] fn from(value: u32) -> Self { Self(value) } } impl core::fmt::Debug for EventMask { fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let variants = [ (Self::INFO_NOTIFY.0, "INFO_NOTIFY", "InfoNotify"), ]; pretty_print_bitmask(fmt, self.0, &variants) } } bitmask_binop!(EventMask, u32); /// Opcode for the SelectInput request pub const SELECT_INPUT_REQUEST: u8 = 8; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SelectInputRequest { pub event_mask: EventMask, } impl_debug_if_no_extra_traits!(SelectInputRequest, "SelectInputRequest"); impl SelectInputRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let event_mask_bytes = u32::from(self.event_mask).serialize(); let mut request0 = vec![ major_opcode, SELECT_INPUT_REQUEST, 0, 0, event_mask_bytes[0], event_mask_bytes[1], event_mask_bytes[2], event_mask_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != SELECT_INPUT_REQUEST { return Err(ParseError::InvalidValue); } let (event_mask, remaining) = u32::try_parse(value)?; let event_mask = event_mask.into(); let _ = remaining; Ok(SelectInputRequest { event_mask, }) } } impl Request for SelectInputRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for SelectInputRequest { } /// Opcode for the InfoNotify event pub const INFO_NOTIFY_EVENT: u16 = 0; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InfoNotifyEvent { pub response_type: u8, pub extension: u8, pub sequence: u16, pub length: u32, pub event_type: u16, pub timestamp: xproto::Timestamp, pub power_level: DPMSMode, pub state: bool, } impl_debug_if_no_extra_traits!(InfoNotifyEvent, "InfoNotifyEvent"); impl TryParse for InfoNotifyEvent { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let (extension, remaining) = u8::try_parse(remaining)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (event_type, remaining) = u16::try_parse(remaining)?; let remaining = remaining.get(2..).ok_or(ParseError::InsufficientData)?; let (timestamp, remaining) = xproto::Timestamp::try_parse(remaining)?; let (power_level, remaining) = u16::try_parse(remaining)?; let (state, remaining) = bool::try_parse(remaining)?; let remaining = remaining.get(21..).ok_or(ParseError::InsufficientData)?; let power_level = power_level.into(); let result = InfoNotifyEvent { response_type, extension, sequence, length, event_type, timestamp, power_level, state }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for InfoNotifyEvent { type Bytes = [u8; 40]; fn serialize(&self) -> [u8; 40] { let response_type_bytes = self.response_type.serialize(); let extension_bytes = self.extension.serialize(); let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let event_type_bytes = self.event_type.serialize(); let timestamp_bytes = self.timestamp.serialize(); let power_level_bytes = u16::from(self.power_level).serialize(); let state_bytes = self.state.serialize(); [ response_type_bytes[0], extension_bytes[0], sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], event_type_bytes[0], event_type_bytes[1], 0, 0, timestamp_bytes[0], timestamp_bytes[1], timestamp_bytes[2], timestamp_bytes[3], power_level_bytes[0], power_level_bytes[1], state_bytes[0], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(40); self.response_type.serialize_into(bytes); self.extension.serialize_into(bytes); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.event_type.serialize_into(bytes); bytes.extend_from_slice(&[0; 2]); self.timestamp.serialize_into(bytes); u16::from(self.power_level).serialize_into(bytes); self.state.serialize_into(bytes); bytes.extend_from_slice(&[0; 21]); } } x11rb-protocol-0.13.1/src/protocol/dri2.rs000064400000000000000000002656341046102023000163600ustar 00000000000000// This file contains generated code. Do not edit directly. // To regenerate this, run 'make'. //! Bindings to the `DRI2` X11 extension. #![allow(clippy::too_many_arguments)] // The code generator is simpler if it can always use conversions #![allow(clippy::useless_conversion)] #[allow(unused_imports)] use alloc::borrow::Cow; #[allow(unused_imports)] use core::convert::TryInto; use alloc::vec; use alloc::vec::Vec; use core::convert::TryFrom; use crate::errors::ParseError; #[allow(unused_imports)] use crate::x11_utils::TryIntoUSize; use crate::BufWithFds; #[allow(unused_imports)] use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; #[allow(unused_imports)] use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; #[allow(unused_imports)] use super::xproto; /// The X11 name of the extension for QueryExtension pub const X11_EXTENSION_NAME: &str = "DRI2"; /// The version number of this extension that this client library supports. /// /// This constant contains the version number of this extension that is supported /// by this build of x11rb. For most things, it does not make sense to use this /// information. If you need to send a `QueryVersion`, it is recommended to instead /// send the maximum version of the extension that you need. pub const X11_XML_VERSION: (u32, u32) = (1, 4); #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Attachment(u32); impl Attachment { pub const BUFFER_FRONT_LEFT: Self = Self(0); pub const BUFFER_BACK_LEFT: Self = Self(1); pub const BUFFER_FRONT_RIGHT: Self = Self(2); pub const BUFFER_BACK_RIGHT: Self = Self(3); pub const BUFFER_DEPTH: Self = Self(4); pub const BUFFER_STENCIL: Self = Self(5); pub const BUFFER_ACCUM: Self = Self(6); pub const BUFFER_FAKE_FRONT_LEFT: Self = Self(7); pub const BUFFER_FAKE_FRONT_RIGHT: Self = Self(8); pub const BUFFER_DEPTH_STENCIL: Self = Self(9); pub const BUFFER_HIZ: Self = Self(10); } impl From for u32 { #[inline] fn from(input: Attachment) -> Self { input.0 } } impl From for Option { #[inline] fn from(input: Attachment) -> Self { Some(input.0) } } impl From for Attachment { #[inline] fn from(value: u8) -> Self { Self(value.into()) } } impl From for Attachment { #[inline] fn from(value: u16) -> Self { Self(value.into()) } } impl From for Attachment { #[inline] fn from(value: u32) -> Self { Self(value) } } impl core::fmt::Debug for Attachment { fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let variants = [ (Self::BUFFER_FRONT_LEFT.0, "BUFFER_FRONT_LEFT", "BufferFrontLeft"), (Self::BUFFER_BACK_LEFT.0, "BUFFER_BACK_LEFT", "BufferBackLeft"), (Self::BUFFER_FRONT_RIGHT.0, "BUFFER_FRONT_RIGHT", "BufferFrontRight"), (Self::BUFFER_BACK_RIGHT.0, "BUFFER_BACK_RIGHT", "BufferBackRight"), (Self::BUFFER_DEPTH.0, "BUFFER_DEPTH", "BufferDepth"), (Self::BUFFER_STENCIL.0, "BUFFER_STENCIL", "BufferStencil"), (Self::BUFFER_ACCUM.0, "BUFFER_ACCUM", "BufferAccum"), (Self::BUFFER_FAKE_FRONT_LEFT.0, "BUFFER_FAKE_FRONT_LEFT", "BufferFakeFrontLeft"), (Self::BUFFER_FAKE_FRONT_RIGHT.0, "BUFFER_FAKE_FRONT_RIGHT", "BufferFakeFrontRight"), (Self::BUFFER_DEPTH_STENCIL.0, "BUFFER_DEPTH_STENCIL", "BufferDepthStencil"), (Self::BUFFER_HIZ.0, "BUFFER_HIZ", "BufferHiz"), ]; pretty_print_enum(fmt, self.0, &variants) } } #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DriverType(u32); impl DriverType { pub const DRI: Self = Self(0); pub const VDPAU: Self = Self(1); } impl From for u32 { #[inline] fn from(input: DriverType) -> Self { input.0 } } impl From for Option { #[inline] fn from(input: DriverType) -> Self { Some(input.0) } } impl From for DriverType { #[inline] fn from(value: u8) -> Self { Self(value.into()) } } impl From for DriverType { #[inline] fn from(value: u16) -> Self { Self(value.into()) } } impl From for DriverType { #[inline] fn from(value: u32) -> Self { Self(value) } } impl core::fmt::Debug for DriverType { fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let variants = [ (Self::DRI.0, "DRI", "DRI"), (Self::VDPAU.0, "VDPAU", "VDPAU"), ]; pretty_print_enum(fmt, self.0, &variants) } } #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct EventType(u16); impl EventType { pub const EXCHANGE_COMPLETE: Self = Self(1); pub const BLIT_COMPLETE: Self = Self(2); pub const FLIP_COMPLETE: Self = Self(3); } impl From for u16 { #[inline] fn from(input: EventType) -> Self { input.0 } } impl From for Option { #[inline] fn from(input: EventType) -> Self { Some(input.0) } } impl From for u32 { #[inline] fn from(input: EventType) -> Self { u32::from(input.0) } } impl From for Option { #[inline] fn from(input: EventType) -> Self { Some(u32::from(input.0)) } } impl From for EventType { #[inline] fn from(value: u8) -> Self { Self(value.into()) } } impl From for EventType { #[inline] fn from(value: u16) -> Self { Self(value) } } impl core::fmt::Debug for EventType { fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let variants = [ (Self::EXCHANGE_COMPLETE.0.into(), "EXCHANGE_COMPLETE", "ExchangeComplete"), (Self::BLIT_COMPLETE.0.into(), "BLIT_COMPLETE", "BlitComplete"), (Self::FLIP_COMPLETE.0.into(), "FLIP_COMPLETE", "FlipComplete"), ]; pretty_print_enum(fmt, self.0.into(), &variants) } } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DRI2Buffer { pub attachment: Attachment, pub name: u32, pub pitch: u32, pub cpp: u32, pub flags: u32, } impl_debug_if_no_extra_traits!(DRI2Buffer, "DRI2Buffer"); impl TryParse for DRI2Buffer { fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> { let (attachment, remaining) = u32::try_parse(remaining)?; let (name, remaining) = u32::try_parse(remaining)?; let (pitch, remaining) = u32::try_parse(remaining)?; let (cpp, remaining) = u32::try_parse(remaining)?; let (flags, remaining) = u32::try_parse(remaining)?; let attachment = attachment.into(); let result = DRI2Buffer { attachment, name, pitch, cpp, flags }; Ok((result, remaining)) } } impl Serialize for DRI2Buffer { type Bytes = [u8; 20]; fn serialize(&self) -> [u8; 20] { let attachment_bytes = u32::from(self.attachment).serialize(); let name_bytes = self.name.serialize(); let pitch_bytes = self.pitch.serialize(); let cpp_bytes = self.cpp.serialize(); let flags_bytes = self.flags.serialize(); [ attachment_bytes[0], attachment_bytes[1], attachment_bytes[2], attachment_bytes[3], name_bytes[0], name_bytes[1], name_bytes[2], name_bytes[3], pitch_bytes[0], pitch_bytes[1], pitch_bytes[2], pitch_bytes[3], cpp_bytes[0], cpp_bytes[1], cpp_bytes[2], cpp_bytes[3], flags_bytes[0], flags_bytes[1], flags_bytes[2], flags_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(20); u32::from(self.attachment).serialize_into(bytes); self.name.serialize_into(bytes); self.pitch.serialize_into(bytes); self.cpp.serialize_into(bytes); self.flags.serialize_into(bytes); } } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AttachFormat { pub attachment: Attachment, pub format: u32, } impl_debug_if_no_extra_traits!(AttachFormat, "AttachFormat"); impl TryParse for AttachFormat { fn try_parse(remaining: &[u8]) -> Result<(Self, &[u8]), ParseError> { let (attachment, remaining) = u32::try_parse(remaining)?; let (format, remaining) = u32::try_parse(remaining)?; let attachment = attachment.into(); let result = AttachFormat { attachment, format }; Ok((result, remaining)) } } impl Serialize for AttachFormat { type Bytes = [u8; 8]; fn serialize(&self) -> [u8; 8] { let attachment_bytes = u32::from(self.attachment).serialize(); let format_bytes = self.format.serialize(); [ attachment_bytes[0], attachment_bytes[1], attachment_bytes[2], attachment_bytes[3], format_bytes[0], format_bytes[1], format_bytes[2], format_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(8); u32::from(self.attachment).serialize_into(bytes); self.format.serialize_into(bytes); } } /// Opcode for the QueryVersion request pub const QUERY_VERSION_REQUEST: u8 = 0; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryVersionRequest { pub major_version: u32, pub minor_version: u32, } impl_debug_if_no_extra_traits!(QueryVersionRequest, "QueryVersionRequest"); impl QueryVersionRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let major_version_bytes = self.major_version.serialize(); let minor_version_bytes = self.minor_version.serialize(); let mut request0 = vec![ major_opcode, QUERY_VERSION_REQUEST, 0, 0, major_version_bytes[0], major_version_bytes[1], major_version_bytes[2], major_version_bytes[3], minor_version_bytes[0], minor_version_bytes[1], minor_version_bytes[2], minor_version_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != QUERY_VERSION_REQUEST { return Err(ParseError::InvalidValue); } let (major_version, remaining) = u32::try_parse(value)?; let (minor_version, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(QueryVersionRequest { major_version, minor_version, }) } } impl Request for QueryVersionRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for QueryVersionRequest { type Reply = QueryVersionReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryVersionReply { pub sequence: u16, pub length: u32, pub major_version: u32, pub minor_version: u32, } impl_debug_if_no_extra_traits!(QueryVersionReply, "QueryVersionReply"); impl TryParse for QueryVersionReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (major_version, remaining) = u32::try_parse(remaining)?; let (minor_version, remaining) = u32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = QueryVersionReply { sequence, length, major_version, minor_version }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for QueryVersionReply { type Bytes = [u8; 16]; fn serialize(&self) -> [u8; 16] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let major_version_bytes = self.major_version.serialize(); let minor_version_bytes = self.minor_version.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], major_version_bytes[0], major_version_bytes[1], major_version_bytes[2], major_version_bytes[3], minor_version_bytes[0], minor_version_bytes[1], minor_version_bytes[2], minor_version_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(16); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.major_version.serialize_into(bytes); self.minor_version.serialize_into(bytes); } } /// Opcode for the Connect request pub const CONNECT_REQUEST: u8 = 1; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ConnectRequest { pub window: xproto::Window, pub driver_type: DriverType, } impl_debug_if_no_extra_traits!(ConnectRequest, "ConnectRequest"); impl ConnectRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let window_bytes = self.window.serialize(); let driver_type_bytes = u32::from(self.driver_type).serialize(); let mut request0 = vec![ major_opcode, CONNECT_REQUEST, 0, 0, window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], driver_type_bytes[0], driver_type_bytes[1], driver_type_bytes[2], driver_type_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != CONNECT_REQUEST { return Err(ParseError::InvalidValue); } let (window, remaining) = xproto::Window::try_parse(value)?; let (driver_type, remaining) = u32::try_parse(remaining)?; let driver_type = driver_type.into(); let _ = remaining; Ok(ConnectRequest { window, driver_type, }) } } impl Request for ConnectRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for ConnectRequest { type Reply = ConnectReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ConnectReply { pub sequence: u16, pub length: u32, pub driver_name: Vec, pub alignment_pad: Vec, pub device_name: Vec, } impl_debug_if_no_extra_traits!(ConnectReply, "ConnectReply"); impl TryParse for ConnectReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (driver_name_length, remaining) = u32::try_parse(remaining)?; let (device_name_length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?; let (driver_name, remaining) = crate::x11_utils::parse_u8_list(remaining, driver_name_length.try_to_usize()?)?; let driver_name = driver_name.to_vec(); let (alignment_pad, remaining) = crate::x11_utils::parse_u8_list(remaining, (u32::from(driver_name_length).checked_add(3u32).ok_or(ParseError::InvalidExpression)? & (!3u32)).checked_sub(u32::from(driver_name_length)).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let alignment_pad = alignment_pad.to_vec(); let (device_name, remaining) = crate::x11_utils::parse_u8_list(remaining, device_name_length.try_to_usize()?)?; let device_name = device_name.to_vec(); if response_type != 1 { return Err(ParseError::InvalidValue); } let result = ConnectReply { sequence, length, driver_name, alignment_pad, device_name }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for ConnectReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); let driver_name_length = u32::try_from(self.driver_name.len()).expect("`driver_name` has too many elements"); driver_name_length.serialize_into(bytes); let device_name_length = u32::try_from(self.device_name.len()).expect("`device_name` has too many elements"); device_name_length.serialize_into(bytes); bytes.extend_from_slice(&[0; 16]); bytes.extend_from_slice(&self.driver_name); assert_eq!(self.alignment_pad.len(), usize::try_from((u32::from(driver_name_length).checked_add(3u32).unwrap() & (!3u32)).checked_sub(u32::from(driver_name_length)).unwrap()).unwrap(), "`alignment_pad` has an incorrect length"); bytes.extend_from_slice(&self.alignment_pad); bytes.extend_from_slice(&self.device_name); } } impl ConnectReply { /// Get the value of the `driver_name_length` field. /// /// The `driver_name_length` field is used as the length field of the `driver_name` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn driver_name_length(&self) -> u32 { self.driver_name.len() .try_into().unwrap() } /// Get the value of the `device_name_length` field. /// /// The `device_name_length` field is used as the length field of the `device_name` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn device_name_length(&self) -> u32 { self.device_name.len() .try_into().unwrap() } } /// Opcode for the Authenticate request pub const AUTHENTICATE_REQUEST: u8 = 2; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthenticateRequest { pub window: xproto::Window, pub magic: u32, } impl_debug_if_no_extra_traits!(AuthenticateRequest, "AuthenticateRequest"); impl AuthenticateRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let window_bytes = self.window.serialize(); let magic_bytes = self.magic.serialize(); let mut request0 = vec![ major_opcode, AUTHENTICATE_REQUEST, 0, 0, window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], magic_bytes[0], magic_bytes[1], magic_bytes[2], magic_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != AUTHENTICATE_REQUEST { return Err(ParseError::InvalidValue); } let (window, remaining) = xproto::Window::try_parse(value)?; let (magic, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(AuthenticateRequest { window, magic, }) } } impl Request for AuthenticateRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for AuthenticateRequest { type Reply = AuthenticateReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AuthenticateReply { pub sequence: u16, pub length: u32, pub authenticated: u32, } impl_debug_if_no_extra_traits!(AuthenticateReply, "AuthenticateReply"); impl TryParse for AuthenticateReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (authenticated, remaining) = u32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = AuthenticateReply { sequence, length, authenticated }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for AuthenticateReply { type Bytes = [u8; 12]; fn serialize(&self) -> [u8; 12] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let authenticated_bytes = self.authenticated.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], authenticated_bytes[0], authenticated_bytes[1], authenticated_bytes[2], authenticated_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(12); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.authenticated.serialize_into(bytes); } } /// Opcode for the CreateDrawable request pub const CREATE_DRAWABLE_REQUEST: u8 = 3; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateDrawableRequest { pub drawable: xproto::Drawable, } impl_debug_if_no_extra_traits!(CreateDrawableRequest, "CreateDrawableRequest"); impl CreateDrawableRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let mut request0 = vec![ major_opcode, CREATE_DRAWABLE_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != CREATE_DRAWABLE_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = xproto::Drawable::try_parse(value)?; let _ = remaining; Ok(CreateDrawableRequest { drawable, }) } } impl Request for CreateDrawableRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for CreateDrawableRequest { } /// Opcode for the DestroyDrawable request pub const DESTROY_DRAWABLE_REQUEST: u8 = 4; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DestroyDrawableRequest { pub drawable: xproto::Drawable, } impl_debug_if_no_extra_traits!(DestroyDrawableRequest, "DestroyDrawableRequest"); impl DestroyDrawableRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let mut request0 = vec![ major_opcode, DESTROY_DRAWABLE_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != DESTROY_DRAWABLE_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = xproto::Drawable::try_parse(value)?; let _ = remaining; Ok(DestroyDrawableRequest { drawable, }) } } impl Request for DestroyDrawableRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for DestroyDrawableRequest { } /// Opcode for the GetBuffers request pub const GET_BUFFERS_REQUEST: u8 = 5; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetBuffersRequest<'input> { pub drawable: xproto::Drawable, pub count: u32, pub attachments: Cow<'input, [u32]>, } impl_debug_if_no_extra_traits!(GetBuffersRequest<'_>, "GetBuffersRequest"); impl<'input> GetBuffersRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let count_bytes = self.count.serialize(); let mut request0 = vec![ major_opcode, GET_BUFFERS_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], count_bytes[0], count_bytes[1], count_bytes[2], count_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let attachments_bytes = self.attachments.serialize(); let length_so_far = length_so_far + attachments_bytes.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), attachments_bytes.into(), padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != GET_BUFFERS_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = xproto::Drawable::try_parse(value)?; let (count, remaining) = u32::try_parse(remaining)?; let mut remaining = remaining; // Length is 'everything left in the input' let mut attachments = Vec::new(); while !remaining.is_empty() { let (v, new_remaining) = u32::try_parse(remaining)?; remaining = new_remaining; attachments.push(v); } let _ = remaining; Ok(GetBuffersRequest { drawable, count, attachments: Cow::Owned(attachments), }) } /// Clone all borrowed data in this GetBuffersRequest. pub fn into_owned(self) -> GetBuffersRequest<'static> { GetBuffersRequest { drawable: self.drawable, count: self.count, attachments: Cow::Owned(self.attachments.into_owned()), } } } impl<'input> Request for GetBuffersRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::ReplyRequest for GetBuffersRequest<'input> { type Reply = GetBuffersReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetBuffersReply { pub sequence: u16, pub length: u32, pub width: u32, pub height: u32, pub buffers: Vec, } impl_debug_if_no_extra_traits!(GetBuffersReply, "GetBuffersReply"); impl TryParse for GetBuffersReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (width, remaining) = u32::try_parse(remaining)?; let (height, remaining) = u32::try_parse(remaining)?; let (count, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (buffers, remaining) = crate::x11_utils::parse_list::(remaining, count.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetBuffersReply { sequence, length, width, height, buffers }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetBuffersReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.width.serialize_into(bytes); self.height.serialize_into(bytes); let count = u32::try_from(self.buffers.len()).expect("`buffers` has too many elements"); count.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.buffers.serialize_into(bytes); } } impl GetBuffersReply { /// Get the value of the `count` field. /// /// The `count` field is used as the length field of the `buffers` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn count(&self) -> u32 { self.buffers.len() .try_into().unwrap() } } /// Opcode for the CopyRegion request pub const COPY_REGION_REQUEST: u8 = 6; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CopyRegionRequest { pub drawable: xproto::Drawable, pub region: u32, pub dest: u32, pub src: u32, } impl_debug_if_no_extra_traits!(CopyRegionRequest, "CopyRegionRequest"); impl CopyRegionRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let region_bytes = self.region.serialize(); let dest_bytes = self.dest.serialize(); let src_bytes = self.src.serialize(); let mut request0 = vec![ major_opcode, COPY_REGION_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], region_bytes[0], region_bytes[1], region_bytes[2], region_bytes[3], dest_bytes[0], dest_bytes[1], dest_bytes[2], dest_bytes[3], src_bytes[0], src_bytes[1], src_bytes[2], src_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != COPY_REGION_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = xproto::Drawable::try_parse(value)?; let (region, remaining) = u32::try_parse(remaining)?; let (dest, remaining) = u32::try_parse(remaining)?; let (src, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(CopyRegionRequest { drawable, region, dest, src, }) } } impl Request for CopyRegionRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for CopyRegionRequest { type Reply = CopyRegionReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CopyRegionReply { pub sequence: u16, pub length: u32, } impl_debug_if_no_extra_traits!(CopyRegionReply, "CopyRegionReply"); impl TryParse for CopyRegionReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = CopyRegionReply { sequence, length }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for CopyRegionReply { type Bytes = [u8; 8]; fn serialize(&self) -> [u8; 8] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(8); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); } } /// Opcode for the GetBuffersWithFormat request pub const GET_BUFFERS_WITH_FORMAT_REQUEST: u8 = 7; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetBuffersWithFormatRequest<'input> { pub drawable: xproto::Drawable, pub count: u32, pub attachments: Cow<'input, [AttachFormat]>, } impl_debug_if_no_extra_traits!(GetBuffersWithFormatRequest<'_>, "GetBuffersWithFormatRequest"); impl<'input> GetBuffersWithFormatRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let count_bytes = self.count.serialize(); let mut request0 = vec![ major_opcode, GET_BUFFERS_WITH_FORMAT_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], count_bytes[0], count_bytes[1], count_bytes[2], count_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let attachments_bytes = self.attachments.serialize(); let length_so_far = length_so_far + attachments_bytes.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), attachments_bytes.into(), padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != GET_BUFFERS_WITH_FORMAT_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = xproto::Drawable::try_parse(value)?; let (count, remaining) = u32::try_parse(remaining)?; let mut remaining = remaining; // Length is 'everything left in the input' let mut attachments = Vec::new(); while !remaining.is_empty() { let (v, new_remaining) = AttachFormat::try_parse(remaining)?; remaining = new_remaining; attachments.push(v); } let _ = remaining; Ok(GetBuffersWithFormatRequest { drawable, count, attachments: Cow::Owned(attachments), }) } /// Clone all borrowed data in this GetBuffersWithFormatRequest. pub fn into_owned(self) -> GetBuffersWithFormatRequest<'static> { GetBuffersWithFormatRequest { drawable: self.drawable, count: self.count, attachments: Cow::Owned(self.attachments.into_owned()), } } } impl<'input> Request for GetBuffersWithFormatRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::ReplyRequest for GetBuffersWithFormatRequest<'input> { type Reply = GetBuffersWithFormatReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetBuffersWithFormatReply { pub sequence: u16, pub length: u32, pub width: u32, pub height: u32, pub buffers: Vec, } impl_debug_if_no_extra_traits!(GetBuffersWithFormatReply, "GetBuffersWithFormatReply"); impl TryParse for GetBuffersWithFormatReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (width, remaining) = u32::try_parse(remaining)?; let (height, remaining) = u32::try_parse(remaining)?; let (count, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (buffers, remaining) = crate::x11_utils::parse_list::(remaining, count.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetBuffersWithFormatReply { sequence, length, width, height, buffers }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetBuffersWithFormatReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.width.serialize_into(bytes); self.height.serialize_into(bytes); let count = u32::try_from(self.buffers.len()).expect("`buffers` has too many elements"); count.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.buffers.serialize_into(bytes); } } impl GetBuffersWithFormatReply { /// Get the value of the `count` field. /// /// The `count` field is used as the length field of the `buffers` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn count(&self) -> u32 { self.buffers.len() .try_into().unwrap() } } /// Opcode for the SwapBuffers request pub const SWAP_BUFFERS_REQUEST: u8 = 8; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SwapBuffersRequest { pub drawable: xproto::Drawable, pub target_msc_hi: u32, pub target_msc_lo: u32, pub divisor_hi: u32, pub divisor_lo: u32, pub remainder_hi: u32, pub remainder_lo: u32, } impl_debug_if_no_extra_traits!(SwapBuffersRequest, "SwapBuffersRequest"); impl SwapBuffersRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let target_msc_hi_bytes = self.target_msc_hi.serialize(); let target_msc_lo_bytes = self.target_msc_lo.serialize(); let divisor_hi_bytes = self.divisor_hi.serialize(); let divisor_lo_bytes = self.divisor_lo.serialize(); let remainder_hi_bytes = self.remainder_hi.serialize(); let remainder_lo_bytes = self.remainder_lo.serialize(); let mut request0 = vec![ major_opcode, SWAP_BUFFERS_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], target_msc_hi_bytes[0], target_msc_hi_bytes[1], target_msc_hi_bytes[2], target_msc_hi_bytes[3], target_msc_lo_bytes[0], target_msc_lo_bytes[1], target_msc_lo_bytes[2], target_msc_lo_bytes[3], divisor_hi_bytes[0], divisor_hi_bytes[1], divisor_hi_bytes[2], divisor_hi_bytes[3], divisor_lo_bytes[0], divisor_lo_bytes[1], divisor_lo_bytes[2], divisor_lo_bytes[3], remainder_hi_bytes[0], remainder_hi_bytes[1], remainder_hi_bytes[2], remainder_hi_bytes[3], remainder_lo_bytes[0], remainder_lo_bytes[1], remainder_lo_bytes[2], remainder_lo_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != SWAP_BUFFERS_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = xproto::Drawable::try_parse(value)?; let (target_msc_hi, remaining) = u32::try_parse(remaining)?; let (target_msc_lo, remaining) = u32::try_parse(remaining)?; let (divisor_hi, remaining) = u32::try_parse(remaining)?; let (divisor_lo, remaining) = u32::try_parse(remaining)?; let (remainder_hi, remaining) = u32::try_parse(remaining)?; let (remainder_lo, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(SwapBuffersRequest { drawable, target_msc_hi, target_msc_lo, divisor_hi, divisor_lo, remainder_hi, remainder_lo, }) } } impl Request for SwapBuffersRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for SwapBuffersRequest { type Reply = SwapBuffersReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SwapBuffersReply { pub sequence: u16, pub length: u32, pub swap_hi: u32, pub swap_lo: u32, } impl_debug_if_no_extra_traits!(SwapBuffersReply, "SwapBuffersReply"); impl TryParse for SwapBuffersReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (swap_hi, remaining) = u32::try_parse(remaining)?; let (swap_lo, remaining) = u32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = SwapBuffersReply { sequence, length, swap_hi, swap_lo }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for SwapBuffersReply { type Bytes = [u8; 16]; fn serialize(&self) -> [u8; 16] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let swap_hi_bytes = self.swap_hi.serialize(); let swap_lo_bytes = self.swap_lo.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], swap_hi_bytes[0], swap_hi_bytes[1], swap_hi_bytes[2], swap_hi_bytes[3], swap_lo_bytes[0], swap_lo_bytes[1], swap_lo_bytes[2], swap_lo_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(16); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.swap_hi.serialize_into(bytes); self.swap_lo.serialize_into(bytes); } } /// Opcode for the GetMSC request pub const GET_MSC_REQUEST: u8 = 9; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMSCRequest { pub drawable: xproto::Drawable, } impl_debug_if_no_extra_traits!(GetMSCRequest, "GetMSCRequest"); impl GetMSCRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let mut request0 = vec![ major_opcode, GET_MSC_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_MSC_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = xproto::Drawable::try_parse(value)?; let _ = remaining; Ok(GetMSCRequest { drawable, }) } } impl Request for GetMSCRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetMSCRequest { type Reply = GetMSCReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMSCReply { pub sequence: u16, pub length: u32, pub ust_hi: u32, pub ust_lo: u32, pub msc_hi: u32, pub msc_lo: u32, pub sbc_hi: u32, pub sbc_lo: u32, } impl_debug_if_no_extra_traits!(GetMSCReply, "GetMSCReply"); impl TryParse for GetMSCReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (ust_hi, remaining) = u32::try_parse(remaining)?; let (ust_lo, remaining) = u32::try_parse(remaining)?; let (msc_hi, remaining) = u32::try_parse(remaining)?; let (msc_lo, remaining) = u32::try_parse(remaining)?; let (sbc_hi, remaining) = u32::try_parse(remaining)?; let (sbc_lo, remaining) = u32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetMSCReply { sequence, length, ust_hi, ust_lo, msc_hi, msc_lo, sbc_hi, sbc_lo }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetMSCReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let ust_hi_bytes = self.ust_hi.serialize(); let ust_lo_bytes = self.ust_lo.serialize(); let msc_hi_bytes = self.msc_hi.serialize(); let msc_lo_bytes = self.msc_lo.serialize(); let sbc_hi_bytes = self.sbc_hi.serialize(); let sbc_lo_bytes = self.sbc_lo.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], ust_hi_bytes[0], ust_hi_bytes[1], ust_hi_bytes[2], ust_hi_bytes[3], ust_lo_bytes[0], ust_lo_bytes[1], ust_lo_bytes[2], ust_lo_bytes[3], msc_hi_bytes[0], msc_hi_bytes[1], msc_hi_bytes[2], msc_hi_bytes[3], msc_lo_bytes[0], msc_lo_bytes[1], msc_lo_bytes[2], msc_lo_bytes[3], sbc_hi_bytes[0], sbc_hi_bytes[1], sbc_hi_bytes[2], sbc_hi_bytes[3], sbc_lo_bytes[0], sbc_lo_bytes[1], sbc_lo_bytes[2], sbc_lo_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.ust_hi.serialize_into(bytes); self.ust_lo.serialize_into(bytes); self.msc_hi.serialize_into(bytes); self.msc_lo.serialize_into(bytes); self.sbc_hi.serialize_into(bytes); self.sbc_lo.serialize_into(bytes); } } /// Opcode for the WaitMSC request pub const WAIT_MSC_REQUEST: u8 = 10; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WaitMSCRequest { pub drawable: xproto::Drawable, pub target_msc_hi: u32, pub target_msc_lo: u32, pub divisor_hi: u32, pub divisor_lo: u32, pub remainder_hi: u32, pub remainder_lo: u32, } impl_debug_if_no_extra_traits!(WaitMSCRequest, "WaitMSCRequest"); impl WaitMSCRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let target_msc_hi_bytes = self.target_msc_hi.serialize(); let target_msc_lo_bytes = self.target_msc_lo.serialize(); let divisor_hi_bytes = self.divisor_hi.serialize(); let divisor_lo_bytes = self.divisor_lo.serialize(); let remainder_hi_bytes = self.remainder_hi.serialize(); let remainder_lo_bytes = self.remainder_lo.serialize(); let mut request0 = vec![ major_opcode, WAIT_MSC_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], target_msc_hi_bytes[0], target_msc_hi_bytes[1], target_msc_hi_bytes[2], target_msc_hi_bytes[3], target_msc_lo_bytes[0], target_msc_lo_bytes[1], target_msc_lo_bytes[2], target_msc_lo_bytes[3], divisor_hi_bytes[0], divisor_hi_bytes[1], divisor_hi_bytes[2], divisor_hi_bytes[3], divisor_lo_bytes[0], divisor_lo_bytes[1], divisor_lo_bytes[2], divisor_lo_bytes[3], remainder_hi_bytes[0], remainder_hi_bytes[1], remainder_hi_bytes[2], remainder_hi_bytes[3], remainder_lo_bytes[0], remainder_lo_bytes[1], remainder_lo_bytes[2], remainder_lo_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != WAIT_MSC_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = xproto::Drawable::try_parse(value)?; let (target_msc_hi, remaining) = u32::try_parse(remaining)?; let (target_msc_lo, remaining) = u32::try_parse(remaining)?; let (divisor_hi, remaining) = u32::try_parse(remaining)?; let (divisor_lo, remaining) = u32::try_parse(remaining)?; let (remainder_hi, remaining) = u32::try_parse(remaining)?; let (remainder_lo, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(WaitMSCRequest { drawable, target_msc_hi, target_msc_lo, divisor_hi, divisor_lo, remainder_hi, remainder_lo, }) } } impl Request for WaitMSCRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for WaitMSCRequest { type Reply = WaitMSCReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WaitMSCReply { pub sequence: u16, pub length: u32, pub ust_hi: u32, pub ust_lo: u32, pub msc_hi: u32, pub msc_lo: u32, pub sbc_hi: u32, pub sbc_lo: u32, } impl_debug_if_no_extra_traits!(WaitMSCReply, "WaitMSCReply"); impl TryParse for WaitMSCReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (ust_hi, remaining) = u32::try_parse(remaining)?; let (ust_lo, remaining) = u32::try_parse(remaining)?; let (msc_hi, remaining) = u32::try_parse(remaining)?; let (msc_lo, remaining) = u32::try_parse(remaining)?; let (sbc_hi, remaining) = u32::try_parse(remaining)?; let (sbc_lo, remaining) = u32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = WaitMSCReply { sequence, length, ust_hi, ust_lo, msc_hi, msc_lo, sbc_hi, sbc_lo }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for WaitMSCReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let ust_hi_bytes = self.ust_hi.serialize(); let ust_lo_bytes = self.ust_lo.serialize(); let msc_hi_bytes = self.msc_hi.serialize(); let msc_lo_bytes = self.msc_lo.serialize(); let sbc_hi_bytes = self.sbc_hi.serialize(); let sbc_lo_bytes = self.sbc_lo.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], ust_hi_bytes[0], ust_hi_bytes[1], ust_hi_bytes[2], ust_hi_bytes[3], ust_lo_bytes[0], ust_lo_bytes[1], ust_lo_bytes[2], ust_lo_bytes[3], msc_hi_bytes[0], msc_hi_bytes[1], msc_hi_bytes[2], msc_hi_bytes[3], msc_lo_bytes[0], msc_lo_bytes[1], msc_lo_bytes[2], msc_lo_bytes[3], sbc_hi_bytes[0], sbc_hi_bytes[1], sbc_hi_bytes[2], sbc_hi_bytes[3], sbc_lo_bytes[0], sbc_lo_bytes[1], sbc_lo_bytes[2], sbc_lo_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.ust_hi.serialize_into(bytes); self.ust_lo.serialize_into(bytes); self.msc_hi.serialize_into(bytes); self.msc_lo.serialize_into(bytes); self.sbc_hi.serialize_into(bytes); self.sbc_lo.serialize_into(bytes); } } /// Opcode for the WaitSBC request pub const WAIT_SBC_REQUEST: u8 = 11; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WaitSBCRequest { pub drawable: xproto::Drawable, pub target_sbc_hi: u32, pub target_sbc_lo: u32, } impl_debug_if_no_extra_traits!(WaitSBCRequest, "WaitSBCRequest"); impl WaitSBCRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let target_sbc_hi_bytes = self.target_sbc_hi.serialize(); let target_sbc_lo_bytes = self.target_sbc_lo.serialize(); let mut request0 = vec![ major_opcode, WAIT_SBC_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], target_sbc_hi_bytes[0], target_sbc_hi_bytes[1], target_sbc_hi_bytes[2], target_sbc_hi_bytes[3], target_sbc_lo_bytes[0], target_sbc_lo_bytes[1], target_sbc_lo_bytes[2], target_sbc_lo_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != WAIT_SBC_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = xproto::Drawable::try_parse(value)?; let (target_sbc_hi, remaining) = u32::try_parse(remaining)?; let (target_sbc_lo, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(WaitSBCRequest { drawable, target_sbc_hi, target_sbc_lo, }) } } impl Request for WaitSBCRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for WaitSBCRequest { type Reply = WaitSBCReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WaitSBCReply { pub sequence: u16, pub length: u32, pub ust_hi: u32, pub ust_lo: u32, pub msc_hi: u32, pub msc_lo: u32, pub sbc_hi: u32, pub sbc_lo: u32, } impl_debug_if_no_extra_traits!(WaitSBCReply, "WaitSBCReply"); impl TryParse for WaitSBCReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (ust_hi, remaining) = u32::try_parse(remaining)?; let (ust_lo, remaining) = u32::try_parse(remaining)?; let (msc_hi, remaining) = u32::try_parse(remaining)?; let (msc_lo, remaining) = u32::try_parse(remaining)?; let (sbc_hi, remaining) = u32::try_parse(remaining)?; let (sbc_lo, remaining) = u32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = WaitSBCReply { sequence, length, ust_hi, ust_lo, msc_hi, msc_lo, sbc_hi, sbc_lo }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for WaitSBCReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let ust_hi_bytes = self.ust_hi.serialize(); let ust_lo_bytes = self.ust_lo.serialize(); let msc_hi_bytes = self.msc_hi.serialize(); let msc_lo_bytes = self.msc_lo.serialize(); let sbc_hi_bytes = self.sbc_hi.serialize(); let sbc_lo_bytes = self.sbc_lo.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], ust_hi_bytes[0], ust_hi_bytes[1], ust_hi_bytes[2], ust_hi_bytes[3], ust_lo_bytes[0], ust_lo_bytes[1], ust_lo_bytes[2], ust_lo_bytes[3], msc_hi_bytes[0], msc_hi_bytes[1], msc_hi_bytes[2], msc_hi_bytes[3], msc_lo_bytes[0], msc_lo_bytes[1], msc_lo_bytes[2], msc_lo_bytes[3], sbc_hi_bytes[0], sbc_hi_bytes[1], sbc_hi_bytes[2], sbc_hi_bytes[3], sbc_lo_bytes[0], sbc_lo_bytes[1], sbc_lo_bytes[2], sbc_lo_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.ust_hi.serialize_into(bytes); self.ust_lo.serialize_into(bytes); self.msc_hi.serialize_into(bytes); self.msc_lo.serialize_into(bytes); self.sbc_hi.serialize_into(bytes); self.sbc_lo.serialize_into(bytes); } } /// Opcode for the SwapInterval request pub const SWAP_INTERVAL_REQUEST: u8 = 12; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SwapIntervalRequest { pub drawable: xproto::Drawable, pub interval: u32, } impl_debug_if_no_extra_traits!(SwapIntervalRequest, "SwapIntervalRequest"); impl SwapIntervalRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let interval_bytes = self.interval.serialize(); let mut request0 = vec![ major_opcode, SWAP_INTERVAL_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], interval_bytes[0], interval_bytes[1], interval_bytes[2], interval_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != SWAP_INTERVAL_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = xproto::Drawable::try_parse(value)?; let (interval, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(SwapIntervalRequest { drawable, interval, }) } } impl Request for SwapIntervalRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for SwapIntervalRequest { } /// Opcode for the GetParam request pub const GET_PARAM_REQUEST: u8 = 13; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetParamRequest { pub drawable: xproto::Drawable, pub param: u32, } impl_debug_if_no_extra_traits!(GetParamRequest, "GetParamRequest"); impl GetParamRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let param_bytes = self.param.serialize(); let mut request0 = vec![ major_opcode, GET_PARAM_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], param_bytes[0], param_bytes[1], param_bytes[2], param_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_PARAM_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = xproto::Drawable::try_parse(value)?; let (param, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetParamRequest { drawable, param, }) } } impl Request for GetParamRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetParamRequest { type Reply = GetParamReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetParamReply { pub is_param_recognized: bool, pub sequence: u16, pub length: u32, pub value_hi: u32, pub value_lo: u32, } impl_debug_if_no_extra_traits!(GetParamReply, "GetParamReply"); impl TryParse for GetParamReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let (is_param_recognized, remaining) = bool::try_parse(remaining)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (value_hi, remaining) = u32::try_parse(remaining)?; let (value_lo, remaining) = u32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetParamReply { is_param_recognized, sequence, length, value_hi, value_lo }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetParamReply { type Bytes = [u8; 16]; fn serialize(&self) -> [u8; 16] { let response_type_bytes = &[1]; let is_param_recognized_bytes = self.is_param_recognized.serialize(); let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let value_hi_bytes = self.value_hi.serialize(); let value_lo_bytes = self.value_lo.serialize(); [ response_type_bytes[0], is_param_recognized_bytes[0], sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], value_hi_bytes[0], value_hi_bytes[1], value_hi_bytes[2], value_hi_bytes[3], value_lo_bytes[0], value_lo_bytes[1], value_lo_bytes[2], value_lo_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(16); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); self.is_param_recognized.serialize_into(bytes); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.value_hi.serialize_into(bytes); self.value_lo.serialize_into(bytes); } } /// Opcode for the BufferSwapComplete event pub const BUFFER_SWAP_COMPLETE_EVENT: u8 = 0; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct BufferSwapCompleteEvent { pub response_type: u8, pub sequence: u16, pub event_type: EventType, pub drawable: xproto::Drawable, pub ust_hi: u32, pub ust_lo: u32, pub msc_hi: u32, pub msc_lo: u32, pub sbc: u32, } impl_debug_if_no_extra_traits!(BufferSwapCompleteEvent, "BufferSwapCompleteEvent"); impl TryParse for BufferSwapCompleteEvent { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (event_type, remaining) = u16::try_parse(remaining)?; let remaining = remaining.get(2..).ok_or(ParseError::InsufficientData)?; let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?; let (ust_hi, remaining) = u32::try_parse(remaining)?; let (ust_lo, remaining) = u32::try_parse(remaining)?; let (msc_hi, remaining) = u32::try_parse(remaining)?; let (msc_lo, remaining) = u32::try_parse(remaining)?; let (sbc, remaining) = u32::try_parse(remaining)?; let event_type = event_type.into(); let result = BufferSwapCompleteEvent { response_type, sequence, event_type, drawable, ust_hi, ust_lo, msc_hi, msc_lo, sbc }; let _ = remaining; let remaining = initial_value.get(32..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for BufferSwapCompleteEvent { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = self.response_type.serialize(); let sequence_bytes = self.sequence.serialize(); let event_type_bytes = u16::from(self.event_type).serialize(); let drawable_bytes = self.drawable.serialize(); let ust_hi_bytes = self.ust_hi.serialize(); let ust_lo_bytes = self.ust_lo.serialize(); let msc_hi_bytes = self.msc_hi.serialize(); let msc_lo_bytes = self.msc_lo.serialize(); let sbc_bytes = self.sbc.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], event_type_bytes[0], event_type_bytes[1], 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], ust_hi_bytes[0], ust_hi_bytes[1], ust_hi_bytes[2], ust_hi_bytes[3], ust_lo_bytes[0], ust_lo_bytes[1], ust_lo_bytes[2], ust_lo_bytes[3], msc_hi_bytes[0], msc_hi_bytes[1], msc_hi_bytes[2], msc_hi_bytes[3], msc_lo_bytes[0], msc_lo_bytes[1], msc_lo_bytes[2], msc_lo_bytes[3], sbc_bytes[0], sbc_bytes[1], sbc_bytes[2], sbc_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); self.response_type.serialize_into(bytes); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); u16::from(self.event_type).serialize_into(bytes); bytes.extend_from_slice(&[0; 2]); self.drawable.serialize_into(bytes); self.ust_hi.serialize_into(bytes); self.ust_lo.serialize_into(bytes); self.msc_hi.serialize_into(bytes); self.msc_lo.serialize_into(bytes); self.sbc.serialize_into(bytes); } } impl From<&BufferSwapCompleteEvent> for [u8; 32] { fn from(input: &BufferSwapCompleteEvent) -> Self { let response_type_bytes = input.response_type.serialize(); let sequence_bytes = input.sequence.serialize(); let event_type_bytes = u16::from(input.event_type).serialize(); let drawable_bytes = input.drawable.serialize(); let ust_hi_bytes = input.ust_hi.serialize(); let ust_lo_bytes = input.ust_lo.serialize(); let msc_hi_bytes = input.msc_hi.serialize(); let msc_lo_bytes = input.msc_lo.serialize(); let sbc_bytes = input.sbc.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], event_type_bytes[0], event_type_bytes[1], 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], ust_hi_bytes[0], ust_hi_bytes[1], ust_hi_bytes[2], ust_hi_bytes[3], ust_lo_bytes[0], ust_lo_bytes[1], ust_lo_bytes[2], ust_lo_bytes[3], msc_hi_bytes[0], msc_hi_bytes[1], msc_hi_bytes[2], msc_hi_bytes[3], msc_lo_bytes[0], msc_lo_bytes[1], msc_lo_bytes[2], msc_lo_bytes[3], sbc_bytes[0], sbc_bytes[1], sbc_bytes[2], sbc_bytes[3], ] } } impl From for [u8; 32] { fn from(input: BufferSwapCompleteEvent) -> Self { Self::from(&input) } } /// Opcode for the InvalidateBuffers event pub const INVALIDATE_BUFFERS_EVENT: u8 = 1; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct InvalidateBuffersEvent { pub response_type: u8, pub sequence: u16, pub drawable: xproto::Drawable, } impl_debug_if_no_extra_traits!(InvalidateBuffersEvent, "InvalidateBuffersEvent"); impl TryParse for InvalidateBuffersEvent { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?; let result = InvalidateBuffersEvent { response_type, sequence, drawable }; let _ = remaining; let remaining = initial_value.get(32..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for InvalidateBuffersEvent { type Bytes = [u8; 8]; fn serialize(&self) -> [u8; 8] { let response_type_bytes = self.response_type.serialize(); let sequence_bytes = self.sequence.serialize(); let drawable_bytes = self.drawable.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(8); self.response_type.serialize_into(bytes); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.drawable.serialize_into(bytes); } } impl From<&InvalidateBuffersEvent> for [u8; 32] { fn from(input: &InvalidateBuffersEvent) -> Self { let response_type_bytes = input.response_type.serialize(); let sequence_bytes = input.sequence.serialize(); let drawable_bytes = input.drawable.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], // trailing padding 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } } impl From for [u8; 32] { fn from(input: InvalidateBuffersEvent) -> Self { Self::from(&input) } } x11rb-protocol-0.13.1/src/protocol/dri3.rs000064400000000000000000001563131046102023000163520ustar 00000000000000// This file contains generated code. Do not edit directly. // To regenerate this, run 'make'. //! Bindings to the `DRI3` X11 extension. #![allow(clippy::too_many_arguments)] // The code generator is simpler if it can always use conversions #![allow(clippy::useless_conversion)] #[allow(unused_imports)] use alloc::borrow::Cow; #[allow(unused_imports)] use core::convert::TryInto; use alloc::vec; use alloc::vec::Vec; use core::convert::TryFrom; use crate::errors::ParseError; #[allow(unused_imports)] use crate::x11_utils::TryIntoUSize; use crate::BufWithFds; #[allow(unused_imports)] use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; #[allow(unused_imports)] use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; #[allow(unused_imports)] use super::xproto; /// The X11 name of the extension for QueryExtension pub const X11_EXTENSION_NAME: &str = "DRI3"; /// The version number of this extension that this client library supports. /// /// This constant contains the version number of this extension that is supported /// by this build of x11rb. For most things, it does not make sense to use this /// information. If you need to send a `QueryVersion`, it is recommended to instead /// send the maximum version of the extension that you need. pub const X11_XML_VERSION: (u32, u32) = (1, 4); pub type Syncobj = u32; /// Opcode for the QueryVersion request pub const QUERY_VERSION_REQUEST: u8 = 0; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryVersionRequest { pub major_version: u32, pub minor_version: u32, } impl_debug_if_no_extra_traits!(QueryVersionRequest, "QueryVersionRequest"); impl QueryVersionRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let major_version_bytes = self.major_version.serialize(); let minor_version_bytes = self.minor_version.serialize(); let mut request0 = vec![ major_opcode, QUERY_VERSION_REQUEST, 0, 0, major_version_bytes[0], major_version_bytes[1], major_version_bytes[2], major_version_bytes[3], minor_version_bytes[0], minor_version_bytes[1], minor_version_bytes[2], minor_version_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != QUERY_VERSION_REQUEST { return Err(ParseError::InvalidValue); } let (major_version, remaining) = u32::try_parse(value)?; let (minor_version, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(QueryVersionRequest { major_version, minor_version, }) } } impl Request for QueryVersionRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for QueryVersionRequest { type Reply = QueryVersionReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryVersionReply { pub sequence: u16, pub length: u32, pub major_version: u32, pub minor_version: u32, } impl_debug_if_no_extra_traits!(QueryVersionReply, "QueryVersionReply"); impl TryParse for QueryVersionReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (major_version, remaining) = u32::try_parse(remaining)?; let (minor_version, remaining) = u32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = QueryVersionReply { sequence, length, major_version, minor_version }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for QueryVersionReply { type Bytes = [u8; 16]; fn serialize(&self) -> [u8; 16] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let major_version_bytes = self.major_version.serialize(); let minor_version_bytes = self.minor_version.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], major_version_bytes[0], major_version_bytes[1], major_version_bytes[2], major_version_bytes[3], minor_version_bytes[0], minor_version_bytes[1], minor_version_bytes[2], minor_version_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(16); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.major_version.serialize_into(bytes); self.minor_version.serialize_into(bytes); } } /// Opcode for the Open request pub const OPEN_REQUEST: u8 = 1; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct OpenRequest { pub drawable: xproto::Drawable, pub provider: u32, } impl_debug_if_no_extra_traits!(OpenRequest, "OpenRequest"); impl OpenRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let provider_bytes = self.provider.serialize(); let mut request0 = vec![ major_opcode, OPEN_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], provider_bytes[0], provider_bytes[1], provider_bytes[2], provider_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != OPEN_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = xproto::Drawable::try_parse(value)?; let (provider, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(OpenRequest { drawable, provider, }) } } impl Request for OpenRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyFDsRequest for OpenRequest { type Reply = OpenReply; } #[cfg_attr(feature = "extra-traits", derive(Debug))] pub struct OpenReply { pub nfd: u8, pub sequence: u16, pub length: u32, pub device_fd: RawFdContainer, } impl_debug_if_no_extra_traits!(OpenReply, "OpenReply"); impl TryParseFd for OpenReply { fn try_parse_fd<'a>(initial_value: &'a [u8], fds: &mut Vec) -> Result<(Self, &'a [u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let (nfd, remaining) = u8::try_parse(remaining)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; if fds.is_empty() { return Err(ParseError::MissingFileDescriptors) } let device_fd = fds.remove(0); let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = OpenReply { nfd, sequence, length, device_fd }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for OpenReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let nfd_bytes = self.nfd.serialize(); let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); [ response_type_bytes[0], nfd_bytes[0], sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); self.nfd.serialize_into(bytes); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 24]); } } /// Opcode for the PixmapFromBuffer request pub const PIXMAP_FROM_BUFFER_REQUEST: u8 = 2; #[cfg_attr(feature = "extra-traits", derive(Debug))] pub struct PixmapFromBufferRequest { pub pixmap: xproto::Pixmap, pub drawable: xproto::Drawable, pub size: u32, pub width: u16, pub height: u16, pub stride: u16, pub depth: u8, pub bpp: u8, pub pixmap_fd: RawFdContainer, } impl_debug_if_no_extra_traits!(PixmapFromBufferRequest, "PixmapFromBufferRequest"); impl PixmapFromBufferRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let pixmap_bytes = self.pixmap.serialize(); let drawable_bytes = self.drawable.serialize(); let size_bytes = self.size.serialize(); let width_bytes = self.width.serialize(); let height_bytes = self.height.serialize(); let stride_bytes = self.stride.serialize(); let depth_bytes = self.depth.serialize(); let bpp_bytes = self.bpp.serialize(); let mut request0 = vec![ major_opcode, PIXMAP_FROM_BUFFER_REQUEST, 0, 0, pixmap_bytes[0], pixmap_bytes[1], pixmap_bytes[2], pixmap_bytes[3], drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], size_bytes[0], size_bytes[1], size_bytes[2], size_bytes[3], width_bytes[0], width_bytes[1], height_bytes[0], height_bytes[1], stride_bytes[0], stride_bytes[1], depth_bytes[0], bpp_bytes[0], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![self.pixmap_fd]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request_fd(header: RequestHeader, value: &[u8], fds: &mut Vec) -> Result { if header.minor_opcode != PIXMAP_FROM_BUFFER_REQUEST { return Err(ParseError::InvalidValue); } let (pixmap, remaining) = xproto::Pixmap::try_parse(value)?; let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?; let (size, remaining) = u32::try_parse(remaining)?; let (width, remaining) = u16::try_parse(remaining)?; let (height, remaining) = u16::try_parse(remaining)?; let (stride, remaining) = u16::try_parse(remaining)?; let (depth, remaining) = u8::try_parse(remaining)?; let (bpp, remaining) = u8::try_parse(remaining)?; if fds.is_empty() { return Err(ParseError::MissingFileDescriptors) } let pixmap_fd = fds.remove(0); let _ = remaining; Ok(PixmapFromBufferRequest { pixmap, drawable, size, width, height, stride, depth, bpp, pixmap_fd, }) } } impl Request for PixmapFromBufferRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for PixmapFromBufferRequest { } /// Opcode for the BufferFromPixmap request pub const BUFFER_FROM_PIXMAP_REQUEST: u8 = 3; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct BufferFromPixmapRequest { pub pixmap: xproto::Pixmap, } impl_debug_if_no_extra_traits!(BufferFromPixmapRequest, "BufferFromPixmapRequest"); impl BufferFromPixmapRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let pixmap_bytes = self.pixmap.serialize(); let mut request0 = vec![ major_opcode, BUFFER_FROM_PIXMAP_REQUEST, 0, 0, pixmap_bytes[0], pixmap_bytes[1], pixmap_bytes[2], pixmap_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != BUFFER_FROM_PIXMAP_REQUEST { return Err(ParseError::InvalidValue); } let (pixmap, remaining) = xproto::Pixmap::try_parse(value)?; let _ = remaining; Ok(BufferFromPixmapRequest { pixmap, }) } } impl Request for BufferFromPixmapRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyFDsRequest for BufferFromPixmapRequest { type Reply = BufferFromPixmapReply; } #[cfg_attr(feature = "extra-traits", derive(Debug))] pub struct BufferFromPixmapReply { pub nfd: u8, pub sequence: u16, pub length: u32, pub size: u32, pub width: u16, pub height: u16, pub stride: u16, pub depth: u8, pub bpp: u8, pub pixmap_fd: RawFdContainer, } impl_debug_if_no_extra_traits!(BufferFromPixmapReply, "BufferFromPixmapReply"); impl TryParseFd for BufferFromPixmapReply { fn try_parse_fd<'a>(initial_value: &'a [u8], fds: &mut Vec) -> Result<(Self, &'a [u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let (nfd, remaining) = u8::try_parse(remaining)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (size, remaining) = u32::try_parse(remaining)?; let (width, remaining) = u16::try_parse(remaining)?; let (height, remaining) = u16::try_parse(remaining)?; let (stride, remaining) = u16::try_parse(remaining)?; let (depth, remaining) = u8::try_parse(remaining)?; let (bpp, remaining) = u8::try_parse(remaining)?; if fds.is_empty() { return Err(ParseError::MissingFileDescriptors) } let pixmap_fd = fds.remove(0); let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = BufferFromPixmapReply { nfd, sequence, length, size, width, height, stride, depth, bpp, pixmap_fd }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for BufferFromPixmapReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let nfd_bytes = self.nfd.serialize(); let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let size_bytes = self.size.serialize(); let width_bytes = self.width.serialize(); let height_bytes = self.height.serialize(); let stride_bytes = self.stride.serialize(); let depth_bytes = self.depth.serialize(); let bpp_bytes = self.bpp.serialize(); [ response_type_bytes[0], nfd_bytes[0], sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], size_bytes[0], size_bytes[1], size_bytes[2], size_bytes[3], width_bytes[0], width_bytes[1], height_bytes[0], height_bytes[1], stride_bytes[0], stride_bytes[1], depth_bytes[0], bpp_bytes[0], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); self.nfd.serialize_into(bytes); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.size.serialize_into(bytes); self.width.serialize_into(bytes); self.height.serialize_into(bytes); self.stride.serialize_into(bytes); self.depth.serialize_into(bytes); self.bpp.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); } } /// Opcode for the FenceFromFD request pub const FENCE_FROM_FD_REQUEST: u8 = 4; #[cfg_attr(feature = "extra-traits", derive(Debug))] pub struct FenceFromFDRequest { pub drawable: xproto::Drawable, pub fence: u32, pub initially_triggered: bool, pub fence_fd: RawFdContainer, } impl_debug_if_no_extra_traits!(FenceFromFDRequest, "FenceFromFDRequest"); impl FenceFromFDRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let fence_bytes = self.fence.serialize(); let initially_triggered_bytes = self.initially_triggered.serialize(); let mut request0 = vec![ major_opcode, FENCE_FROM_FD_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], fence_bytes[0], fence_bytes[1], fence_bytes[2], fence_bytes[3], initially_triggered_bytes[0], 0, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![self.fence_fd]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request_fd(header: RequestHeader, value: &[u8], fds: &mut Vec) -> Result { if header.minor_opcode != FENCE_FROM_FD_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = xproto::Drawable::try_parse(value)?; let (fence, remaining) = u32::try_parse(remaining)?; let (initially_triggered, remaining) = bool::try_parse(remaining)?; let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?; if fds.is_empty() { return Err(ParseError::MissingFileDescriptors) } let fence_fd = fds.remove(0); let _ = remaining; Ok(FenceFromFDRequest { drawable, fence, initially_triggered, fence_fd, }) } } impl Request for FenceFromFDRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for FenceFromFDRequest { } /// Opcode for the FDFromFence request pub const FD_FROM_FENCE_REQUEST: u8 = 5; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct FDFromFenceRequest { pub drawable: xproto::Drawable, pub fence: u32, } impl_debug_if_no_extra_traits!(FDFromFenceRequest, "FDFromFenceRequest"); impl FDFromFenceRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let fence_bytes = self.fence.serialize(); let mut request0 = vec![ major_opcode, FD_FROM_FENCE_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], fence_bytes[0], fence_bytes[1], fence_bytes[2], fence_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != FD_FROM_FENCE_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = xproto::Drawable::try_parse(value)?; let (fence, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(FDFromFenceRequest { drawable, fence, }) } } impl Request for FDFromFenceRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyFDsRequest for FDFromFenceRequest { type Reply = FDFromFenceReply; } #[cfg_attr(feature = "extra-traits", derive(Debug))] pub struct FDFromFenceReply { pub nfd: u8, pub sequence: u16, pub length: u32, pub fence_fd: RawFdContainer, } impl_debug_if_no_extra_traits!(FDFromFenceReply, "FDFromFenceReply"); impl TryParseFd for FDFromFenceReply { fn try_parse_fd<'a>(initial_value: &'a [u8], fds: &mut Vec) -> Result<(Self, &'a [u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let (nfd, remaining) = u8::try_parse(remaining)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; if fds.is_empty() { return Err(ParseError::MissingFileDescriptors) } let fence_fd = fds.remove(0); let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = FDFromFenceReply { nfd, sequence, length, fence_fd }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for FDFromFenceReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let nfd_bytes = self.nfd.serialize(); let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); [ response_type_bytes[0], nfd_bytes[0], sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); self.nfd.serialize_into(bytes); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 24]); } } /// Opcode for the GetSupportedModifiers request pub const GET_SUPPORTED_MODIFIERS_REQUEST: u8 = 6; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetSupportedModifiersRequest { pub window: u32, pub depth: u8, pub bpp: u8, } impl_debug_if_no_extra_traits!(GetSupportedModifiersRequest, "GetSupportedModifiersRequest"); impl GetSupportedModifiersRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let window_bytes = self.window.serialize(); let depth_bytes = self.depth.serialize(); let bpp_bytes = self.bpp.serialize(); let mut request0 = vec![ major_opcode, GET_SUPPORTED_MODIFIERS_REQUEST, 0, 0, window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], depth_bytes[0], bpp_bytes[0], 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_SUPPORTED_MODIFIERS_REQUEST { return Err(ParseError::InvalidValue); } let (window, remaining) = u32::try_parse(value)?; let (depth, remaining) = u8::try_parse(remaining)?; let (bpp, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(2..).ok_or(ParseError::InsufficientData)?; let _ = remaining; Ok(GetSupportedModifiersRequest { window, depth, bpp, }) } } impl Request for GetSupportedModifiersRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetSupportedModifiersRequest { type Reply = GetSupportedModifiersReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetSupportedModifiersReply { pub sequence: u16, pub length: u32, pub window_modifiers: Vec, pub screen_modifiers: Vec, } impl_debug_if_no_extra_traits!(GetSupportedModifiersReply, "GetSupportedModifiersReply"); impl TryParse for GetSupportedModifiersReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (num_window_modifiers, remaining) = u32::try_parse(remaining)?; let (num_screen_modifiers, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?; let (window_modifiers, remaining) = crate::x11_utils::parse_list::(remaining, num_window_modifiers.try_to_usize()?)?; let (screen_modifiers, remaining) = crate::x11_utils::parse_list::(remaining, num_screen_modifiers.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetSupportedModifiersReply { sequence, length, window_modifiers, screen_modifiers }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetSupportedModifiersReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); let num_window_modifiers = u32::try_from(self.window_modifiers.len()).expect("`window_modifiers` has too many elements"); num_window_modifiers.serialize_into(bytes); let num_screen_modifiers = u32::try_from(self.screen_modifiers.len()).expect("`screen_modifiers` has too many elements"); num_screen_modifiers.serialize_into(bytes); bytes.extend_from_slice(&[0; 16]); self.window_modifiers.serialize_into(bytes); self.screen_modifiers.serialize_into(bytes); } } impl GetSupportedModifiersReply { /// Get the value of the `num_window_modifiers` field. /// /// The `num_window_modifiers` field is used as the length field of the `window_modifiers` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn num_window_modifiers(&self) -> u32 { self.window_modifiers.len() .try_into().unwrap() } /// Get the value of the `num_screen_modifiers` field. /// /// The `num_screen_modifiers` field is used as the length field of the `screen_modifiers` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn num_screen_modifiers(&self) -> u32 { self.screen_modifiers.len() .try_into().unwrap() } } /// Opcode for the PixmapFromBuffers request pub const PIXMAP_FROM_BUFFERS_REQUEST: u8 = 7; #[cfg_attr(feature = "extra-traits", derive(Debug))] pub struct PixmapFromBuffersRequest { pub pixmap: xproto::Pixmap, pub window: xproto::Window, pub width: u16, pub height: u16, pub stride0: u32, pub offset0: u32, pub stride1: u32, pub offset1: u32, pub stride2: u32, pub offset2: u32, pub stride3: u32, pub offset3: u32, pub depth: u8, pub bpp: u8, pub modifier: u64, pub buffers: Vec, } impl_debug_if_no_extra_traits!(PixmapFromBuffersRequest, "PixmapFromBuffersRequest"); impl PixmapFromBuffersRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let pixmap_bytes = self.pixmap.serialize(); let window_bytes = self.window.serialize(); let num_buffers = u8::try_from(self.buffers.len()).expect("`buffers` has too many elements"); let num_buffers_bytes = num_buffers.serialize(); let width_bytes = self.width.serialize(); let height_bytes = self.height.serialize(); let stride0_bytes = self.stride0.serialize(); let offset0_bytes = self.offset0.serialize(); let stride1_bytes = self.stride1.serialize(); let offset1_bytes = self.offset1.serialize(); let stride2_bytes = self.stride2.serialize(); let offset2_bytes = self.offset2.serialize(); let stride3_bytes = self.stride3.serialize(); let offset3_bytes = self.offset3.serialize(); let depth_bytes = self.depth.serialize(); let bpp_bytes = self.bpp.serialize(); let modifier_bytes = self.modifier.serialize(); let mut request0 = vec![ major_opcode, PIXMAP_FROM_BUFFERS_REQUEST, 0, 0, pixmap_bytes[0], pixmap_bytes[1], pixmap_bytes[2], pixmap_bytes[3], window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], num_buffers_bytes[0], 0, 0, 0, width_bytes[0], width_bytes[1], height_bytes[0], height_bytes[1], stride0_bytes[0], stride0_bytes[1], stride0_bytes[2], stride0_bytes[3], offset0_bytes[0], offset0_bytes[1], offset0_bytes[2], offset0_bytes[3], stride1_bytes[0], stride1_bytes[1], stride1_bytes[2], stride1_bytes[3], offset1_bytes[0], offset1_bytes[1], offset1_bytes[2], offset1_bytes[3], stride2_bytes[0], stride2_bytes[1], stride2_bytes[2], stride2_bytes[3], offset2_bytes[0], offset2_bytes[1], offset2_bytes[2], offset2_bytes[3], stride3_bytes[0], stride3_bytes[1], stride3_bytes[2], stride3_bytes[3], offset3_bytes[0], offset3_bytes[1], offset3_bytes[2], offset3_bytes[3], depth_bytes[0], bpp_bytes[0], 0, 0, modifier_bytes[0], modifier_bytes[1], modifier_bytes[2], modifier_bytes[3], modifier_bytes[4], modifier_bytes[5], modifier_bytes[6], modifier_bytes[7], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], self.buffers) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request_fd(header: RequestHeader, value: &[u8], fds: &mut Vec) -> Result { if header.minor_opcode != PIXMAP_FROM_BUFFERS_REQUEST { return Err(ParseError::InvalidValue); } let (pixmap, remaining) = xproto::Pixmap::try_parse(value)?; let (window, remaining) = xproto::Window::try_parse(remaining)?; let (num_buffers, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?; let (width, remaining) = u16::try_parse(remaining)?; let (height, remaining) = u16::try_parse(remaining)?; let (stride0, remaining) = u32::try_parse(remaining)?; let (offset0, remaining) = u32::try_parse(remaining)?; let (stride1, remaining) = u32::try_parse(remaining)?; let (offset1, remaining) = u32::try_parse(remaining)?; let (stride2, remaining) = u32::try_parse(remaining)?; let (offset2, remaining) = u32::try_parse(remaining)?; let (stride3, remaining) = u32::try_parse(remaining)?; let (offset3, remaining) = u32::try_parse(remaining)?; let (depth, remaining) = u8::try_parse(remaining)?; let (bpp, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(2..).ok_or(ParseError::InsufficientData)?; let (modifier, remaining) = u64::try_parse(remaining)?; let fds_len = num_buffers.try_to_usize()?; if fds.len() < fds_len { return Err(ParseError::MissingFileDescriptors) } let mut buffers = fds.split_off(fds_len); core::mem::swap(fds, &mut buffers); let _ = remaining; Ok(PixmapFromBuffersRequest { pixmap, window, width, height, stride0, offset0, stride1, offset1, stride2, offset2, stride3, offset3, depth, bpp, modifier, buffers, }) } } impl Request for PixmapFromBuffersRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for PixmapFromBuffersRequest { } /// Opcode for the BuffersFromPixmap request pub const BUFFERS_FROM_PIXMAP_REQUEST: u8 = 8; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct BuffersFromPixmapRequest { pub pixmap: xproto::Pixmap, } impl_debug_if_no_extra_traits!(BuffersFromPixmapRequest, "BuffersFromPixmapRequest"); impl BuffersFromPixmapRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let pixmap_bytes = self.pixmap.serialize(); let mut request0 = vec![ major_opcode, BUFFERS_FROM_PIXMAP_REQUEST, 0, 0, pixmap_bytes[0], pixmap_bytes[1], pixmap_bytes[2], pixmap_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != BUFFERS_FROM_PIXMAP_REQUEST { return Err(ParseError::InvalidValue); } let (pixmap, remaining) = xproto::Pixmap::try_parse(value)?; let _ = remaining; Ok(BuffersFromPixmapRequest { pixmap, }) } } impl Request for BuffersFromPixmapRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyFDsRequest for BuffersFromPixmapRequest { type Reply = BuffersFromPixmapReply; } #[cfg_attr(feature = "extra-traits", derive(Debug))] pub struct BuffersFromPixmapReply { pub sequence: u16, pub length: u32, pub width: u16, pub height: u16, pub modifier: u64, pub depth: u8, pub bpp: u8, pub strides: Vec, pub offsets: Vec, pub buffers: Vec, } impl_debug_if_no_extra_traits!(BuffersFromPixmapReply, "BuffersFromPixmapReply"); impl TryParseFd for BuffersFromPixmapReply { fn try_parse_fd<'a>(initial_value: &'a [u8], fds: &mut Vec) -> Result<(Self, &'a [u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let (nfd, remaining) = u8::try_parse(remaining)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (width, remaining) = u16::try_parse(remaining)?; let (height, remaining) = u16::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (modifier, remaining) = u64::try_parse(remaining)?; let (depth, remaining) = u8::try_parse(remaining)?; let (bpp, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(6..).ok_or(ParseError::InsufficientData)?; let (strides, remaining) = crate::x11_utils::parse_list::(remaining, nfd.try_to_usize()?)?; let (offsets, remaining) = crate::x11_utils::parse_list::(remaining, nfd.try_to_usize()?)?; let fds_len = nfd.try_to_usize()?; if fds.len() < fds_len { return Err(ParseError::MissingFileDescriptors) } let mut buffers = fds.split_off(fds_len); core::mem::swap(fds, &mut buffers); if response_type != 1 { return Err(ParseError::InvalidValue); } let result = BuffersFromPixmapReply { sequence, length, width, height, modifier, depth, bpp, strides, offsets, buffers }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for BuffersFromPixmapReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); let nfd = u8::try_from(self.strides.len()).expect("`strides` has too many elements"); nfd.serialize_into(bytes); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.width.serialize_into(bytes); self.height.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); self.modifier.serialize_into(bytes); self.depth.serialize_into(bytes); self.bpp.serialize_into(bytes); bytes.extend_from_slice(&[0; 6]); self.strides.serialize_into(bytes); assert_eq!(self.offsets.len(), usize::try_from(nfd).unwrap(), "`offsets` has an incorrect length"); self.offsets.serialize_into(bytes); assert_eq!(self.buffers.len(), usize::try_from(nfd).unwrap(), "`buffers` has an incorrect length"); } } impl BuffersFromPixmapReply { /// Get the value of the `nfd` field. /// /// The `nfd` field is used as the length field of the `strides` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn nfd(&self) -> u8 { self.strides.len() .try_into().unwrap() } } /// Opcode for the SetDRMDeviceInUse request pub const SET_DRM_DEVICE_IN_USE_REQUEST: u8 = 9; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetDRMDeviceInUseRequest { pub window: xproto::Window, pub drm_major: u32, pub drm_minor: u32, } impl_debug_if_no_extra_traits!(SetDRMDeviceInUseRequest, "SetDRMDeviceInUseRequest"); impl SetDRMDeviceInUseRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let window_bytes = self.window.serialize(); let drm_major_bytes = self.drm_major.serialize(); let drm_minor_bytes = self.drm_minor.serialize(); let mut request0 = vec![ major_opcode, SET_DRM_DEVICE_IN_USE_REQUEST, 0, 0, window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], drm_major_bytes[0], drm_major_bytes[1], drm_major_bytes[2], drm_major_bytes[3], drm_minor_bytes[0], drm_minor_bytes[1], drm_minor_bytes[2], drm_minor_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != SET_DRM_DEVICE_IN_USE_REQUEST { return Err(ParseError::InvalidValue); } let (window, remaining) = xproto::Window::try_parse(value)?; let (drm_major, remaining) = u32::try_parse(remaining)?; let (drm_minor, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(SetDRMDeviceInUseRequest { window, drm_major, drm_minor, }) } } impl Request for SetDRMDeviceInUseRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for SetDRMDeviceInUseRequest { } /// Opcode for the ImportSyncobj request pub const IMPORT_SYNCOBJ_REQUEST: u8 = 10; #[cfg_attr(feature = "extra-traits", derive(Debug))] pub struct ImportSyncobjRequest { pub syncobj: Syncobj, pub drawable: xproto::Drawable, pub syncobj_fd: RawFdContainer, } impl_debug_if_no_extra_traits!(ImportSyncobjRequest, "ImportSyncobjRequest"); impl ImportSyncobjRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let syncobj_bytes = self.syncobj.serialize(); let drawable_bytes = self.drawable.serialize(); let mut request0 = vec![ major_opcode, IMPORT_SYNCOBJ_REQUEST, 0, 0, syncobj_bytes[0], syncobj_bytes[1], syncobj_bytes[2], syncobj_bytes[3], drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![self.syncobj_fd]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request_fd(header: RequestHeader, value: &[u8], fds: &mut Vec) -> Result { if header.minor_opcode != IMPORT_SYNCOBJ_REQUEST { return Err(ParseError::InvalidValue); } let (syncobj, remaining) = Syncobj::try_parse(value)?; let (drawable, remaining) = xproto::Drawable::try_parse(remaining)?; if fds.is_empty() { return Err(ParseError::MissingFileDescriptors) } let syncobj_fd = fds.remove(0); let _ = remaining; Ok(ImportSyncobjRequest { syncobj, drawable, syncobj_fd, }) } } impl Request for ImportSyncobjRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for ImportSyncobjRequest { } /// Opcode for the FreeSyncobj request pub const FREE_SYNCOBJ_REQUEST: u8 = 11; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct FreeSyncobjRequest { pub syncobj: Syncobj, } impl_debug_if_no_extra_traits!(FreeSyncobjRequest, "FreeSyncobjRequest"); impl FreeSyncobjRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let syncobj_bytes = self.syncobj.serialize(); let mut request0 = vec![ major_opcode, FREE_SYNCOBJ_REQUEST, 0, 0, syncobj_bytes[0], syncobj_bytes[1], syncobj_bytes[2], syncobj_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != FREE_SYNCOBJ_REQUEST { return Err(ParseError::InvalidValue); } let (syncobj, remaining) = Syncobj::try_parse(value)?; let _ = remaining; Ok(FreeSyncobjRequest { syncobj, }) } } impl Request for FreeSyncobjRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for FreeSyncobjRequest { } x11rb-protocol-0.13.1/src/protocol/ge.rs000064400000000000000000000152671046102023000161060ustar 00000000000000// This file contains generated code. Do not edit directly. // To regenerate this, run 'make'. //! Bindings to the `GenericEvent` X11 extension. #![allow(clippy::too_many_arguments)] // The code generator is simpler if it can always use conversions #![allow(clippy::useless_conversion)] #[allow(unused_imports)] use alloc::borrow::Cow; #[allow(unused_imports)] use core::convert::TryInto; use alloc::vec; use alloc::vec::Vec; use core::convert::TryFrom; use crate::errors::ParseError; #[allow(unused_imports)] use crate::x11_utils::TryIntoUSize; use crate::BufWithFds; #[allow(unused_imports)] use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; #[allow(unused_imports)] use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; /// The X11 name of the extension for QueryExtension pub const X11_EXTENSION_NAME: &str = "Generic Event Extension"; /// The version number of this extension that this client library supports. /// /// This constant contains the version number of this extension that is supported /// by this build of x11rb. For most things, it does not make sense to use this /// information. If you need to send a `QueryVersion`, it is recommended to instead /// send the maximum version of the extension that you need. pub const X11_XML_VERSION: (u32, u32) = (1, 0); /// Opcode for the QueryVersion request pub const QUERY_VERSION_REQUEST: u8 = 0; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryVersionRequest { pub client_major_version: u16, pub client_minor_version: u16, } impl_debug_if_no_extra_traits!(QueryVersionRequest, "QueryVersionRequest"); impl QueryVersionRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let client_major_version_bytes = self.client_major_version.serialize(); let client_minor_version_bytes = self.client_minor_version.serialize(); let mut request0 = vec![ major_opcode, QUERY_VERSION_REQUEST, 0, 0, client_major_version_bytes[0], client_major_version_bytes[1], client_minor_version_bytes[0], client_minor_version_bytes[1], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != QUERY_VERSION_REQUEST { return Err(ParseError::InvalidValue); } let (client_major_version, remaining) = u16::try_parse(value)?; let (client_minor_version, remaining) = u16::try_parse(remaining)?; let _ = remaining; Ok(QueryVersionRequest { client_major_version, client_minor_version, }) } } impl Request for QueryVersionRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for QueryVersionRequest { type Reply = QueryVersionReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryVersionReply { pub sequence: u16, pub length: u32, pub major_version: u16, pub minor_version: u16, } impl_debug_if_no_extra_traits!(QueryVersionReply, "QueryVersionReply"); impl TryParse for QueryVersionReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (major_version, remaining) = u16::try_parse(remaining)?; let (minor_version, remaining) = u16::try_parse(remaining)?; let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = QueryVersionReply { sequence, length, major_version, minor_version }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for QueryVersionReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let major_version_bytes = self.major_version.serialize(); let minor_version_bytes = self.minor_version.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], major_version_bytes[0], major_version_bytes[1], minor_version_bytes[0], minor_version_bytes[1], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.major_version.serialize_into(bytes); self.minor_version.serialize_into(bytes); bytes.extend_from_slice(&[0; 20]); } } x11rb-protocol-0.13.1/src/protocol/glx.rs000064400000000000000000017327451046102023000163150ustar 00000000000000// This file contains generated code. Do not edit directly. // To regenerate this, run 'make'. //! Bindings to the `Glx` X11 extension. #![allow(clippy::too_many_arguments)] // The code generator is simpler if it can always use conversions #![allow(clippy::useless_conversion)] #[allow(unused_imports)] use alloc::borrow::Cow; #[allow(unused_imports)] use core::convert::TryInto; use alloc::vec; use alloc::vec::Vec; use core::convert::TryFrom; use crate::errors::ParseError; #[allow(unused_imports)] use crate::x11_utils::TryIntoUSize; use crate::BufWithFds; #[allow(unused_imports)] use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; #[allow(unused_imports)] use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; #[allow(unused_imports)] use super::xproto; /// The X11 name of the extension for QueryExtension pub const X11_EXTENSION_NAME: &str = "GLX"; /// The version number of this extension that this client library supports. /// /// This constant contains the version number of this extension that is supported /// by this build of x11rb. For most things, it does not make sense to use this /// information. If you need to send a `QueryVersion`, it is recommended to instead /// send the maximum version of the extension that you need. pub const X11_XML_VERSION: (u32, u32) = (1, 4); pub type Pixmap = u32; pub type Context = u32; pub type Pbuffer = u32; pub type Window = u32; pub type Fbconfig = u32; pub type Drawable = u32; pub type Float32 = f32; pub type Float64 = f64; pub type Bool32 = u32; pub type ContextTag = u32; /// Opcode for the BadContext error pub const BAD_CONTEXT_ERROR: u8 = 0; /// Opcode for the BadContextState error pub const BAD_CONTEXT_STATE_ERROR: u8 = 1; /// Opcode for the BadDrawable error pub const BAD_DRAWABLE_ERROR: u8 = 2; /// Opcode for the BadPixmap error pub const BAD_PIXMAP_ERROR: u8 = 3; /// Opcode for the BadContextTag error pub const BAD_CONTEXT_TAG_ERROR: u8 = 4; /// Opcode for the BadCurrentWindow error pub const BAD_CURRENT_WINDOW_ERROR: u8 = 5; /// Opcode for the BadRenderRequest error pub const BAD_RENDER_REQUEST_ERROR: u8 = 6; /// Opcode for the BadLargeRequest error pub const BAD_LARGE_REQUEST_ERROR: u8 = 7; /// Opcode for the UnsupportedPrivateRequest error pub const UNSUPPORTED_PRIVATE_REQUEST_ERROR: u8 = 8; /// Opcode for the BadFBConfig error pub const BAD_FB_CONFIG_ERROR: u8 = 9; /// Opcode for the BadPbuffer error pub const BAD_PBUFFER_ERROR: u8 = 10; /// Opcode for the BadCurrentDrawable error pub const BAD_CURRENT_DRAWABLE_ERROR: u8 = 11; /// Opcode for the BadWindow error pub const BAD_WINDOW_ERROR: u8 = 12; /// Opcode for the GLXBadProfileARB error pub const GLX_BAD_PROFILE_ARB_ERROR: u8 = 13; /// Opcode for the PbufferClobber event pub const PBUFFER_CLOBBER_EVENT: u8 = 0; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct PbufferClobberEvent { pub response_type: u8, pub sequence: u16, pub event_type: u16, pub draw_type: u16, pub drawable: Drawable, pub b_mask: u32, pub aux_buffer: u16, pub x: u16, pub y: u16, pub width: u16, pub height: u16, pub count: u16, } impl_debug_if_no_extra_traits!(PbufferClobberEvent, "PbufferClobberEvent"); impl TryParse for PbufferClobberEvent { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (event_type, remaining) = u16::try_parse(remaining)?; let (draw_type, remaining) = u16::try_parse(remaining)?; let (drawable, remaining) = Drawable::try_parse(remaining)?; let (b_mask, remaining) = u32::try_parse(remaining)?; let (aux_buffer, remaining) = u16::try_parse(remaining)?; let (x, remaining) = u16::try_parse(remaining)?; let (y, remaining) = u16::try_parse(remaining)?; let (width, remaining) = u16::try_parse(remaining)?; let (height, remaining) = u16::try_parse(remaining)?; let (count, remaining) = u16::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let result = PbufferClobberEvent { response_type, sequence, event_type, draw_type, drawable, b_mask, aux_buffer, x, y, width, height, count }; let _ = remaining; let remaining = initial_value.get(32..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for PbufferClobberEvent { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = self.response_type.serialize(); let sequence_bytes = self.sequence.serialize(); let event_type_bytes = self.event_type.serialize(); let draw_type_bytes = self.draw_type.serialize(); let drawable_bytes = self.drawable.serialize(); let b_mask_bytes = self.b_mask.serialize(); let aux_buffer_bytes = self.aux_buffer.serialize(); let x_bytes = self.x.serialize(); let y_bytes = self.y.serialize(); let width_bytes = self.width.serialize(); let height_bytes = self.height.serialize(); let count_bytes = self.count.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], event_type_bytes[0], event_type_bytes[1], draw_type_bytes[0], draw_type_bytes[1], drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], b_mask_bytes[0], b_mask_bytes[1], b_mask_bytes[2], b_mask_bytes[3], aux_buffer_bytes[0], aux_buffer_bytes[1], x_bytes[0], x_bytes[1], y_bytes[0], y_bytes[1], width_bytes[0], width_bytes[1], height_bytes[0], height_bytes[1], count_bytes[0], count_bytes[1], 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); self.response_type.serialize_into(bytes); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.event_type.serialize_into(bytes); self.draw_type.serialize_into(bytes); self.drawable.serialize_into(bytes); self.b_mask.serialize_into(bytes); self.aux_buffer.serialize_into(bytes); self.x.serialize_into(bytes); self.y.serialize_into(bytes); self.width.serialize_into(bytes); self.height.serialize_into(bytes); self.count.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); } } impl From<&PbufferClobberEvent> for [u8; 32] { fn from(input: &PbufferClobberEvent) -> Self { let response_type_bytes = input.response_type.serialize(); let sequence_bytes = input.sequence.serialize(); let event_type_bytes = input.event_type.serialize(); let draw_type_bytes = input.draw_type.serialize(); let drawable_bytes = input.drawable.serialize(); let b_mask_bytes = input.b_mask.serialize(); let aux_buffer_bytes = input.aux_buffer.serialize(); let x_bytes = input.x.serialize(); let y_bytes = input.y.serialize(); let width_bytes = input.width.serialize(); let height_bytes = input.height.serialize(); let count_bytes = input.count.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], event_type_bytes[0], event_type_bytes[1], draw_type_bytes[0], draw_type_bytes[1], drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], b_mask_bytes[0], b_mask_bytes[1], b_mask_bytes[2], b_mask_bytes[3], aux_buffer_bytes[0], aux_buffer_bytes[1], x_bytes[0], x_bytes[1], y_bytes[0], y_bytes[1], width_bytes[0], width_bytes[1], height_bytes[0], height_bytes[1], count_bytes[0], count_bytes[1], 0, 0, 0, 0, ] } } impl From for [u8; 32] { fn from(input: PbufferClobberEvent) -> Self { Self::from(&input) } } /// Opcode for the BufferSwapComplete event pub const BUFFER_SWAP_COMPLETE_EVENT: u8 = 1; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct BufferSwapCompleteEvent { pub response_type: u8, pub sequence: u16, pub event_type: u16, pub drawable: Drawable, pub ust_hi: u32, pub ust_lo: u32, pub msc_hi: u32, pub msc_lo: u32, pub sbc: u32, } impl_debug_if_no_extra_traits!(BufferSwapCompleteEvent, "BufferSwapCompleteEvent"); impl TryParse for BufferSwapCompleteEvent { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (event_type, remaining) = u16::try_parse(remaining)?; let remaining = remaining.get(2..).ok_or(ParseError::InsufficientData)?; let (drawable, remaining) = Drawable::try_parse(remaining)?; let (ust_hi, remaining) = u32::try_parse(remaining)?; let (ust_lo, remaining) = u32::try_parse(remaining)?; let (msc_hi, remaining) = u32::try_parse(remaining)?; let (msc_lo, remaining) = u32::try_parse(remaining)?; let (sbc, remaining) = u32::try_parse(remaining)?; let result = BufferSwapCompleteEvent { response_type, sequence, event_type, drawable, ust_hi, ust_lo, msc_hi, msc_lo, sbc }; let _ = remaining; let remaining = initial_value.get(32..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for BufferSwapCompleteEvent { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = self.response_type.serialize(); let sequence_bytes = self.sequence.serialize(); let event_type_bytes = self.event_type.serialize(); let drawable_bytes = self.drawable.serialize(); let ust_hi_bytes = self.ust_hi.serialize(); let ust_lo_bytes = self.ust_lo.serialize(); let msc_hi_bytes = self.msc_hi.serialize(); let msc_lo_bytes = self.msc_lo.serialize(); let sbc_bytes = self.sbc.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], event_type_bytes[0], event_type_bytes[1], 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], ust_hi_bytes[0], ust_hi_bytes[1], ust_hi_bytes[2], ust_hi_bytes[3], ust_lo_bytes[0], ust_lo_bytes[1], ust_lo_bytes[2], ust_lo_bytes[3], msc_hi_bytes[0], msc_hi_bytes[1], msc_hi_bytes[2], msc_hi_bytes[3], msc_lo_bytes[0], msc_lo_bytes[1], msc_lo_bytes[2], msc_lo_bytes[3], sbc_bytes[0], sbc_bytes[1], sbc_bytes[2], sbc_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); self.response_type.serialize_into(bytes); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.event_type.serialize_into(bytes); bytes.extend_from_slice(&[0; 2]); self.drawable.serialize_into(bytes); self.ust_hi.serialize_into(bytes); self.ust_lo.serialize_into(bytes); self.msc_hi.serialize_into(bytes); self.msc_lo.serialize_into(bytes); self.sbc.serialize_into(bytes); } } impl From<&BufferSwapCompleteEvent> for [u8; 32] { fn from(input: &BufferSwapCompleteEvent) -> Self { let response_type_bytes = input.response_type.serialize(); let sequence_bytes = input.sequence.serialize(); let event_type_bytes = input.event_type.serialize(); let drawable_bytes = input.drawable.serialize(); let ust_hi_bytes = input.ust_hi.serialize(); let ust_lo_bytes = input.ust_lo.serialize(); let msc_hi_bytes = input.msc_hi.serialize(); let msc_lo_bytes = input.msc_lo.serialize(); let sbc_bytes = input.sbc.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], event_type_bytes[0], event_type_bytes[1], 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], ust_hi_bytes[0], ust_hi_bytes[1], ust_hi_bytes[2], ust_hi_bytes[3], ust_lo_bytes[0], ust_lo_bytes[1], ust_lo_bytes[2], ust_lo_bytes[3], msc_hi_bytes[0], msc_hi_bytes[1], msc_hi_bytes[2], msc_hi_bytes[3], msc_lo_bytes[0], msc_lo_bytes[1], msc_lo_bytes[2], msc_lo_bytes[3], sbc_bytes[0], sbc_bytes[1], sbc_bytes[2], sbc_bytes[3], ] } } impl From for [u8; 32] { fn from(input: BufferSwapCompleteEvent) -> Self { Self::from(&input) } } #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct PBCET(u16); impl PBCET { pub const DAMAGED: Self = Self(32791); pub const SAVED: Self = Self(32792); } impl From for u16 { #[inline] fn from(input: PBCET) -> Self { input.0 } } impl From for Option { #[inline] fn from(input: PBCET) -> Self { Some(input.0) } } impl From for u32 { #[inline] fn from(input: PBCET) -> Self { u32::from(input.0) } } impl From for Option { #[inline] fn from(input: PBCET) -> Self { Some(u32::from(input.0)) } } impl From for PBCET { #[inline] fn from(value: u8) -> Self { Self(value.into()) } } impl From for PBCET { #[inline] fn from(value: u16) -> Self { Self(value) } } impl core::fmt::Debug for PBCET { fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let variants = [ (Self::DAMAGED.0.into(), "DAMAGED", "Damaged"), (Self::SAVED.0.into(), "SAVED", "Saved"), ]; pretty_print_enum(fmt, self.0.into(), &variants) } } #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct PBCDT(u16); impl PBCDT { pub const WINDOW: Self = Self(32793); pub const PBUFFER: Self = Self(32794); } impl From for u16 { #[inline] fn from(input: PBCDT) -> Self { input.0 } } impl From for Option { #[inline] fn from(input: PBCDT) -> Self { Some(input.0) } } impl From for u32 { #[inline] fn from(input: PBCDT) -> Self { u32::from(input.0) } } impl From for Option { #[inline] fn from(input: PBCDT) -> Self { Some(u32::from(input.0)) } } impl From for PBCDT { #[inline] fn from(value: u8) -> Self { Self(value.into()) } } impl From for PBCDT { #[inline] fn from(value: u16) -> Self { Self(value) } } impl core::fmt::Debug for PBCDT { fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let variants = [ (Self::WINDOW.0.into(), "WINDOW", "Window"), (Self::PBUFFER.0.into(), "PBUFFER", "Pbuffer"), ]; pretty_print_enum(fmt, self.0.into(), &variants) } } /// Opcode for the Render request pub const RENDER_REQUEST: u8 = 1; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct RenderRequest<'input> { pub context_tag: ContextTag, pub data: Cow<'input, [u8]>, } impl_debug_if_no_extra_traits!(RenderRequest<'_>, "RenderRequest"); impl<'input> RenderRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let mut request0 = vec![ major_opcode, RENDER_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let length_so_far = length_so_far + self.data.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), self.data, padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != RENDER_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (data, remaining) = remaining.split_at(remaining.len()); let _ = remaining; Ok(RenderRequest { context_tag, data: Cow::Borrowed(data), }) } /// Clone all borrowed data in this RenderRequest. pub fn into_owned(self) -> RenderRequest<'static> { RenderRequest { context_tag: self.context_tag, data: Cow::Owned(self.data.into_owned()), } } } impl<'input> Request for RenderRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::VoidRequest for RenderRequest<'input> { } /// Opcode for the RenderLarge request pub const RENDER_LARGE_REQUEST: u8 = 2; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct RenderLargeRequest<'input> { pub context_tag: ContextTag, pub request_num: u16, pub request_total: u16, pub data: Cow<'input, [u8]>, } impl_debug_if_no_extra_traits!(RenderLargeRequest<'_>, "RenderLargeRequest"); impl<'input> RenderLargeRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let request_num_bytes = self.request_num.serialize(); let request_total_bytes = self.request_total.serialize(); let data_len = u32::try_from(self.data.len()).expect("`data` has too many elements"); let data_len_bytes = data_len.serialize(); let mut request0 = vec![ major_opcode, RENDER_LARGE_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], request_num_bytes[0], request_num_bytes[1], request_total_bytes[0], request_total_bytes[1], data_len_bytes[0], data_len_bytes[1], data_len_bytes[2], data_len_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let length_so_far = length_so_far + self.data.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), self.data, padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != RENDER_LARGE_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (request_num, remaining) = u16::try_parse(remaining)?; let (request_total, remaining) = u16::try_parse(remaining)?; let (data_len, remaining) = u32::try_parse(remaining)?; let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, data_len.try_to_usize()?)?; let _ = remaining; Ok(RenderLargeRequest { context_tag, request_num, request_total, data: Cow::Borrowed(data), }) } /// Clone all borrowed data in this RenderLargeRequest. pub fn into_owned(self) -> RenderLargeRequest<'static> { RenderLargeRequest { context_tag: self.context_tag, request_num: self.request_num, request_total: self.request_total, data: Cow::Owned(self.data.into_owned()), } } } impl<'input> Request for RenderLargeRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::VoidRequest for RenderLargeRequest<'input> { } /// Opcode for the CreateContext request pub const CREATE_CONTEXT_REQUEST: u8 = 3; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateContextRequest { pub context: Context, pub visual: xproto::Visualid, pub screen: u32, pub share_list: Context, pub is_direct: bool, } impl_debug_if_no_extra_traits!(CreateContextRequest, "CreateContextRequest"); impl CreateContextRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_bytes = self.context.serialize(); let visual_bytes = self.visual.serialize(); let screen_bytes = self.screen.serialize(); let share_list_bytes = self.share_list.serialize(); let is_direct_bytes = self.is_direct.serialize(); let mut request0 = vec![ major_opcode, CREATE_CONTEXT_REQUEST, 0, 0, context_bytes[0], context_bytes[1], context_bytes[2], context_bytes[3], visual_bytes[0], visual_bytes[1], visual_bytes[2], visual_bytes[3], screen_bytes[0], screen_bytes[1], screen_bytes[2], screen_bytes[3], share_list_bytes[0], share_list_bytes[1], share_list_bytes[2], share_list_bytes[3], is_direct_bytes[0], 0, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != CREATE_CONTEXT_REQUEST { return Err(ParseError::InvalidValue); } let (context, remaining) = Context::try_parse(value)?; let (visual, remaining) = xproto::Visualid::try_parse(remaining)?; let (screen, remaining) = u32::try_parse(remaining)?; let (share_list, remaining) = Context::try_parse(remaining)?; let (is_direct, remaining) = bool::try_parse(remaining)?; let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?; let _ = remaining; Ok(CreateContextRequest { context, visual, screen, share_list, is_direct, }) } } impl Request for CreateContextRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for CreateContextRequest { } /// Opcode for the DestroyContext request pub const DESTROY_CONTEXT_REQUEST: u8 = 4; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DestroyContextRequest { pub context: Context, } impl_debug_if_no_extra_traits!(DestroyContextRequest, "DestroyContextRequest"); impl DestroyContextRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_bytes = self.context.serialize(); let mut request0 = vec![ major_opcode, DESTROY_CONTEXT_REQUEST, 0, 0, context_bytes[0], context_bytes[1], context_bytes[2], context_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != DESTROY_CONTEXT_REQUEST { return Err(ParseError::InvalidValue); } let (context, remaining) = Context::try_parse(value)?; let _ = remaining; Ok(DestroyContextRequest { context, }) } } impl Request for DestroyContextRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for DestroyContextRequest { } /// Opcode for the MakeCurrent request pub const MAKE_CURRENT_REQUEST: u8 = 5; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MakeCurrentRequest { pub drawable: Drawable, pub context: Context, pub old_context_tag: ContextTag, } impl_debug_if_no_extra_traits!(MakeCurrentRequest, "MakeCurrentRequest"); impl MakeCurrentRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let context_bytes = self.context.serialize(); let old_context_tag_bytes = self.old_context_tag.serialize(); let mut request0 = vec![ major_opcode, MAKE_CURRENT_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], context_bytes[0], context_bytes[1], context_bytes[2], context_bytes[3], old_context_tag_bytes[0], old_context_tag_bytes[1], old_context_tag_bytes[2], old_context_tag_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != MAKE_CURRENT_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = Drawable::try_parse(value)?; let (context, remaining) = Context::try_parse(remaining)?; let (old_context_tag, remaining) = ContextTag::try_parse(remaining)?; let _ = remaining; Ok(MakeCurrentRequest { drawable, context, old_context_tag, }) } } impl Request for MakeCurrentRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for MakeCurrentRequest { type Reply = MakeCurrentReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MakeCurrentReply { pub sequence: u16, pub length: u32, pub context_tag: ContextTag, } impl_debug_if_no_extra_traits!(MakeCurrentReply, "MakeCurrentReply"); impl TryParse for MakeCurrentReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (context_tag, remaining) = ContextTag::try_parse(remaining)?; let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = MakeCurrentReply { sequence, length, context_tag }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for MakeCurrentReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let context_tag_bytes = self.context_tag.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.context_tag.serialize_into(bytes); bytes.extend_from_slice(&[0; 20]); } } /// Opcode for the IsDirect request pub const IS_DIRECT_REQUEST: u8 = 6; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct IsDirectRequest { pub context: Context, } impl_debug_if_no_extra_traits!(IsDirectRequest, "IsDirectRequest"); impl IsDirectRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_bytes = self.context.serialize(); let mut request0 = vec![ major_opcode, IS_DIRECT_REQUEST, 0, 0, context_bytes[0], context_bytes[1], context_bytes[2], context_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != IS_DIRECT_REQUEST { return Err(ParseError::InvalidValue); } let (context, remaining) = Context::try_parse(value)?; let _ = remaining; Ok(IsDirectRequest { context, }) } } impl Request for IsDirectRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for IsDirectRequest { type Reply = IsDirectReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct IsDirectReply { pub sequence: u16, pub length: u32, pub is_direct: bool, } impl_debug_if_no_extra_traits!(IsDirectReply, "IsDirectReply"); impl TryParse for IsDirectReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (is_direct, remaining) = bool::try_parse(remaining)?; let remaining = remaining.get(23..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = IsDirectReply { sequence, length, is_direct }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for IsDirectReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let is_direct_bytes = self.is_direct.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], is_direct_bytes[0], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.is_direct.serialize_into(bytes); bytes.extend_from_slice(&[0; 23]); } } /// Opcode for the QueryVersion request pub const QUERY_VERSION_REQUEST: u8 = 7; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryVersionRequest { pub major_version: u32, pub minor_version: u32, } impl_debug_if_no_extra_traits!(QueryVersionRequest, "QueryVersionRequest"); impl QueryVersionRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let major_version_bytes = self.major_version.serialize(); let minor_version_bytes = self.minor_version.serialize(); let mut request0 = vec![ major_opcode, QUERY_VERSION_REQUEST, 0, 0, major_version_bytes[0], major_version_bytes[1], major_version_bytes[2], major_version_bytes[3], minor_version_bytes[0], minor_version_bytes[1], minor_version_bytes[2], minor_version_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != QUERY_VERSION_REQUEST { return Err(ParseError::InvalidValue); } let (major_version, remaining) = u32::try_parse(value)?; let (minor_version, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(QueryVersionRequest { major_version, minor_version, }) } } impl Request for QueryVersionRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for QueryVersionRequest { type Reply = QueryVersionReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryVersionReply { pub sequence: u16, pub length: u32, pub major_version: u32, pub minor_version: u32, } impl_debug_if_no_extra_traits!(QueryVersionReply, "QueryVersionReply"); impl TryParse for QueryVersionReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (major_version, remaining) = u32::try_parse(remaining)?; let (minor_version, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = QueryVersionReply { sequence, length, major_version, minor_version }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for QueryVersionReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let major_version_bytes = self.major_version.serialize(); let minor_version_bytes = self.minor_version.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], major_version_bytes[0], major_version_bytes[1], major_version_bytes[2], major_version_bytes[3], minor_version_bytes[0], minor_version_bytes[1], minor_version_bytes[2], minor_version_bytes[3], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.major_version.serialize_into(bytes); self.minor_version.serialize_into(bytes); bytes.extend_from_slice(&[0; 16]); } } /// Opcode for the WaitGL request pub const WAIT_GL_REQUEST: u8 = 8; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WaitGLRequest { pub context_tag: ContextTag, } impl_debug_if_no_extra_traits!(WaitGLRequest, "WaitGLRequest"); impl WaitGLRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let mut request0 = vec![ major_opcode, WAIT_GL_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != WAIT_GL_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let _ = remaining; Ok(WaitGLRequest { context_tag, }) } } impl Request for WaitGLRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for WaitGLRequest { } /// Opcode for the WaitX request pub const WAIT_X_REQUEST: u8 = 9; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct WaitXRequest { pub context_tag: ContextTag, } impl_debug_if_no_extra_traits!(WaitXRequest, "WaitXRequest"); impl WaitXRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let mut request0 = vec![ major_opcode, WAIT_X_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != WAIT_X_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let _ = remaining; Ok(WaitXRequest { context_tag, }) } } impl Request for WaitXRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for WaitXRequest { } /// Opcode for the CopyContext request pub const COPY_CONTEXT_REQUEST: u8 = 10; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CopyContextRequest { pub src: Context, pub dest: Context, pub mask: u32, pub src_context_tag: ContextTag, } impl_debug_if_no_extra_traits!(CopyContextRequest, "CopyContextRequest"); impl CopyContextRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let src_bytes = self.src.serialize(); let dest_bytes = self.dest.serialize(); let mask_bytes = self.mask.serialize(); let src_context_tag_bytes = self.src_context_tag.serialize(); let mut request0 = vec![ major_opcode, COPY_CONTEXT_REQUEST, 0, 0, src_bytes[0], src_bytes[1], src_bytes[2], src_bytes[3], dest_bytes[0], dest_bytes[1], dest_bytes[2], dest_bytes[3], mask_bytes[0], mask_bytes[1], mask_bytes[2], mask_bytes[3], src_context_tag_bytes[0], src_context_tag_bytes[1], src_context_tag_bytes[2], src_context_tag_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != COPY_CONTEXT_REQUEST { return Err(ParseError::InvalidValue); } let (src, remaining) = Context::try_parse(value)?; let (dest, remaining) = Context::try_parse(remaining)?; let (mask, remaining) = u32::try_parse(remaining)?; let (src_context_tag, remaining) = ContextTag::try_parse(remaining)?; let _ = remaining; Ok(CopyContextRequest { src, dest, mask, src_context_tag, }) } } impl Request for CopyContextRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for CopyContextRequest { } #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GC(u32); impl GC { pub const GL_CURRENT_BIT: Self = Self(1 << 0); pub const GL_POINT_BIT: Self = Self(1 << 1); pub const GL_LINE_BIT: Self = Self(1 << 2); pub const GL_POLYGON_BIT: Self = Self(1 << 3); pub const GL_POLYGON_STIPPLE_BIT: Self = Self(1 << 4); pub const GL_PIXEL_MODE_BIT: Self = Self(1 << 5); pub const GL_LIGHTING_BIT: Self = Self(1 << 6); pub const GL_FOG_BIT: Self = Self(1 << 7); pub const GL_DEPTH_BUFFER_BIT: Self = Self(1 << 8); pub const GL_ACCUM_BUFFER_BIT: Self = Self(1 << 9); pub const GL_STENCIL_BUFFER_BIT: Self = Self(1 << 10); pub const GL_VIEWPORT_BIT: Self = Self(1 << 11); pub const GL_TRANSFORM_BIT: Self = Self(1 << 12); pub const GL_ENABLE_BIT: Self = Self(1 << 13); pub const GL_COLOR_BUFFER_BIT: Self = Self(1 << 14); pub const GL_HINT_BIT: Self = Self(1 << 15); pub const GL_EVAL_BIT: Self = Self(1 << 16); pub const GL_LIST_BIT: Self = Self(1 << 17); pub const GL_TEXTURE_BIT: Self = Self(1 << 18); pub const GL_SCISSOR_BIT: Self = Self(1 << 19); pub const GL_ALL_ATTRIB_BITS: Self = Self(16_777_215); } impl From for u32 { #[inline] fn from(input: GC) -> Self { input.0 } } impl From for Option { #[inline] fn from(input: GC) -> Self { Some(input.0) } } impl From for GC { #[inline] fn from(value: u8) -> Self { Self(value.into()) } } impl From for GC { #[inline] fn from(value: u16) -> Self { Self(value.into()) } } impl From for GC { #[inline] fn from(value: u32) -> Self { Self(value) } } impl core::fmt::Debug for GC { fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let variants = [ (Self::GL_CURRENT_BIT.0, "GL_CURRENT_BIT", "GL_CURRENT_BIT"), (Self::GL_POINT_BIT.0, "GL_POINT_BIT", "GL_POINT_BIT"), (Self::GL_LINE_BIT.0, "GL_LINE_BIT", "GL_LINE_BIT"), (Self::GL_POLYGON_BIT.0, "GL_POLYGON_BIT", "GL_POLYGON_BIT"), (Self::GL_POLYGON_STIPPLE_BIT.0, "GL_POLYGON_STIPPLE_BIT", "GL_POLYGON_STIPPLE_BIT"), (Self::GL_PIXEL_MODE_BIT.0, "GL_PIXEL_MODE_BIT", "GL_PIXEL_MODE_BIT"), (Self::GL_LIGHTING_BIT.0, "GL_LIGHTING_BIT", "GL_LIGHTING_BIT"), (Self::GL_FOG_BIT.0, "GL_FOG_BIT", "GL_FOG_BIT"), (Self::GL_DEPTH_BUFFER_BIT.0, "GL_DEPTH_BUFFER_BIT", "GL_DEPTH_BUFFER_BIT"), (Self::GL_ACCUM_BUFFER_BIT.0, "GL_ACCUM_BUFFER_BIT", "GL_ACCUM_BUFFER_BIT"), (Self::GL_STENCIL_BUFFER_BIT.0, "GL_STENCIL_BUFFER_BIT", "GL_STENCIL_BUFFER_BIT"), (Self::GL_VIEWPORT_BIT.0, "GL_VIEWPORT_BIT", "GL_VIEWPORT_BIT"), (Self::GL_TRANSFORM_BIT.0, "GL_TRANSFORM_BIT", "GL_TRANSFORM_BIT"), (Self::GL_ENABLE_BIT.0, "GL_ENABLE_BIT", "GL_ENABLE_BIT"), (Self::GL_COLOR_BUFFER_BIT.0, "GL_COLOR_BUFFER_BIT", "GL_COLOR_BUFFER_BIT"), (Self::GL_HINT_BIT.0, "GL_HINT_BIT", "GL_HINT_BIT"), (Self::GL_EVAL_BIT.0, "GL_EVAL_BIT", "GL_EVAL_BIT"), (Self::GL_LIST_BIT.0, "GL_LIST_BIT", "GL_LIST_BIT"), (Self::GL_TEXTURE_BIT.0, "GL_TEXTURE_BIT", "GL_TEXTURE_BIT"), (Self::GL_SCISSOR_BIT.0, "GL_SCISSOR_BIT", "GL_SCISSOR_BIT"), (Self::GL_ALL_ATTRIB_BITS.0, "GL_ALL_ATTRIB_BITS", "GL_ALL_ATTRIB_BITS"), ]; pretty_print_enum(fmt, self.0, &variants) } } /// Opcode for the SwapBuffers request pub const SWAP_BUFFERS_REQUEST: u8 = 11; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SwapBuffersRequest { pub context_tag: ContextTag, pub drawable: Drawable, } impl_debug_if_no_extra_traits!(SwapBuffersRequest, "SwapBuffersRequest"); impl SwapBuffersRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let drawable_bytes = self.drawable.serialize(); let mut request0 = vec![ major_opcode, SWAP_BUFFERS_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != SWAP_BUFFERS_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (drawable, remaining) = Drawable::try_parse(remaining)?; let _ = remaining; Ok(SwapBuffersRequest { context_tag, drawable, }) } } impl Request for SwapBuffersRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for SwapBuffersRequest { } /// Opcode for the UseXFont request pub const USE_X_FONT_REQUEST: u8 = 12; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct UseXFontRequest { pub context_tag: ContextTag, pub font: xproto::Font, pub first: u32, pub count: u32, pub list_base: u32, } impl_debug_if_no_extra_traits!(UseXFontRequest, "UseXFontRequest"); impl UseXFontRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let font_bytes = self.font.serialize(); let first_bytes = self.first.serialize(); let count_bytes = self.count.serialize(); let list_base_bytes = self.list_base.serialize(); let mut request0 = vec![ major_opcode, USE_X_FONT_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], font_bytes[0], font_bytes[1], font_bytes[2], font_bytes[3], first_bytes[0], first_bytes[1], first_bytes[2], first_bytes[3], count_bytes[0], count_bytes[1], count_bytes[2], count_bytes[3], list_base_bytes[0], list_base_bytes[1], list_base_bytes[2], list_base_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != USE_X_FONT_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (font, remaining) = xproto::Font::try_parse(remaining)?; let (first, remaining) = u32::try_parse(remaining)?; let (count, remaining) = u32::try_parse(remaining)?; let (list_base, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(UseXFontRequest { context_tag, font, first, count, list_base, }) } } impl Request for UseXFontRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for UseXFontRequest { } /// Opcode for the CreateGLXPixmap request pub const CREATE_GLX_PIXMAP_REQUEST: u8 = 13; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateGLXPixmapRequest { pub screen: u32, pub visual: xproto::Visualid, pub pixmap: xproto::Pixmap, pub glx_pixmap: Pixmap, } impl_debug_if_no_extra_traits!(CreateGLXPixmapRequest, "CreateGLXPixmapRequest"); impl CreateGLXPixmapRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let screen_bytes = self.screen.serialize(); let visual_bytes = self.visual.serialize(); let pixmap_bytes = self.pixmap.serialize(); let glx_pixmap_bytes = self.glx_pixmap.serialize(); let mut request0 = vec![ major_opcode, CREATE_GLX_PIXMAP_REQUEST, 0, 0, screen_bytes[0], screen_bytes[1], screen_bytes[2], screen_bytes[3], visual_bytes[0], visual_bytes[1], visual_bytes[2], visual_bytes[3], pixmap_bytes[0], pixmap_bytes[1], pixmap_bytes[2], pixmap_bytes[3], glx_pixmap_bytes[0], glx_pixmap_bytes[1], glx_pixmap_bytes[2], glx_pixmap_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != CREATE_GLX_PIXMAP_REQUEST { return Err(ParseError::InvalidValue); } let (screen, remaining) = u32::try_parse(value)?; let (visual, remaining) = xproto::Visualid::try_parse(remaining)?; let (pixmap, remaining) = xproto::Pixmap::try_parse(remaining)?; let (glx_pixmap, remaining) = Pixmap::try_parse(remaining)?; let _ = remaining; Ok(CreateGLXPixmapRequest { screen, visual, pixmap, glx_pixmap, }) } } impl Request for CreateGLXPixmapRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for CreateGLXPixmapRequest { } /// Opcode for the GetVisualConfigs request pub const GET_VISUAL_CONFIGS_REQUEST: u8 = 14; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetVisualConfigsRequest { pub screen: u32, } impl_debug_if_no_extra_traits!(GetVisualConfigsRequest, "GetVisualConfigsRequest"); impl GetVisualConfigsRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let screen_bytes = self.screen.serialize(); let mut request0 = vec![ major_opcode, GET_VISUAL_CONFIGS_REQUEST, 0, 0, screen_bytes[0], screen_bytes[1], screen_bytes[2], screen_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_VISUAL_CONFIGS_REQUEST { return Err(ParseError::InvalidValue); } let (screen, remaining) = u32::try_parse(value)?; let _ = remaining; Ok(GetVisualConfigsRequest { screen, }) } } impl Request for GetVisualConfigsRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetVisualConfigsRequest { type Reply = GetVisualConfigsReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetVisualConfigsReply { pub sequence: u16, pub num_visuals: u32, pub num_properties: u32, pub property_list: Vec, } impl_debug_if_no_extra_traits!(GetVisualConfigsReply, "GetVisualConfigsReply"); impl TryParse for GetVisualConfigsReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (num_visuals, remaining) = u32::try_parse(remaining)?; let (num_properties, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?; let (property_list, remaining) = crate::x11_utils::parse_list::(remaining, length.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetVisualConfigsReply { sequence, num_visuals, num_properties, property_list }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetVisualConfigsReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); let length = u32::try_from(self.property_list.len()).expect("`property_list` has too many elements"); length.serialize_into(bytes); self.num_visuals.serialize_into(bytes); self.num_properties.serialize_into(bytes); bytes.extend_from_slice(&[0; 16]); self.property_list.serialize_into(bytes); } } impl GetVisualConfigsReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `property_list` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.property_list.len() .try_into().unwrap() } } /// Opcode for the DestroyGLXPixmap request pub const DESTROY_GLX_PIXMAP_REQUEST: u8 = 15; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DestroyGLXPixmapRequest { pub glx_pixmap: Pixmap, } impl_debug_if_no_extra_traits!(DestroyGLXPixmapRequest, "DestroyGLXPixmapRequest"); impl DestroyGLXPixmapRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let glx_pixmap_bytes = self.glx_pixmap.serialize(); let mut request0 = vec![ major_opcode, DESTROY_GLX_PIXMAP_REQUEST, 0, 0, glx_pixmap_bytes[0], glx_pixmap_bytes[1], glx_pixmap_bytes[2], glx_pixmap_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != DESTROY_GLX_PIXMAP_REQUEST { return Err(ParseError::InvalidValue); } let (glx_pixmap, remaining) = Pixmap::try_parse(value)?; let _ = remaining; Ok(DestroyGLXPixmapRequest { glx_pixmap, }) } } impl Request for DestroyGLXPixmapRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for DestroyGLXPixmapRequest { } /// Opcode for the VendorPrivate request pub const VENDOR_PRIVATE_REQUEST: u8 = 16; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct VendorPrivateRequest<'input> { pub vendor_code: u32, pub context_tag: ContextTag, pub data: Cow<'input, [u8]>, } impl_debug_if_no_extra_traits!(VendorPrivateRequest<'_>, "VendorPrivateRequest"); impl<'input> VendorPrivateRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let vendor_code_bytes = self.vendor_code.serialize(); let context_tag_bytes = self.context_tag.serialize(); let mut request0 = vec![ major_opcode, VENDOR_PRIVATE_REQUEST, 0, 0, vendor_code_bytes[0], vendor_code_bytes[1], vendor_code_bytes[2], vendor_code_bytes[3], context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let length_so_far = length_so_far + self.data.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), self.data, padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != VENDOR_PRIVATE_REQUEST { return Err(ParseError::InvalidValue); } let (vendor_code, remaining) = u32::try_parse(value)?; let (context_tag, remaining) = ContextTag::try_parse(remaining)?; let (data, remaining) = remaining.split_at(remaining.len()); let _ = remaining; Ok(VendorPrivateRequest { vendor_code, context_tag, data: Cow::Borrowed(data), }) } /// Clone all borrowed data in this VendorPrivateRequest. pub fn into_owned(self) -> VendorPrivateRequest<'static> { VendorPrivateRequest { vendor_code: self.vendor_code, context_tag: self.context_tag, data: Cow::Owned(self.data.into_owned()), } } } impl<'input> Request for VendorPrivateRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::VoidRequest for VendorPrivateRequest<'input> { } /// Opcode for the VendorPrivateWithReply request pub const VENDOR_PRIVATE_WITH_REPLY_REQUEST: u8 = 17; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct VendorPrivateWithReplyRequest<'input> { pub vendor_code: u32, pub context_tag: ContextTag, pub data: Cow<'input, [u8]>, } impl_debug_if_no_extra_traits!(VendorPrivateWithReplyRequest<'_>, "VendorPrivateWithReplyRequest"); impl<'input> VendorPrivateWithReplyRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let vendor_code_bytes = self.vendor_code.serialize(); let context_tag_bytes = self.context_tag.serialize(); let mut request0 = vec![ major_opcode, VENDOR_PRIVATE_WITH_REPLY_REQUEST, 0, 0, vendor_code_bytes[0], vendor_code_bytes[1], vendor_code_bytes[2], vendor_code_bytes[3], context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let length_so_far = length_so_far + self.data.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), self.data, padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != VENDOR_PRIVATE_WITH_REPLY_REQUEST { return Err(ParseError::InvalidValue); } let (vendor_code, remaining) = u32::try_parse(value)?; let (context_tag, remaining) = ContextTag::try_parse(remaining)?; let (data, remaining) = remaining.split_at(remaining.len()); let _ = remaining; Ok(VendorPrivateWithReplyRequest { vendor_code, context_tag, data: Cow::Borrowed(data), }) } /// Clone all borrowed data in this VendorPrivateWithReplyRequest. pub fn into_owned(self) -> VendorPrivateWithReplyRequest<'static> { VendorPrivateWithReplyRequest { vendor_code: self.vendor_code, context_tag: self.context_tag, data: Cow::Owned(self.data.into_owned()), } } } impl<'input> Request for VendorPrivateWithReplyRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::ReplyRequest for VendorPrivateWithReplyRequest<'input> { type Reply = VendorPrivateWithReplyReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct VendorPrivateWithReplyReply { pub sequence: u16, pub retval: u32, pub data1: [u8; 24], pub data2: Vec, } impl_debug_if_no_extra_traits!(VendorPrivateWithReplyReply, "VendorPrivateWithReplyReply"); impl TryParse for VendorPrivateWithReplyReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (retval, remaining) = u32::try_parse(remaining)?; let (data1, remaining) = crate::x11_utils::parse_u8_array::<24>(remaining)?; let (data2, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let data2 = data2.to_vec(); if response_type != 1 { return Err(ParseError::InvalidValue); } let result = VendorPrivateWithReplyReply { sequence, retval, data1, data2 }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for VendorPrivateWithReplyReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(36); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); assert_eq!(self.data2.len() % 4, 0, "`data2` has an incorrect length, must be a multiple of 4"); let length = u32::try_from(self.data2.len() / 4).expect("`data2` has too many elements"); length.serialize_into(bytes); self.retval.serialize_into(bytes); bytes.extend_from_slice(&self.data1); bytes.extend_from_slice(&self.data2); } } impl VendorPrivateWithReplyReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `data2` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.data2.len() .checked_div(4).unwrap() .try_into().unwrap() } } /// Opcode for the QueryExtensionsString request pub const QUERY_EXTENSIONS_STRING_REQUEST: u8 = 18; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryExtensionsStringRequest { pub screen: u32, } impl_debug_if_no_extra_traits!(QueryExtensionsStringRequest, "QueryExtensionsStringRequest"); impl QueryExtensionsStringRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let screen_bytes = self.screen.serialize(); let mut request0 = vec![ major_opcode, QUERY_EXTENSIONS_STRING_REQUEST, 0, 0, screen_bytes[0], screen_bytes[1], screen_bytes[2], screen_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != QUERY_EXTENSIONS_STRING_REQUEST { return Err(ParseError::InvalidValue); } let (screen, remaining) = u32::try_parse(value)?; let _ = remaining; Ok(QueryExtensionsStringRequest { screen, }) } } impl Request for QueryExtensionsStringRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for QueryExtensionsStringRequest { type Reply = QueryExtensionsStringReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryExtensionsStringReply { pub sequence: u16, pub length: u32, pub n: u32, } impl_debug_if_no_extra_traits!(QueryExtensionsStringReply, "QueryExtensionsStringReply"); impl TryParse for QueryExtensionsStringReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = QueryExtensionsStringReply { sequence, length, n }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for QueryExtensionsStringReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let n_bytes = self.n.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], 0, 0, 0, 0, n_bytes[0], n_bytes[1], n_bytes[2], n_bytes[3], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); self.n.serialize_into(bytes); bytes.extend_from_slice(&[0; 16]); } } /// Opcode for the QueryServerString request pub const QUERY_SERVER_STRING_REQUEST: u8 = 19; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryServerStringRequest { pub screen: u32, pub name: u32, } impl_debug_if_no_extra_traits!(QueryServerStringRequest, "QueryServerStringRequest"); impl QueryServerStringRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let screen_bytes = self.screen.serialize(); let name_bytes = self.name.serialize(); let mut request0 = vec![ major_opcode, QUERY_SERVER_STRING_REQUEST, 0, 0, screen_bytes[0], screen_bytes[1], screen_bytes[2], screen_bytes[3], name_bytes[0], name_bytes[1], name_bytes[2], name_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != QUERY_SERVER_STRING_REQUEST { return Err(ParseError::InvalidValue); } let (screen, remaining) = u32::try_parse(value)?; let (name, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(QueryServerStringRequest { screen, name, }) } } impl Request for QueryServerStringRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for QueryServerStringRequest { type Reply = QueryServerStringReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryServerStringReply { pub sequence: u16, pub length: u32, pub string: Vec, } impl_debug_if_no_extra_traits!(QueryServerStringReply, "QueryServerStringReply"); impl TryParse for QueryServerStringReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (str_len, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?; let (string, remaining) = crate::x11_utils::parse_u8_list(remaining, str_len.try_to_usize()?)?; let string = string.to_vec(); if response_type != 1 { return Err(ParseError::InvalidValue); } let result = QueryServerStringReply { sequence, length, string }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for QueryServerStringReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let str_len = u32::try_from(self.string.len()).expect("`string` has too many elements"); str_len.serialize_into(bytes); bytes.extend_from_slice(&[0; 16]); bytes.extend_from_slice(&self.string); } } impl QueryServerStringReply { /// Get the value of the `str_len` field. /// /// The `str_len` field is used as the length field of the `string` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn str_len(&self) -> u32 { self.string.len() .try_into().unwrap() } } /// Opcode for the ClientInfo request pub const CLIENT_INFO_REQUEST: u8 = 20; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ClientInfoRequest<'input> { pub major_version: u32, pub minor_version: u32, pub string: Cow<'input, [u8]>, } impl_debug_if_no_extra_traits!(ClientInfoRequest<'_>, "ClientInfoRequest"); impl<'input> ClientInfoRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let major_version_bytes = self.major_version.serialize(); let minor_version_bytes = self.minor_version.serialize(); let str_len = u32::try_from(self.string.len()).expect("`string` has too many elements"); let str_len_bytes = str_len.serialize(); let mut request0 = vec![ major_opcode, CLIENT_INFO_REQUEST, 0, 0, major_version_bytes[0], major_version_bytes[1], major_version_bytes[2], major_version_bytes[3], minor_version_bytes[0], minor_version_bytes[1], minor_version_bytes[2], minor_version_bytes[3], str_len_bytes[0], str_len_bytes[1], str_len_bytes[2], str_len_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let length_so_far = length_so_far + self.string.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), self.string, padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != CLIENT_INFO_REQUEST { return Err(ParseError::InvalidValue); } let (major_version, remaining) = u32::try_parse(value)?; let (minor_version, remaining) = u32::try_parse(remaining)?; let (str_len, remaining) = u32::try_parse(remaining)?; let (string, remaining) = crate::x11_utils::parse_u8_list(remaining, str_len.try_to_usize()?)?; let _ = remaining; Ok(ClientInfoRequest { major_version, minor_version, string: Cow::Borrowed(string), }) } /// Clone all borrowed data in this ClientInfoRequest. pub fn into_owned(self) -> ClientInfoRequest<'static> { ClientInfoRequest { major_version: self.major_version, minor_version: self.minor_version, string: Cow::Owned(self.string.into_owned()), } } } impl<'input> Request for ClientInfoRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::VoidRequest for ClientInfoRequest<'input> { } /// Opcode for the GetFBConfigs request pub const GET_FB_CONFIGS_REQUEST: u8 = 21; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetFBConfigsRequest { pub screen: u32, } impl_debug_if_no_extra_traits!(GetFBConfigsRequest, "GetFBConfigsRequest"); impl GetFBConfigsRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let screen_bytes = self.screen.serialize(); let mut request0 = vec![ major_opcode, GET_FB_CONFIGS_REQUEST, 0, 0, screen_bytes[0], screen_bytes[1], screen_bytes[2], screen_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_FB_CONFIGS_REQUEST { return Err(ParseError::InvalidValue); } let (screen, remaining) = u32::try_parse(value)?; let _ = remaining; Ok(GetFBConfigsRequest { screen, }) } } impl Request for GetFBConfigsRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetFBConfigsRequest { type Reply = GetFBConfigsReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetFBConfigsReply { pub sequence: u16, pub num_fb_configs: u32, pub num_properties: u32, pub property_list: Vec, } impl_debug_if_no_extra_traits!(GetFBConfigsReply, "GetFBConfigsReply"); impl TryParse for GetFBConfigsReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (num_fb_configs, remaining) = u32::try_parse(remaining)?; let (num_properties, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?; let (property_list, remaining) = crate::x11_utils::parse_list::(remaining, length.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetFBConfigsReply { sequence, num_fb_configs, num_properties, property_list }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetFBConfigsReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); let length = u32::try_from(self.property_list.len()).expect("`property_list` has too many elements"); length.serialize_into(bytes); self.num_fb_configs.serialize_into(bytes); self.num_properties.serialize_into(bytes); bytes.extend_from_slice(&[0; 16]); self.property_list.serialize_into(bytes); } } impl GetFBConfigsReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `property_list` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.property_list.len() .try_into().unwrap() } } /// Opcode for the CreatePixmap request pub const CREATE_PIXMAP_REQUEST: u8 = 22; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreatePixmapRequest<'input> { pub screen: u32, pub fbconfig: Fbconfig, pub pixmap: xproto::Pixmap, pub glx_pixmap: Pixmap, pub attribs: Cow<'input, [u32]>, } impl_debug_if_no_extra_traits!(CreatePixmapRequest<'_>, "CreatePixmapRequest"); impl<'input> CreatePixmapRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let screen_bytes = self.screen.serialize(); let fbconfig_bytes = self.fbconfig.serialize(); let pixmap_bytes = self.pixmap.serialize(); let glx_pixmap_bytes = self.glx_pixmap.serialize(); assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2"); let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements"); let num_attribs_bytes = num_attribs.serialize(); let mut request0 = vec![ major_opcode, CREATE_PIXMAP_REQUEST, 0, 0, screen_bytes[0], screen_bytes[1], screen_bytes[2], screen_bytes[3], fbconfig_bytes[0], fbconfig_bytes[1], fbconfig_bytes[2], fbconfig_bytes[3], pixmap_bytes[0], pixmap_bytes[1], pixmap_bytes[2], pixmap_bytes[3], glx_pixmap_bytes[0], glx_pixmap_bytes[1], glx_pixmap_bytes[2], glx_pixmap_bytes[3], num_attribs_bytes[0], num_attribs_bytes[1], num_attribs_bytes[2], num_attribs_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let attribs_bytes = self.attribs.serialize(); let length_so_far = length_so_far + attribs_bytes.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), attribs_bytes.into(), padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != CREATE_PIXMAP_REQUEST { return Err(ParseError::InvalidValue); } let (screen, remaining) = u32::try_parse(value)?; let (fbconfig, remaining) = Fbconfig::try_parse(remaining)?; let (pixmap, remaining) = xproto::Pixmap::try_parse(remaining)?; let (glx_pixmap, remaining) = Pixmap::try_parse(remaining)?; let (num_attribs, remaining) = u32::try_parse(remaining)?; let (attribs, remaining) = crate::x11_utils::parse_list::(remaining, u32::from(num_attribs).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let _ = remaining; Ok(CreatePixmapRequest { screen, fbconfig, pixmap, glx_pixmap, attribs: Cow::Owned(attribs), }) } /// Clone all borrowed data in this CreatePixmapRequest. pub fn into_owned(self) -> CreatePixmapRequest<'static> { CreatePixmapRequest { screen: self.screen, fbconfig: self.fbconfig, pixmap: self.pixmap, glx_pixmap: self.glx_pixmap, attribs: Cow::Owned(self.attribs.into_owned()), } } } impl<'input> Request for CreatePixmapRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::VoidRequest for CreatePixmapRequest<'input> { } /// Opcode for the DestroyPixmap request pub const DESTROY_PIXMAP_REQUEST: u8 = 23; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DestroyPixmapRequest { pub glx_pixmap: Pixmap, } impl_debug_if_no_extra_traits!(DestroyPixmapRequest, "DestroyPixmapRequest"); impl DestroyPixmapRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let glx_pixmap_bytes = self.glx_pixmap.serialize(); let mut request0 = vec![ major_opcode, DESTROY_PIXMAP_REQUEST, 0, 0, glx_pixmap_bytes[0], glx_pixmap_bytes[1], glx_pixmap_bytes[2], glx_pixmap_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != DESTROY_PIXMAP_REQUEST { return Err(ParseError::InvalidValue); } let (glx_pixmap, remaining) = Pixmap::try_parse(value)?; let _ = remaining; Ok(DestroyPixmapRequest { glx_pixmap, }) } } impl Request for DestroyPixmapRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for DestroyPixmapRequest { } /// Opcode for the CreateNewContext request pub const CREATE_NEW_CONTEXT_REQUEST: u8 = 24; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateNewContextRequest { pub context: Context, pub fbconfig: Fbconfig, pub screen: u32, pub render_type: u32, pub share_list: Context, pub is_direct: bool, } impl_debug_if_no_extra_traits!(CreateNewContextRequest, "CreateNewContextRequest"); impl CreateNewContextRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_bytes = self.context.serialize(); let fbconfig_bytes = self.fbconfig.serialize(); let screen_bytes = self.screen.serialize(); let render_type_bytes = self.render_type.serialize(); let share_list_bytes = self.share_list.serialize(); let is_direct_bytes = self.is_direct.serialize(); let mut request0 = vec![ major_opcode, CREATE_NEW_CONTEXT_REQUEST, 0, 0, context_bytes[0], context_bytes[1], context_bytes[2], context_bytes[3], fbconfig_bytes[0], fbconfig_bytes[1], fbconfig_bytes[2], fbconfig_bytes[3], screen_bytes[0], screen_bytes[1], screen_bytes[2], screen_bytes[3], render_type_bytes[0], render_type_bytes[1], render_type_bytes[2], render_type_bytes[3], share_list_bytes[0], share_list_bytes[1], share_list_bytes[2], share_list_bytes[3], is_direct_bytes[0], 0, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != CREATE_NEW_CONTEXT_REQUEST { return Err(ParseError::InvalidValue); } let (context, remaining) = Context::try_parse(value)?; let (fbconfig, remaining) = Fbconfig::try_parse(remaining)?; let (screen, remaining) = u32::try_parse(remaining)?; let (render_type, remaining) = u32::try_parse(remaining)?; let (share_list, remaining) = Context::try_parse(remaining)?; let (is_direct, remaining) = bool::try_parse(remaining)?; let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?; let _ = remaining; Ok(CreateNewContextRequest { context, fbconfig, screen, render_type, share_list, is_direct, }) } } impl Request for CreateNewContextRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for CreateNewContextRequest { } /// Opcode for the QueryContext request pub const QUERY_CONTEXT_REQUEST: u8 = 25; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryContextRequest { pub context: Context, } impl_debug_if_no_extra_traits!(QueryContextRequest, "QueryContextRequest"); impl QueryContextRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_bytes = self.context.serialize(); let mut request0 = vec![ major_opcode, QUERY_CONTEXT_REQUEST, 0, 0, context_bytes[0], context_bytes[1], context_bytes[2], context_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != QUERY_CONTEXT_REQUEST { return Err(ParseError::InvalidValue); } let (context, remaining) = Context::try_parse(value)?; let _ = remaining; Ok(QueryContextRequest { context, }) } } impl Request for QueryContextRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for QueryContextRequest { type Reply = QueryContextReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct QueryContextReply { pub sequence: u16, pub length: u32, pub attribs: Vec, } impl_debug_if_no_extra_traits!(QueryContextReply, "QueryContextReply"); impl TryParse for QueryContextReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (num_attribs, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?; let (attribs, remaining) = crate::x11_utils::parse_list::(remaining, u32::from(num_attribs).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = QueryContextReply { sequence, length, attribs }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for QueryContextReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2"); let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements"); num_attribs.serialize_into(bytes); bytes.extend_from_slice(&[0; 20]); self.attribs.serialize_into(bytes); } } impl QueryContextReply { /// Get the value of the `num_attribs` field. /// /// The `num_attribs` field is used as the length field of the `attribs` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn num_attribs(&self) -> u32 { self.attribs.len() .checked_div(2).unwrap() .try_into().unwrap() } } /// Opcode for the MakeContextCurrent request pub const MAKE_CONTEXT_CURRENT_REQUEST: u8 = 26; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MakeContextCurrentRequest { pub old_context_tag: ContextTag, pub drawable: Drawable, pub read_drawable: Drawable, pub context: Context, } impl_debug_if_no_extra_traits!(MakeContextCurrentRequest, "MakeContextCurrentRequest"); impl MakeContextCurrentRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let old_context_tag_bytes = self.old_context_tag.serialize(); let drawable_bytes = self.drawable.serialize(); let read_drawable_bytes = self.read_drawable.serialize(); let context_bytes = self.context.serialize(); let mut request0 = vec![ major_opcode, MAKE_CONTEXT_CURRENT_REQUEST, 0, 0, old_context_tag_bytes[0], old_context_tag_bytes[1], old_context_tag_bytes[2], old_context_tag_bytes[3], drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], read_drawable_bytes[0], read_drawable_bytes[1], read_drawable_bytes[2], read_drawable_bytes[3], context_bytes[0], context_bytes[1], context_bytes[2], context_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != MAKE_CONTEXT_CURRENT_REQUEST { return Err(ParseError::InvalidValue); } let (old_context_tag, remaining) = ContextTag::try_parse(value)?; let (drawable, remaining) = Drawable::try_parse(remaining)?; let (read_drawable, remaining) = Drawable::try_parse(remaining)?; let (context, remaining) = Context::try_parse(remaining)?; let _ = remaining; Ok(MakeContextCurrentRequest { old_context_tag, drawable, read_drawable, context, }) } } impl Request for MakeContextCurrentRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for MakeContextCurrentRequest { type Reply = MakeContextCurrentReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct MakeContextCurrentReply { pub sequence: u16, pub length: u32, pub context_tag: ContextTag, } impl_debug_if_no_extra_traits!(MakeContextCurrentReply, "MakeContextCurrentReply"); impl TryParse for MakeContextCurrentReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (context_tag, remaining) = ContextTag::try_parse(remaining)?; let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = MakeContextCurrentReply { sequence, length, context_tag }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for MakeContextCurrentReply { type Bytes = [u8; 32]; fn serialize(&self) -> [u8; 32] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let context_tag_bytes = self.context_tag.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.context_tag.serialize_into(bytes); bytes.extend_from_slice(&[0; 20]); } } /// Opcode for the CreatePbuffer request pub const CREATE_PBUFFER_REQUEST: u8 = 27; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreatePbufferRequest<'input> { pub screen: u32, pub fbconfig: Fbconfig, pub pbuffer: Pbuffer, pub attribs: Cow<'input, [u32]>, } impl_debug_if_no_extra_traits!(CreatePbufferRequest<'_>, "CreatePbufferRequest"); impl<'input> CreatePbufferRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let screen_bytes = self.screen.serialize(); let fbconfig_bytes = self.fbconfig.serialize(); let pbuffer_bytes = self.pbuffer.serialize(); assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2"); let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements"); let num_attribs_bytes = num_attribs.serialize(); let mut request0 = vec![ major_opcode, CREATE_PBUFFER_REQUEST, 0, 0, screen_bytes[0], screen_bytes[1], screen_bytes[2], screen_bytes[3], fbconfig_bytes[0], fbconfig_bytes[1], fbconfig_bytes[2], fbconfig_bytes[3], pbuffer_bytes[0], pbuffer_bytes[1], pbuffer_bytes[2], pbuffer_bytes[3], num_attribs_bytes[0], num_attribs_bytes[1], num_attribs_bytes[2], num_attribs_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let attribs_bytes = self.attribs.serialize(); let length_so_far = length_so_far + attribs_bytes.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), attribs_bytes.into(), padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != CREATE_PBUFFER_REQUEST { return Err(ParseError::InvalidValue); } let (screen, remaining) = u32::try_parse(value)?; let (fbconfig, remaining) = Fbconfig::try_parse(remaining)?; let (pbuffer, remaining) = Pbuffer::try_parse(remaining)?; let (num_attribs, remaining) = u32::try_parse(remaining)?; let (attribs, remaining) = crate::x11_utils::parse_list::(remaining, u32::from(num_attribs).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let _ = remaining; Ok(CreatePbufferRequest { screen, fbconfig, pbuffer, attribs: Cow::Owned(attribs), }) } /// Clone all borrowed data in this CreatePbufferRequest. pub fn into_owned(self) -> CreatePbufferRequest<'static> { CreatePbufferRequest { screen: self.screen, fbconfig: self.fbconfig, pbuffer: self.pbuffer, attribs: Cow::Owned(self.attribs.into_owned()), } } } impl<'input> Request for CreatePbufferRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::VoidRequest for CreatePbufferRequest<'input> { } /// Opcode for the DestroyPbuffer request pub const DESTROY_PBUFFER_REQUEST: u8 = 28; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DestroyPbufferRequest { pub pbuffer: Pbuffer, } impl_debug_if_no_extra_traits!(DestroyPbufferRequest, "DestroyPbufferRequest"); impl DestroyPbufferRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let pbuffer_bytes = self.pbuffer.serialize(); let mut request0 = vec![ major_opcode, DESTROY_PBUFFER_REQUEST, 0, 0, pbuffer_bytes[0], pbuffer_bytes[1], pbuffer_bytes[2], pbuffer_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != DESTROY_PBUFFER_REQUEST { return Err(ParseError::InvalidValue); } let (pbuffer, remaining) = Pbuffer::try_parse(value)?; let _ = remaining; Ok(DestroyPbufferRequest { pbuffer, }) } } impl Request for DestroyPbufferRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for DestroyPbufferRequest { } /// Opcode for the GetDrawableAttributes request pub const GET_DRAWABLE_ATTRIBUTES_REQUEST: u8 = 29; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetDrawableAttributesRequest { pub drawable: Drawable, } impl_debug_if_no_extra_traits!(GetDrawableAttributesRequest, "GetDrawableAttributesRequest"); impl GetDrawableAttributesRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); let mut request0 = vec![ major_opcode, GET_DRAWABLE_ATTRIBUTES_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_DRAWABLE_ATTRIBUTES_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = Drawable::try_parse(value)?; let _ = remaining; Ok(GetDrawableAttributesRequest { drawable, }) } } impl Request for GetDrawableAttributesRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetDrawableAttributesRequest { type Reply = GetDrawableAttributesReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetDrawableAttributesReply { pub sequence: u16, pub length: u32, pub attribs: Vec, } impl_debug_if_no_extra_traits!(GetDrawableAttributesReply, "GetDrawableAttributesReply"); impl TryParse for GetDrawableAttributesReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (num_attribs, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?; let (attribs, remaining) = crate::x11_utils::parse_list::(remaining, u32::from(num_attribs).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetDrawableAttributesReply { sequence, length, attribs }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetDrawableAttributesReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2"); let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements"); num_attribs.serialize_into(bytes); bytes.extend_from_slice(&[0; 20]); self.attribs.serialize_into(bytes); } } impl GetDrawableAttributesReply { /// Get the value of the `num_attribs` field. /// /// The `num_attribs` field is used as the length field of the `attribs` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn num_attribs(&self) -> u32 { self.attribs.len() .checked_div(2).unwrap() .try_into().unwrap() } } /// Opcode for the ChangeDrawableAttributes request pub const CHANGE_DRAWABLE_ATTRIBUTES_REQUEST: u8 = 30; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ChangeDrawableAttributesRequest<'input> { pub drawable: Drawable, pub attribs: Cow<'input, [u32]>, } impl_debug_if_no_extra_traits!(ChangeDrawableAttributesRequest<'_>, "ChangeDrawableAttributesRequest"); impl<'input> ChangeDrawableAttributesRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let drawable_bytes = self.drawable.serialize(); assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2"); let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements"); let num_attribs_bytes = num_attribs.serialize(); let mut request0 = vec![ major_opcode, CHANGE_DRAWABLE_ATTRIBUTES_REQUEST, 0, 0, drawable_bytes[0], drawable_bytes[1], drawable_bytes[2], drawable_bytes[3], num_attribs_bytes[0], num_attribs_bytes[1], num_attribs_bytes[2], num_attribs_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let attribs_bytes = self.attribs.serialize(); let length_so_far = length_so_far + attribs_bytes.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), attribs_bytes.into(), padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != CHANGE_DRAWABLE_ATTRIBUTES_REQUEST { return Err(ParseError::InvalidValue); } let (drawable, remaining) = Drawable::try_parse(value)?; let (num_attribs, remaining) = u32::try_parse(remaining)?; let (attribs, remaining) = crate::x11_utils::parse_list::(remaining, u32::from(num_attribs).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let _ = remaining; Ok(ChangeDrawableAttributesRequest { drawable, attribs: Cow::Owned(attribs), }) } /// Clone all borrowed data in this ChangeDrawableAttributesRequest. pub fn into_owned(self) -> ChangeDrawableAttributesRequest<'static> { ChangeDrawableAttributesRequest { drawable: self.drawable, attribs: Cow::Owned(self.attribs.into_owned()), } } } impl<'input> Request for ChangeDrawableAttributesRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::VoidRequest for ChangeDrawableAttributesRequest<'input> { } /// Opcode for the CreateWindow request pub const CREATE_WINDOW_REQUEST: u8 = 31; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateWindowRequest<'input> { pub screen: u32, pub fbconfig: Fbconfig, pub window: xproto::Window, pub glx_window: Window, pub attribs: Cow<'input, [u32]>, } impl_debug_if_no_extra_traits!(CreateWindowRequest<'_>, "CreateWindowRequest"); impl<'input> CreateWindowRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let screen_bytes = self.screen.serialize(); let fbconfig_bytes = self.fbconfig.serialize(); let window_bytes = self.window.serialize(); let glx_window_bytes = self.glx_window.serialize(); assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2"); let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements"); let num_attribs_bytes = num_attribs.serialize(); let mut request0 = vec![ major_opcode, CREATE_WINDOW_REQUEST, 0, 0, screen_bytes[0], screen_bytes[1], screen_bytes[2], screen_bytes[3], fbconfig_bytes[0], fbconfig_bytes[1], fbconfig_bytes[2], fbconfig_bytes[3], window_bytes[0], window_bytes[1], window_bytes[2], window_bytes[3], glx_window_bytes[0], glx_window_bytes[1], glx_window_bytes[2], glx_window_bytes[3], num_attribs_bytes[0], num_attribs_bytes[1], num_attribs_bytes[2], num_attribs_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let attribs_bytes = self.attribs.serialize(); let length_so_far = length_so_far + attribs_bytes.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), attribs_bytes.into(), padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != CREATE_WINDOW_REQUEST { return Err(ParseError::InvalidValue); } let (screen, remaining) = u32::try_parse(value)?; let (fbconfig, remaining) = Fbconfig::try_parse(remaining)?; let (window, remaining) = xproto::Window::try_parse(remaining)?; let (glx_window, remaining) = Window::try_parse(remaining)?; let (num_attribs, remaining) = u32::try_parse(remaining)?; let (attribs, remaining) = crate::x11_utils::parse_list::(remaining, u32::from(num_attribs).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let _ = remaining; Ok(CreateWindowRequest { screen, fbconfig, window, glx_window, attribs: Cow::Owned(attribs), }) } /// Clone all borrowed data in this CreateWindowRequest. pub fn into_owned(self) -> CreateWindowRequest<'static> { CreateWindowRequest { screen: self.screen, fbconfig: self.fbconfig, window: self.window, glx_window: self.glx_window, attribs: Cow::Owned(self.attribs.into_owned()), } } } impl<'input> Request for CreateWindowRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::VoidRequest for CreateWindowRequest<'input> { } /// Opcode for the DeleteWindow request pub const DELETE_WINDOW_REQUEST: u8 = 32; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DeleteWindowRequest { pub glxwindow: Window, } impl_debug_if_no_extra_traits!(DeleteWindowRequest, "DeleteWindowRequest"); impl DeleteWindowRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let glxwindow_bytes = self.glxwindow.serialize(); let mut request0 = vec![ major_opcode, DELETE_WINDOW_REQUEST, 0, 0, glxwindow_bytes[0], glxwindow_bytes[1], glxwindow_bytes[2], glxwindow_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != DELETE_WINDOW_REQUEST { return Err(ParseError::InvalidValue); } let (glxwindow, remaining) = Window::try_parse(value)?; let _ = remaining; Ok(DeleteWindowRequest { glxwindow, }) } } impl Request for DeleteWindowRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for DeleteWindowRequest { } /// Opcode for the SetClientInfoARB request pub const SET_CLIENT_INFO_ARB_REQUEST: u8 = 33; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetClientInfoARBRequest<'input> { pub major_version: u32, pub minor_version: u32, pub gl_versions: Cow<'input, [u32]>, pub gl_extension_string: Cow<'input, [u8]>, pub glx_extension_string: Cow<'input, [u8]>, } impl_debug_if_no_extra_traits!(SetClientInfoARBRequest<'_>, "SetClientInfoARBRequest"); impl<'input> SetClientInfoARBRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 6]> { let length_so_far = 0; let major_version_bytes = self.major_version.serialize(); let minor_version_bytes = self.minor_version.serialize(); assert_eq!(self.gl_versions.len() % 2, 0, "`gl_versions` has an incorrect length, must be a multiple of 2"); let num_versions = u32::try_from(self.gl_versions.len() / 2).expect("`gl_versions` has too many elements"); let num_versions_bytes = num_versions.serialize(); let gl_str_len = u32::try_from(self.gl_extension_string.len()).expect("`gl_extension_string` has too many elements"); let gl_str_len_bytes = gl_str_len.serialize(); let glx_str_len = u32::try_from(self.glx_extension_string.len()).expect("`glx_extension_string` has too many elements"); let glx_str_len_bytes = glx_str_len.serialize(); let mut request0 = vec![ major_opcode, SET_CLIENT_INFO_ARB_REQUEST, 0, 0, major_version_bytes[0], major_version_bytes[1], major_version_bytes[2], major_version_bytes[3], minor_version_bytes[0], minor_version_bytes[1], minor_version_bytes[2], minor_version_bytes[3], num_versions_bytes[0], num_versions_bytes[1], num_versions_bytes[2], num_versions_bytes[3], gl_str_len_bytes[0], gl_str_len_bytes[1], gl_str_len_bytes[2], gl_str_len_bytes[3], glx_str_len_bytes[0], glx_str_len_bytes[1], glx_str_len_bytes[2], glx_str_len_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let gl_versions_bytes = self.gl_versions.serialize(); let length_so_far = length_so_far + gl_versions_bytes.len(); let length_so_far = length_so_far + self.gl_extension_string.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); let length_so_far = length_so_far + self.glx_extension_string.len(); let padding1 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding1.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), gl_versions_bytes.into(), self.gl_extension_string, padding0.into(), self.glx_extension_string, padding1.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != SET_CLIENT_INFO_ARB_REQUEST { return Err(ParseError::InvalidValue); } let (major_version, remaining) = u32::try_parse(value)?; let (minor_version, remaining) = u32::try_parse(remaining)?; let (num_versions, remaining) = u32::try_parse(remaining)?; let (gl_str_len, remaining) = u32::try_parse(remaining)?; let (glx_str_len, remaining) = u32::try_parse(remaining)?; let (gl_versions, remaining) = crate::x11_utils::parse_list::(remaining, u32::from(num_versions).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let (gl_extension_string, remaining) = crate::x11_utils::parse_u8_list(remaining, gl_str_len.try_to_usize()?)?; // Align offset to multiple of 4 let offset = remaining.as_ptr() as usize - value.as_ptr() as usize; let misalignment = (4 - (offset % 4)) % 4; let remaining = remaining.get(misalignment..).ok_or(ParseError::InsufficientData)?; let (glx_extension_string, remaining) = crate::x11_utils::parse_u8_list(remaining, glx_str_len.try_to_usize()?)?; let _ = remaining; Ok(SetClientInfoARBRequest { major_version, minor_version, gl_versions: Cow::Owned(gl_versions), gl_extension_string: Cow::Borrowed(gl_extension_string), glx_extension_string: Cow::Borrowed(glx_extension_string), }) } /// Clone all borrowed data in this SetClientInfoARBRequest. pub fn into_owned(self) -> SetClientInfoARBRequest<'static> { SetClientInfoARBRequest { major_version: self.major_version, minor_version: self.minor_version, gl_versions: Cow::Owned(self.gl_versions.into_owned()), gl_extension_string: Cow::Owned(self.gl_extension_string.into_owned()), glx_extension_string: Cow::Owned(self.glx_extension_string.into_owned()), } } } impl<'input> Request for SetClientInfoARBRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::VoidRequest for SetClientInfoARBRequest<'input> { } /// Opcode for the CreateContextAttribsARB request pub const CREATE_CONTEXT_ATTRIBS_ARB_REQUEST: u8 = 34; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct CreateContextAttribsARBRequest<'input> { pub context: Context, pub fbconfig: Fbconfig, pub screen: u32, pub share_list: Context, pub is_direct: bool, pub attribs: Cow<'input, [u32]>, } impl_debug_if_no_extra_traits!(CreateContextAttribsARBRequest<'_>, "CreateContextAttribsARBRequest"); impl<'input> CreateContextAttribsARBRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let context_bytes = self.context.serialize(); let fbconfig_bytes = self.fbconfig.serialize(); let screen_bytes = self.screen.serialize(); let share_list_bytes = self.share_list.serialize(); let is_direct_bytes = self.is_direct.serialize(); assert_eq!(self.attribs.len() % 2, 0, "`attribs` has an incorrect length, must be a multiple of 2"); let num_attribs = u32::try_from(self.attribs.len() / 2).expect("`attribs` has too many elements"); let num_attribs_bytes = num_attribs.serialize(); let mut request0 = vec![ major_opcode, CREATE_CONTEXT_ATTRIBS_ARB_REQUEST, 0, 0, context_bytes[0], context_bytes[1], context_bytes[2], context_bytes[3], fbconfig_bytes[0], fbconfig_bytes[1], fbconfig_bytes[2], fbconfig_bytes[3], screen_bytes[0], screen_bytes[1], screen_bytes[2], screen_bytes[3], share_list_bytes[0], share_list_bytes[1], share_list_bytes[2], share_list_bytes[3], is_direct_bytes[0], 0, 0, 0, num_attribs_bytes[0], num_attribs_bytes[1], num_attribs_bytes[2], num_attribs_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let attribs_bytes = self.attribs.serialize(); let length_so_far = length_so_far + attribs_bytes.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), attribs_bytes.into(), padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != CREATE_CONTEXT_ATTRIBS_ARB_REQUEST { return Err(ParseError::InvalidValue); } let (context, remaining) = Context::try_parse(value)?; let (fbconfig, remaining) = Fbconfig::try_parse(remaining)?; let (screen, remaining) = u32::try_parse(remaining)?; let (share_list, remaining) = Context::try_parse(remaining)?; let (is_direct, remaining) = bool::try_parse(remaining)?; let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?; let (num_attribs, remaining) = u32::try_parse(remaining)?; let (attribs, remaining) = crate::x11_utils::parse_list::(remaining, u32::from(num_attribs).checked_mul(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let _ = remaining; Ok(CreateContextAttribsARBRequest { context, fbconfig, screen, share_list, is_direct, attribs: Cow::Owned(attribs), }) } /// Clone all borrowed data in this CreateContextAttribsARBRequest. pub fn into_owned(self) -> CreateContextAttribsARBRequest<'static> { CreateContextAttribsARBRequest { context: self.context, fbconfig: self.fbconfig, screen: self.screen, share_list: self.share_list, is_direct: self.is_direct, attribs: Cow::Owned(self.attribs.into_owned()), } } } impl<'input> Request for CreateContextAttribsARBRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::VoidRequest for CreateContextAttribsARBRequest<'input> { } /// Opcode for the SetClientInfo2ARB request pub const SET_CLIENT_INFO2_ARB_REQUEST: u8 = 35; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SetClientInfo2ARBRequest<'input> { pub major_version: u32, pub minor_version: u32, pub gl_versions: Cow<'input, [u32]>, pub gl_extension_string: Cow<'input, [u8]>, pub glx_extension_string: Cow<'input, [u8]>, } impl_debug_if_no_extra_traits!(SetClientInfo2ARBRequest<'_>, "SetClientInfo2ARBRequest"); impl<'input> SetClientInfo2ARBRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 6]> { let length_so_far = 0; let major_version_bytes = self.major_version.serialize(); let minor_version_bytes = self.minor_version.serialize(); assert_eq!(self.gl_versions.len() % 3, 0, "`gl_versions` has an incorrect length, must be a multiple of 3"); let num_versions = u32::try_from(self.gl_versions.len() / 3).expect("`gl_versions` has too many elements"); let num_versions_bytes = num_versions.serialize(); let gl_str_len = u32::try_from(self.gl_extension_string.len()).expect("`gl_extension_string` has too many elements"); let gl_str_len_bytes = gl_str_len.serialize(); let glx_str_len = u32::try_from(self.glx_extension_string.len()).expect("`glx_extension_string` has too many elements"); let glx_str_len_bytes = glx_str_len.serialize(); let mut request0 = vec![ major_opcode, SET_CLIENT_INFO2_ARB_REQUEST, 0, 0, major_version_bytes[0], major_version_bytes[1], major_version_bytes[2], major_version_bytes[3], minor_version_bytes[0], minor_version_bytes[1], minor_version_bytes[2], minor_version_bytes[3], num_versions_bytes[0], num_versions_bytes[1], num_versions_bytes[2], num_versions_bytes[3], gl_str_len_bytes[0], gl_str_len_bytes[1], gl_str_len_bytes[2], gl_str_len_bytes[3], glx_str_len_bytes[0], glx_str_len_bytes[1], glx_str_len_bytes[2], glx_str_len_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let gl_versions_bytes = self.gl_versions.serialize(); let length_so_far = length_so_far + gl_versions_bytes.len(); let length_so_far = length_so_far + self.gl_extension_string.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); let length_so_far = length_so_far + self.glx_extension_string.len(); let padding1 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding1.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), gl_versions_bytes.into(), self.gl_extension_string, padding0.into(), self.glx_extension_string, padding1.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != SET_CLIENT_INFO2_ARB_REQUEST { return Err(ParseError::InvalidValue); } let (major_version, remaining) = u32::try_parse(value)?; let (minor_version, remaining) = u32::try_parse(remaining)?; let (num_versions, remaining) = u32::try_parse(remaining)?; let (gl_str_len, remaining) = u32::try_parse(remaining)?; let (glx_str_len, remaining) = u32::try_parse(remaining)?; let (gl_versions, remaining) = crate::x11_utils::parse_list::(remaining, u32::from(num_versions).checked_mul(3u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let (gl_extension_string, remaining) = crate::x11_utils::parse_u8_list(remaining, gl_str_len.try_to_usize()?)?; // Align offset to multiple of 4 let offset = remaining.as_ptr() as usize - value.as_ptr() as usize; let misalignment = (4 - (offset % 4)) % 4; let remaining = remaining.get(misalignment..).ok_or(ParseError::InsufficientData)?; let (glx_extension_string, remaining) = crate::x11_utils::parse_u8_list(remaining, glx_str_len.try_to_usize()?)?; let _ = remaining; Ok(SetClientInfo2ARBRequest { major_version, minor_version, gl_versions: Cow::Owned(gl_versions), gl_extension_string: Cow::Borrowed(gl_extension_string), glx_extension_string: Cow::Borrowed(glx_extension_string), }) } /// Clone all borrowed data in this SetClientInfo2ARBRequest. pub fn into_owned(self) -> SetClientInfo2ARBRequest<'static> { SetClientInfo2ARBRequest { major_version: self.major_version, minor_version: self.minor_version, gl_versions: Cow::Owned(self.gl_versions.into_owned()), gl_extension_string: Cow::Owned(self.gl_extension_string.into_owned()), glx_extension_string: Cow::Owned(self.glx_extension_string.into_owned()), } } } impl<'input> Request for SetClientInfo2ARBRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::VoidRequest for SetClientInfo2ARBRequest<'input> { } /// Opcode for the NewList request pub const NEW_LIST_REQUEST: u8 = 101; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct NewListRequest { pub context_tag: ContextTag, pub list: u32, pub mode: u32, } impl_debug_if_no_extra_traits!(NewListRequest, "NewListRequest"); impl NewListRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let list_bytes = self.list.serialize(); let mode_bytes = self.mode.serialize(); let mut request0 = vec![ major_opcode, NEW_LIST_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], list_bytes[0], list_bytes[1], list_bytes[2], list_bytes[3], mode_bytes[0], mode_bytes[1], mode_bytes[2], mode_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != NEW_LIST_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (list, remaining) = u32::try_parse(remaining)?; let (mode, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(NewListRequest { context_tag, list, mode, }) } } impl Request for NewListRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for NewListRequest { } /// Opcode for the EndList request pub const END_LIST_REQUEST: u8 = 102; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct EndListRequest { pub context_tag: ContextTag, } impl_debug_if_no_extra_traits!(EndListRequest, "EndListRequest"); impl EndListRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let mut request0 = vec![ major_opcode, END_LIST_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != END_LIST_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let _ = remaining; Ok(EndListRequest { context_tag, }) } } impl Request for EndListRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for EndListRequest { } /// Opcode for the DeleteLists request pub const DELETE_LISTS_REQUEST: u8 = 103; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DeleteListsRequest { pub context_tag: ContextTag, pub list: u32, pub range: i32, } impl_debug_if_no_extra_traits!(DeleteListsRequest, "DeleteListsRequest"); impl DeleteListsRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let list_bytes = self.list.serialize(); let range_bytes = self.range.serialize(); let mut request0 = vec![ major_opcode, DELETE_LISTS_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], list_bytes[0], list_bytes[1], list_bytes[2], list_bytes[3], range_bytes[0], range_bytes[1], range_bytes[2], range_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != DELETE_LISTS_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (list, remaining) = u32::try_parse(remaining)?; let (range, remaining) = i32::try_parse(remaining)?; let _ = remaining; Ok(DeleteListsRequest { context_tag, list, range, }) } } impl Request for DeleteListsRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for DeleteListsRequest { } /// Opcode for the GenLists request pub const GEN_LISTS_REQUEST: u8 = 104; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GenListsRequest { pub context_tag: ContextTag, pub range: i32, } impl_debug_if_no_extra_traits!(GenListsRequest, "GenListsRequest"); impl GenListsRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let range_bytes = self.range.serialize(); let mut request0 = vec![ major_opcode, GEN_LISTS_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], range_bytes[0], range_bytes[1], range_bytes[2], range_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GEN_LISTS_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (range, remaining) = i32::try_parse(remaining)?; let _ = remaining; Ok(GenListsRequest { context_tag, range, }) } } impl Request for GenListsRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GenListsRequest { type Reply = GenListsReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GenListsReply { pub sequence: u16, pub length: u32, pub ret_val: u32, } impl_debug_if_no_extra_traits!(GenListsReply, "GenListsReply"); impl TryParse for GenListsReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (ret_val, remaining) = u32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GenListsReply { sequence, length, ret_val }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GenListsReply { type Bytes = [u8; 12]; fn serialize(&self) -> [u8; 12] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let ret_val_bytes = self.ret_val.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], ret_val_bytes[0], ret_val_bytes[1], ret_val_bytes[2], ret_val_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(12); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.ret_val.serialize_into(bytes); } } /// Opcode for the FeedbackBuffer request pub const FEEDBACK_BUFFER_REQUEST: u8 = 105; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct FeedbackBufferRequest { pub context_tag: ContextTag, pub size: i32, pub type_: i32, } impl_debug_if_no_extra_traits!(FeedbackBufferRequest, "FeedbackBufferRequest"); impl FeedbackBufferRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let size_bytes = self.size.serialize(); let type_bytes = self.type_.serialize(); let mut request0 = vec![ major_opcode, FEEDBACK_BUFFER_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], size_bytes[0], size_bytes[1], size_bytes[2], size_bytes[3], type_bytes[0], type_bytes[1], type_bytes[2], type_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != FEEDBACK_BUFFER_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (size, remaining) = i32::try_parse(remaining)?; let (type_, remaining) = i32::try_parse(remaining)?; let _ = remaining; Ok(FeedbackBufferRequest { context_tag, size, type_, }) } } impl Request for FeedbackBufferRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for FeedbackBufferRequest { } /// Opcode for the SelectBuffer request pub const SELECT_BUFFER_REQUEST: u8 = 106; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct SelectBufferRequest { pub context_tag: ContextTag, pub size: i32, } impl_debug_if_no_extra_traits!(SelectBufferRequest, "SelectBufferRequest"); impl SelectBufferRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let size_bytes = self.size.serialize(); let mut request0 = vec![ major_opcode, SELECT_BUFFER_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], size_bytes[0], size_bytes[1], size_bytes[2], size_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != SELECT_BUFFER_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (size, remaining) = i32::try_parse(remaining)?; let _ = remaining; Ok(SelectBufferRequest { context_tag, size, }) } } impl Request for SelectBufferRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for SelectBufferRequest { } /// Opcode for the RenderMode request pub const RENDER_MODE_REQUEST: u8 = 107; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct RenderModeRequest { pub context_tag: ContextTag, pub mode: u32, } impl_debug_if_no_extra_traits!(RenderModeRequest, "RenderModeRequest"); impl RenderModeRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let mode_bytes = self.mode.serialize(); let mut request0 = vec![ major_opcode, RENDER_MODE_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], mode_bytes[0], mode_bytes[1], mode_bytes[2], mode_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != RENDER_MODE_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (mode, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(RenderModeRequest { context_tag, mode, }) } } impl Request for RenderModeRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for RenderModeRequest { type Reply = RenderModeReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct RenderModeReply { pub sequence: u16, pub length: u32, pub ret_val: u32, pub new_mode: u32, pub data: Vec, } impl_debug_if_no_extra_traits!(RenderModeReply, "RenderModeReply"); impl TryParse for RenderModeReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (ret_val, remaining) = u32::try_parse(remaining)?; let (n, remaining) = u32::try_parse(remaining)?; let (new_mode, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = RenderModeReply { sequence, length, ret_val, new_mode, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for RenderModeReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.ret_val.serialize_into(bytes); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.new_mode.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl RenderModeReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct RM(u16); impl RM { pub const GL_RENDER: Self = Self(7168); pub const GL_FEEDBACK: Self = Self(7169); pub const GL_SELECT: Self = Self(7170); } impl From for u16 { #[inline] fn from(input: RM) -> Self { input.0 } } impl From for Option { #[inline] fn from(input: RM) -> Self { Some(input.0) } } impl From for u32 { #[inline] fn from(input: RM) -> Self { u32::from(input.0) } } impl From for Option { #[inline] fn from(input: RM) -> Self { Some(u32::from(input.0)) } } impl From for RM { #[inline] fn from(value: u8) -> Self { Self(value.into()) } } impl From for RM { #[inline] fn from(value: u16) -> Self { Self(value) } } impl core::fmt::Debug for RM { fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let variants = [ (Self::GL_RENDER.0.into(), "GL_RENDER", "GL_RENDER"), (Self::GL_FEEDBACK.0.into(), "GL_FEEDBACK", "GL_FEEDBACK"), (Self::GL_SELECT.0.into(), "GL_SELECT", "GL_SELECT"), ]; pretty_print_enum(fmt, self.0.into(), &variants) } } /// Opcode for the Finish request pub const FINISH_REQUEST: u8 = 108; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct FinishRequest { pub context_tag: ContextTag, } impl_debug_if_no_extra_traits!(FinishRequest, "FinishRequest"); impl FinishRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let mut request0 = vec![ major_opcode, FINISH_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != FINISH_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let _ = remaining; Ok(FinishRequest { context_tag, }) } } impl Request for FinishRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for FinishRequest { type Reply = FinishReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct FinishReply { pub sequence: u16, pub length: u32, } impl_debug_if_no_extra_traits!(FinishReply, "FinishReply"); impl TryParse for FinishReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = FinishReply { sequence, length }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for FinishReply { type Bytes = [u8; 8]; fn serialize(&self) -> [u8; 8] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(8); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); } } /// Opcode for the PixelStoref request pub const PIXEL_STOREF_REQUEST: u8 = 109; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct PixelStorefRequest { pub context_tag: ContextTag, pub pname: u32, pub datum: Float32, } impl_debug_if_no_extra_traits!(PixelStorefRequest, "PixelStorefRequest"); impl PixelStorefRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let pname_bytes = self.pname.serialize(); let datum_bytes = self.datum.serialize(); let mut request0 = vec![ major_opcode, PIXEL_STOREF_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], datum_bytes[0], datum_bytes[1], datum_bytes[2], datum_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != PIXEL_STOREF_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (pname, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float32::try_parse(remaining)?; let _ = remaining; Ok(PixelStorefRequest { context_tag, pname, datum, }) } } impl Request for PixelStorefRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for PixelStorefRequest { } /// Opcode for the PixelStorei request pub const PIXEL_STOREI_REQUEST: u8 = 110; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct PixelStoreiRequest { pub context_tag: ContextTag, pub pname: u32, pub datum: i32, } impl_debug_if_no_extra_traits!(PixelStoreiRequest, "PixelStoreiRequest"); impl PixelStoreiRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let pname_bytes = self.pname.serialize(); let datum_bytes = self.datum.serialize(); let mut request0 = vec![ major_opcode, PIXEL_STOREI_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], datum_bytes[0], datum_bytes[1], datum_bytes[2], datum_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != PIXEL_STOREI_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (pname, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = i32::try_parse(remaining)?; let _ = remaining; Ok(PixelStoreiRequest { context_tag, pname, datum, }) } } impl Request for PixelStoreiRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for PixelStoreiRequest { } /// Opcode for the ReadPixels request pub const READ_PIXELS_REQUEST: u8 = 111; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ReadPixelsRequest { pub context_tag: ContextTag, pub x: i32, pub y: i32, pub width: i32, pub height: i32, pub format: u32, pub type_: u32, pub swap_bytes: bool, pub lsb_first: bool, } impl_debug_if_no_extra_traits!(ReadPixelsRequest, "ReadPixelsRequest"); impl ReadPixelsRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let x_bytes = self.x.serialize(); let y_bytes = self.y.serialize(); let width_bytes = self.width.serialize(); let height_bytes = self.height.serialize(); let format_bytes = self.format.serialize(); let type_bytes = self.type_.serialize(); let swap_bytes_bytes = self.swap_bytes.serialize(); let lsb_first_bytes = self.lsb_first.serialize(); let mut request0 = vec![ major_opcode, READ_PIXELS_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], x_bytes[0], x_bytes[1], x_bytes[2], x_bytes[3], y_bytes[0], y_bytes[1], y_bytes[2], y_bytes[3], width_bytes[0], width_bytes[1], width_bytes[2], width_bytes[3], height_bytes[0], height_bytes[1], height_bytes[2], height_bytes[3], format_bytes[0], format_bytes[1], format_bytes[2], format_bytes[3], type_bytes[0], type_bytes[1], type_bytes[2], type_bytes[3], swap_bytes_bytes[0], lsb_first_bytes[0], 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != READ_PIXELS_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (x, remaining) = i32::try_parse(remaining)?; let (y, remaining) = i32::try_parse(remaining)?; let (width, remaining) = i32::try_parse(remaining)?; let (height, remaining) = i32::try_parse(remaining)?; let (format, remaining) = u32::try_parse(remaining)?; let (type_, remaining) = u32::try_parse(remaining)?; let (swap_bytes, remaining) = bool::try_parse(remaining)?; let (lsb_first, remaining) = bool::try_parse(remaining)?; let _ = remaining; Ok(ReadPixelsRequest { context_tag, x, y, width, height, format, type_, swap_bytes, lsb_first, }) } } impl Request for ReadPixelsRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for ReadPixelsRequest { type Reply = ReadPixelsReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct ReadPixelsReply { pub sequence: u16, pub data: Vec, } impl_debug_if_no_extra_traits!(ReadPixelsReply, "ReadPixelsReply"); impl TryParse for ReadPixelsReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let data = data.to_vec(); if response_type != 1 { return Err(ParseError::InvalidValue); } let result = ReadPixelsReply { sequence, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for ReadPixelsReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4"); let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements"); length.serialize_into(bytes); bytes.extend_from_slice(&[0; 24]); bytes.extend_from_slice(&self.data); } } impl ReadPixelsReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.data.len() .checked_div(4).unwrap() .try_into().unwrap() } } /// Opcode for the GetBooleanv request pub const GET_BOOLEANV_REQUEST: u8 = 112; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetBooleanvRequest { pub context_tag: ContextTag, pub pname: i32, } impl_debug_if_no_extra_traits!(GetBooleanvRequest, "GetBooleanvRequest"); impl GetBooleanvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_BOOLEANV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_BOOLEANV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (pname, remaining) = i32::try_parse(remaining)?; let _ = remaining; Ok(GetBooleanvRequest { context_tag, pname, }) } } impl Request for GetBooleanvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetBooleanvRequest { type Reply = GetBooleanvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetBooleanvReply { pub sequence: u16, pub length: u32, pub datum: bool, pub data: Vec, } impl_debug_if_no_extra_traits!(GetBooleanvReply, "GetBooleanvReply"); impl TryParse for GetBooleanvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = bool::try_parse(remaining)?; let remaining = remaining.get(15..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetBooleanvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetBooleanvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 15]); self.data.serialize_into(bytes); } } impl GetBooleanvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetClipPlane request pub const GET_CLIP_PLANE_REQUEST: u8 = 113; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetClipPlaneRequest { pub context_tag: ContextTag, pub plane: i32, } impl_debug_if_no_extra_traits!(GetClipPlaneRequest, "GetClipPlaneRequest"); impl GetClipPlaneRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let plane_bytes = self.plane.serialize(); let mut request0 = vec![ major_opcode, GET_CLIP_PLANE_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], plane_bytes[0], plane_bytes[1], plane_bytes[2], plane_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_CLIP_PLANE_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (plane, remaining) = i32::try_parse(remaining)?; let _ = remaining; Ok(GetClipPlaneRequest { context_tag, plane, }) } } impl Request for GetClipPlaneRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetClipPlaneRequest { type Reply = GetClipPlaneReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetClipPlaneReply { pub sequence: u16, pub data: Vec, } impl_debug_if_no_extra_traits!(GetClipPlaneReply, "GetClipPlaneReply"); impl TryParse for GetClipPlaneReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, u32::from(length).checked_div(2u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetClipPlaneReply { sequence, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetClipPlaneReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); let length = u32::try_from(self.data.len()).ok().and_then(|len| len.checked_mul(2)).expect("`data` has too many elements"); length.serialize_into(bytes); bytes.extend_from_slice(&[0; 24]); self.data.serialize_into(bytes); } } impl GetClipPlaneReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.data.len() .checked_mul(2).unwrap() .try_into().unwrap() } } /// Opcode for the GetDoublev request pub const GET_DOUBLEV_REQUEST: u8 = 114; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetDoublevRequest { pub context_tag: ContextTag, pub pname: u32, } impl_debug_if_no_extra_traits!(GetDoublevRequest, "GetDoublevRequest"); impl GetDoublevRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_DOUBLEV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_DOUBLEV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetDoublevRequest { context_tag, pname, }) } } impl Request for GetDoublevRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetDoublevRequest { type Reply = GetDoublevReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetDoublevReply { pub sequence: u16, pub length: u32, pub datum: Float64, pub data: Vec, } impl_debug_if_no_extra_traits!(GetDoublevReply, "GetDoublevReply"); impl TryParse for GetDoublevReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float64::try_parse(remaining)?; let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetDoublevReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetDoublevReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 8]); self.data.serialize_into(bytes); } } impl GetDoublevReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetError request pub const GET_ERROR_REQUEST: u8 = 115; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetErrorRequest { pub context_tag: ContextTag, } impl_debug_if_no_extra_traits!(GetErrorRequest, "GetErrorRequest"); impl GetErrorRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let mut request0 = vec![ major_opcode, GET_ERROR_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_ERROR_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let _ = remaining; Ok(GetErrorRequest { context_tag, }) } } impl Request for GetErrorRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetErrorRequest { type Reply = GetErrorReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetErrorReply { pub sequence: u16, pub length: u32, pub error: i32, } impl_debug_if_no_extra_traits!(GetErrorReply, "GetErrorReply"); impl TryParse for GetErrorReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (error, remaining) = i32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetErrorReply { sequence, length, error }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetErrorReply { type Bytes = [u8; 12]; fn serialize(&self) -> [u8; 12] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let error_bytes = self.error.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], error_bytes[0], error_bytes[1], error_bytes[2], error_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(12); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.error.serialize_into(bytes); } } /// Opcode for the GetFloatv request pub const GET_FLOATV_REQUEST: u8 = 116; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetFloatvRequest { pub context_tag: ContextTag, pub pname: u32, } impl_debug_if_no_extra_traits!(GetFloatvRequest, "GetFloatvRequest"); impl GetFloatvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_FLOATV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_FLOATV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetFloatvRequest { context_tag, pname, }) } } impl Request for GetFloatvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetFloatvRequest { type Reply = GetFloatvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetFloatvReply { pub sequence: u16, pub length: u32, pub datum: Float32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetFloatvReply, "GetFloatvReply"); impl TryParse for GetFloatvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetFloatvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetFloatvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetFloatvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetIntegerv request pub const GET_INTEGERV_REQUEST: u8 = 117; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetIntegervRequest { pub context_tag: ContextTag, pub pname: u32, } impl_debug_if_no_extra_traits!(GetIntegervRequest, "GetIntegervRequest"); impl GetIntegervRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_INTEGERV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_INTEGERV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetIntegervRequest { context_tag, pname, }) } } impl Request for GetIntegervRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetIntegervRequest { type Reply = GetIntegervReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetIntegervReply { pub sequence: u16, pub length: u32, pub datum: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetIntegervReply, "GetIntegervReply"); impl TryParse for GetIntegervReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetIntegervReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetIntegervReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetIntegervReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetLightfv request pub const GET_LIGHTFV_REQUEST: u8 = 118; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetLightfvRequest { pub context_tag: ContextTag, pub light: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetLightfvRequest, "GetLightfvRequest"); impl GetLightfvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let light_bytes = self.light.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_LIGHTFV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], light_bytes[0], light_bytes[1], light_bytes[2], light_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_LIGHTFV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (light, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetLightfvRequest { context_tag, light, pname, }) } } impl Request for GetLightfvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetLightfvRequest { type Reply = GetLightfvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetLightfvReply { pub sequence: u16, pub length: u32, pub datum: Float32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetLightfvReply, "GetLightfvReply"); impl TryParse for GetLightfvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetLightfvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetLightfvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetLightfvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetLightiv request pub const GET_LIGHTIV_REQUEST: u8 = 119; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetLightivRequest { pub context_tag: ContextTag, pub light: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetLightivRequest, "GetLightivRequest"); impl GetLightivRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let light_bytes = self.light.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_LIGHTIV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], light_bytes[0], light_bytes[1], light_bytes[2], light_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_LIGHTIV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (light, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetLightivRequest { context_tag, light, pname, }) } } impl Request for GetLightivRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetLightivRequest { type Reply = GetLightivReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetLightivReply { pub sequence: u16, pub length: u32, pub datum: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetLightivReply, "GetLightivReply"); impl TryParse for GetLightivReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetLightivReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetLightivReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetLightivReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetMapdv request pub const GET_MAPDV_REQUEST: u8 = 120; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMapdvRequest { pub context_tag: ContextTag, pub target: u32, pub query: u32, } impl_debug_if_no_extra_traits!(GetMapdvRequest, "GetMapdvRequest"); impl GetMapdvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let query_bytes = self.query.serialize(); let mut request0 = vec![ major_opcode, GET_MAPDV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], query_bytes[0], query_bytes[1], query_bytes[2], query_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_MAPDV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (query, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetMapdvRequest { context_tag, target, query, }) } } impl Request for GetMapdvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetMapdvRequest { type Reply = GetMapdvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMapdvReply { pub sequence: u16, pub length: u32, pub datum: Float64, pub data: Vec, } impl_debug_if_no_extra_traits!(GetMapdvReply, "GetMapdvReply"); impl TryParse for GetMapdvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float64::try_parse(remaining)?; let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetMapdvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetMapdvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 8]); self.data.serialize_into(bytes); } } impl GetMapdvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetMapfv request pub const GET_MAPFV_REQUEST: u8 = 121; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMapfvRequest { pub context_tag: ContextTag, pub target: u32, pub query: u32, } impl_debug_if_no_extra_traits!(GetMapfvRequest, "GetMapfvRequest"); impl GetMapfvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let query_bytes = self.query.serialize(); let mut request0 = vec![ major_opcode, GET_MAPFV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], query_bytes[0], query_bytes[1], query_bytes[2], query_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_MAPFV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (query, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetMapfvRequest { context_tag, target, query, }) } } impl Request for GetMapfvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetMapfvRequest { type Reply = GetMapfvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMapfvReply { pub sequence: u16, pub length: u32, pub datum: Float32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetMapfvReply, "GetMapfvReply"); impl TryParse for GetMapfvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetMapfvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetMapfvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetMapfvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetMapiv request pub const GET_MAPIV_REQUEST: u8 = 122; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMapivRequest { pub context_tag: ContextTag, pub target: u32, pub query: u32, } impl_debug_if_no_extra_traits!(GetMapivRequest, "GetMapivRequest"); impl GetMapivRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let query_bytes = self.query.serialize(); let mut request0 = vec![ major_opcode, GET_MAPIV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], query_bytes[0], query_bytes[1], query_bytes[2], query_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_MAPIV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (query, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetMapivRequest { context_tag, target, query, }) } } impl Request for GetMapivRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetMapivRequest { type Reply = GetMapivReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMapivReply { pub sequence: u16, pub length: u32, pub datum: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetMapivReply, "GetMapivReply"); impl TryParse for GetMapivReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetMapivReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetMapivReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetMapivReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetMaterialfv request pub const GET_MATERIALFV_REQUEST: u8 = 123; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMaterialfvRequest { pub context_tag: ContextTag, pub face: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetMaterialfvRequest, "GetMaterialfvRequest"); impl GetMaterialfvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let face_bytes = self.face.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_MATERIALFV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], face_bytes[0], face_bytes[1], face_bytes[2], face_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_MATERIALFV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (face, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetMaterialfvRequest { context_tag, face, pname, }) } } impl Request for GetMaterialfvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetMaterialfvRequest { type Reply = GetMaterialfvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMaterialfvReply { pub sequence: u16, pub length: u32, pub datum: Float32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetMaterialfvReply, "GetMaterialfvReply"); impl TryParse for GetMaterialfvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetMaterialfvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetMaterialfvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetMaterialfvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetMaterialiv request pub const GET_MATERIALIV_REQUEST: u8 = 124; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMaterialivRequest { pub context_tag: ContextTag, pub face: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetMaterialivRequest, "GetMaterialivRequest"); impl GetMaterialivRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let face_bytes = self.face.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_MATERIALIV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], face_bytes[0], face_bytes[1], face_bytes[2], face_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_MATERIALIV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (face, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetMaterialivRequest { context_tag, face, pname, }) } } impl Request for GetMaterialivRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetMaterialivRequest { type Reply = GetMaterialivReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMaterialivReply { pub sequence: u16, pub length: u32, pub datum: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetMaterialivReply, "GetMaterialivReply"); impl TryParse for GetMaterialivReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetMaterialivReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetMaterialivReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetMaterialivReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetPixelMapfv request pub const GET_PIXEL_MAPFV_REQUEST: u8 = 125; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetPixelMapfvRequest { pub context_tag: ContextTag, pub map: u32, } impl_debug_if_no_extra_traits!(GetPixelMapfvRequest, "GetPixelMapfvRequest"); impl GetPixelMapfvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let map_bytes = self.map.serialize(); let mut request0 = vec![ major_opcode, GET_PIXEL_MAPFV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], map_bytes[0], map_bytes[1], map_bytes[2], map_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_PIXEL_MAPFV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (map, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetPixelMapfvRequest { context_tag, map, }) } } impl Request for GetPixelMapfvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetPixelMapfvRequest { type Reply = GetPixelMapfvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetPixelMapfvReply { pub sequence: u16, pub length: u32, pub datum: Float32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetPixelMapfvReply, "GetPixelMapfvReply"); impl TryParse for GetPixelMapfvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetPixelMapfvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetPixelMapfvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetPixelMapfvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetPixelMapuiv request pub const GET_PIXEL_MAPUIV_REQUEST: u8 = 126; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetPixelMapuivRequest { pub context_tag: ContextTag, pub map: u32, } impl_debug_if_no_extra_traits!(GetPixelMapuivRequest, "GetPixelMapuivRequest"); impl GetPixelMapuivRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let map_bytes = self.map.serialize(); let mut request0 = vec![ major_opcode, GET_PIXEL_MAPUIV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], map_bytes[0], map_bytes[1], map_bytes[2], map_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_PIXEL_MAPUIV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (map, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetPixelMapuivRequest { context_tag, map, }) } } impl Request for GetPixelMapuivRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetPixelMapuivRequest { type Reply = GetPixelMapuivReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetPixelMapuivReply { pub sequence: u16, pub length: u32, pub datum: u32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetPixelMapuivReply, "GetPixelMapuivReply"); impl TryParse for GetPixelMapuivReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetPixelMapuivReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetPixelMapuivReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetPixelMapuivReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetPixelMapusv request pub const GET_PIXEL_MAPUSV_REQUEST: u8 = 127; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetPixelMapusvRequest { pub context_tag: ContextTag, pub map: u32, } impl_debug_if_no_extra_traits!(GetPixelMapusvRequest, "GetPixelMapusvRequest"); impl GetPixelMapusvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let map_bytes = self.map.serialize(); let mut request0 = vec![ major_opcode, GET_PIXEL_MAPUSV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], map_bytes[0], map_bytes[1], map_bytes[2], map_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_PIXEL_MAPUSV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (map, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetPixelMapusvRequest { context_tag, map, }) } } impl Request for GetPixelMapusvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetPixelMapusvRequest { type Reply = GetPixelMapusvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetPixelMapusvReply { pub sequence: u16, pub length: u32, pub datum: u16, pub data: Vec, } impl_debug_if_no_extra_traits!(GetPixelMapusvReply, "GetPixelMapusvReply"); impl TryParse for GetPixelMapusvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = u16::try_parse(remaining)?; let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetPixelMapusvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetPixelMapusvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(34); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 16]); self.data.serialize_into(bytes); } } impl GetPixelMapusvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetPolygonStipple request pub const GET_POLYGON_STIPPLE_REQUEST: u8 = 128; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetPolygonStippleRequest { pub context_tag: ContextTag, pub lsb_first: bool, } impl_debug_if_no_extra_traits!(GetPolygonStippleRequest, "GetPolygonStippleRequest"); impl GetPolygonStippleRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let lsb_first_bytes = self.lsb_first.serialize(); let mut request0 = vec![ major_opcode, GET_POLYGON_STIPPLE_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], lsb_first_bytes[0], 0, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_POLYGON_STIPPLE_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (lsb_first, remaining) = bool::try_parse(remaining)?; let _ = remaining; Ok(GetPolygonStippleRequest { context_tag, lsb_first, }) } } impl Request for GetPolygonStippleRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetPolygonStippleRequest { type Reply = GetPolygonStippleReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetPolygonStippleReply { pub sequence: u16, pub data: Vec, } impl_debug_if_no_extra_traits!(GetPolygonStippleReply, "GetPolygonStippleReply"); impl TryParse for GetPolygonStippleReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let data = data.to_vec(); if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetPolygonStippleReply { sequence, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetPolygonStippleReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4"); let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements"); length.serialize_into(bytes); bytes.extend_from_slice(&[0; 24]); bytes.extend_from_slice(&self.data); } } impl GetPolygonStippleReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.data.len() .checked_div(4).unwrap() .try_into().unwrap() } } /// Opcode for the GetString request pub const GET_STRING_REQUEST: u8 = 129; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetStringRequest { pub context_tag: ContextTag, pub name: u32, } impl_debug_if_no_extra_traits!(GetStringRequest, "GetStringRequest"); impl GetStringRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let name_bytes = self.name.serialize(); let mut request0 = vec![ major_opcode, GET_STRING_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], name_bytes[0], name_bytes[1], name_bytes[2], name_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_STRING_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (name, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetStringRequest { context_tag, name, }) } } impl Request for GetStringRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetStringRequest { type Reply = GetStringReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetStringReply { pub sequence: u16, pub length: u32, pub string: Vec, } impl_debug_if_no_extra_traits!(GetStringReply, "GetStringReply"); impl TryParse for GetStringReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?; let (string, remaining) = crate::x11_utils::parse_u8_list(remaining, n.try_to_usize()?)?; let string = string.to_vec(); if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetStringReply { sequence, length, string }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetStringReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.string.len()).expect("`string` has too many elements"); n.serialize_into(bytes); bytes.extend_from_slice(&[0; 16]); bytes.extend_from_slice(&self.string); } } impl GetStringReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `string` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.string.len() .try_into().unwrap() } } /// Opcode for the GetTexEnvfv request pub const GET_TEX_ENVFV_REQUEST: u8 = 130; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexEnvfvRequest { pub context_tag: ContextTag, pub target: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetTexEnvfvRequest, "GetTexEnvfvRequest"); impl GetTexEnvfvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_TEX_ENVFV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_TEX_ENVFV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetTexEnvfvRequest { context_tag, target, pname, }) } } impl Request for GetTexEnvfvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetTexEnvfvRequest { type Reply = GetTexEnvfvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexEnvfvReply { pub sequence: u16, pub length: u32, pub datum: Float32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetTexEnvfvReply, "GetTexEnvfvReply"); impl TryParse for GetTexEnvfvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetTexEnvfvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetTexEnvfvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetTexEnvfvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetTexEnviv request pub const GET_TEX_ENVIV_REQUEST: u8 = 131; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexEnvivRequest { pub context_tag: ContextTag, pub target: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetTexEnvivRequest, "GetTexEnvivRequest"); impl GetTexEnvivRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_TEX_ENVIV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_TEX_ENVIV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetTexEnvivRequest { context_tag, target, pname, }) } } impl Request for GetTexEnvivRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetTexEnvivRequest { type Reply = GetTexEnvivReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexEnvivReply { pub sequence: u16, pub length: u32, pub datum: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetTexEnvivReply, "GetTexEnvivReply"); impl TryParse for GetTexEnvivReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetTexEnvivReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetTexEnvivReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetTexEnvivReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetTexGendv request pub const GET_TEX_GENDV_REQUEST: u8 = 132; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexGendvRequest { pub context_tag: ContextTag, pub coord: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetTexGendvRequest, "GetTexGendvRequest"); impl GetTexGendvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let coord_bytes = self.coord.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_TEX_GENDV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], coord_bytes[0], coord_bytes[1], coord_bytes[2], coord_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_TEX_GENDV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (coord, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetTexGendvRequest { context_tag, coord, pname, }) } } impl Request for GetTexGendvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetTexGendvRequest { type Reply = GetTexGendvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexGendvReply { pub sequence: u16, pub length: u32, pub datum: Float64, pub data: Vec, } impl_debug_if_no_extra_traits!(GetTexGendvReply, "GetTexGendvReply"); impl TryParse for GetTexGendvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float64::try_parse(remaining)?; let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetTexGendvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetTexGendvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 8]); self.data.serialize_into(bytes); } } impl GetTexGendvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetTexGenfv request pub const GET_TEX_GENFV_REQUEST: u8 = 133; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexGenfvRequest { pub context_tag: ContextTag, pub coord: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetTexGenfvRequest, "GetTexGenfvRequest"); impl GetTexGenfvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let coord_bytes = self.coord.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_TEX_GENFV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], coord_bytes[0], coord_bytes[1], coord_bytes[2], coord_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_TEX_GENFV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (coord, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetTexGenfvRequest { context_tag, coord, pname, }) } } impl Request for GetTexGenfvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetTexGenfvRequest { type Reply = GetTexGenfvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexGenfvReply { pub sequence: u16, pub length: u32, pub datum: Float32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetTexGenfvReply, "GetTexGenfvReply"); impl TryParse for GetTexGenfvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetTexGenfvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetTexGenfvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetTexGenfvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetTexGeniv request pub const GET_TEX_GENIV_REQUEST: u8 = 134; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexGenivRequest { pub context_tag: ContextTag, pub coord: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetTexGenivRequest, "GetTexGenivRequest"); impl GetTexGenivRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let coord_bytes = self.coord.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_TEX_GENIV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], coord_bytes[0], coord_bytes[1], coord_bytes[2], coord_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_TEX_GENIV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (coord, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetTexGenivRequest { context_tag, coord, pname, }) } } impl Request for GetTexGenivRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetTexGenivRequest { type Reply = GetTexGenivReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexGenivReply { pub sequence: u16, pub length: u32, pub datum: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetTexGenivReply, "GetTexGenivReply"); impl TryParse for GetTexGenivReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetTexGenivReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetTexGenivReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetTexGenivReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetTexImage request pub const GET_TEX_IMAGE_REQUEST: u8 = 135; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexImageRequest { pub context_tag: ContextTag, pub target: u32, pub level: i32, pub format: u32, pub type_: u32, pub swap_bytes: bool, } impl_debug_if_no_extra_traits!(GetTexImageRequest, "GetTexImageRequest"); impl GetTexImageRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let level_bytes = self.level.serialize(); let format_bytes = self.format.serialize(); let type_bytes = self.type_.serialize(); let swap_bytes_bytes = self.swap_bytes.serialize(); let mut request0 = vec![ major_opcode, GET_TEX_IMAGE_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], level_bytes[0], level_bytes[1], level_bytes[2], level_bytes[3], format_bytes[0], format_bytes[1], format_bytes[2], format_bytes[3], type_bytes[0], type_bytes[1], type_bytes[2], type_bytes[3], swap_bytes_bytes[0], 0, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_TEX_IMAGE_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (level, remaining) = i32::try_parse(remaining)?; let (format, remaining) = u32::try_parse(remaining)?; let (type_, remaining) = u32::try_parse(remaining)?; let (swap_bytes, remaining) = bool::try_parse(remaining)?; let _ = remaining; Ok(GetTexImageRequest { context_tag, target, level, format, type_, swap_bytes, }) } } impl Request for GetTexImageRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetTexImageRequest { type Reply = GetTexImageReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexImageReply { pub sequence: u16, pub width: i32, pub height: i32, pub depth: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetTexImageReply, "GetTexImageReply"); impl TryParse for GetTexImageReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?; let (width, remaining) = i32::try_parse(remaining)?; let (height, remaining) = i32::try_parse(remaining)?; let (depth, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let data = data.to_vec(); if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetTexImageReply { sequence, width, height, depth, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetTexImageReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4"); let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements"); length.serialize_into(bytes); bytes.extend_from_slice(&[0; 8]); self.width.serialize_into(bytes); self.height.serialize_into(bytes); self.depth.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); bytes.extend_from_slice(&self.data); } } impl GetTexImageReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.data.len() .checked_div(4).unwrap() .try_into().unwrap() } } /// Opcode for the GetTexParameterfv request pub const GET_TEX_PARAMETERFV_REQUEST: u8 = 136; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexParameterfvRequest { pub context_tag: ContextTag, pub target: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetTexParameterfvRequest, "GetTexParameterfvRequest"); impl GetTexParameterfvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_TEX_PARAMETERFV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_TEX_PARAMETERFV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetTexParameterfvRequest { context_tag, target, pname, }) } } impl Request for GetTexParameterfvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetTexParameterfvRequest { type Reply = GetTexParameterfvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexParameterfvReply { pub sequence: u16, pub length: u32, pub datum: Float32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetTexParameterfvReply, "GetTexParameterfvReply"); impl TryParse for GetTexParameterfvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetTexParameterfvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetTexParameterfvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetTexParameterfvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetTexParameteriv request pub const GET_TEX_PARAMETERIV_REQUEST: u8 = 137; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexParameterivRequest { pub context_tag: ContextTag, pub target: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetTexParameterivRequest, "GetTexParameterivRequest"); impl GetTexParameterivRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_TEX_PARAMETERIV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_TEX_PARAMETERIV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetTexParameterivRequest { context_tag, target, pname, }) } } impl Request for GetTexParameterivRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetTexParameterivRequest { type Reply = GetTexParameterivReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexParameterivReply { pub sequence: u16, pub length: u32, pub datum: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetTexParameterivReply, "GetTexParameterivReply"); impl TryParse for GetTexParameterivReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetTexParameterivReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetTexParameterivReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetTexParameterivReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetTexLevelParameterfv request pub const GET_TEX_LEVEL_PARAMETERFV_REQUEST: u8 = 138; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexLevelParameterfvRequest { pub context_tag: ContextTag, pub target: u32, pub level: i32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetTexLevelParameterfvRequest, "GetTexLevelParameterfvRequest"); impl GetTexLevelParameterfvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let level_bytes = self.level.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_TEX_LEVEL_PARAMETERFV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], level_bytes[0], level_bytes[1], level_bytes[2], level_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_TEX_LEVEL_PARAMETERFV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (level, remaining) = i32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetTexLevelParameterfvRequest { context_tag, target, level, pname, }) } } impl Request for GetTexLevelParameterfvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetTexLevelParameterfvRequest { type Reply = GetTexLevelParameterfvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexLevelParameterfvReply { pub sequence: u16, pub length: u32, pub datum: Float32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetTexLevelParameterfvReply, "GetTexLevelParameterfvReply"); impl TryParse for GetTexLevelParameterfvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetTexLevelParameterfvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetTexLevelParameterfvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetTexLevelParameterfvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetTexLevelParameteriv request pub const GET_TEX_LEVEL_PARAMETERIV_REQUEST: u8 = 139; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexLevelParameterivRequest { pub context_tag: ContextTag, pub target: u32, pub level: i32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetTexLevelParameterivRequest, "GetTexLevelParameterivRequest"); impl GetTexLevelParameterivRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let level_bytes = self.level.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_TEX_LEVEL_PARAMETERIV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], level_bytes[0], level_bytes[1], level_bytes[2], level_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_TEX_LEVEL_PARAMETERIV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (level, remaining) = i32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetTexLevelParameterivRequest { context_tag, target, level, pname, }) } } impl Request for GetTexLevelParameterivRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetTexLevelParameterivRequest { type Reply = GetTexLevelParameterivReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetTexLevelParameterivReply { pub sequence: u16, pub length: u32, pub datum: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetTexLevelParameterivReply, "GetTexLevelParameterivReply"); impl TryParse for GetTexLevelParameterivReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetTexLevelParameterivReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetTexLevelParameterivReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetTexLevelParameterivReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the IsEnabled request pub const IS_ENABLED_REQUEST: u8 = 140; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct IsEnabledRequest { pub context_tag: ContextTag, pub capability: u32, } impl_debug_if_no_extra_traits!(IsEnabledRequest, "IsEnabledRequest"); impl IsEnabledRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let capability_bytes = self.capability.serialize(); let mut request0 = vec![ major_opcode, IS_ENABLED_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], capability_bytes[0], capability_bytes[1], capability_bytes[2], capability_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != IS_ENABLED_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (capability, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(IsEnabledRequest { context_tag, capability, }) } } impl Request for IsEnabledRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for IsEnabledRequest { type Reply = IsEnabledReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct IsEnabledReply { pub sequence: u16, pub length: u32, pub ret_val: Bool32, } impl_debug_if_no_extra_traits!(IsEnabledReply, "IsEnabledReply"); impl TryParse for IsEnabledReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (ret_val, remaining) = Bool32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = IsEnabledReply { sequence, length, ret_val }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for IsEnabledReply { type Bytes = [u8; 12]; fn serialize(&self) -> [u8; 12] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let ret_val_bytes = self.ret_val.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], ret_val_bytes[0], ret_val_bytes[1], ret_val_bytes[2], ret_val_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(12); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.ret_val.serialize_into(bytes); } } /// Opcode for the IsList request pub const IS_LIST_REQUEST: u8 = 141; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct IsListRequest { pub context_tag: ContextTag, pub list: u32, } impl_debug_if_no_extra_traits!(IsListRequest, "IsListRequest"); impl IsListRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let list_bytes = self.list.serialize(); let mut request0 = vec![ major_opcode, IS_LIST_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], list_bytes[0], list_bytes[1], list_bytes[2], list_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != IS_LIST_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (list, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(IsListRequest { context_tag, list, }) } } impl Request for IsListRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for IsListRequest { type Reply = IsListReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct IsListReply { pub sequence: u16, pub length: u32, pub ret_val: Bool32, } impl_debug_if_no_extra_traits!(IsListReply, "IsListReply"); impl TryParse for IsListReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (ret_val, remaining) = Bool32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = IsListReply { sequence, length, ret_val }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for IsListReply { type Bytes = [u8; 12]; fn serialize(&self) -> [u8; 12] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let ret_val_bytes = self.ret_val.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], ret_val_bytes[0], ret_val_bytes[1], ret_val_bytes[2], ret_val_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(12); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.ret_val.serialize_into(bytes); } } /// Opcode for the Flush request pub const FLUSH_REQUEST: u8 = 142; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct FlushRequest { pub context_tag: ContextTag, } impl_debug_if_no_extra_traits!(FlushRequest, "FlushRequest"); impl FlushRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let mut request0 = vec![ major_opcode, FLUSH_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != FLUSH_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let _ = remaining; Ok(FlushRequest { context_tag, }) } } impl Request for FlushRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::VoidRequest for FlushRequest { } /// Opcode for the AreTexturesResident request pub const ARE_TEXTURES_RESIDENT_REQUEST: u8 = 143; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AreTexturesResidentRequest<'input> { pub context_tag: ContextTag, pub textures: Cow<'input, [u32]>, } impl_debug_if_no_extra_traits!(AreTexturesResidentRequest<'_>, "AreTexturesResidentRequest"); impl<'input> AreTexturesResidentRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let n = i32::try_from(self.textures.len()).expect("`textures` has too many elements"); let n_bytes = n.serialize(); let mut request0 = vec![ major_opcode, ARE_TEXTURES_RESIDENT_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], n_bytes[0], n_bytes[1], n_bytes[2], n_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let textures_bytes = self.textures.serialize(); let length_so_far = length_so_far + textures_bytes.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), textures_bytes.into(), padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != ARE_TEXTURES_RESIDENT_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (n, remaining) = i32::try_parse(remaining)?; let (textures, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; let _ = remaining; Ok(AreTexturesResidentRequest { context_tag, textures: Cow::Owned(textures), }) } /// Clone all borrowed data in this AreTexturesResidentRequest. pub fn into_owned(self) -> AreTexturesResidentRequest<'static> { AreTexturesResidentRequest { context_tag: self.context_tag, textures: Cow::Owned(self.textures.into_owned()), } } } impl<'input> Request for AreTexturesResidentRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::ReplyRequest for AreTexturesResidentRequest<'input> { type Reply = AreTexturesResidentReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct AreTexturesResidentReply { pub sequence: u16, pub ret_val: Bool32, pub data: Vec, } impl_debug_if_no_extra_traits!(AreTexturesResidentReply, "AreTexturesResidentReply"); impl TryParse for AreTexturesResidentReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (ret_val, remaining) = Bool32::try_parse(remaining)?; let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = AreTexturesResidentReply { sequence, ret_val, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for AreTexturesResidentReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4"); let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements"); length.serialize_into(bytes); self.ret_val.serialize_into(bytes); bytes.extend_from_slice(&[0; 20]); self.data.serialize_into(bytes); } } impl AreTexturesResidentReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.data.len() .checked_div(4).unwrap() .try_into().unwrap() } } /// Opcode for the DeleteTextures request pub const DELETE_TEXTURES_REQUEST: u8 = 144; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DeleteTexturesRequest<'input> { pub context_tag: ContextTag, pub textures: Cow<'input, [u32]>, } impl_debug_if_no_extra_traits!(DeleteTexturesRequest<'_>, "DeleteTexturesRequest"); impl<'input> DeleteTexturesRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let n = i32::try_from(self.textures.len()).expect("`textures` has too many elements"); let n_bytes = n.serialize(); let mut request0 = vec![ major_opcode, DELETE_TEXTURES_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], n_bytes[0], n_bytes[1], n_bytes[2], n_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let textures_bytes = self.textures.serialize(); let length_so_far = length_so_far + textures_bytes.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), textures_bytes.into(), padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != DELETE_TEXTURES_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (n, remaining) = i32::try_parse(remaining)?; let (textures, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; let _ = remaining; Ok(DeleteTexturesRequest { context_tag, textures: Cow::Owned(textures), }) } /// Clone all borrowed data in this DeleteTexturesRequest. pub fn into_owned(self) -> DeleteTexturesRequest<'static> { DeleteTexturesRequest { context_tag: self.context_tag, textures: Cow::Owned(self.textures.into_owned()), } } } impl<'input> Request for DeleteTexturesRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::VoidRequest for DeleteTexturesRequest<'input> { } /// Opcode for the GenTextures request pub const GEN_TEXTURES_REQUEST: u8 = 145; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GenTexturesRequest { pub context_tag: ContextTag, pub n: i32, } impl_debug_if_no_extra_traits!(GenTexturesRequest, "GenTexturesRequest"); impl GenTexturesRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let n_bytes = self.n.serialize(); let mut request0 = vec![ major_opcode, GEN_TEXTURES_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], n_bytes[0], n_bytes[1], n_bytes[2], n_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GEN_TEXTURES_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (n, remaining) = i32::try_parse(remaining)?; let _ = remaining; Ok(GenTexturesRequest { context_tag, n, }) } } impl Request for GenTexturesRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GenTexturesRequest { type Reply = GenTexturesReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GenTexturesReply { pub sequence: u16, pub data: Vec, } impl_debug_if_no_extra_traits!(GenTexturesReply, "GenTexturesReply"); impl TryParse for GenTexturesReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, length.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GenTexturesReply { sequence, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GenTexturesReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); let length = u32::try_from(self.data.len()).expect("`data` has too many elements"); length.serialize_into(bytes); bytes.extend_from_slice(&[0; 24]); self.data.serialize_into(bytes); } } impl GenTexturesReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the IsTexture request pub const IS_TEXTURE_REQUEST: u8 = 146; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct IsTextureRequest { pub context_tag: ContextTag, pub texture: u32, } impl_debug_if_no_extra_traits!(IsTextureRequest, "IsTextureRequest"); impl IsTextureRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let texture_bytes = self.texture.serialize(); let mut request0 = vec![ major_opcode, IS_TEXTURE_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], texture_bytes[0], texture_bytes[1], texture_bytes[2], texture_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != IS_TEXTURE_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (texture, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(IsTextureRequest { context_tag, texture, }) } } impl Request for IsTextureRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for IsTextureRequest { type Reply = IsTextureReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct IsTextureReply { pub sequence: u16, pub length: u32, pub ret_val: Bool32, } impl_debug_if_no_extra_traits!(IsTextureReply, "IsTextureReply"); impl TryParse for IsTextureReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (ret_val, remaining) = Bool32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = IsTextureReply { sequence, length, ret_val }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for IsTextureReply { type Bytes = [u8; 12]; fn serialize(&self) -> [u8; 12] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let ret_val_bytes = self.ret_val.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], ret_val_bytes[0], ret_val_bytes[1], ret_val_bytes[2], ret_val_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(12); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.ret_val.serialize_into(bytes); } } /// Opcode for the GetColorTable request pub const GET_COLOR_TABLE_REQUEST: u8 = 147; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetColorTableRequest { pub context_tag: ContextTag, pub target: u32, pub format: u32, pub type_: u32, pub swap_bytes: bool, } impl_debug_if_no_extra_traits!(GetColorTableRequest, "GetColorTableRequest"); impl GetColorTableRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let format_bytes = self.format.serialize(); let type_bytes = self.type_.serialize(); let swap_bytes_bytes = self.swap_bytes.serialize(); let mut request0 = vec![ major_opcode, GET_COLOR_TABLE_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], format_bytes[0], format_bytes[1], format_bytes[2], format_bytes[3], type_bytes[0], type_bytes[1], type_bytes[2], type_bytes[3], swap_bytes_bytes[0], 0, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_COLOR_TABLE_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (format, remaining) = u32::try_parse(remaining)?; let (type_, remaining) = u32::try_parse(remaining)?; let (swap_bytes, remaining) = bool::try_parse(remaining)?; let _ = remaining; Ok(GetColorTableRequest { context_tag, target, format, type_, swap_bytes, }) } } impl Request for GetColorTableRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetColorTableRequest { type Reply = GetColorTableReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetColorTableReply { pub sequence: u16, pub width: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetColorTableReply, "GetColorTableReply"); impl TryParse for GetColorTableReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?; let (width, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let data = data.to_vec(); if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetColorTableReply { sequence, width, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetColorTableReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4"); let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements"); length.serialize_into(bytes); bytes.extend_from_slice(&[0; 8]); self.width.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); bytes.extend_from_slice(&self.data); } } impl GetColorTableReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.data.len() .checked_div(4).unwrap() .try_into().unwrap() } } /// Opcode for the GetColorTableParameterfv request pub const GET_COLOR_TABLE_PARAMETERFV_REQUEST: u8 = 148; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetColorTableParameterfvRequest { pub context_tag: ContextTag, pub target: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetColorTableParameterfvRequest, "GetColorTableParameterfvRequest"); impl GetColorTableParameterfvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_COLOR_TABLE_PARAMETERFV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_COLOR_TABLE_PARAMETERFV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetColorTableParameterfvRequest { context_tag, target, pname, }) } } impl Request for GetColorTableParameterfvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetColorTableParameterfvRequest { type Reply = GetColorTableParameterfvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetColorTableParameterfvReply { pub sequence: u16, pub length: u32, pub datum: Float32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetColorTableParameterfvReply, "GetColorTableParameterfvReply"); impl TryParse for GetColorTableParameterfvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetColorTableParameterfvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetColorTableParameterfvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetColorTableParameterfvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetColorTableParameteriv request pub const GET_COLOR_TABLE_PARAMETERIV_REQUEST: u8 = 149; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetColorTableParameterivRequest { pub context_tag: ContextTag, pub target: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetColorTableParameterivRequest, "GetColorTableParameterivRequest"); impl GetColorTableParameterivRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_COLOR_TABLE_PARAMETERIV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_COLOR_TABLE_PARAMETERIV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetColorTableParameterivRequest { context_tag, target, pname, }) } } impl Request for GetColorTableParameterivRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetColorTableParameterivRequest { type Reply = GetColorTableParameterivReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetColorTableParameterivReply { pub sequence: u16, pub length: u32, pub datum: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetColorTableParameterivReply, "GetColorTableParameterivReply"); impl TryParse for GetColorTableParameterivReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetColorTableParameterivReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetColorTableParameterivReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetColorTableParameterivReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetConvolutionFilter request pub const GET_CONVOLUTION_FILTER_REQUEST: u8 = 150; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetConvolutionFilterRequest { pub context_tag: ContextTag, pub target: u32, pub format: u32, pub type_: u32, pub swap_bytes: bool, } impl_debug_if_no_extra_traits!(GetConvolutionFilterRequest, "GetConvolutionFilterRequest"); impl GetConvolutionFilterRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let format_bytes = self.format.serialize(); let type_bytes = self.type_.serialize(); let swap_bytes_bytes = self.swap_bytes.serialize(); let mut request0 = vec![ major_opcode, GET_CONVOLUTION_FILTER_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], format_bytes[0], format_bytes[1], format_bytes[2], format_bytes[3], type_bytes[0], type_bytes[1], type_bytes[2], type_bytes[3], swap_bytes_bytes[0], 0, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_CONVOLUTION_FILTER_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (format, remaining) = u32::try_parse(remaining)?; let (type_, remaining) = u32::try_parse(remaining)?; let (swap_bytes, remaining) = bool::try_parse(remaining)?; let _ = remaining; Ok(GetConvolutionFilterRequest { context_tag, target, format, type_, swap_bytes, }) } } impl Request for GetConvolutionFilterRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetConvolutionFilterRequest { type Reply = GetConvolutionFilterReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetConvolutionFilterReply { pub sequence: u16, pub width: i32, pub height: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetConvolutionFilterReply, "GetConvolutionFilterReply"); impl TryParse for GetConvolutionFilterReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?; let (width, remaining) = i32::try_parse(remaining)?; let (height, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let data = data.to_vec(); if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetConvolutionFilterReply { sequence, width, height, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetConvolutionFilterReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4"); let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements"); length.serialize_into(bytes); bytes.extend_from_slice(&[0; 8]); self.width.serialize_into(bytes); self.height.serialize_into(bytes); bytes.extend_from_slice(&[0; 8]); bytes.extend_from_slice(&self.data); } } impl GetConvolutionFilterReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.data.len() .checked_div(4).unwrap() .try_into().unwrap() } } /// Opcode for the GetConvolutionParameterfv request pub const GET_CONVOLUTION_PARAMETERFV_REQUEST: u8 = 151; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetConvolutionParameterfvRequest { pub context_tag: ContextTag, pub target: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetConvolutionParameterfvRequest, "GetConvolutionParameterfvRequest"); impl GetConvolutionParameterfvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_CONVOLUTION_PARAMETERFV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_CONVOLUTION_PARAMETERFV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetConvolutionParameterfvRequest { context_tag, target, pname, }) } } impl Request for GetConvolutionParameterfvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetConvolutionParameterfvRequest { type Reply = GetConvolutionParameterfvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetConvolutionParameterfvReply { pub sequence: u16, pub length: u32, pub datum: Float32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetConvolutionParameterfvReply, "GetConvolutionParameterfvReply"); impl TryParse for GetConvolutionParameterfvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetConvolutionParameterfvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetConvolutionParameterfvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetConvolutionParameterfvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetConvolutionParameteriv request pub const GET_CONVOLUTION_PARAMETERIV_REQUEST: u8 = 152; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetConvolutionParameterivRequest { pub context_tag: ContextTag, pub target: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetConvolutionParameterivRequest, "GetConvolutionParameterivRequest"); impl GetConvolutionParameterivRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_CONVOLUTION_PARAMETERIV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_CONVOLUTION_PARAMETERIV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetConvolutionParameterivRequest { context_tag, target, pname, }) } } impl Request for GetConvolutionParameterivRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetConvolutionParameterivRequest { type Reply = GetConvolutionParameterivReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetConvolutionParameterivReply { pub sequence: u16, pub length: u32, pub datum: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetConvolutionParameterivReply, "GetConvolutionParameterivReply"); impl TryParse for GetConvolutionParameterivReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetConvolutionParameterivReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetConvolutionParameterivReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetConvolutionParameterivReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetSeparableFilter request pub const GET_SEPARABLE_FILTER_REQUEST: u8 = 153; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetSeparableFilterRequest { pub context_tag: ContextTag, pub target: u32, pub format: u32, pub type_: u32, pub swap_bytes: bool, } impl_debug_if_no_extra_traits!(GetSeparableFilterRequest, "GetSeparableFilterRequest"); impl GetSeparableFilterRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let format_bytes = self.format.serialize(); let type_bytes = self.type_.serialize(); let swap_bytes_bytes = self.swap_bytes.serialize(); let mut request0 = vec![ major_opcode, GET_SEPARABLE_FILTER_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], format_bytes[0], format_bytes[1], format_bytes[2], format_bytes[3], type_bytes[0], type_bytes[1], type_bytes[2], type_bytes[3], swap_bytes_bytes[0], 0, 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_SEPARABLE_FILTER_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (format, remaining) = u32::try_parse(remaining)?; let (type_, remaining) = u32::try_parse(remaining)?; let (swap_bytes, remaining) = bool::try_parse(remaining)?; let _ = remaining; Ok(GetSeparableFilterRequest { context_tag, target, format, type_, swap_bytes, }) } } impl Request for GetSeparableFilterRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetSeparableFilterRequest { type Reply = GetSeparableFilterReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetSeparableFilterReply { pub sequence: u16, pub row_w: i32, pub col_h: i32, pub rows_and_cols: Vec, } impl_debug_if_no_extra_traits!(GetSeparableFilterReply, "GetSeparableFilterReply"); impl TryParse for GetSeparableFilterReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?; let (row_w, remaining) = i32::try_parse(remaining)?; let (col_h, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?; let (rows_and_cols, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let rows_and_cols = rows_and_cols.to_vec(); if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetSeparableFilterReply { sequence, row_w, col_h, rows_and_cols }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetSeparableFilterReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); assert_eq!(self.rows_and_cols.len() % 4, 0, "`rows_and_cols` has an incorrect length, must be a multiple of 4"); let length = u32::try_from(self.rows_and_cols.len() / 4).expect("`rows_and_cols` has too many elements"); length.serialize_into(bytes); bytes.extend_from_slice(&[0; 8]); self.row_w.serialize_into(bytes); self.col_h.serialize_into(bytes); bytes.extend_from_slice(&[0; 8]); bytes.extend_from_slice(&self.rows_and_cols); } } impl GetSeparableFilterReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `rows_and_cols` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.rows_and_cols.len() .checked_div(4).unwrap() .try_into().unwrap() } } /// Opcode for the GetHistogram request pub const GET_HISTOGRAM_REQUEST: u8 = 154; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetHistogramRequest { pub context_tag: ContextTag, pub target: u32, pub format: u32, pub type_: u32, pub swap_bytes: bool, pub reset: bool, } impl_debug_if_no_extra_traits!(GetHistogramRequest, "GetHistogramRequest"); impl GetHistogramRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let format_bytes = self.format.serialize(); let type_bytes = self.type_.serialize(); let swap_bytes_bytes = self.swap_bytes.serialize(); let reset_bytes = self.reset.serialize(); let mut request0 = vec![ major_opcode, GET_HISTOGRAM_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], format_bytes[0], format_bytes[1], format_bytes[2], format_bytes[3], type_bytes[0], type_bytes[1], type_bytes[2], type_bytes[3], swap_bytes_bytes[0], reset_bytes[0], 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_HISTOGRAM_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (format, remaining) = u32::try_parse(remaining)?; let (type_, remaining) = u32::try_parse(remaining)?; let (swap_bytes, remaining) = bool::try_parse(remaining)?; let (reset, remaining) = bool::try_parse(remaining)?; let _ = remaining; Ok(GetHistogramRequest { context_tag, target, format, type_, swap_bytes, reset, }) } } impl Request for GetHistogramRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetHistogramRequest { type Reply = GetHistogramReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetHistogramReply { pub sequence: u16, pub width: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetHistogramReply, "GetHistogramReply"); impl TryParse for GetHistogramReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?; let (width, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let data = data.to_vec(); if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetHistogramReply { sequence, width, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetHistogramReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4"); let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements"); length.serialize_into(bytes); bytes.extend_from_slice(&[0; 8]); self.width.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); bytes.extend_from_slice(&self.data); } } impl GetHistogramReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.data.len() .checked_div(4).unwrap() .try_into().unwrap() } } /// Opcode for the GetHistogramParameterfv request pub const GET_HISTOGRAM_PARAMETERFV_REQUEST: u8 = 155; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetHistogramParameterfvRequest { pub context_tag: ContextTag, pub target: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetHistogramParameterfvRequest, "GetHistogramParameterfvRequest"); impl GetHistogramParameterfvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_HISTOGRAM_PARAMETERFV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_HISTOGRAM_PARAMETERFV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetHistogramParameterfvRequest { context_tag, target, pname, }) } } impl Request for GetHistogramParameterfvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetHistogramParameterfvRequest { type Reply = GetHistogramParameterfvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetHistogramParameterfvReply { pub sequence: u16, pub length: u32, pub datum: Float32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetHistogramParameterfvReply, "GetHistogramParameterfvReply"); impl TryParse for GetHistogramParameterfvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetHistogramParameterfvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetHistogramParameterfvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetHistogramParameterfvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetHistogramParameteriv request pub const GET_HISTOGRAM_PARAMETERIV_REQUEST: u8 = 156; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetHistogramParameterivRequest { pub context_tag: ContextTag, pub target: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetHistogramParameterivRequest, "GetHistogramParameterivRequest"); impl GetHistogramParameterivRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_HISTOGRAM_PARAMETERIV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_HISTOGRAM_PARAMETERIV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetHistogramParameterivRequest { context_tag, target, pname, }) } } impl Request for GetHistogramParameterivRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetHistogramParameterivRequest { type Reply = GetHistogramParameterivReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetHistogramParameterivReply { pub sequence: u16, pub length: u32, pub datum: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetHistogramParameterivReply, "GetHistogramParameterivReply"); impl TryParse for GetHistogramParameterivReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetHistogramParameterivReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetHistogramParameterivReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetHistogramParameterivReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetMinmax request pub const GET_MINMAX_REQUEST: u8 = 157; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMinmaxRequest { pub context_tag: ContextTag, pub target: u32, pub format: u32, pub type_: u32, pub swap_bytes: bool, pub reset: bool, } impl_debug_if_no_extra_traits!(GetMinmaxRequest, "GetMinmaxRequest"); impl GetMinmaxRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let format_bytes = self.format.serialize(); let type_bytes = self.type_.serialize(); let swap_bytes_bytes = self.swap_bytes.serialize(); let reset_bytes = self.reset.serialize(); let mut request0 = vec![ major_opcode, GET_MINMAX_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], format_bytes[0], format_bytes[1], format_bytes[2], format_bytes[3], type_bytes[0], type_bytes[1], type_bytes[2], type_bytes[3], swap_bytes_bytes[0], reset_bytes[0], 0, 0, ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_MINMAX_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (format, remaining) = u32::try_parse(remaining)?; let (type_, remaining) = u32::try_parse(remaining)?; let (swap_bytes, remaining) = bool::try_parse(remaining)?; let (reset, remaining) = bool::try_parse(remaining)?; let _ = remaining; Ok(GetMinmaxRequest { context_tag, target, format, type_, swap_bytes, reset, }) } } impl Request for GetMinmaxRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetMinmaxRequest { type Reply = GetMinmaxReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMinmaxReply { pub sequence: u16, pub data: Vec, } impl_debug_if_no_extra_traits!(GetMinmaxReply, "GetMinmaxReply"); impl TryParse for GetMinmaxReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let data = data.to_vec(); if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetMinmaxReply { sequence, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetMinmaxReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4"); let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements"); length.serialize_into(bytes); bytes.extend_from_slice(&[0; 24]); bytes.extend_from_slice(&self.data); } } impl GetMinmaxReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.data.len() .checked_div(4).unwrap() .try_into().unwrap() } } /// Opcode for the GetMinmaxParameterfv request pub const GET_MINMAX_PARAMETERFV_REQUEST: u8 = 158; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMinmaxParameterfvRequest { pub context_tag: ContextTag, pub target: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetMinmaxParameterfvRequest, "GetMinmaxParameterfvRequest"); impl GetMinmaxParameterfvRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_MINMAX_PARAMETERFV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_MINMAX_PARAMETERFV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetMinmaxParameterfvRequest { context_tag, target, pname, }) } } impl Request for GetMinmaxParameterfvRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetMinmaxParameterfvRequest { type Reply = GetMinmaxParameterfvReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, PartialOrd))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMinmaxParameterfvReply { pub sequence: u16, pub length: u32, pub datum: Float32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetMinmaxParameterfvReply, "GetMinmaxParameterfvReply"); impl TryParse for GetMinmaxParameterfvReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = Float32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetMinmaxParameterfvReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetMinmaxParameterfvReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetMinmaxParameterfvReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetMinmaxParameteriv request pub const GET_MINMAX_PARAMETERIV_REQUEST: u8 = 159; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMinmaxParameterivRequest { pub context_tag: ContextTag, pub target: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetMinmaxParameterivRequest, "GetMinmaxParameterivRequest"); impl GetMinmaxParameterivRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_MINMAX_PARAMETERIV_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_MINMAX_PARAMETERIV_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetMinmaxParameterivRequest { context_tag, target, pname, }) } } impl Request for GetMinmaxParameterivRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetMinmaxParameterivRequest { type Reply = GetMinmaxParameterivReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetMinmaxParameterivReply { pub sequence: u16, pub length: u32, pub datum: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetMinmaxParameterivReply, "GetMinmaxParameterivReply"); impl TryParse for GetMinmaxParameterivReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetMinmaxParameterivReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetMinmaxParameterivReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetMinmaxParameterivReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetCompressedTexImageARB request pub const GET_COMPRESSED_TEX_IMAGE_ARB_REQUEST: u8 = 160; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetCompressedTexImageARBRequest { pub context_tag: ContextTag, pub target: u32, pub level: i32, } impl_debug_if_no_extra_traits!(GetCompressedTexImageARBRequest, "GetCompressedTexImageARBRequest"); impl GetCompressedTexImageARBRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let level_bytes = self.level.serialize(); let mut request0 = vec![ major_opcode, GET_COMPRESSED_TEX_IMAGE_ARB_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], level_bytes[0], level_bytes[1], level_bytes[2], level_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_COMPRESSED_TEX_IMAGE_ARB_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (level, remaining) = i32::try_parse(remaining)?; let _ = remaining; Ok(GetCompressedTexImageARBRequest { context_tag, target, level, }) } } impl Request for GetCompressedTexImageARBRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetCompressedTexImageARBRequest { type Reply = GetCompressedTexImageARBReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetCompressedTexImageARBReply { pub sequence: u16, pub size: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetCompressedTexImageARBReply, "GetCompressedTexImageARBReply"); impl TryParse for GetCompressedTexImageARBReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(8..).ok_or(ParseError::InsufficientData)?; let (size, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_u8_list(remaining, u32::from(length).checked_mul(4u32).ok_or(ParseError::InvalidExpression)?.try_to_usize()?)?; let data = data.to_vec(); if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetCompressedTexImageARBReply { sequence, size, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetCompressedTexImageARBReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); assert_eq!(self.data.len() % 4, 0, "`data` has an incorrect length, must be a multiple of 4"); let length = u32::try_from(self.data.len() / 4).expect("`data` has too many elements"); length.serialize_into(bytes); bytes.extend_from_slice(&[0; 8]); self.size.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); bytes.extend_from_slice(&self.data); } } impl GetCompressedTexImageARBReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.data.len() .checked_div(4).unwrap() .try_into().unwrap() } } /// Opcode for the DeleteQueriesARB request pub const DELETE_QUERIES_ARB_REQUEST: u8 = 161; #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct DeleteQueriesARBRequest<'input> { pub context_tag: ContextTag, pub ids: Cow<'input, [u32]>, } impl_debug_if_no_extra_traits!(DeleteQueriesARBRequest<'_>, "DeleteQueriesARBRequest"); impl<'input> DeleteQueriesARBRequest<'input> { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'input, [u8]>; 3]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let n = i32::try_from(self.ids.len()).expect("`ids` has too many elements"); let n_bytes = n.serialize(); let mut request0 = vec![ major_opcode, DELETE_QUERIES_ARB_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], n_bytes[0], n_bytes[1], n_bytes[2], n_bytes[3], ]; let length_so_far = length_so_far + request0.len(); let ids_bytes = self.ids.serialize(); let length_so_far = length_so_far + ids_bytes.len(); let padding0 = &[0; 3][..(4 - (length_so_far % 4)) % 4]; let length_so_far = length_so_far + padding0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into(), ids_bytes.into(), padding0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &'input [u8]) -> Result { if header.minor_opcode != DELETE_QUERIES_ARB_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (n, remaining) = i32::try_parse(remaining)?; let (ids, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; let _ = remaining; Ok(DeleteQueriesARBRequest { context_tag, ids: Cow::Owned(ids), }) } /// Clone all borrowed data in this DeleteQueriesARBRequest. pub fn into_owned(self) -> DeleteQueriesARBRequest<'static> { DeleteQueriesARBRequest { context_tag: self.context_tag, ids: Cow::Owned(self.ids.into_owned()), } } } impl<'input> Request for DeleteQueriesARBRequest<'input> { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl<'input> crate::x11_utils::VoidRequest for DeleteQueriesARBRequest<'input> { } /// Opcode for the GenQueriesARB request pub const GEN_QUERIES_ARB_REQUEST: u8 = 162; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GenQueriesARBRequest { pub context_tag: ContextTag, pub n: i32, } impl_debug_if_no_extra_traits!(GenQueriesARBRequest, "GenQueriesARBRequest"); impl GenQueriesARBRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let n_bytes = self.n.serialize(); let mut request0 = vec![ major_opcode, GEN_QUERIES_ARB_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], n_bytes[0], n_bytes[1], n_bytes[2], n_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GEN_QUERIES_ARB_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (n, remaining) = i32::try_parse(remaining)?; let _ = remaining; Ok(GenQueriesARBRequest { context_tag, n, }) } } impl Request for GenQueriesARBRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GenQueriesARBRequest { type Reply = GenQueriesARBReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GenQueriesARBReply { pub sequence: u16, pub data: Vec, } impl_debug_if_no_extra_traits!(GenQueriesARBReply, "GenQueriesARBReply"); impl TryParse for GenQueriesARBReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(24..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, length.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GenQueriesARBReply { sequence, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GenQueriesARBReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); let length = u32::try_from(self.data.len()).expect("`data` has too many elements"); length.serialize_into(bytes); bytes.extend_from_slice(&[0; 24]); self.data.serialize_into(bytes); } } impl GenQueriesARBReply { /// Get the value of the `length` field. /// /// The `length` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn length(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the IsQueryARB request pub const IS_QUERY_ARB_REQUEST: u8 = 163; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct IsQueryARBRequest { pub context_tag: ContextTag, pub id: u32, } impl_debug_if_no_extra_traits!(IsQueryARBRequest, "IsQueryARBRequest"); impl IsQueryARBRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let id_bytes = self.id.serialize(); let mut request0 = vec![ major_opcode, IS_QUERY_ARB_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], id_bytes[0], id_bytes[1], id_bytes[2], id_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != IS_QUERY_ARB_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (id, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(IsQueryARBRequest { context_tag, id, }) } } impl Request for IsQueryARBRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for IsQueryARBRequest { type Reply = IsQueryARBReply; } #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct IsQueryARBReply { pub sequence: u16, pub length: u32, pub ret_val: Bool32, } impl_debug_if_no_extra_traits!(IsQueryARBReply, "IsQueryARBReply"); impl TryParse for IsQueryARBReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let (ret_val, remaining) = Bool32::try_parse(remaining)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = IsQueryARBReply { sequence, length, ret_val }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for IsQueryARBReply { type Bytes = [u8; 12]; fn serialize(&self) -> [u8; 12] { let response_type_bytes = &[1]; let sequence_bytes = self.sequence.serialize(); let length_bytes = self.length.serialize(); let ret_val_bytes = self.ret_val.serialize(); [ response_type_bytes[0], 0, sequence_bytes[0], sequence_bytes[1], length_bytes[0], length_bytes[1], length_bytes[2], length_bytes[3], ret_val_bytes[0], ret_val_bytes[1], ret_val_bytes[2], ret_val_bytes[3], ] } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(12); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); self.ret_val.serialize_into(bytes); } } /// Opcode for the GetQueryivARB request pub const GET_QUERYIV_ARB_REQUEST: u8 = 164; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetQueryivARBRequest { pub context_tag: ContextTag, pub target: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetQueryivARBRequest, "GetQueryivARBRequest"); impl GetQueryivARBRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let target_bytes = self.target.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_QUERYIV_ARB_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], target_bytes[0], target_bytes[1], target_bytes[2], target_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_QUERYIV_ARB_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (target, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetQueryivARBRequest { context_tag, target, pname, }) } } impl Request for GetQueryivARBRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetQueryivARBRequest { type Reply = GetQueryivARBReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetQueryivARBReply { pub sequence: u16, pub length: u32, pub datum: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetQueryivARBReply, "GetQueryivARBReply"); impl TryParse for GetQueryivARBReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetQueryivARBReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetQueryivARBReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetQueryivARBReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetQueryObjectivARB request pub const GET_QUERY_OBJECTIV_ARB_REQUEST: u8 = 165; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetQueryObjectivARBRequest { pub context_tag: ContextTag, pub id: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetQueryObjectivARBRequest, "GetQueryObjectivARBRequest"); impl GetQueryObjectivARBRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let id_bytes = self.id.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_QUERY_OBJECTIV_ARB_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], id_bytes[0], id_bytes[1], id_bytes[2], id_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_QUERY_OBJECTIV_ARB_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (id, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetQueryObjectivARBRequest { context_tag, id, pname, }) } } impl Request for GetQueryObjectivARBRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetQueryObjectivARBRequest { type Reply = GetQueryObjectivARBReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetQueryObjectivARBReply { pub sequence: u16, pub length: u32, pub datum: i32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetQueryObjectivARBReply, "GetQueryObjectivARBReply"); impl TryParse for GetQueryObjectivARBReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = i32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetQueryObjectivARBReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetQueryObjectivARBReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetQueryObjectivARBReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } /// Opcode for the GetQueryObjectuivARB request pub const GET_QUERY_OBJECTUIV_ARB_REQUEST: u8 = 166; #[derive(Clone, Copy, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetQueryObjectuivARBRequest { pub context_tag: ContextTag, pub id: u32, pub pname: u32, } impl_debug_if_no_extra_traits!(GetQueryObjectuivARBRequest, "GetQueryObjectuivARBRequest"); impl GetQueryObjectuivARBRequest { /// Serialize this request into bytes for the provided connection pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> { let length_so_far = 0; let context_tag_bytes = self.context_tag.serialize(); let id_bytes = self.id.serialize(); let pname_bytes = self.pname.serialize(); let mut request0 = vec![ major_opcode, GET_QUERY_OBJECTUIV_ARB_REQUEST, 0, 0, context_tag_bytes[0], context_tag_bytes[1], context_tag_bytes[2], context_tag_bytes[3], id_bytes[0], id_bytes[1], id_bytes[2], id_bytes[3], pname_bytes[0], pname_bytes[1], pname_bytes[2], pname_bytes[3], ]; let length_so_far = length_so_far + request0.len(); assert_eq!(length_so_far % 4, 0); let length = u16::try_from(length_so_far / 4).unwrap_or(0); request0[2..4].copy_from_slice(&length.to_ne_bytes()); ([request0.into()], vec![]) } /// Parse this request given its header, its body, and any fds that go along with it #[cfg(feature = "request-parsing")] pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { if header.minor_opcode != GET_QUERY_OBJECTUIV_ARB_REQUEST { return Err(ParseError::InvalidValue); } let (context_tag, remaining) = ContextTag::try_parse(value)?; let (id, remaining) = u32::try_parse(remaining)?; let (pname, remaining) = u32::try_parse(remaining)?; let _ = remaining; Ok(GetQueryObjectuivARBRequest { context_tag, id, pname, }) } } impl Request for GetQueryObjectuivARBRequest { const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); fn serialize(self, major_opcode: u8) -> BufWithFds> { let (bufs, fds) = self.serialize(major_opcode); // Flatten the buffers into a single vector let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); (buf, fds) } } impl crate::x11_utils::ReplyRequest for GetQueryObjectuivARBRequest { type Reply = GetQueryObjectuivARBReply; } #[derive(Clone, Default)] #[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct GetQueryObjectuivARBReply { pub sequence: u16, pub length: u32, pub datum: u32, pub data: Vec, } impl_debug_if_no_extra_traits!(GetQueryObjectuivARBReply, "GetQueryObjectuivARBReply"); impl TryParse for GetQueryObjectuivARBReply { fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> { let remaining = initial_value; let (response_type, remaining) = u8::try_parse(remaining)?; let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?; let (sequence, remaining) = u16::try_parse(remaining)?; let (length, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(4..).ok_or(ParseError::InsufficientData)?; let (n, remaining) = u32::try_parse(remaining)?; let (datum, remaining) = u32::try_parse(remaining)?; let remaining = remaining.get(12..).ok_or(ParseError::InsufficientData)?; let (data, remaining) = crate::x11_utils::parse_list::(remaining, n.try_to_usize()?)?; if response_type != 1 { return Err(ParseError::InvalidValue); } let result = GetQueryObjectuivARBReply { sequence, length, datum, data }; let _ = remaining; let remaining = initial_value.get(32 + length as usize * 4..) .ok_or(ParseError::InsufficientData)?; Ok((result, remaining)) } } impl Serialize for GetQueryObjectuivARBReply { type Bytes = Vec; fn serialize(&self) -> Vec { let mut result = Vec::new(); self.serialize_into(&mut result); result } fn serialize_into(&self, bytes: &mut Vec) { bytes.reserve(32); let response_type_bytes = &[1]; bytes.push(response_type_bytes[0]); bytes.extend_from_slice(&[0; 1]); self.sequence.serialize_into(bytes); self.length.serialize_into(bytes); bytes.extend_from_slice(&[0; 4]); let n = u32::try_from(self.data.len()).expect("`data` has too many elements"); n.serialize_into(bytes); self.datum.serialize_into(bytes); bytes.extend_from_slice(&[0; 12]); self.data.serialize_into(bytes); } } impl GetQueryObjectuivARBReply { /// Get the value of the `n` field. /// /// The `n` field is used as the length field of the `data` field. /// This function computes the field's value again based on the length of the list. /// /// # Panics /// /// Panics if the value cannot be represented in the target type. This /// cannot happen with values of the struct received from the X11 server. pub fn n(&self) -> u32 { self.data.len() .try_into().unwrap() } } x11rb-protocol-0.13.1/src/protocol/mod.rs000064400000000000000000020500021046102023000162560ustar 00000000000000// This file contains generated code. Do not edit directly. // To regenerate this, run 'make'. //! Bindings to the X11 protocol. //! //! Each sub-module of this module corresponds to one X11 extension. It contains all the //! definitions from that extension. The core X11 protocol is in [`xproto`](xproto/index.html). // Clippy does not like some names from the XML. #![allow(clippy::upper_case_acronyms)] // This is not easy to fix, so ignore it. #![allow(clippy::needless_borrow, clippy::needless_lifetimes)] // clippy::unnecessary_fallible_conversions is new in 1.75. TODO: Remove once our MSRV is high enough. #![allow(unknown_lints)] // We use TryFrom in places where From could be used, but fixing this would make the code generator more complicated #![allow(clippy::unnecessary_fallible_conversions)] use alloc::borrow::Cow; use alloc::string::String; use alloc::vec::Vec; use core::convert::TryInto; use crate::errors::ParseError; use crate::RawFdContainer; use crate::x11_utils::{TryParse, TryParseFd, X11Error, ReplyRequest, ReplyFDsRequest}; use crate::x11_utils::{ExtInfoProvider, ReplyParsingFunction, RequestHeader}; fn parse_reply<'a, R: ReplyRequest>(bytes: &'a [u8], _: &mut Vec) -> Result<(Reply, &'a [u8]), ParseError> { let (reply, remaining) = R::Reply::try_parse(bytes)?; Ok((reply.into(), remaining)) } #[allow(dead_code)] fn parse_reply_fds<'a, R: ReplyFDsRequest>(bytes: &'a [u8], fds: &mut Vec) -> Result<(Reply, &'a [u8]), ParseError> { let (reply, remaining) = R::Reply::try_parse_fd(bytes, fds)?; Ok((reply.into(), remaining)) } pub mod xproto; pub mod bigreq; #[cfg(feature = "composite")] pub mod composite; #[cfg(feature = "damage")] pub mod damage; #[cfg(feature = "dbe")] pub mod dbe; #[cfg(feature = "dpms")] pub mod dpms; #[cfg(feature = "dri2")] pub mod dri2; #[cfg(feature = "dri3")] pub mod dri3; pub mod ge; #[cfg(feature = "glx")] pub mod glx; #[cfg(feature = "present")] pub mod present; #[cfg(feature = "randr")] pub mod randr; #[cfg(feature = "record")] pub mod record; #[cfg(feature = "render")] pub mod render; #[cfg(feature = "res")] pub mod res; #[cfg(feature = "screensaver")] pub mod screensaver; #[cfg(feature = "shape")] pub mod shape; #[cfg(feature = "shm")] pub mod shm; #[cfg(feature = "sync")] pub mod sync; pub mod xc_misc; #[cfg(feature = "xevie")] pub mod xevie; #[cfg(feature = "xf86dri")] pub mod xf86dri; #[cfg(feature = "xf86vidmode")] pub mod xf86vidmode; #[cfg(feature = "xfixes")] pub mod xfixes; #[cfg(feature = "xinerama")] pub mod xinerama; #[cfg(feature = "xinput")] pub mod xinput; #[cfg(feature = "xkb")] pub mod xkb; #[cfg(feature = "xprint")] pub mod xprint; #[cfg(feature = "xselinux")] pub mod xselinux; #[cfg(feature = "xtest")] pub mod xtest; #[cfg(feature = "xv")] pub mod xv; #[cfg(feature = "xvmc")] pub mod xvmc; /// Helper container for translating numeric request information to a string #[derive(Debug)] enum RequestInfo { /// A core protocol request Xproto(&'static str), /// A known request from a known extension. String is of the form "ExtName::RequestName". KnownExt(&'static str), /// A request which could not be identified. The first entry is the extension name (or none for xproto). Second is opcode. UnknownRequest(Option<&'static str>, u8), /// A request from an extension that could not be identified UnknownExtension(u8, u8), } /// Get information about a request based on its major and minor code. /// /// The major and minor opcode are the first and second byte of a request. /// Core requests do not have a minor opcode. For these, the minor opcode is ignored by this function. /// /// This function returns the name of the extension to which the request belongs, if available, and information about the specific request. fn get_request_name_internal( ext_info_provider: &dyn ExtInfoProvider, major_opcode: u8, minor_opcode: u8, ) -> (Option<&str>, RequestInfo) { // From the X11 protocol reference manual: // Major opcodes 128 through 255 are reserved for extensions. if major_opcode < 128 { match major_opcode { xproto::CREATE_WINDOW_REQUEST => (None, RequestInfo::Xproto("CreateWindow")), xproto::CHANGE_WINDOW_ATTRIBUTES_REQUEST => (None, RequestInfo::Xproto("ChangeWindowAttributes")), xproto::GET_WINDOW_ATTRIBUTES_REQUEST => (None, RequestInfo::Xproto("GetWindowAttributes")), xproto::DESTROY_WINDOW_REQUEST => (None, RequestInfo::Xproto("DestroyWindow")), xproto::DESTROY_SUBWINDOWS_REQUEST => (None, RequestInfo::Xproto("DestroySubwindows")), xproto::CHANGE_SAVE_SET_REQUEST => (None, RequestInfo::Xproto("ChangeSaveSet")), xproto::REPARENT_WINDOW_REQUEST => (None, RequestInfo::Xproto("ReparentWindow")), xproto::MAP_WINDOW_REQUEST => (None, RequestInfo::Xproto("MapWindow")), xproto::MAP_SUBWINDOWS_REQUEST => (None, RequestInfo::Xproto("MapSubwindows")), xproto::UNMAP_WINDOW_REQUEST => (None, RequestInfo::Xproto("UnmapWindow")), xproto::UNMAP_SUBWINDOWS_REQUEST => (None, RequestInfo::Xproto("UnmapSubwindows")), xproto::CONFIGURE_WINDOW_REQUEST => (None, RequestInfo::Xproto("ConfigureWindow")), xproto::CIRCULATE_WINDOW_REQUEST => (None, RequestInfo::Xproto("CirculateWindow")), xproto::GET_GEOMETRY_REQUEST => (None, RequestInfo::Xproto("GetGeometry")), xproto::QUERY_TREE_REQUEST => (None, RequestInfo::Xproto("QueryTree")), xproto::INTERN_ATOM_REQUEST => (None, RequestInfo::Xproto("InternAtom")), xproto::GET_ATOM_NAME_REQUEST => (None, RequestInfo::Xproto("GetAtomName")), xproto::CHANGE_PROPERTY_REQUEST => (None, RequestInfo::Xproto("ChangeProperty")), xproto::DELETE_PROPERTY_REQUEST => (None, RequestInfo::Xproto("DeleteProperty")), xproto::GET_PROPERTY_REQUEST => (None, RequestInfo::Xproto("GetProperty")), xproto::LIST_PROPERTIES_REQUEST => (None, RequestInfo::Xproto("ListProperties")), xproto::SET_SELECTION_OWNER_REQUEST => (None, RequestInfo::Xproto("SetSelectionOwner")), xproto::GET_SELECTION_OWNER_REQUEST => (None, RequestInfo::Xproto("GetSelectionOwner")), xproto::CONVERT_SELECTION_REQUEST => (None, RequestInfo::Xproto("ConvertSelection")), xproto::SEND_EVENT_REQUEST => (None, RequestInfo::Xproto("SendEvent")), xproto::GRAB_POINTER_REQUEST => (None, RequestInfo::Xproto("GrabPointer")), xproto::UNGRAB_POINTER_REQUEST => (None, RequestInfo::Xproto("UngrabPointer")), xproto::GRAB_BUTTON_REQUEST => (None, RequestInfo::Xproto("GrabButton")), xproto::UNGRAB_BUTTON_REQUEST => (None, RequestInfo::Xproto("UngrabButton")), xproto::CHANGE_ACTIVE_POINTER_GRAB_REQUEST => (None, RequestInfo::Xproto("ChangeActivePointerGrab")), xproto::GRAB_KEYBOARD_REQUEST => (None, RequestInfo::Xproto("GrabKeyboard")), xproto::UNGRAB_KEYBOARD_REQUEST => (None, RequestInfo::Xproto("UngrabKeyboard")), xproto::GRAB_KEY_REQUEST => (None, RequestInfo::Xproto("GrabKey")), xproto::UNGRAB_KEY_REQUEST => (None, RequestInfo::Xproto("UngrabKey")), xproto::ALLOW_EVENTS_REQUEST => (None, RequestInfo::Xproto("AllowEvents")), xproto::GRAB_SERVER_REQUEST => (None, RequestInfo::Xproto("GrabServer")), xproto::UNGRAB_SERVER_REQUEST => (None, RequestInfo::Xproto("UngrabServer")), xproto::QUERY_POINTER_REQUEST => (None, RequestInfo::Xproto("QueryPointer")), xproto::GET_MOTION_EVENTS_REQUEST => (None, RequestInfo::Xproto("GetMotionEvents")), xproto::TRANSLATE_COORDINATES_REQUEST => (None, RequestInfo::Xproto("TranslateCoordinates")), xproto::WARP_POINTER_REQUEST => (None, RequestInfo::Xproto("WarpPointer")), xproto::SET_INPUT_FOCUS_REQUEST => (None, RequestInfo::Xproto("SetInputFocus")), xproto::GET_INPUT_FOCUS_REQUEST => (None, RequestInfo::Xproto("GetInputFocus")), xproto::QUERY_KEYMAP_REQUEST => (None, RequestInfo::Xproto("QueryKeymap")), xproto::OPEN_FONT_REQUEST => (None, RequestInfo::Xproto("OpenFont")), xproto::CLOSE_FONT_REQUEST => (None, RequestInfo::Xproto("CloseFont")), xproto::QUERY_FONT_REQUEST => (None, RequestInfo::Xproto("QueryFont")), xproto::QUERY_TEXT_EXTENTS_REQUEST => (None, RequestInfo::Xproto("QueryTextExtents")), xproto::LIST_FONTS_REQUEST => (None, RequestInfo::Xproto("ListFonts")), xproto::LIST_FONTS_WITH_INFO_REQUEST => (None, RequestInfo::Xproto("ListFontsWithInfo")), xproto::SET_FONT_PATH_REQUEST => (None, RequestInfo::Xproto("SetFontPath")), xproto::GET_FONT_PATH_REQUEST => (None, RequestInfo::Xproto("GetFontPath")), xproto::CREATE_PIXMAP_REQUEST => (None, RequestInfo::Xproto("CreatePixmap")), xproto::FREE_PIXMAP_REQUEST => (None, RequestInfo::Xproto("FreePixmap")), xproto::CREATE_GC_REQUEST => (None, RequestInfo::Xproto("CreateGC")), xproto::CHANGE_GC_REQUEST => (None, RequestInfo::Xproto("ChangeGC")), xproto::COPY_GC_REQUEST => (None, RequestInfo::Xproto("CopyGC")), xproto::SET_DASHES_REQUEST => (None, RequestInfo::Xproto("SetDashes")), xproto::SET_CLIP_RECTANGLES_REQUEST => (None, RequestInfo::Xproto("SetClipRectangles")), xproto::FREE_GC_REQUEST => (None, RequestInfo::Xproto("FreeGC")), xproto::CLEAR_AREA_REQUEST => (None, RequestInfo::Xproto("ClearArea")), xproto::COPY_AREA_REQUEST => (None, RequestInfo::Xproto("CopyArea")), xproto::COPY_PLANE_REQUEST => (None, RequestInfo::Xproto("CopyPlane")), xproto::POLY_POINT_REQUEST => (None, RequestInfo::Xproto("PolyPoint")), xproto::POLY_LINE_REQUEST => (None, RequestInfo::Xproto("PolyLine")), xproto::POLY_SEGMENT_REQUEST => (None, RequestInfo::Xproto("PolySegment")), xproto::POLY_RECTANGLE_REQUEST => (None, RequestInfo::Xproto("PolyRectangle")), xproto::POLY_ARC_REQUEST => (None, RequestInfo::Xproto("PolyArc")), xproto::FILL_POLY_REQUEST => (None, RequestInfo::Xproto("FillPoly")), xproto::POLY_FILL_RECTANGLE_REQUEST => (None, RequestInfo::Xproto("PolyFillRectangle")), xproto::POLY_FILL_ARC_REQUEST => (None, RequestInfo::Xproto("PolyFillArc")), xproto::PUT_IMAGE_REQUEST => (None, RequestInfo::Xproto("PutImage")), xproto::GET_IMAGE_REQUEST => (None, RequestInfo::Xproto("GetImage")), xproto::POLY_TEXT8_REQUEST => (None, RequestInfo::Xproto("PolyText8")), xproto::POLY_TEXT16_REQUEST => (None, RequestInfo::Xproto("PolyText16")), xproto::IMAGE_TEXT8_REQUEST => (None, RequestInfo::Xproto("ImageText8")), xproto::IMAGE_TEXT16_REQUEST => (None, RequestInfo::Xproto("ImageText16")), xproto::CREATE_COLORMAP_REQUEST => (None, RequestInfo::Xproto("CreateColormap")), xproto::FREE_COLORMAP_REQUEST => (None, RequestInfo::Xproto("FreeColormap")), xproto::COPY_COLORMAP_AND_FREE_REQUEST => (None, RequestInfo::Xproto("CopyColormapAndFree")), xproto::INSTALL_COLORMAP_REQUEST => (None, RequestInfo::Xproto("InstallColormap")), xproto::UNINSTALL_COLORMAP_REQUEST => (None, RequestInfo::Xproto("UninstallColormap")), xproto::LIST_INSTALLED_COLORMAPS_REQUEST => (None, RequestInfo::Xproto("ListInstalledColormaps")), xproto::ALLOC_COLOR_REQUEST => (None, RequestInfo::Xproto("AllocColor")), xproto::ALLOC_NAMED_COLOR_REQUEST => (None, RequestInfo::Xproto("AllocNamedColor")), xproto::ALLOC_COLOR_CELLS_REQUEST => (None, RequestInfo::Xproto("AllocColorCells")), xproto::ALLOC_COLOR_PLANES_REQUEST => (None, RequestInfo::Xproto("AllocColorPlanes")), xproto::FREE_COLORS_REQUEST => (None, RequestInfo::Xproto("FreeColors")), xproto::STORE_COLORS_REQUEST => (None, RequestInfo::Xproto("StoreColors")), xproto::STORE_NAMED_COLOR_REQUEST => (None, RequestInfo::Xproto("StoreNamedColor")), xproto::QUERY_COLORS_REQUEST => (None, RequestInfo::Xproto("QueryColors")), xproto::LOOKUP_COLOR_REQUEST => (None, RequestInfo::Xproto("LookupColor")), xproto::CREATE_CURSOR_REQUEST => (None, RequestInfo::Xproto("CreateCursor")), xproto::CREATE_GLYPH_CURSOR_REQUEST => (None, RequestInfo::Xproto("CreateGlyphCursor")), xproto::FREE_CURSOR_REQUEST => (None, RequestInfo::Xproto("FreeCursor")), xproto::RECOLOR_CURSOR_REQUEST => (None, RequestInfo::Xproto("RecolorCursor")), xproto::QUERY_BEST_SIZE_REQUEST => (None, RequestInfo::Xproto("QueryBestSize")), xproto::QUERY_EXTENSION_REQUEST => (None, RequestInfo::Xproto("QueryExtension")), xproto::LIST_EXTENSIONS_REQUEST => (None, RequestInfo::Xproto("ListExtensions")), xproto::CHANGE_KEYBOARD_MAPPING_REQUEST => (None, RequestInfo::Xproto("ChangeKeyboardMapping")), xproto::GET_KEYBOARD_MAPPING_REQUEST => (None, RequestInfo::Xproto("GetKeyboardMapping")), xproto::CHANGE_KEYBOARD_CONTROL_REQUEST => (None, RequestInfo::Xproto("ChangeKeyboardControl")), xproto::GET_KEYBOARD_CONTROL_REQUEST => (None, RequestInfo::Xproto("GetKeyboardControl")), xproto::BELL_REQUEST => (None, RequestInfo::Xproto("Bell")), xproto::CHANGE_POINTER_CONTROL_REQUEST => (None, RequestInfo::Xproto("ChangePointerControl")), xproto::GET_POINTER_CONTROL_REQUEST => (None, RequestInfo::Xproto("GetPointerControl")), xproto::SET_SCREEN_SAVER_REQUEST => (None, RequestInfo::Xproto("SetScreenSaver")), xproto::GET_SCREEN_SAVER_REQUEST => (None, RequestInfo::Xproto("GetScreenSaver")), xproto::CHANGE_HOSTS_REQUEST => (None, RequestInfo::Xproto("ChangeHosts")), xproto::LIST_HOSTS_REQUEST => (None, RequestInfo::Xproto("ListHosts")), xproto::SET_ACCESS_CONTROL_REQUEST => (None, RequestInfo::Xproto("SetAccessControl")), xproto::SET_CLOSE_DOWN_MODE_REQUEST => (None, RequestInfo::Xproto("SetCloseDownMode")), xproto::KILL_CLIENT_REQUEST => (None, RequestInfo::Xproto("KillClient")), xproto::ROTATE_PROPERTIES_REQUEST => (None, RequestInfo::Xproto("RotateProperties")), xproto::FORCE_SCREEN_SAVER_REQUEST => (None, RequestInfo::Xproto("ForceScreenSaver")), xproto::SET_POINTER_MAPPING_REQUEST => (None, RequestInfo::Xproto("SetPointerMapping")), xproto::GET_POINTER_MAPPING_REQUEST => (None, RequestInfo::Xproto("GetPointerMapping")), xproto::SET_MODIFIER_MAPPING_REQUEST => (None, RequestInfo::Xproto("SetModifierMapping")), xproto::GET_MODIFIER_MAPPING_REQUEST => (None, RequestInfo::Xproto("GetModifierMapping")), xproto::NO_OPERATION_REQUEST => (None, RequestInfo::Xproto("NoOperation")), _ => (None, RequestInfo::UnknownRequest(None, major_opcode)), } } else { // Figure out the extension name let ext_name = match ext_info_provider.get_from_major_opcode(major_opcode) { Some((name, _)) => name, None => return (None, RequestInfo::UnknownExtension(major_opcode, minor_opcode)), }; let info = match ext_name { bigreq::X11_EXTENSION_NAME => { match minor_opcode { bigreq::ENABLE_REQUEST => RequestInfo::KnownExt("BigRequests::Enable"), _ => RequestInfo::UnknownRequest(Some("BigRequests"), minor_opcode), } } #[cfg(feature = "composite")] composite::X11_EXTENSION_NAME => { match minor_opcode { composite::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("Composite::QueryVersion"), composite::REDIRECT_WINDOW_REQUEST => RequestInfo::KnownExt("Composite::RedirectWindow"), composite::REDIRECT_SUBWINDOWS_REQUEST => RequestInfo::KnownExt("Composite::RedirectSubwindows"), composite::UNREDIRECT_WINDOW_REQUEST => RequestInfo::KnownExt("Composite::UnredirectWindow"), composite::UNREDIRECT_SUBWINDOWS_REQUEST => RequestInfo::KnownExt("Composite::UnredirectSubwindows"), composite::CREATE_REGION_FROM_BORDER_CLIP_REQUEST => RequestInfo::KnownExt("Composite::CreateRegionFromBorderClip"), composite::NAME_WINDOW_PIXMAP_REQUEST => RequestInfo::KnownExt("Composite::NameWindowPixmap"), composite::GET_OVERLAY_WINDOW_REQUEST => RequestInfo::KnownExt("Composite::GetOverlayWindow"), composite::RELEASE_OVERLAY_WINDOW_REQUEST => RequestInfo::KnownExt("Composite::ReleaseOverlayWindow"), _ => RequestInfo::UnknownRequest(Some("Composite"), minor_opcode), } } #[cfg(feature = "damage")] damage::X11_EXTENSION_NAME => { match minor_opcode { damage::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("Damage::QueryVersion"), damage::CREATE_REQUEST => RequestInfo::KnownExt("Damage::Create"), damage::DESTROY_REQUEST => RequestInfo::KnownExt("Damage::Destroy"), damage::SUBTRACT_REQUEST => RequestInfo::KnownExt("Damage::Subtract"), damage::ADD_REQUEST => RequestInfo::KnownExt("Damage::Add"), _ => RequestInfo::UnknownRequest(Some("Damage"), minor_opcode), } } #[cfg(feature = "dbe")] dbe::X11_EXTENSION_NAME => { match minor_opcode { dbe::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("Dbe::QueryVersion"), dbe::ALLOCATE_BACK_BUFFER_REQUEST => RequestInfo::KnownExt("Dbe::AllocateBackBuffer"), dbe::DEALLOCATE_BACK_BUFFER_REQUEST => RequestInfo::KnownExt("Dbe::DeallocateBackBuffer"), dbe::SWAP_BUFFERS_REQUEST => RequestInfo::KnownExt("Dbe::SwapBuffers"), dbe::BEGIN_IDIOM_REQUEST => RequestInfo::KnownExt("Dbe::BeginIdiom"), dbe::END_IDIOM_REQUEST => RequestInfo::KnownExt("Dbe::EndIdiom"), dbe::GET_VISUAL_INFO_REQUEST => RequestInfo::KnownExt("Dbe::GetVisualInfo"), dbe::GET_BACK_BUFFER_ATTRIBUTES_REQUEST => RequestInfo::KnownExt("Dbe::GetBackBufferAttributes"), _ => RequestInfo::UnknownRequest(Some("Dbe"), minor_opcode), } } #[cfg(feature = "dpms")] dpms::X11_EXTENSION_NAME => { match minor_opcode { dpms::GET_VERSION_REQUEST => RequestInfo::KnownExt("DPMS::GetVersion"), dpms::CAPABLE_REQUEST => RequestInfo::KnownExt("DPMS::Capable"), dpms::GET_TIMEOUTS_REQUEST => RequestInfo::KnownExt("DPMS::GetTimeouts"), dpms::SET_TIMEOUTS_REQUEST => RequestInfo::KnownExt("DPMS::SetTimeouts"), dpms::ENABLE_REQUEST => RequestInfo::KnownExt("DPMS::Enable"), dpms::DISABLE_REQUEST => RequestInfo::KnownExt("DPMS::Disable"), dpms::FORCE_LEVEL_REQUEST => RequestInfo::KnownExt("DPMS::ForceLevel"), dpms::INFO_REQUEST => RequestInfo::KnownExt("DPMS::Info"), dpms::SELECT_INPUT_REQUEST => RequestInfo::KnownExt("DPMS::SelectInput"), _ => RequestInfo::UnknownRequest(Some("DPMS"), minor_opcode), } } #[cfg(feature = "dri2")] dri2::X11_EXTENSION_NAME => { match minor_opcode { dri2::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("DRI2::QueryVersion"), dri2::CONNECT_REQUEST => RequestInfo::KnownExt("DRI2::Connect"), dri2::AUTHENTICATE_REQUEST => RequestInfo::KnownExt("DRI2::Authenticate"), dri2::CREATE_DRAWABLE_REQUEST => RequestInfo::KnownExt("DRI2::CreateDrawable"), dri2::DESTROY_DRAWABLE_REQUEST => RequestInfo::KnownExt("DRI2::DestroyDrawable"), dri2::GET_BUFFERS_REQUEST => RequestInfo::KnownExt("DRI2::GetBuffers"), dri2::COPY_REGION_REQUEST => RequestInfo::KnownExt("DRI2::CopyRegion"), dri2::GET_BUFFERS_WITH_FORMAT_REQUEST => RequestInfo::KnownExt("DRI2::GetBuffersWithFormat"), dri2::SWAP_BUFFERS_REQUEST => RequestInfo::KnownExt("DRI2::SwapBuffers"), dri2::GET_MSC_REQUEST => RequestInfo::KnownExt("DRI2::GetMSC"), dri2::WAIT_MSC_REQUEST => RequestInfo::KnownExt("DRI2::WaitMSC"), dri2::WAIT_SBC_REQUEST => RequestInfo::KnownExt("DRI2::WaitSBC"), dri2::SWAP_INTERVAL_REQUEST => RequestInfo::KnownExt("DRI2::SwapInterval"), dri2::GET_PARAM_REQUEST => RequestInfo::KnownExt("DRI2::GetParam"), _ => RequestInfo::UnknownRequest(Some("DRI2"), minor_opcode), } } #[cfg(feature = "dri3")] dri3::X11_EXTENSION_NAME => { match minor_opcode { dri3::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("DRI3::QueryVersion"), dri3::OPEN_REQUEST => RequestInfo::KnownExt("DRI3::Open"), dri3::PIXMAP_FROM_BUFFER_REQUEST => RequestInfo::KnownExt("DRI3::PixmapFromBuffer"), dri3::BUFFER_FROM_PIXMAP_REQUEST => RequestInfo::KnownExt("DRI3::BufferFromPixmap"), dri3::FENCE_FROM_FD_REQUEST => RequestInfo::KnownExt("DRI3::FenceFromFD"), dri3::FD_FROM_FENCE_REQUEST => RequestInfo::KnownExt("DRI3::FDFromFence"), dri3::GET_SUPPORTED_MODIFIERS_REQUEST => RequestInfo::KnownExt("DRI3::GetSupportedModifiers"), dri3::PIXMAP_FROM_BUFFERS_REQUEST => RequestInfo::KnownExt("DRI3::PixmapFromBuffers"), dri3::BUFFERS_FROM_PIXMAP_REQUEST => RequestInfo::KnownExt("DRI3::BuffersFromPixmap"), dri3::SET_DRM_DEVICE_IN_USE_REQUEST => RequestInfo::KnownExt("DRI3::SetDRMDeviceInUse"), dri3::IMPORT_SYNCOBJ_REQUEST => RequestInfo::KnownExt("DRI3::ImportSyncobj"), dri3::FREE_SYNCOBJ_REQUEST => RequestInfo::KnownExt("DRI3::FreeSyncobj"), _ => RequestInfo::UnknownRequest(Some("DRI3"), minor_opcode), } } ge::X11_EXTENSION_NAME => { match minor_opcode { ge::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("GenericEvent::QueryVersion"), _ => RequestInfo::UnknownRequest(Some("GenericEvent"), minor_opcode), } } #[cfg(feature = "glx")] glx::X11_EXTENSION_NAME => { match minor_opcode { glx::RENDER_REQUEST => RequestInfo::KnownExt("Glx::Render"), glx::RENDER_LARGE_REQUEST => RequestInfo::KnownExt("Glx::RenderLarge"), glx::CREATE_CONTEXT_REQUEST => RequestInfo::KnownExt("Glx::CreateContext"), glx::DESTROY_CONTEXT_REQUEST => RequestInfo::KnownExt("Glx::DestroyContext"), glx::MAKE_CURRENT_REQUEST => RequestInfo::KnownExt("Glx::MakeCurrent"), glx::IS_DIRECT_REQUEST => RequestInfo::KnownExt("Glx::IsDirect"), glx::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("Glx::QueryVersion"), glx::WAIT_GL_REQUEST => RequestInfo::KnownExt("Glx::WaitGL"), glx::WAIT_X_REQUEST => RequestInfo::KnownExt("Glx::WaitX"), glx::COPY_CONTEXT_REQUEST => RequestInfo::KnownExt("Glx::CopyContext"), glx::SWAP_BUFFERS_REQUEST => RequestInfo::KnownExt("Glx::SwapBuffers"), glx::USE_X_FONT_REQUEST => RequestInfo::KnownExt("Glx::UseXFont"), glx::CREATE_GLX_PIXMAP_REQUEST => RequestInfo::KnownExt("Glx::CreateGLXPixmap"), glx::GET_VISUAL_CONFIGS_REQUEST => RequestInfo::KnownExt("Glx::GetVisualConfigs"), glx::DESTROY_GLX_PIXMAP_REQUEST => RequestInfo::KnownExt("Glx::DestroyGLXPixmap"), glx::VENDOR_PRIVATE_REQUEST => RequestInfo::KnownExt("Glx::VendorPrivate"), glx::VENDOR_PRIVATE_WITH_REPLY_REQUEST => RequestInfo::KnownExt("Glx::VendorPrivateWithReply"), glx::QUERY_EXTENSIONS_STRING_REQUEST => RequestInfo::KnownExt("Glx::QueryExtensionsString"), glx::QUERY_SERVER_STRING_REQUEST => RequestInfo::KnownExt("Glx::QueryServerString"), glx::CLIENT_INFO_REQUEST => RequestInfo::KnownExt("Glx::ClientInfo"), glx::GET_FB_CONFIGS_REQUEST => RequestInfo::KnownExt("Glx::GetFBConfigs"), glx::CREATE_PIXMAP_REQUEST => RequestInfo::KnownExt("Glx::CreatePixmap"), glx::DESTROY_PIXMAP_REQUEST => RequestInfo::KnownExt("Glx::DestroyPixmap"), glx::CREATE_NEW_CONTEXT_REQUEST => RequestInfo::KnownExt("Glx::CreateNewContext"), glx::QUERY_CONTEXT_REQUEST => RequestInfo::KnownExt("Glx::QueryContext"), glx::MAKE_CONTEXT_CURRENT_REQUEST => RequestInfo::KnownExt("Glx::MakeContextCurrent"), glx::CREATE_PBUFFER_REQUEST => RequestInfo::KnownExt("Glx::CreatePbuffer"), glx::DESTROY_PBUFFER_REQUEST => RequestInfo::KnownExt("Glx::DestroyPbuffer"), glx::GET_DRAWABLE_ATTRIBUTES_REQUEST => RequestInfo::KnownExt("Glx::GetDrawableAttributes"), glx::CHANGE_DRAWABLE_ATTRIBUTES_REQUEST => RequestInfo::KnownExt("Glx::ChangeDrawableAttributes"), glx::CREATE_WINDOW_REQUEST => RequestInfo::KnownExt("Glx::CreateWindow"), glx::DELETE_WINDOW_REQUEST => RequestInfo::KnownExt("Glx::DeleteWindow"), glx::SET_CLIENT_INFO_ARB_REQUEST => RequestInfo::KnownExt("Glx::SetClientInfoARB"), glx::CREATE_CONTEXT_ATTRIBS_ARB_REQUEST => RequestInfo::KnownExt("Glx::CreateContextAttribsARB"), glx::SET_CLIENT_INFO2_ARB_REQUEST => RequestInfo::KnownExt("Glx::SetClientInfo2ARB"), glx::NEW_LIST_REQUEST => RequestInfo::KnownExt("Glx::NewList"), glx::END_LIST_REQUEST => RequestInfo::KnownExt("Glx::EndList"), glx::DELETE_LISTS_REQUEST => RequestInfo::KnownExt("Glx::DeleteLists"), glx::GEN_LISTS_REQUEST => RequestInfo::KnownExt("Glx::GenLists"), glx::FEEDBACK_BUFFER_REQUEST => RequestInfo::KnownExt("Glx::FeedbackBuffer"), glx::SELECT_BUFFER_REQUEST => RequestInfo::KnownExt("Glx::SelectBuffer"), glx::RENDER_MODE_REQUEST => RequestInfo::KnownExt("Glx::RenderMode"), glx::FINISH_REQUEST => RequestInfo::KnownExt("Glx::Finish"), glx::PIXEL_STOREF_REQUEST => RequestInfo::KnownExt("Glx::PixelStoref"), glx::PIXEL_STOREI_REQUEST => RequestInfo::KnownExt("Glx::PixelStorei"), glx::READ_PIXELS_REQUEST => RequestInfo::KnownExt("Glx::ReadPixels"), glx::GET_BOOLEANV_REQUEST => RequestInfo::KnownExt("Glx::GetBooleanv"), glx::GET_CLIP_PLANE_REQUEST => RequestInfo::KnownExt("Glx::GetClipPlane"), glx::GET_DOUBLEV_REQUEST => RequestInfo::KnownExt("Glx::GetDoublev"), glx::GET_ERROR_REQUEST => RequestInfo::KnownExt("Glx::GetError"), glx::GET_FLOATV_REQUEST => RequestInfo::KnownExt("Glx::GetFloatv"), glx::GET_INTEGERV_REQUEST => RequestInfo::KnownExt("Glx::GetIntegerv"), glx::GET_LIGHTFV_REQUEST => RequestInfo::KnownExt("Glx::GetLightfv"), glx::GET_LIGHTIV_REQUEST => RequestInfo::KnownExt("Glx::GetLightiv"), glx::GET_MAPDV_REQUEST => RequestInfo::KnownExt("Glx::GetMapdv"), glx::GET_MAPFV_REQUEST => RequestInfo::KnownExt("Glx::GetMapfv"), glx::GET_MAPIV_REQUEST => RequestInfo::KnownExt("Glx::GetMapiv"), glx::GET_MATERIALFV_REQUEST => RequestInfo::KnownExt("Glx::GetMaterialfv"), glx::GET_MATERIALIV_REQUEST => RequestInfo::KnownExt("Glx::GetMaterialiv"), glx::GET_PIXEL_MAPFV_REQUEST => RequestInfo::KnownExt("Glx::GetPixelMapfv"), glx::GET_PIXEL_MAPUIV_REQUEST => RequestInfo::KnownExt("Glx::GetPixelMapuiv"), glx::GET_PIXEL_MAPUSV_REQUEST => RequestInfo::KnownExt("Glx::GetPixelMapusv"), glx::GET_POLYGON_STIPPLE_REQUEST => RequestInfo::KnownExt("Glx::GetPolygonStipple"), glx::GET_STRING_REQUEST => RequestInfo::KnownExt("Glx::GetString"), glx::GET_TEX_ENVFV_REQUEST => RequestInfo::KnownExt("Glx::GetTexEnvfv"), glx::GET_TEX_ENVIV_REQUEST => RequestInfo::KnownExt("Glx::GetTexEnviv"), glx::GET_TEX_GENDV_REQUEST => RequestInfo::KnownExt("Glx::GetTexGendv"), glx::GET_TEX_GENFV_REQUEST => RequestInfo::KnownExt("Glx::GetTexGenfv"), glx::GET_TEX_GENIV_REQUEST => RequestInfo::KnownExt("Glx::GetTexGeniv"), glx::GET_TEX_IMAGE_REQUEST => RequestInfo::KnownExt("Glx::GetTexImage"), glx::GET_TEX_PARAMETERFV_REQUEST => RequestInfo::KnownExt("Glx::GetTexParameterfv"), glx::GET_TEX_PARAMETERIV_REQUEST => RequestInfo::KnownExt("Glx::GetTexParameteriv"), glx::GET_TEX_LEVEL_PARAMETERFV_REQUEST => RequestInfo::KnownExt("Glx::GetTexLevelParameterfv"), glx::GET_TEX_LEVEL_PARAMETERIV_REQUEST => RequestInfo::KnownExt("Glx::GetTexLevelParameteriv"), glx::IS_ENABLED_REQUEST => RequestInfo::KnownExt("Glx::IsEnabled"), glx::IS_LIST_REQUEST => RequestInfo::KnownExt("Glx::IsList"), glx::FLUSH_REQUEST => RequestInfo::KnownExt("Glx::Flush"), glx::ARE_TEXTURES_RESIDENT_REQUEST => RequestInfo::KnownExt("Glx::AreTexturesResident"), glx::DELETE_TEXTURES_REQUEST => RequestInfo::KnownExt("Glx::DeleteTextures"), glx::GEN_TEXTURES_REQUEST => RequestInfo::KnownExt("Glx::GenTextures"), glx::IS_TEXTURE_REQUEST => RequestInfo::KnownExt("Glx::IsTexture"), glx::GET_COLOR_TABLE_REQUEST => RequestInfo::KnownExt("Glx::GetColorTable"), glx::GET_COLOR_TABLE_PARAMETERFV_REQUEST => RequestInfo::KnownExt("Glx::GetColorTableParameterfv"), glx::GET_COLOR_TABLE_PARAMETERIV_REQUEST => RequestInfo::KnownExt("Glx::GetColorTableParameteriv"), glx::GET_CONVOLUTION_FILTER_REQUEST => RequestInfo::KnownExt("Glx::GetConvolutionFilter"), glx::GET_CONVOLUTION_PARAMETERFV_REQUEST => RequestInfo::KnownExt("Glx::GetConvolutionParameterfv"), glx::GET_CONVOLUTION_PARAMETERIV_REQUEST => RequestInfo::KnownExt("Glx::GetConvolutionParameteriv"), glx::GET_SEPARABLE_FILTER_REQUEST => RequestInfo::KnownExt("Glx::GetSeparableFilter"), glx::GET_HISTOGRAM_REQUEST => RequestInfo::KnownExt("Glx::GetHistogram"), glx::GET_HISTOGRAM_PARAMETERFV_REQUEST => RequestInfo::KnownExt("Glx::GetHistogramParameterfv"), glx::GET_HISTOGRAM_PARAMETERIV_REQUEST => RequestInfo::KnownExt("Glx::GetHistogramParameteriv"), glx::GET_MINMAX_REQUEST => RequestInfo::KnownExt("Glx::GetMinmax"), glx::GET_MINMAX_PARAMETERFV_REQUEST => RequestInfo::KnownExt("Glx::GetMinmaxParameterfv"), glx::GET_MINMAX_PARAMETERIV_REQUEST => RequestInfo::KnownExt("Glx::GetMinmaxParameteriv"), glx::GET_COMPRESSED_TEX_IMAGE_ARB_REQUEST => RequestInfo::KnownExt("Glx::GetCompressedTexImageARB"), glx::DELETE_QUERIES_ARB_REQUEST => RequestInfo::KnownExt("Glx::DeleteQueriesARB"), glx::GEN_QUERIES_ARB_REQUEST => RequestInfo::KnownExt("Glx::GenQueriesARB"), glx::IS_QUERY_ARB_REQUEST => RequestInfo::KnownExt("Glx::IsQueryARB"), glx::GET_QUERYIV_ARB_REQUEST => RequestInfo::KnownExt("Glx::GetQueryivARB"), glx::GET_QUERY_OBJECTIV_ARB_REQUEST => RequestInfo::KnownExt("Glx::GetQueryObjectivARB"), glx::GET_QUERY_OBJECTUIV_ARB_REQUEST => RequestInfo::KnownExt("Glx::GetQueryObjectuivARB"), _ => RequestInfo::UnknownRequest(Some("Glx"), minor_opcode), } } #[cfg(feature = "present")] present::X11_EXTENSION_NAME => { match minor_opcode { present::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("Present::QueryVersion"), present::PIXMAP_REQUEST => RequestInfo::KnownExt("Present::Pixmap"), present::NOTIFY_MSC_REQUEST => RequestInfo::KnownExt("Present::NotifyMSC"), present::SELECT_INPUT_REQUEST => RequestInfo::KnownExt("Present::SelectInput"), present::QUERY_CAPABILITIES_REQUEST => RequestInfo::KnownExt("Present::QueryCapabilities"), present::PIXMAP_SYNCED_REQUEST => RequestInfo::KnownExt("Present::PixmapSynced"), _ => RequestInfo::UnknownRequest(Some("Present"), minor_opcode), } } #[cfg(feature = "randr")] randr::X11_EXTENSION_NAME => { match minor_opcode { randr::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("RandR::QueryVersion"), randr::SET_SCREEN_CONFIG_REQUEST => RequestInfo::KnownExt("RandR::SetScreenConfig"), randr::SELECT_INPUT_REQUEST => RequestInfo::KnownExt("RandR::SelectInput"), randr::GET_SCREEN_INFO_REQUEST => RequestInfo::KnownExt("RandR::GetScreenInfo"), randr::GET_SCREEN_SIZE_RANGE_REQUEST => RequestInfo::KnownExt("RandR::GetScreenSizeRange"), randr::SET_SCREEN_SIZE_REQUEST => RequestInfo::KnownExt("RandR::SetScreenSize"), randr::GET_SCREEN_RESOURCES_REQUEST => RequestInfo::KnownExt("RandR::GetScreenResources"), randr::GET_OUTPUT_INFO_REQUEST => RequestInfo::KnownExt("RandR::GetOutputInfo"), randr::LIST_OUTPUT_PROPERTIES_REQUEST => RequestInfo::KnownExt("RandR::ListOutputProperties"), randr::QUERY_OUTPUT_PROPERTY_REQUEST => RequestInfo::KnownExt("RandR::QueryOutputProperty"), randr::CONFIGURE_OUTPUT_PROPERTY_REQUEST => RequestInfo::KnownExt("RandR::ConfigureOutputProperty"), randr::CHANGE_OUTPUT_PROPERTY_REQUEST => RequestInfo::KnownExt("RandR::ChangeOutputProperty"), randr::DELETE_OUTPUT_PROPERTY_REQUEST => RequestInfo::KnownExt("RandR::DeleteOutputProperty"), randr::GET_OUTPUT_PROPERTY_REQUEST => RequestInfo::KnownExt("RandR::GetOutputProperty"), randr::CREATE_MODE_REQUEST => RequestInfo::KnownExt("RandR::CreateMode"), randr::DESTROY_MODE_REQUEST => RequestInfo::KnownExt("RandR::DestroyMode"), randr::ADD_OUTPUT_MODE_REQUEST => RequestInfo::KnownExt("RandR::AddOutputMode"), randr::DELETE_OUTPUT_MODE_REQUEST => RequestInfo::KnownExt("RandR::DeleteOutputMode"), randr::GET_CRTC_INFO_REQUEST => RequestInfo::KnownExt("RandR::GetCrtcInfo"), randr::SET_CRTC_CONFIG_REQUEST => RequestInfo::KnownExt("RandR::SetCrtcConfig"), randr::GET_CRTC_GAMMA_SIZE_REQUEST => RequestInfo::KnownExt("RandR::GetCrtcGammaSize"), randr::GET_CRTC_GAMMA_REQUEST => RequestInfo::KnownExt("RandR::GetCrtcGamma"), randr::SET_CRTC_GAMMA_REQUEST => RequestInfo::KnownExt("RandR::SetCrtcGamma"), randr::GET_SCREEN_RESOURCES_CURRENT_REQUEST => RequestInfo::KnownExt("RandR::GetScreenResourcesCurrent"), randr::SET_CRTC_TRANSFORM_REQUEST => RequestInfo::KnownExt("RandR::SetCrtcTransform"), randr::GET_CRTC_TRANSFORM_REQUEST => RequestInfo::KnownExt("RandR::GetCrtcTransform"), randr::GET_PANNING_REQUEST => RequestInfo::KnownExt("RandR::GetPanning"), randr::SET_PANNING_REQUEST => RequestInfo::KnownExt("RandR::SetPanning"), randr::SET_OUTPUT_PRIMARY_REQUEST => RequestInfo::KnownExt("RandR::SetOutputPrimary"), randr::GET_OUTPUT_PRIMARY_REQUEST => RequestInfo::KnownExt("RandR::GetOutputPrimary"), randr::GET_PROVIDERS_REQUEST => RequestInfo::KnownExt("RandR::GetProviders"), randr::GET_PROVIDER_INFO_REQUEST => RequestInfo::KnownExt("RandR::GetProviderInfo"), randr::SET_PROVIDER_OFFLOAD_SINK_REQUEST => RequestInfo::KnownExt("RandR::SetProviderOffloadSink"), randr::SET_PROVIDER_OUTPUT_SOURCE_REQUEST => RequestInfo::KnownExt("RandR::SetProviderOutputSource"), randr::LIST_PROVIDER_PROPERTIES_REQUEST => RequestInfo::KnownExt("RandR::ListProviderProperties"), randr::QUERY_PROVIDER_PROPERTY_REQUEST => RequestInfo::KnownExt("RandR::QueryProviderProperty"), randr::CONFIGURE_PROVIDER_PROPERTY_REQUEST => RequestInfo::KnownExt("RandR::ConfigureProviderProperty"), randr::CHANGE_PROVIDER_PROPERTY_REQUEST => RequestInfo::KnownExt("RandR::ChangeProviderProperty"), randr::DELETE_PROVIDER_PROPERTY_REQUEST => RequestInfo::KnownExt("RandR::DeleteProviderProperty"), randr::GET_PROVIDER_PROPERTY_REQUEST => RequestInfo::KnownExt("RandR::GetProviderProperty"), randr::GET_MONITORS_REQUEST => RequestInfo::KnownExt("RandR::GetMonitors"), randr::SET_MONITOR_REQUEST => RequestInfo::KnownExt("RandR::SetMonitor"), randr::DELETE_MONITOR_REQUEST => RequestInfo::KnownExt("RandR::DeleteMonitor"), randr::CREATE_LEASE_REQUEST => RequestInfo::KnownExt("RandR::CreateLease"), randr::FREE_LEASE_REQUEST => RequestInfo::KnownExt("RandR::FreeLease"), _ => RequestInfo::UnknownRequest(Some("RandR"), minor_opcode), } } #[cfg(feature = "record")] record::X11_EXTENSION_NAME => { match minor_opcode { record::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("Record::QueryVersion"), record::CREATE_CONTEXT_REQUEST => RequestInfo::KnownExt("Record::CreateContext"), record::REGISTER_CLIENTS_REQUEST => RequestInfo::KnownExt("Record::RegisterClients"), record::UNREGISTER_CLIENTS_REQUEST => RequestInfo::KnownExt("Record::UnregisterClients"), record::GET_CONTEXT_REQUEST => RequestInfo::KnownExt("Record::GetContext"), record::ENABLE_CONTEXT_REQUEST => RequestInfo::KnownExt("Record::EnableContext"), record::DISABLE_CONTEXT_REQUEST => RequestInfo::KnownExt("Record::DisableContext"), record::FREE_CONTEXT_REQUEST => RequestInfo::KnownExt("Record::FreeContext"), _ => RequestInfo::UnknownRequest(Some("Record"), minor_opcode), } } #[cfg(feature = "render")] render::X11_EXTENSION_NAME => { match minor_opcode { render::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("Render::QueryVersion"), render::QUERY_PICT_FORMATS_REQUEST => RequestInfo::KnownExt("Render::QueryPictFormats"), render::QUERY_PICT_INDEX_VALUES_REQUEST => RequestInfo::KnownExt("Render::QueryPictIndexValues"), render::CREATE_PICTURE_REQUEST => RequestInfo::KnownExt("Render::CreatePicture"), render::CHANGE_PICTURE_REQUEST => RequestInfo::KnownExt("Render::ChangePicture"), render::SET_PICTURE_CLIP_RECTANGLES_REQUEST => RequestInfo::KnownExt("Render::SetPictureClipRectangles"), render::FREE_PICTURE_REQUEST => RequestInfo::KnownExt("Render::FreePicture"), render::COMPOSITE_REQUEST => RequestInfo::KnownExt("Render::Composite"), render::TRAPEZOIDS_REQUEST => RequestInfo::KnownExt("Render::Trapezoids"), render::TRIANGLES_REQUEST => RequestInfo::KnownExt("Render::Triangles"), render::TRI_STRIP_REQUEST => RequestInfo::KnownExt("Render::TriStrip"), render::TRI_FAN_REQUEST => RequestInfo::KnownExt("Render::TriFan"), render::CREATE_GLYPH_SET_REQUEST => RequestInfo::KnownExt("Render::CreateGlyphSet"), render::REFERENCE_GLYPH_SET_REQUEST => RequestInfo::KnownExt("Render::ReferenceGlyphSet"), render::FREE_GLYPH_SET_REQUEST => RequestInfo::KnownExt("Render::FreeGlyphSet"), render::ADD_GLYPHS_REQUEST => RequestInfo::KnownExt("Render::AddGlyphs"), render::FREE_GLYPHS_REQUEST => RequestInfo::KnownExt("Render::FreeGlyphs"), render::COMPOSITE_GLYPHS8_REQUEST => RequestInfo::KnownExt("Render::CompositeGlyphs8"), render::COMPOSITE_GLYPHS16_REQUEST => RequestInfo::KnownExt("Render::CompositeGlyphs16"), render::COMPOSITE_GLYPHS32_REQUEST => RequestInfo::KnownExt("Render::CompositeGlyphs32"), render::FILL_RECTANGLES_REQUEST => RequestInfo::KnownExt("Render::FillRectangles"), render::CREATE_CURSOR_REQUEST => RequestInfo::KnownExt("Render::CreateCursor"), render::SET_PICTURE_TRANSFORM_REQUEST => RequestInfo::KnownExt("Render::SetPictureTransform"), render::QUERY_FILTERS_REQUEST => RequestInfo::KnownExt("Render::QueryFilters"), render::SET_PICTURE_FILTER_REQUEST => RequestInfo::KnownExt("Render::SetPictureFilter"), render::CREATE_ANIM_CURSOR_REQUEST => RequestInfo::KnownExt("Render::CreateAnimCursor"), render::ADD_TRAPS_REQUEST => RequestInfo::KnownExt("Render::AddTraps"), render::CREATE_SOLID_FILL_REQUEST => RequestInfo::KnownExt("Render::CreateSolidFill"), render::CREATE_LINEAR_GRADIENT_REQUEST => RequestInfo::KnownExt("Render::CreateLinearGradient"), render::CREATE_RADIAL_GRADIENT_REQUEST => RequestInfo::KnownExt("Render::CreateRadialGradient"), render::CREATE_CONICAL_GRADIENT_REQUEST => RequestInfo::KnownExt("Render::CreateConicalGradient"), _ => RequestInfo::UnknownRequest(Some("Render"), minor_opcode), } } #[cfg(feature = "res")] res::X11_EXTENSION_NAME => { match minor_opcode { res::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("Res::QueryVersion"), res::QUERY_CLIENTS_REQUEST => RequestInfo::KnownExt("Res::QueryClients"), res::QUERY_CLIENT_RESOURCES_REQUEST => RequestInfo::KnownExt("Res::QueryClientResources"), res::QUERY_CLIENT_PIXMAP_BYTES_REQUEST => RequestInfo::KnownExt("Res::QueryClientPixmapBytes"), res::QUERY_CLIENT_IDS_REQUEST => RequestInfo::KnownExt("Res::QueryClientIds"), res::QUERY_RESOURCE_BYTES_REQUEST => RequestInfo::KnownExt("Res::QueryResourceBytes"), _ => RequestInfo::UnknownRequest(Some("Res"), minor_opcode), } } #[cfg(feature = "screensaver")] screensaver::X11_EXTENSION_NAME => { match minor_opcode { screensaver::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("ScreenSaver::QueryVersion"), screensaver::QUERY_INFO_REQUEST => RequestInfo::KnownExt("ScreenSaver::QueryInfo"), screensaver::SELECT_INPUT_REQUEST => RequestInfo::KnownExt("ScreenSaver::SelectInput"), screensaver::SET_ATTRIBUTES_REQUEST => RequestInfo::KnownExt("ScreenSaver::SetAttributes"), screensaver::UNSET_ATTRIBUTES_REQUEST => RequestInfo::KnownExt("ScreenSaver::UnsetAttributes"), screensaver::SUSPEND_REQUEST => RequestInfo::KnownExt("ScreenSaver::Suspend"), _ => RequestInfo::UnknownRequest(Some("ScreenSaver"), minor_opcode), } } #[cfg(feature = "shape")] shape::X11_EXTENSION_NAME => { match minor_opcode { shape::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("Shape::QueryVersion"), shape::RECTANGLES_REQUEST => RequestInfo::KnownExt("Shape::Rectangles"), shape::MASK_REQUEST => RequestInfo::KnownExt("Shape::Mask"), shape::COMBINE_REQUEST => RequestInfo::KnownExt("Shape::Combine"), shape::OFFSET_REQUEST => RequestInfo::KnownExt("Shape::Offset"), shape::QUERY_EXTENTS_REQUEST => RequestInfo::KnownExt("Shape::QueryExtents"), shape::SELECT_INPUT_REQUEST => RequestInfo::KnownExt("Shape::SelectInput"), shape::INPUT_SELECTED_REQUEST => RequestInfo::KnownExt("Shape::InputSelected"), shape::GET_RECTANGLES_REQUEST => RequestInfo::KnownExt("Shape::GetRectangles"), _ => RequestInfo::UnknownRequest(Some("Shape"), minor_opcode), } } #[cfg(feature = "shm")] shm::X11_EXTENSION_NAME => { match minor_opcode { shm::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("Shm::QueryVersion"), shm::ATTACH_REQUEST => RequestInfo::KnownExt("Shm::Attach"), shm::DETACH_REQUEST => RequestInfo::KnownExt("Shm::Detach"), shm::PUT_IMAGE_REQUEST => RequestInfo::KnownExt("Shm::PutImage"), shm::GET_IMAGE_REQUEST => RequestInfo::KnownExt("Shm::GetImage"), shm::CREATE_PIXMAP_REQUEST => RequestInfo::KnownExt("Shm::CreatePixmap"), shm::ATTACH_FD_REQUEST => RequestInfo::KnownExt("Shm::AttachFd"), shm::CREATE_SEGMENT_REQUEST => RequestInfo::KnownExt("Shm::CreateSegment"), _ => RequestInfo::UnknownRequest(Some("Shm"), minor_opcode), } } #[cfg(feature = "sync")] sync::X11_EXTENSION_NAME => { match minor_opcode { sync::INITIALIZE_REQUEST => RequestInfo::KnownExt("Sync::Initialize"), sync::LIST_SYSTEM_COUNTERS_REQUEST => RequestInfo::KnownExt("Sync::ListSystemCounters"), sync::CREATE_COUNTER_REQUEST => RequestInfo::KnownExt("Sync::CreateCounter"), sync::DESTROY_COUNTER_REQUEST => RequestInfo::KnownExt("Sync::DestroyCounter"), sync::QUERY_COUNTER_REQUEST => RequestInfo::KnownExt("Sync::QueryCounter"), sync::AWAIT_REQUEST => RequestInfo::KnownExt("Sync::Await"), sync::CHANGE_COUNTER_REQUEST => RequestInfo::KnownExt("Sync::ChangeCounter"), sync::SET_COUNTER_REQUEST => RequestInfo::KnownExt("Sync::SetCounter"), sync::CREATE_ALARM_REQUEST => RequestInfo::KnownExt("Sync::CreateAlarm"), sync::CHANGE_ALARM_REQUEST => RequestInfo::KnownExt("Sync::ChangeAlarm"), sync::DESTROY_ALARM_REQUEST => RequestInfo::KnownExt("Sync::DestroyAlarm"), sync::QUERY_ALARM_REQUEST => RequestInfo::KnownExt("Sync::QueryAlarm"), sync::SET_PRIORITY_REQUEST => RequestInfo::KnownExt("Sync::SetPriority"), sync::GET_PRIORITY_REQUEST => RequestInfo::KnownExt("Sync::GetPriority"), sync::CREATE_FENCE_REQUEST => RequestInfo::KnownExt("Sync::CreateFence"), sync::TRIGGER_FENCE_REQUEST => RequestInfo::KnownExt("Sync::TriggerFence"), sync::RESET_FENCE_REQUEST => RequestInfo::KnownExt("Sync::ResetFence"), sync::DESTROY_FENCE_REQUEST => RequestInfo::KnownExt("Sync::DestroyFence"), sync::QUERY_FENCE_REQUEST => RequestInfo::KnownExt("Sync::QueryFence"), sync::AWAIT_FENCE_REQUEST => RequestInfo::KnownExt("Sync::AwaitFence"), _ => RequestInfo::UnknownRequest(Some("Sync"), minor_opcode), } } xc_misc::X11_EXTENSION_NAME => { match minor_opcode { xc_misc::GET_VERSION_REQUEST => RequestInfo::KnownExt("XCMisc::GetVersion"), xc_misc::GET_XID_RANGE_REQUEST => RequestInfo::KnownExt("XCMisc::GetXIDRange"), xc_misc::GET_XID_LIST_REQUEST => RequestInfo::KnownExt("XCMisc::GetXIDList"), _ => RequestInfo::UnknownRequest(Some("XCMisc"), minor_opcode), } } #[cfg(feature = "xevie")] xevie::X11_EXTENSION_NAME => { match minor_opcode { xevie::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("Xevie::QueryVersion"), xevie::START_REQUEST => RequestInfo::KnownExt("Xevie::Start"), xevie::END_REQUEST => RequestInfo::KnownExt("Xevie::End"), xevie::SEND_REQUEST => RequestInfo::KnownExt("Xevie::Send"), xevie::SELECT_INPUT_REQUEST => RequestInfo::KnownExt("Xevie::SelectInput"), _ => RequestInfo::UnknownRequest(Some("Xevie"), minor_opcode), } } #[cfg(feature = "xf86dri")] xf86dri::X11_EXTENSION_NAME => { match minor_opcode { xf86dri::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("XF86Dri::QueryVersion"), xf86dri::QUERY_DIRECT_RENDERING_CAPABLE_REQUEST => RequestInfo::KnownExt("XF86Dri::QueryDirectRenderingCapable"), xf86dri::OPEN_CONNECTION_REQUEST => RequestInfo::KnownExt("XF86Dri::OpenConnection"), xf86dri::CLOSE_CONNECTION_REQUEST => RequestInfo::KnownExt("XF86Dri::CloseConnection"), xf86dri::GET_CLIENT_DRIVER_NAME_REQUEST => RequestInfo::KnownExt("XF86Dri::GetClientDriverName"), xf86dri::CREATE_CONTEXT_REQUEST => RequestInfo::KnownExt("XF86Dri::CreateContext"), xf86dri::DESTROY_CONTEXT_REQUEST => RequestInfo::KnownExt("XF86Dri::DestroyContext"), xf86dri::CREATE_DRAWABLE_REQUEST => RequestInfo::KnownExt("XF86Dri::CreateDrawable"), xf86dri::DESTROY_DRAWABLE_REQUEST => RequestInfo::KnownExt("XF86Dri::DestroyDrawable"), xf86dri::GET_DRAWABLE_INFO_REQUEST => RequestInfo::KnownExt("XF86Dri::GetDrawableInfo"), xf86dri::GET_DEVICE_INFO_REQUEST => RequestInfo::KnownExt("XF86Dri::GetDeviceInfo"), xf86dri::AUTH_CONNECTION_REQUEST => RequestInfo::KnownExt("XF86Dri::AuthConnection"), _ => RequestInfo::UnknownRequest(Some("XF86Dri"), minor_opcode), } } #[cfg(feature = "xf86vidmode")] xf86vidmode::X11_EXTENSION_NAME => { match minor_opcode { xf86vidmode::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("XF86VidMode::QueryVersion"), xf86vidmode::GET_MODE_LINE_REQUEST => RequestInfo::KnownExt("XF86VidMode::GetModeLine"), xf86vidmode::MOD_MODE_LINE_REQUEST => RequestInfo::KnownExt("XF86VidMode::ModModeLine"), xf86vidmode::SWITCH_MODE_REQUEST => RequestInfo::KnownExt("XF86VidMode::SwitchMode"), xf86vidmode::GET_MONITOR_REQUEST => RequestInfo::KnownExt("XF86VidMode::GetMonitor"), xf86vidmode::LOCK_MODE_SWITCH_REQUEST => RequestInfo::KnownExt("XF86VidMode::LockModeSwitch"), xf86vidmode::GET_ALL_MODE_LINES_REQUEST => RequestInfo::KnownExt("XF86VidMode::GetAllModeLines"), xf86vidmode::ADD_MODE_LINE_REQUEST => RequestInfo::KnownExt("XF86VidMode::AddModeLine"), xf86vidmode::DELETE_MODE_LINE_REQUEST => RequestInfo::KnownExt("XF86VidMode::DeleteModeLine"), xf86vidmode::VALIDATE_MODE_LINE_REQUEST => RequestInfo::KnownExt("XF86VidMode::ValidateModeLine"), xf86vidmode::SWITCH_TO_MODE_REQUEST => RequestInfo::KnownExt("XF86VidMode::SwitchToMode"), xf86vidmode::GET_VIEW_PORT_REQUEST => RequestInfo::KnownExt("XF86VidMode::GetViewPort"), xf86vidmode::SET_VIEW_PORT_REQUEST => RequestInfo::KnownExt("XF86VidMode::SetViewPort"), xf86vidmode::GET_DOT_CLOCKS_REQUEST => RequestInfo::KnownExt("XF86VidMode::GetDotClocks"), xf86vidmode::SET_CLIENT_VERSION_REQUEST => RequestInfo::KnownExt("XF86VidMode::SetClientVersion"), xf86vidmode::SET_GAMMA_REQUEST => RequestInfo::KnownExt("XF86VidMode::SetGamma"), xf86vidmode::GET_GAMMA_REQUEST => RequestInfo::KnownExt("XF86VidMode::GetGamma"), xf86vidmode::GET_GAMMA_RAMP_REQUEST => RequestInfo::KnownExt("XF86VidMode::GetGammaRamp"), xf86vidmode::SET_GAMMA_RAMP_REQUEST => RequestInfo::KnownExt("XF86VidMode::SetGammaRamp"), xf86vidmode::GET_GAMMA_RAMP_SIZE_REQUEST => RequestInfo::KnownExt("XF86VidMode::GetGammaRampSize"), xf86vidmode::GET_PERMISSIONS_REQUEST => RequestInfo::KnownExt("XF86VidMode::GetPermissions"), _ => RequestInfo::UnknownRequest(Some("XF86VidMode"), minor_opcode), } } #[cfg(feature = "xfixes")] xfixes::X11_EXTENSION_NAME => { match minor_opcode { xfixes::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("XFixes::QueryVersion"), xfixes::CHANGE_SAVE_SET_REQUEST => RequestInfo::KnownExt("XFixes::ChangeSaveSet"), xfixes::SELECT_SELECTION_INPUT_REQUEST => RequestInfo::KnownExt("XFixes::SelectSelectionInput"), xfixes::SELECT_CURSOR_INPUT_REQUEST => RequestInfo::KnownExt("XFixes::SelectCursorInput"), xfixes::GET_CURSOR_IMAGE_REQUEST => RequestInfo::KnownExt("XFixes::GetCursorImage"), xfixes::CREATE_REGION_REQUEST => RequestInfo::KnownExt("XFixes::CreateRegion"), xfixes::CREATE_REGION_FROM_BITMAP_REQUEST => RequestInfo::KnownExt("XFixes::CreateRegionFromBitmap"), xfixes::CREATE_REGION_FROM_WINDOW_REQUEST => RequestInfo::KnownExt("XFixes::CreateRegionFromWindow"), xfixes::CREATE_REGION_FROM_GC_REQUEST => RequestInfo::KnownExt("XFixes::CreateRegionFromGC"), xfixes::CREATE_REGION_FROM_PICTURE_REQUEST => RequestInfo::KnownExt("XFixes::CreateRegionFromPicture"), xfixes::DESTROY_REGION_REQUEST => RequestInfo::KnownExt("XFixes::DestroyRegion"), xfixes::SET_REGION_REQUEST => RequestInfo::KnownExt("XFixes::SetRegion"), xfixes::COPY_REGION_REQUEST => RequestInfo::KnownExt("XFixes::CopyRegion"), xfixes::UNION_REGION_REQUEST => RequestInfo::KnownExt("XFixes::UnionRegion"), xfixes::INTERSECT_REGION_REQUEST => RequestInfo::KnownExt("XFixes::IntersectRegion"), xfixes::SUBTRACT_REGION_REQUEST => RequestInfo::KnownExt("XFixes::SubtractRegion"), xfixes::INVERT_REGION_REQUEST => RequestInfo::KnownExt("XFixes::InvertRegion"), xfixes::TRANSLATE_REGION_REQUEST => RequestInfo::KnownExt("XFixes::TranslateRegion"), xfixes::REGION_EXTENTS_REQUEST => RequestInfo::KnownExt("XFixes::RegionExtents"), xfixes::FETCH_REGION_REQUEST => RequestInfo::KnownExt("XFixes::FetchRegion"), xfixes::SET_GC_CLIP_REGION_REQUEST => RequestInfo::KnownExt("XFixes::SetGCClipRegion"), xfixes::SET_WINDOW_SHAPE_REGION_REQUEST => RequestInfo::KnownExt("XFixes::SetWindowShapeRegion"), xfixes::SET_PICTURE_CLIP_REGION_REQUEST => RequestInfo::KnownExt("XFixes::SetPictureClipRegion"), xfixes::SET_CURSOR_NAME_REQUEST => RequestInfo::KnownExt("XFixes::SetCursorName"), xfixes::GET_CURSOR_NAME_REQUEST => RequestInfo::KnownExt("XFixes::GetCursorName"), xfixes::GET_CURSOR_IMAGE_AND_NAME_REQUEST => RequestInfo::KnownExt("XFixes::GetCursorImageAndName"), xfixes::CHANGE_CURSOR_REQUEST => RequestInfo::KnownExt("XFixes::ChangeCursor"), xfixes::CHANGE_CURSOR_BY_NAME_REQUEST => RequestInfo::KnownExt("XFixes::ChangeCursorByName"), xfixes::EXPAND_REGION_REQUEST => RequestInfo::KnownExt("XFixes::ExpandRegion"), xfixes::HIDE_CURSOR_REQUEST => RequestInfo::KnownExt("XFixes::HideCursor"), xfixes::SHOW_CURSOR_REQUEST => RequestInfo::KnownExt("XFixes::ShowCursor"), xfixes::CREATE_POINTER_BARRIER_REQUEST => RequestInfo::KnownExt("XFixes::CreatePointerBarrier"), xfixes::DELETE_POINTER_BARRIER_REQUEST => RequestInfo::KnownExt("XFixes::DeletePointerBarrier"), xfixes::SET_CLIENT_DISCONNECT_MODE_REQUEST => RequestInfo::KnownExt("XFixes::SetClientDisconnectMode"), xfixes::GET_CLIENT_DISCONNECT_MODE_REQUEST => RequestInfo::KnownExt("XFixes::GetClientDisconnectMode"), _ => RequestInfo::UnknownRequest(Some("XFixes"), minor_opcode), } } #[cfg(feature = "xinerama")] xinerama::X11_EXTENSION_NAME => { match minor_opcode { xinerama::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("Xinerama::QueryVersion"), xinerama::GET_STATE_REQUEST => RequestInfo::KnownExt("Xinerama::GetState"), xinerama::GET_SCREEN_COUNT_REQUEST => RequestInfo::KnownExt("Xinerama::GetScreenCount"), xinerama::GET_SCREEN_SIZE_REQUEST => RequestInfo::KnownExt("Xinerama::GetScreenSize"), xinerama::IS_ACTIVE_REQUEST => RequestInfo::KnownExt("Xinerama::IsActive"), xinerama::QUERY_SCREENS_REQUEST => RequestInfo::KnownExt("Xinerama::QueryScreens"), _ => RequestInfo::UnknownRequest(Some("Xinerama"), minor_opcode), } } #[cfg(feature = "xinput")] xinput::X11_EXTENSION_NAME => { match minor_opcode { xinput::GET_EXTENSION_VERSION_REQUEST => RequestInfo::KnownExt("Input::GetExtensionVersion"), xinput::LIST_INPUT_DEVICES_REQUEST => RequestInfo::KnownExt("Input::ListInputDevices"), xinput::OPEN_DEVICE_REQUEST => RequestInfo::KnownExt("Input::OpenDevice"), xinput::CLOSE_DEVICE_REQUEST => RequestInfo::KnownExt("Input::CloseDevice"), xinput::SET_DEVICE_MODE_REQUEST => RequestInfo::KnownExt("Input::SetDeviceMode"), xinput::SELECT_EXTENSION_EVENT_REQUEST => RequestInfo::KnownExt("Input::SelectExtensionEvent"), xinput::GET_SELECTED_EXTENSION_EVENTS_REQUEST => RequestInfo::KnownExt("Input::GetSelectedExtensionEvents"), xinput::CHANGE_DEVICE_DONT_PROPAGATE_LIST_REQUEST => RequestInfo::KnownExt("Input::ChangeDeviceDontPropagateList"), xinput::GET_DEVICE_DONT_PROPAGATE_LIST_REQUEST => RequestInfo::KnownExt("Input::GetDeviceDontPropagateList"), xinput::GET_DEVICE_MOTION_EVENTS_REQUEST => RequestInfo::KnownExt("Input::GetDeviceMotionEvents"), xinput::CHANGE_KEYBOARD_DEVICE_REQUEST => RequestInfo::KnownExt("Input::ChangeKeyboardDevice"), xinput::CHANGE_POINTER_DEVICE_REQUEST => RequestInfo::KnownExt("Input::ChangePointerDevice"), xinput::GRAB_DEVICE_REQUEST => RequestInfo::KnownExt("Input::GrabDevice"), xinput::UNGRAB_DEVICE_REQUEST => RequestInfo::KnownExt("Input::UngrabDevice"), xinput::GRAB_DEVICE_KEY_REQUEST => RequestInfo::KnownExt("Input::GrabDeviceKey"), xinput::UNGRAB_DEVICE_KEY_REQUEST => RequestInfo::KnownExt("Input::UngrabDeviceKey"), xinput::GRAB_DEVICE_BUTTON_REQUEST => RequestInfo::KnownExt("Input::GrabDeviceButton"), xinput::UNGRAB_DEVICE_BUTTON_REQUEST => RequestInfo::KnownExt("Input::UngrabDeviceButton"), xinput::ALLOW_DEVICE_EVENTS_REQUEST => RequestInfo::KnownExt("Input::AllowDeviceEvents"), xinput::GET_DEVICE_FOCUS_REQUEST => RequestInfo::KnownExt("Input::GetDeviceFocus"), xinput::SET_DEVICE_FOCUS_REQUEST => RequestInfo::KnownExt("Input::SetDeviceFocus"), xinput::GET_FEEDBACK_CONTROL_REQUEST => RequestInfo::KnownExt("Input::GetFeedbackControl"), xinput::CHANGE_FEEDBACK_CONTROL_REQUEST => RequestInfo::KnownExt("Input::ChangeFeedbackControl"), xinput::GET_DEVICE_KEY_MAPPING_REQUEST => RequestInfo::KnownExt("Input::GetDeviceKeyMapping"), xinput::CHANGE_DEVICE_KEY_MAPPING_REQUEST => RequestInfo::KnownExt("Input::ChangeDeviceKeyMapping"), xinput::GET_DEVICE_MODIFIER_MAPPING_REQUEST => RequestInfo::KnownExt("Input::GetDeviceModifierMapping"), xinput::SET_DEVICE_MODIFIER_MAPPING_REQUEST => RequestInfo::KnownExt("Input::SetDeviceModifierMapping"), xinput::GET_DEVICE_BUTTON_MAPPING_REQUEST => RequestInfo::KnownExt("Input::GetDeviceButtonMapping"), xinput::SET_DEVICE_BUTTON_MAPPING_REQUEST => RequestInfo::KnownExt("Input::SetDeviceButtonMapping"), xinput::QUERY_DEVICE_STATE_REQUEST => RequestInfo::KnownExt("Input::QueryDeviceState"), xinput::DEVICE_BELL_REQUEST => RequestInfo::KnownExt("Input::DeviceBell"), xinput::SET_DEVICE_VALUATORS_REQUEST => RequestInfo::KnownExt("Input::SetDeviceValuators"), xinput::GET_DEVICE_CONTROL_REQUEST => RequestInfo::KnownExt("Input::GetDeviceControl"), xinput::CHANGE_DEVICE_CONTROL_REQUEST => RequestInfo::KnownExt("Input::ChangeDeviceControl"), xinput::LIST_DEVICE_PROPERTIES_REQUEST => RequestInfo::KnownExt("Input::ListDeviceProperties"), xinput::CHANGE_DEVICE_PROPERTY_REQUEST => RequestInfo::KnownExt("Input::ChangeDeviceProperty"), xinput::DELETE_DEVICE_PROPERTY_REQUEST => RequestInfo::KnownExt("Input::DeleteDeviceProperty"), xinput::GET_DEVICE_PROPERTY_REQUEST => RequestInfo::KnownExt("Input::GetDeviceProperty"), xinput::XI_QUERY_POINTER_REQUEST => RequestInfo::KnownExt("Input::XIQueryPointer"), xinput::XI_WARP_POINTER_REQUEST => RequestInfo::KnownExt("Input::XIWarpPointer"), xinput::XI_CHANGE_CURSOR_REQUEST => RequestInfo::KnownExt("Input::XIChangeCursor"), xinput::XI_CHANGE_HIERARCHY_REQUEST => RequestInfo::KnownExt("Input::XIChangeHierarchy"), xinput::XI_SET_CLIENT_POINTER_REQUEST => RequestInfo::KnownExt("Input::XISetClientPointer"), xinput::XI_GET_CLIENT_POINTER_REQUEST => RequestInfo::KnownExt("Input::XIGetClientPointer"), xinput::XI_SELECT_EVENTS_REQUEST => RequestInfo::KnownExt("Input::XISelectEvents"), xinput::XI_QUERY_VERSION_REQUEST => RequestInfo::KnownExt("Input::XIQueryVersion"), xinput::XI_QUERY_DEVICE_REQUEST => RequestInfo::KnownExt("Input::XIQueryDevice"), xinput::XI_SET_FOCUS_REQUEST => RequestInfo::KnownExt("Input::XISetFocus"), xinput::XI_GET_FOCUS_REQUEST => RequestInfo::KnownExt("Input::XIGetFocus"), xinput::XI_GRAB_DEVICE_REQUEST => RequestInfo::KnownExt("Input::XIGrabDevice"), xinput::XI_UNGRAB_DEVICE_REQUEST => RequestInfo::KnownExt("Input::XIUngrabDevice"), xinput::XI_ALLOW_EVENTS_REQUEST => RequestInfo::KnownExt("Input::XIAllowEvents"), xinput::XI_PASSIVE_GRAB_DEVICE_REQUEST => RequestInfo::KnownExt("Input::XIPassiveGrabDevice"), xinput::XI_PASSIVE_UNGRAB_DEVICE_REQUEST => RequestInfo::KnownExt("Input::XIPassiveUngrabDevice"), xinput::XI_LIST_PROPERTIES_REQUEST => RequestInfo::KnownExt("Input::XIListProperties"), xinput::XI_CHANGE_PROPERTY_REQUEST => RequestInfo::KnownExt("Input::XIChangeProperty"), xinput::XI_DELETE_PROPERTY_REQUEST => RequestInfo::KnownExt("Input::XIDeleteProperty"), xinput::XI_GET_PROPERTY_REQUEST => RequestInfo::KnownExt("Input::XIGetProperty"), xinput::XI_GET_SELECTED_EVENTS_REQUEST => RequestInfo::KnownExt("Input::XIGetSelectedEvents"), xinput::XI_BARRIER_RELEASE_POINTER_REQUEST => RequestInfo::KnownExt("Input::XIBarrierReleasePointer"), xinput::SEND_EXTENSION_EVENT_REQUEST => RequestInfo::KnownExt("Input::SendExtensionEvent"), _ => RequestInfo::UnknownRequest(Some("Input"), minor_opcode), } } #[cfg(feature = "xkb")] xkb::X11_EXTENSION_NAME => { match minor_opcode { xkb::USE_EXTENSION_REQUEST => RequestInfo::KnownExt("xkb::UseExtension"), xkb::SELECT_EVENTS_REQUEST => RequestInfo::KnownExt("xkb::SelectEvents"), xkb::BELL_REQUEST => RequestInfo::KnownExt("xkb::Bell"), xkb::GET_STATE_REQUEST => RequestInfo::KnownExt("xkb::GetState"), xkb::LATCH_LOCK_STATE_REQUEST => RequestInfo::KnownExt("xkb::LatchLockState"), xkb::GET_CONTROLS_REQUEST => RequestInfo::KnownExt("xkb::GetControls"), xkb::SET_CONTROLS_REQUEST => RequestInfo::KnownExt("xkb::SetControls"), xkb::GET_MAP_REQUEST => RequestInfo::KnownExt("xkb::GetMap"), xkb::SET_MAP_REQUEST => RequestInfo::KnownExt("xkb::SetMap"), xkb::GET_COMPAT_MAP_REQUEST => RequestInfo::KnownExt("xkb::GetCompatMap"), xkb::SET_COMPAT_MAP_REQUEST => RequestInfo::KnownExt("xkb::SetCompatMap"), xkb::GET_INDICATOR_STATE_REQUEST => RequestInfo::KnownExt("xkb::GetIndicatorState"), xkb::GET_INDICATOR_MAP_REQUEST => RequestInfo::KnownExt("xkb::GetIndicatorMap"), xkb::SET_INDICATOR_MAP_REQUEST => RequestInfo::KnownExt("xkb::SetIndicatorMap"), xkb::GET_NAMED_INDICATOR_REQUEST => RequestInfo::KnownExt("xkb::GetNamedIndicator"), xkb::SET_NAMED_INDICATOR_REQUEST => RequestInfo::KnownExt("xkb::SetNamedIndicator"), xkb::GET_NAMES_REQUEST => RequestInfo::KnownExt("xkb::GetNames"), xkb::SET_NAMES_REQUEST => RequestInfo::KnownExt("xkb::SetNames"), xkb::PER_CLIENT_FLAGS_REQUEST => RequestInfo::KnownExt("xkb::PerClientFlags"), xkb::LIST_COMPONENTS_REQUEST => RequestInfo::KnownExt("xkb::ListComponents"), xkb::GET_KBD_BY_NAME_REQUEST => RequestInfo::KnownExt("xkb::GetKbdByName"), xkb::GET_DEVICE_INFO_REQUEST => RequestInfo::KnownExt("xkb::GetDeviceInfo"), xkb::SET_DEVICE_INFO_REQUEST => RequestInfo::KnownExt("xkb::SetDeviceInfo"), xkb::SET_DEBUGGING_FLAGS_REQUEST => RequestInfo::KnownExt("xkb::SetDebuggingFlags"), _ => RequestInfo::UnknownRequest(Some("xkb"), minor_opcode), } } #[cfg(feature = "xprint")] xprint::X11_EXTENSION_NAME => { match minor_opcode { xprint::PRINT_QUERY_VERSION_REQUEST => RequestInfo::KnownExt("XPrint::PrintQueryVersion"), xprint::PRINT_GET_PRINTER_LIST_REQUEST => RequestInfo::KnownExt("XPrint::PrintGetPrinterList"), xprint::PRINT_REHASH_PRINTER_LIST_REQUEST => RequestInfo::KnownExt("XPrint::PrintRehashPrinterList"), xprint::CREATE_CONTEXT_REQUEST => RequestInfo::KnownExt("XPrint::CreateContext"), xprint::PRINT_SET_CONTEXT_REQUEST => RequestInfo::KnownExt("XPrint::PrintSetContext"), xprint::PRINT_GET_CONTEXT_REQUEST => RequestInfo::KnownExt("XPrint::PrintGetContext"), xprint::PRINT_DESTROY_CONTEXT_REQUEST => RequestInfo::KnownExt("XPrint::PrintDestroyContext"), xprint::PRINT_GET_SCREEN_OF_CONTEXT_REQUEST => RequestInfo::KnownExt("XPrint::PrintGetScreenOfContext"), xprint::PRINT_START_JOB_REQUEST => RequestInfo::KnownExt("XPrint::PrintStartJob"), xprint::PRINT_END_JOB_REQUEST => RequestInfo::KnownExt("XPrint::PrintEndJob"), xprint::PRINT_START_DOC_REQUEST => RequestInfo::KnownExt("XPrint::PrintStartDoc"), xprint::PRINT_END_DOC_REQUEST => RequestInfo::KnownExt("XPrint::PrintEndDoc"), xprint::PRINT_PUT_DOCUMENT_DATA_REQUEST => RequestInfo::KnownExt("XPrint::PrintPutDocumentData"), xprint::PRINT_GET_DOCUMENT_DATA_REQUEST => RequestInfo::KnownExt("XPrint::PrintGetDocumentData"), xprint::PRINT_START_PAGE_REQUEST => RequestInfo::KnownExt("XPrint::PrintStartPage"), xprint::PRINT_END_PAGE_REQUEST => RequestInfo::KnownExt("XPrint::PrintEndPage"), xprint::PRINT_SELECT_INPUT_REQUEST => RequestInfo::KnownExt("XPrint::PrintSelectInput"), xprint::PRINT_INPUT_SELECTED_REQUEST => RequestInfo::KnownExt("XPrint::PrintInputSelected"), xprint::PRINT_GET_ATTRIBUTES_REQUEST => RequestInfo::KnownExt("XPrint::PrintGetAttributes"), xprint::PRINT_GET_ONE_ATTRIBUTES_REQUEST => RequestInfo::KnownExt("XPrint::PrintGetOneAttributes"), xprint::PRINT_SET_ATTRIBUTES_REQUEST => RequestInfo::KnownExt("XPrint::PrintSetAttributes"), xprint::PRINT_GET_PAGE_DIMENSIONS_REQUEST => RequestInfo::KnownExt("XPrint::PrintGetPageDimensions"), xprint::PRINT_QUERY_SCREENS_REQUEST => RequestInfo::KnownExt("XPrint::PrintQueryScreens"), xprint::PRINT_SET_IMAGE_RESOLUTION_REQUEST => RequestInfo::KnownExt("XPrint::PrintSetImageResolution"), xprint::PRINT_GET_IMAGE_RESOLUTION_REQUEST => RequestInfo::KnownExt("XPrint::PrintGetImageResolution"), _ => RequestInfo::UnknownRequest(Some("XPrint"), minor_opcode), } } #[cfg(feature = "xselinux")] xselinux::X11_EXTENSION_NAME => { match minor_opcode { xselinux::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("SELinux::QueryVersion"), xselinux::SET_DEVICE_CREATE_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::SetDeviceCreateContext"), xselinux::GET_DEVICE_CREATE_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::GetDeviceCreateContext"), xselinux::SET_DEVICE_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::SetDeviceContext"), xselinux::GET_DEVICE_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::GetDeviceContext"), xselinux::SET_WINDOW_CREATE_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::SetWindowCreateContext"), xselinux::GET_WINDOW_CREATE_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::GetWindowCreateContext"), xselinux::GET_WINDOW_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::GetWindowContext"), xselinux::SET_PROPERTY_CREATE_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::SetPropertyCreateContext"), xselinux::GET_PROPERTY_CREATE_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::GetPropertyCreateContext"), xselinux::SET_PROPERTY_USE_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::SetPropertyUseContext"), xselinux::GET_PROPERTY_USE_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::GetPropertyUseContext"), xselinux::GET_PROPERTY_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::GetPropertyContext"), xselinux::GET_PROPERTY_DATA_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::GetPropertyDataContext"), xselinux::LIST_PROPERTIES_REQUEST => RequestInfo::KnownExt("SELinux::ListProperties"), xselinux::SET_SELECTION_CREATE_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::SetSelectionCreateContext"), xselinux::GET_SELECTION_CREATE_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::GetSelectionCreateContext"), xselinux::SET_SELECTION_USE_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::SetSelectionUseContext"), xselinux::GET_SELECTION_USE_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::GetSelectionUseContext"), xselinux::GET_SELECTION_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::GetSelectionContext"), xselinux::GET_SELECTION_DATA_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::GetSelectionDataContext"), xselinux::LIST_SELECTIONS_REQUEST => RequestInfo::KnownExt("SELinux::ListSelections"), xselinux::GET_CLIENT_CONTEXT_REQUEST => RequestInfo::KnownExt("SELinux::GetClientContext"), _ => RequestInfo::UnknownRequest(Some("SELinux"), minor_opcode), } } #[cfg(feature = "xtest")] xtest::X11_EXTENSION_NAME => { match minor_opcode { xtest::GET_VERSION_REQUEST => RequestInfo::KnownExt("Test::GetVersion"), xtest::COMPARE_CURSOR_REQUEST => RequestInfo::KnownExt("Test::CompareCursor"), xtest::FAKE_INPUT_REQUEST => RequestInfo::KnownExt("Test::FakeInput"), xtest::GRAB_CONTROL_REQUEST => RequestInfo::KnownExt("Test::GrabControl"), _ => RequestInfo::UnknownRequest(Some("Test"), minor_opcode), } } #[cfg(feature = "xv")] xv::X11_EXTENSION_NAME => { match minor_opcode { xv::QUERY_EXTENSION_REQUEST => RequestInfo::KnownExt("Xv::QueryExtension"), xv::QUERY_ADAPTORS_REQUEST => RequestInfo::KnownExt("Xv::QueryAdaptors"), xv::QUERY_ENCODINGS_REQUEST => RequestInfo::KnownExt("Xv::QueryEncodings"), xv::GRAB_PORT_REQUEST => RequestInfo::KnownExt("Xv::GrabPort"), xv::UNGRAB_PORT_REQUEST => RequestInfo::KnownExt("Xv::UngrabPort"), xv::PUT_VIDEO_REQUEST => RequestInfo::KnownExt("Xv::PutVideo"), xv::PUT_STILL_REQUEST => RequestInfo::KnownExt("Xv::PutStill"), xv::GET_VIDEO_REQUEST => RequestInfo::KnownExt("Xv::GetVideo"), xv::GET_STILL_REQUEST => RequestInfo::KnownExt("Xv::GetStill"), xv::STOP_VIDEO_REQUEST => RequestInfo::KnownExt("Xv::StopVideo"), xv::SELECT_VIDEO_NOTIFY_REQUEST => RequestInfo::KnownExt("Xv::SelectVideoNotify"), xv::SELECT_PORT_NOTIFY_REQUEST => RequestInfo::KnownExt("Xv::SelectPortNotify"), xv::QUERY_BEST_SIZE_REQUEST => RequestInfo::KnownExt("Xv::QueryBestSize"), xv::SET_PORT_ATTRIBUTE_REQUEST => RequestInfo::KnownExt("Xv::SetPortAttribute"), xv::GET_PORT_ATTRIBUTE_REQUEST => RequestInfo::KnownExt("Xv::GetPortAttribute"), xv::QUERY_PORT_ATTRIBUTES_REQUEST => RequestInfo::KnownExt("Xv::QueryPortAttributes"), xv::LIST_IMAGE_FORMATS_REQUEST => RequestInfo::KnownExt("Xv::ListImageFormats"), xv::QUERY_IMAGE_ATTRIBUTES_REQUEST => RequestInfo::KnownExt("Xv::QueryImageAttributes"), xv::PUT_IMAGE_REQUEST => RequestInfo::KnownExt("Xv::PutImage"), xv::SHM_PUT_IMAGE_REQUEST => RequestInfo::KnownExt("Xv::ShmPutImage"), _ => RequestInfo::UnknownRequest(Some("Xv"), minor_opcode), } } #[cfg(feature = "xvmc")] xvmc::X11_EXTENSION_NAME => { match minor_opcode { xvmc::QUERY_VERSION_REQUEST => RequestInfo::KnownExt("XvMC::QueryVersion"), xvmc::LIST_SURFACE_TYPES_REQUEST => RequestInfo::KnownExt("XvMC::ListSurfaceTypes"), xvmc::CREATE_CONTEXT_REQUEST => RequestInfo::KnownExt("XvMC::CreateContext"), xvmc::DESTROY_CONTEXT_REQUEST => RequestInfo::KnownExt("XvMC::DestroyContext"), xvmc::CREATE_SURFACE_REQUEST => RequestInfo::KnownExt("XvMC::CreateSurface"), xvmc::DESTROY_SURFACE_REQUEST => RequestInfo::KnownExt("XvMC::DestroySurface"), xvmc::CREATE_SUBPICTURE_REQUEST => RequestInfo::KnownExt("XvMC::CreateSubpicture"), xvmc::DESTROY_SUBPICTURE_REQUEST => RequestInfo::KnownExt("XvMC::DestroySubpicture"), xvmc::LIST_SUBPICTURE_TYPES_REQUEST => RequestInfo::KnownExt("XvMC::ListSubpictureTypes"), _ => RequestInfo::UnknownRequest(Some("XvMC"), minor_opcode), } } _ => RequestInfo::UnknownExtension(major_opcode, minor_opcode), }; (Some(ext_name), info) } } /// Get the name of a request based on its major and minor code. /// /// The major and minor opcode are the first and second byte of a request. /// Core requests do not have a minor opcode. For these, the minor opcode is ignored by this function. pub fn get_request_name( ext_info_provider: &dyn ExtInfoProvider, major_opcode: u8, minor_opcode: u8, ) -> Cow<'static, str> { let (ext_name, info) = get_request_name_internal(ext_info_provider, major_opcode, minor_opcode); match info { RequestInfo::Xproto(request) => request.into(), RequestInfo::KnownExt(ext_and_request) => ext_and_request.into(), RequestInfo::UnknownRequest(None, opcode) => alloc::format!("xproto::opcode {}", opcode).into(), RequestInfo::UnknownRequest(Some(ext), opcode) => alloc::format!("{}::opcode {}", ext, opcode).into(), RequestInfo::UnknownExtension(major_opcode, minor_opcode) => match ext_name { None => alloc::format!("ext {}::opcode {}", major_opcode, minor_opcode).into(), Some(ext_name) => alloc::format!("ext {}::opcode {}", ext_name, minor_opcode).into(), } } } /// Enumeration of all possible X11 requests. #[derive(Debug)] #[allow(clippy::large_enum_variant)] #[non_exhaustive] pub enum Request<'input> { Unknown(RequestHeader, Cow<'input, [u8]>), CreateWindow(xproto::CreateWindowRequest<'input>), ChangeWindowAttributes(xproto::ChangeWindowAttributesRequest<'input>), GetWindowAttributes(xproto::GetWindowAttributesRequest), DestroyWindow(xproto::DestroyWindowRequest), DestroySubwindows(xproto::DestroySubwindowsRequest), ChangeSaveSet(xproto::ChangeSaveSetRequest), ReparentWindow(xproto::ReparentWindowRequest), MapWindow(xproto::MapWindowRequest), MapSubwindows(xproto::MapSubwindowsRequest), UnmapWindow(xproto::UnmapWindowRequest), UnmapSubwindows(xproto::UnmapSubwindowsRequest), ConfigureWindow(xproto::ConfigureWindowRequest<'input>), CirculateWindow(xproto::CirculateWindowRequest), GetGeometry(xproto::GetGeometryRequest), QueryTree(xproto::QueryTreeRequest), InternAtom(xproto::InternAtomRequest<'input>), GetAtomName(xproto::GetAtomNameRequest), ChangeProperty(xproto::ChangePropertyRequest<'input>), DeleteProperty(xproto::DeletePropertyRequest), GetProperty(xproto::GetPropertyRequest), ListProperties(xproto::ListPropertiesRequest), SetSelectionOwner(xproto::SetSelectionOwnerRequest), GetSelectionOwner(xproto::GetSelectionOwnerRequest), ConvertSelection(xproto::ConvertSelectionRequest), SendEvent(xproto::SendEventRequest<'input>), GrabPointer(xproto::GrabPointerRequest), UngrabPointer(xproto::UngrabPointerRequest), GrabButton(xproto::GrabButtonRequest), UngrabButton(xproto::UngrabButtonRequest), ChangeActivePointerGrab(xproto::ChangeActivePointerGrabRequest), GrabKeyboard(xproto::GrabKeyboardRequest), UngrabKeyboard(xproto::UngrabKeyboardRequest), GrabKey(xproto::GrabKeyRequest), UngrabKey(xproto::UngrabKeyRequest), AllowEvents(xproto::AllowEventsRequest), GrabServer(xproto::GrabServerRequest), UngrabServer(xproto::UngrabServerRequest), QueryPointer(xproto::QueryPointerRequest), GetMotionEvents(xproto::GetMotionEventsRequest), TranslateCoordinates(xproto::TranslateCoordinatesRequest), WarpPointer(xproto::WarpPointerRequest), SetInputFocus(xproto::SetInputFocusRequest), GetInputFocus(xproto::GetInputFocusRequest), QueryKeymap(xproto::QueryKeymapRequest), OpenFont(xproto::OpenFontRequest<'input>), CloseFont(xproto::CloseFontRequest), QueryFont(xproto::QueryFontRequest), QueryTextExtents(xproto::QueryTextExtentsRequest<'input>), ListFonts(xproto::ListFontsRequest<'input>), ListFontsWithInfo(xproto::ListFontsWithInfoRequest<'input>), SetFontPath(xproto::SetFontPathRequest<'input>), GetFontPath(xproto::GetFontPathRequest), CreatePixmap(xproto::CreatePixmapRequest), FreePixmap(xproto::FreePixmapRequest), CreateGC(xproto::CreateGCRequest<'input>), ChangeGC(xproto::ChangeGCRequest<'input>), CopyGC(xproto::CopyGCRequest), SetDashes(xproto::SetDashesRequest<'input>), SetClipRectangles(xproto::SetClipRectanglesRequest<'input>), FreeGC(xproto::FreeGCRequest), ClearArea(xproto::ClearAreaRequest), CopyArea(xproto::CopyAreaRequest), CopyPlane(xproto::CopyPlaneRequest), PolyPoint(xproto::PolyPointRequest<'input>), PolyLine(xproto::PolyLineRequest<'input>), PolySegment(xproto::PolySegmentRequest<'input>), PolyRectangle(xproto::PolyRectangleRequest<'input>), PolyArc(xproto::PolyArcRequest<'input>), FillPoly(xproto::FillPolyRequest<'input>), PolyFillRectangle(xproto::PolyFillRectangleRequest<'input>), PolyFillArc(xproto::PolyFillArcRequest<'input>), PutImage(xproto::PutImageRequest<'input>), GetImage(xproto::GetImageRequest), PolyText8(xproto::PolyText8Request<'input>), PolyText16(xproto::PolyText16Request<'input>), ImageText8(xproto::ImageText8Request<'input>), ImageText16(xproto::ImageText16Request<'input>), CreateColormap(xproto::CreateColormapRequest), FreeColormap(xproto::FreeColormapRequest), CopyColormapAndFree(xproto::CopyColormapAndFreeRequest), InstallColormap(xproto::InstallColormapRequest), UninstallColormap(xproto::UninstallColormapRequest), ListInstalledColormaps(xproto::ListInstalledColormapsRequest), AllocColor(xproto::AllocColorRequest), AllocNamedColor(xproto::AllocNamedColorRequest<'input>), AllocColorCells(xproto::AllocColorCellsRequest), AllocColorPlanes(xproto::AllocColorPlanesRequest), FreeColors(xproto::FreeColorsRequest<'input>), StoreColors(xproto::StoreColorsRequest<'input>), StoreNamedColor(xproto::StoreNamedColorRequest<'input>), QueryColors(xproto::QueryColorsRequest<'input>), LookupColor(xproto::LookupColorRequest<'input>), CreateCursor(xproto::CreateCursorRequest), CreateGlyphCursor(xproto::CreateGlyphCursorRequest), FreeCursor(xproto::FreeCursorRequest), RecolorCursor(xproto::RecolorCursorRequest), QueryBestSize(xproto::QueryBestSizeRequest), QueryExtension(xproto::QueryExtensionRequest<'input>), ListExtensions(xproto::ListExtensionsRequest), ChangeKeyboardMapping(xproto::ChangeKeyboardMappingRequest<'input>), GetKeyboardMapping(xproto::GetKeyboardMappingRequest), ChangeKeyboardControl(xproto::ChangeKeyboardControlRequest<'input>), GetKeyboardControl(xproto::GetKeyboardControlRequest), Bell(xproto::BellRequest), ChangePointerControl(xproto::ChangePointerControlRequest), GetPointerControl(xproto::GetPointerControlRequest), SetScreenSaver(xproto::SetScreenSaverRequest), GetScreenSaver(xproto::GetScreenSaverRequest), ChangeHosts(xproto::ChangeHostsRequest<'input>), ListHosts(xproto::ListHostsRequest), SetAccessControl(xproto::SetAccessControlRequest), SetCloseDownMode(xproto::SetCloseDownModeRequest), KillClient(xproto::KillClientRequest), RotateProperties(xproto::RotatePropertiesRequest<'input>), ForceScreenSaver(xproto::ForceScreenSaverRequest), SetPointerMapping(xproto::SetPointerMappingRequest<'input>), GetPointerMapping(xproto::GetPointerMappingRequest), SetModifierMapping(xproto::SetModifierMappingRequest<'input>), GetModifierMapping(xproto::GetModifierMappingRequest), NoOperation(xproto::NoOperationRequest), BigreqEnable(bigreq::EnableRequest), #[cfg(feature = "composite")] CompositeQueryVersion(composite::QueryVersionRequest), #[cfg(feature = "composite")] CompositeRedirectWindow(composite::RedirectWindowRequest), #[cfg(feature = "composite")] CompositeRedirectSubwindows(composite::RedirectSubwindowsRequest), #[cfg(feature = "composite")] CompositeUnredirectWindow(composite::UnredirectWindowRequest), #[cfg(feature = "composite")] CompositeUnredirectSubwindows(composite::UnredirectSubwindowsRequest), #[cfg(feature = "composite")] CompositeCreateRegionFromBorderClip(composite::CreateRegionFromBorderClipRequest), #[cfg(feature = "composite")] CompositeNameWindowPixmap(composite::NameWindowPixmapRequest), #[cfg(feature = "composite")] CompositeGetOverlayWindow(composite::GetOverlayWindowRequest), #[cfg(feature = "composite")] CompositeReleaseOverlayWindow(composite::ReleaseOverlayWindowRequest), #[cfg(feature = "damage")] DamageQueryVersion(damage::QueryVersionRequest), #[cfg(feature = "damage")] DamageCreate(damage::CreateRequest), #[cfg(feature = "damage")] DamageDestroy(damage::DestroyRequest), #[cfg(feature = "damage")] DamageSubtract(damage::SubtractRequest), #[cfg(feature = "damage")] DamageAdd(damage::AddRequest), #[cfg(feature = "dbe")] DbeQueryVersion(dbe::QueryVersionRequest), #[cfg(feature = "dbe")] DbeAllocateBackBuffer(dbe::AllocateBackBufferRequest), #[cfg(feature = "dbe")] DbeDeallocateBackBuffer(dbe::DeallocateBackBufferRequest), #[cfg(feature = "dbe")] DbeSwapBuffers(dbe::SwapBuffersRequest<'input>), #[cfg(feature = "dbe")] DbeBeginIdiom(dbe::BeginIdiomRequest), #[cfg(feature = "dbe")] DbeEndIdiom(dbe::EndIdiomRequest), #[cfg(feature = "dbe")] DbeGetVisualInfo(dbe::GetVisualInfoRequest<'input>), #[cfg(feature = "dbe")] DbeGetBackBufferAttributes(dbe::GetBackBufferAttributesRequest), #[cfg(feature = "dpms")] DpmsGetVersion(dpms::GetVersionRequest), #[cfg(feature = "dpms")] DpmsCapable(dpms::CapableRequest), #[cfg(feature = "dpms")] DpmsGetTimeouts(dpms::GetTimeoutsRequest), #[cfg(feature = "dpms")] DpmsSetTimeouts(dpms::SetTimeoutsRequest), #[cfg(feature = "dpms")] DpmsEnable(dpms::EnableRequest), #[cfg(feature = "dpms")] DpmsDisable(dpms::DisableRequest), #[cfg(feature = "dpms")] DpmsForceLevel(dpms::ForceLevelRequest), #[cfg(feature = "dpms")] DpmsInfo(dpms::InfoRequest), #[cfg(feature = "dpms")] DpmsSelectInput(dpms::SelectInputRequest), #[cfg(feature = "dri2")] Dri2QueryVersion(dri2::QueryVersionRequest), #[cfg(feature = "dri2")] Dri2Connect(dri2::ConnectRequest), #[cfg(feature = "dri2")] Dri2Authenticate(dri2::AuthenticateRequest), #[cfg(feature = "dri2")] Dri2CreateDrawable(dri2::CreateDrawableRequest), #[cfg(feature = "dri2")] Dri2DestroyDrawable(dri2::DestroyDrawableRequest), #[cfg(feature = "dri2")] Dri2GetBuffers(dri2::GetBuffersRequest<'input>), #[cfg(feature = "dri2")] Dri2CopyRegion(dri2::CopyRegionRequest), #[cfg(feature = "dri2")] Dri2GetBuffersWithFormat(dri2::GetBuffersWithFormatRequest<'input>), #[cfg(feature = "dri2")] Dri2SwapBuffers(dri2::SwapBuffersRequest), #[cfg(feature = "dri2")] Dri2GetMSC(dri2::GetMSCRequest), #[cfg(feature = "dri2")] Dri2WaitMSC(dri2::WaitMSCRequest), #[cfg(feature = "dri2")] Dri2WaitSBC(dri2::WaitSBCRequest), #[cfg(feature = "dri2")] Dri2SwapInterval(dri2::SwapIntervalRequest), #[cfg(feature = "dri2")] Dri2GetParam(dri2::GetParamRequest), #[cfg(feature = "dri3")] Dri3QueryVersion(dri3::QueryVersionRequest), #[cfg(feature = "dri3")] Dri3Open(dri3::OpenRequest), #[cfg(feature = "dri3")] Dri3PixmapFromBuffer(dri3::PixmapFromBufferRequest), #[cfg(feature = "dri3")] Dri3BufferFromPixmap(dri3::BufferFromPixmapRequest), #[cfg(feature = "dri3")] Dri3FenceFromFD(dri3::FenceFromFDRequest), #[cfg(feature = "dri3")] Dri3FDFromFence(dri3::FDFromFenceRequest), #[cfg(feature = "dri3")] Dri3GetSupportedModifiers(dri3::GetSupportedModifiersRequest), #[cfg(feature = "dri3")] Dri3PixmapFromBuffers(dri3::PixmapFromBuffersRequest), #[cfg(feature = "dri3")] Dri3BuffersFromPixmap(dri3::BuffersFromPixmapRequest), #[cfg(feature = "dri3")] Dri3SetDRMDeviceInUse(dri3::SetDRMDeviceInUseRequest), #[cfg(feature = "dri3")] Dri3ImportSyncobj(dri3::ImportSyncobjRequest), #[cfg(feature = "dri3")] Dri3FreeSyncobj(dri3::FreeSyncobjRequest), GeQueryVersion(ge::QueryVersionRequest), #[cfg(feature = "glx")] GlxRender(glx::RenderRequest<'input>), #[cfg(feature = "glx")] GlxRenderLarge(glx::RenderLargeRequest<'input>), #[cfg(feature = "glx")] GlxCreateContext(glx::CreateContextRequest), #[cfg(feature = "glx")] GlxDestroyContext(glx::DestroyContextRequest), #[cfg(feature = "glx")] GlxMakeCurrent(glx::MakeCurrentRequest), #[cfg(feature = "glx")] GlxIsDirect(glx::IsDirectRequest), #[cfg(feature = "glx")] GlxQueryVersion(glx::QueryVersionRequest), #[cfg(feature = "glx")] GlxWaitGL(glx::WaitGLRequest), #[cfg(feature = "glx")] GlxWaitX(glx::WaitXRequest), #[cfg(feature = "glx")] GlxCopyContext(glx::CopyContextRequest), #[cfg(feature = "glx")] GlxSwapBuffers(glx::SwapBuffersRequest), #[cfg(feature = "glx")] GlxUseXFont(glx::UseXFontRequest), #[cfg(feature = "glx")] GlxCreateGLXPixmap(glx::CreateGLXPixmapRequest), #[cfg(feature = "glx")] GlxGetVisualConfigs(glx::GetVisualConfigsRequest), #[cfg(feature = "glx")] GlxDestroyGLXPixmap(glx::DestroyGLXPixmapRequest), #[cfg(feature = "glx")] GlxVendorPrivate(glx::VendorPrivateRequest<'input>), #[cfg(feature = "glx")] GlxVendorPrivateWithReply(glx::VendorPrivateWithReplyRequest<'input>), #[cfg(feature = "glx")] GlxQueryExtensionsString(glx::QueryExtensionsStringRequest), #[cfg(feature = "glx")] GlxQueryServerString(glx::QueryServerStringRequest), #[cfg(feature = "glx")] GlxClientInfo(glx::ClientInfoRequest<'input>), #[cfg(feature = "glx")] GlxGetFBConfigs(glx::GetFBConfigsRequest), #[cfg(feature = "glx")] GlxCreatePixmap(glx::CreatePixmapRequest<'input>), #[cfg(feature = "glx")] GlxDestroyPixmap(glx::DestroyPixmapRequest), #[cfg(feature = "glx")] GlxCreateNewContext(glx::CreateNewContextRequest), #[cfg(feature = "glx")] GlxQueryContext(glx::QueryContextRequest), #[cfg(feature = "glx")] GlxMakeContextCurrent(glx::MakeContextCurrentRequest), #[cfg(feature = "glx")] GlxCreatePbuffer(glx::CreatePbufferRequest<'input>), #[cfg(feature = "glx")] GlxDestroyPbuffer(glx::DestroyPbufferRequest), #[cfg(feature = "glx")] GlxGetDrawableAttributes(glx::GetDrawableAttributesRequest), #[cfg(feature = "glx")] GlxChangeDrawableAttributes(glx::ChangeDrawableAttributesRequest<'input>), #[cfg(feature = "glx")] GlxCreateWindow(glx::CreateWindowRequest<'input>), #[cfg(feature = "glx")] GlxDeleteWindow(glx::DeleteWindowRequest), #[cfg(feature = "glx")] GlxSetClientInfoARB(glx::SetClientInfoARBRequest<'input>), #[cfg(feature = "glx")] GlxCreateContextAttribsARB(glx::CreateContextAttribsARBRequest<'input>), #[cfg(feature = "glx")] GlxSetClientInfo2ARB(glx::SetClientInfo2ARBRequest<'input>), #[cfg(feature = "glx")] GlxNewList(glx::NewListRequest), #[cfg(feature = "glx")] GlxEndList(glx::EndListRequest), #[cfg(feature = "glx")] GlxDeleteLists(glx::DeleteListsRequest), #[cfg(feature = "glx")] GlxGenLists(glx::GenListsRequest), #[cfg(feature = "glx")] GlxFeedbackBuffer(glx::FeedbackBufferRequest), #[cfg(feature = "glx")] GlxSelectBuffer(glx::SelectBufferRequest), #[cfg(feature = "glx")] GlxRenderMode(glx::RenderModeRequest), #[cfg(feature = "glx")] GlxFinish(glx::FinishRequest), #[cfg(feature = "glx")] GlxPixelStoref(glx::PixelStorefRequest), #[cfg(feature = "glx")] GlxPixelStorei(glx::PixelStoreiRequest), #[cfg(feature = "glx")] GlxReadPixels(glx::ReadPixelsRequest), #[cfg(feature = "glx")] GlxGetBooleanv(glx::GetBooleanvRequest), #[cfg(feature = "glx")] GlxGetClipPlane(glx::GetClipPlaneRequest), #[cfg(feature = "glx")] GlxGetDoublev(glx::GetDoublevRequest), #[cfg(feature = "glx")] GlxGetError(glx::GetErrorRequest), #[cfg(feature = "glx")] GlxGetFloatv(glx::GetFloatvRequest), #[cfg(feature = "glx")] GlxGetIntegerv(glx::GetIntegervRequest), #[cfg(feature = "glx")] GlxGetLightfv(glx::GetLightfvRequest), #[cfg(feature = "glx")] GlxGetLightiv(glx::GetLightivRequest), #[cfg(feature = "glx")] GlxGetMapdv(glx::GetMapdvRequest), #[cfg(feature = "glx")] GlxGetMapfv(glx::GetMapfvRequest), #[cfg(feature = "glx")] GlxGetMapiv(glx::GetMapivRequest), #[cfg(feature = "glx")] GlxGetMaterialfv(glx::GetMaterialfvRequest), #[cfg(feature = "glx")] GlxGetMaterialiv(glx::GetMaterialivRequest), #[cfg(feature = "glx")] GlxGetPixelMapfv(glx::GetPixelMapfvRequest), #[cfg(feature = "glx")] GlxGetPixelMapuiv(glx::GetPixelMapuivRequest), #[cfg(feature = "glx")] GlxGetPixelMapusv(glx::GetPixelMapusvRequest), #[cfg(feature = "glx")] GlxGetPolygonStipple(glx::GetPolygonStippleRequest), #[cfg(feature = "glx")] GlxGetString(glx::GetStringRequest), #[cfg(feature = "glx")] GlxGetTexEnvfv(glx::GetTexEnvfvRequest), #[cfg(feature = "glx")] GlxGetTexEnviv(glx::GetTexEnvivRequest), #[cfg(feature = "glx")] GlxGetTexGendv(glx::GetTexGendvRequest), #[cfg(feature = "glx")] GlxGetTexGenfv(glx::GetTexGenfvRequest), #[cfg(feature = "glx")] GlxGetTexGeniv(glx::GetTexGenivRequest), #[cfg(feature = "glx")] GlxGetTexImage(glx::GetTexImageRequest), #[cfg(feature = "glx")] GlxGetTexParameterfv(glx::GetTexParameterfvRequest), #[cfg(feature = "glx")] GlxGetTexParameteriv(glx::GetTexParameterivRequest), #[cfg(feature = "glx")] GlxGetTexLevelParameterfv(glx::GetTexLevelParameterfvRequest), #[cfg(feature = "glx")] GlxGetTexLevelParameteriv(glx::GetTexLevelParameterivRequest), #[cfg(feature = "glx")] GlxIsEnabled(glx::IsEnabledRequest), #[cfg(feature = "glx")] GlxIsList(glx::IsListRequest), #[cfg(feature = "glx")] GlxFlush(glx::FlushRequest), #[cfg(feature = "glx")] GlxAreTexturesResident(glx::AreTexturesResidentRequest<'input>), #[cfg(feature = "glx")] GlxDeleteTextures(glx::DeleteTexturesRequest<'input>), #[cfg(feature = "glx")] GlxGenTextures(glx::GenTexturesRequest), #[cfg(feature = "glx")] GlxIsTexture(glx::IsTextureRequest), #[cfg(feature = "glx")] GlxGetColorTable(glx::GetColorTableRequest), #[cfg(feature = "glx")] GlxGetColorTableParameterfv(glx::GetColorTableParameterfvRequest), #[cfg(feature = "glx")] GlxGetColorTableParameteriv(glx::GetColorTableParameterivRequest), #[cfg(feature = "glx")] GlxGetConvolutionFilter(glx::GetConvolutionFilterRequest), #[cfg(feature = "glx")] GlxGetConvolutionParameterfv(glx::GetConvolutionParameterfvRequest), #[cfg(feature = "glx")] GlxGetConvolutionParameteriv(glx::GetConvolutionParameterivRequest), #[cfg(feature = "glx")] GlxGetSeparableFilter(glx::GetSeparableFilterRequest), #[cfg(feature = "glx")] GlxGetHistogram(glx::GetHistogramRequest), #[cfg(feature = "glx")] GlxGetHistogramParameterfv(glx::GetHistogramParameterfvRequest), #[cfg(feature = "glx")] GlxGetHistogramParameteriv(glx::GetHistogramParameterivRequest), #[cfg(feature = "glx")] GlxGetMinmax(glx::GetMinmaxRequest), #[cfg(feature = "glx")] GlxGetMinmaxParameterfv(glx::GetMinmaxParameterfvRequest), #[cfg(feature = "glx")] GlxGetMinmaxParameteriv(glx::GetMinmaxParameterivRequest), #[cfg(feature = "glx")] GlxGetCompressedTexImageARB(glx::GetCompressedTexImageARBRequest), #[cfg(feature = "glx")] GlxDeleteQueriesARB(glx::DeleteQueriesARBRequest<'input>), #[cfg(feature = "glx")] GlxGenQueriesARB(glx::GenQueriesARBRequest), #[cfg(feature = "glx")] GlxIsQueryARB(glx::IsQueryARBRequest), #[cfg(feature = "glx")] GlxGetQueryivARB(glx::GetQueryivARBRequest), #[cfg(feature = "glx")] GlxGetQueryObjectivARB(glx::GetQueryObjectivARBRequest), #[cfg(feature = "glx")] GlxGetQueryObjectuivARB(glx::GetQueryObjectuivARBRequest), #[cfg(feature = "present")] PresentQueryVersion(present::QueryVersionRequest), #[cfg(feature = "present")] PresentPixmap(present::PixmapRequest<'input>), #[cfg(feature = "present")] PresentNotifyMSC(present::NotifyMSCRequest), #[cfg(feature = "present")] PresentSelectInput(present::SelectInputRequest), #[cfg(feature = "present")] PresentQueryCapabilities(present::QueryCapabilitiesRequest), #[cfg(feature = "present")] PresentPixmapSynced(present::PixmapSyncedRequest<'input>), #[cfg(feature = "randr")] RandrQueryVersion(randr::QueryVersionRequest), #[cfg(feature = "randr")] RandrSetScreenConfig(randr::SetScreenConfigRequest), #[cfg(feature = "randr")] RandrSelectInput(randr::SelectInputRequest), #[cfg(feature = "randr")] RandrGetScreenInfo(randr::GetScreenInfoRequest), #[cfg(feature = "randr")] RandrGetScreenSizeRange(randr::GetScreenSizeRangeRequest), #[cfg(feature = "randr")] RandrSetScreenSize(randr::SetScreenSizeRequest), #[cfg(feature = "randr")] RandrGetScreenResources(randr::GetScreenResourcesRequest), #[cfg(feature = "randr")] RandrGetOutputInfo(randr::GetOutputInfoRequest), #[cfg(feature = "randr")] RandrListOutputProperties(randr::ListOutputPropertiesRequest), #[cfg(feature = "randr")] RandrQueryOutputProperty(randr::QueryOutputPropertyRequest), #[cfg(feature = "randr")] RandrConfigureOutputProperty(randr::ConfigureOutputPropertyRequest<'input>), #[cfg(feature = "randr")] RandrChangeOutputProperty(randr::ChangeOutputPropertyRequest<'input>), #[cfg(feature = "randr")] RandrDeleteOutputProperty(randr::DeleteOutputPropertyRequest), #[cfg(feature = "randr")] RandrGetOutputProperty(randr::GetOutputPropertyRequest), #[cfg(feature = "randr")] RandrCreateMode(randr::CreateModeRequest<'input>), #[cfg(feature = "randr")] RandrDestroyMode(randr::DestroyModeRequest), #[cfg(feature = "randr")] RandrAddOutputMode(randr::AddOutputModeRequest), #[cfg(feature = "randr")] RandrDeleteOutputMode(randr::DeleteOutputModeRequest), #[cfg(feature = "randr")] RandrGetCrtcInfo(randr::GetCrtcInfoRequest), #[cfg(feature = "randr")] RandrSetCrtcConfig(randr::SetCrtcConfigRequest<'input>), #[cfg(feature = "randr")] RandrGetCrtcGammaSize(randr::GetCrtcGammaSizeRequest), #[cfg(feature = "randr")] RandrGetCrtcGamma(randr::GetCrtcGammaRequest), #[cfg(feature = "randr")] RandrSetCrtcGamma(randr::SetCrtcGammaRequest<'input>), #[cfg(feature = "randr")] RandrGetScreenResourcesCurrent(randr::GetScreenResourcesCurrentRequest), #[cfg(feature = "randr")] RandrSetCrtcTransform(randr::SetCrtcTransformRequest<'input>), #[cfg(feature = "randr")] RandrGetCrtcTransform(randr::GetCrtcTransformRequest), #[cfg(feature = "randr")] RandrGetPanning(randr::GetPanningRequest), #[cfg(feature = "randr")] RandrSetPanning(randr::SetPanningRequest), #[cfg(feature = "randr")] RandrSetOutputPrimary(randr::SetOutputPrimaryRequest), #[cfg(feature = "randr")] RandrGetOutputPrimary(randr::GetOutputPrimaryRequest), #[cfg(feature = "randr")] RandrGetProviders(randr::GetProvidersRequest), #[cfg(feature = "randr")] RandrGetProviderInfo(randr::GetProviderInfoRequest), #[cfg(feature = "randr")] RandrSetProviderOffloadSink(randr::SetProviderOffloadSinkRequest), #[cfg(feature = "randr")] RandrSetProviderOutputSource(randr::SetProviderOutputSourceRequest), #[cfg(feature = "randr")] RandrListProviderProperties(randr::ListProviderPropertiesRequest), #[cfg(feature = "randr")] RandrQueryProviderProperty(randr::QueryProviderPropertyRequest), #[cfg(feature = "randr")] RandrConfigureProviderProperty(randr::ConfigureProviderPropertyRequest<'input>), #[cfg(feature = "randr")] RandrChangeProviderProperty(randr::ChangeProviderPropertyRequest<'input>), #[cfg(feature = "randr")] RandrDeleteProviderProperty(randr::DeleteProviderPropertyRequest), #[cfg(feature = "randr")] RandrGetProviderProperty(randr::GetProviderPropertyRequest), #[cfg(feature = "randr")] RandrGetMonitors(randr::GetMonitorsRequest), #[cfg(feature = "randr")] RandrSetMonitor(randr::SetMonitorRequest), #[cfg(feature = "randr")] RandrDeleteMonitor(randr::DeleteMonitorRequest), #[cfg(feature = "randr")] RandrCreateLease(randr::CreateLeaseRequest<'input>), #[cfg(feature = "randr")] RandrFreeLease(randr::FreeLeaseRequest), #[cfg(feature = "record")] RecordQueryVersion(record::QueryVersionRequest), #[cfg(feature = "record")] RecordCreateContext(record::CreateContextRequest<'input>), #[cfg(feature = "record")] RecordRegisterClients(record::RegisterClientsRequest<'input>), #[cfg(feature = "record")] RecordUnregisterClients(record::UnregisterClientsRequest<'input>), #[cfg(feature = "record")] RecordGetContext(record::GetContextRequest), #[cfg(feature = "record")] RecordEnableContext(record::EnableContextRequest), #[cfg(feature = "record")] RecordDisableContext(record::DisableContextRequest), #[cfg(feature = "record")] RecordFreeContext(record::FreeContextRequest), #[cfg(feature = "render")] RenderQueryVersion(render::QueryVersionRequest), #[cfg(feature = "render")] RenderQueryPictFormats(render::QueryPictFormatsRequest), #[cfg(feature = "render")] RenderQueryPictIndexValues(render::QueryPictIndexValuesRequest), #[cfg(feature = "render")] RenderCreatePicture(render::CreatePictureRequest<'input>), #[cfg(feature = "render")] RenderChangePicture(render::ChangePictureRequest<'input>), #[cfg(feature = "render")] RenderSetPictureClipRectangles(render::SetPictureClipRectanglesRequest<'input>), #[cfg(feature = "render")] RenderFreePicture(render::FreePictureRequest), #[cfg(feature = "render")] RenderComposite(render::CompositeRequest), #[cfg(feature = "render")] RenderTrapezoids(render::TrapezoidsRequest<'input>), #[cfg(feature = "render")] RenderTriangles(render::TrianglesRequest<'input>), #[cfg(feature = "render")] RenderTriStrip(render::TriStripRequest<'input>), #[cfg(feature = "render")] RenderTriFan(render::TriFanRequest<'input>), #[cfg(feature = "render")] RenderCreateGlyphSet(render::CreateGlyphSetRequest), #[cfg(feature = "render")] RenderReferenceGlyphSet(render::ReferenceGlyphSetRequest), #[cfg(feature = "render")] RenderFreeGlyphSet(render::FreeGlyphSetRequest), #[cfg(feature = "render")] RenderAddGlyphs(render::AddGlyphsRequest<'input>), #[cfg(feature = "render")] RenderFreeGlyphs(render::FreeGlyphsRequest<'input>), #[cfg(feature = "render")] RenderCompositeGlyphs8(render::CompositeGlyphs8Request<'input>), #[cfg(feature = "render")] RenderCompositeGlyphs16(render::CompositeGlyphs16Request<'input>), #[cfg(feature = "render")] RenderCompositeGlyphs32(render::CompositeGlyphs32Request<'input>), #[cfg(feature = "render")] RenderFillRectangles(render::FillRectanglesRequest<'input>), #[cfg(feature = "render")] RenderCreateCursor(render::CreateCursorRequest), #[cfg(feature = "render")] RenderSetPictureTransform(render::SetPictureTransformRequest), #[cfg(feature = "render")] RenderQueryFilters(render::QueryFiltersRequest), #[cfg(feature = "render")] RenderSetPictureFilter(render::SetPictureFilterRequest<'input>), #[cfg(feature = "render")] RenderCreateAnimCursor(render::CreateAnimCursorRequest<'input>), #[cfg(feature = "render")] RenderAddTraps(render::AddTrapsRequest<'input>), #[cfg(feature = "render")] RenderCreateSolidFill(render::CreateSolidFillRequest), #[cfg(feature = "render")] RenderCreateLinearGradient(render::CreateLinearGradientRequest<'input>), #[cfg(feature = "render")] RenderCreateRadialGradient(render::CreateRadialGradientRequest<'input>), #[cfg(feature = "render")] RenderCreateConicalGradient(render::CreateConicalGradientRequest<'input>), #[cfg(feature = "res")] ResQueryVersion(res::QueryVersionRequest), #[cfg(feature = "res")] ResQueryClients(res::QueryClientsRequest), #[cfg(feature = "res")] ResQueryClientResources(res::QueryClientResourcesRequest), #[cfg(feature = "res")] ResQueryClientPixmapBytes(res::QueryClientPixmapBytesRequest), #[cfg(feature = "res")] ResQueryClientIds(res::QueryClientIdsRequest<'input>), #[cfg(feature = "res")] ResQueryResourceBytes(res::QueryResourceBytesRequest<'input>), #[cfg(feature = "screensaver")] ScreensaverQueryVersion(screensaver::QueryVersionRequest), #[cfg(feature = "screensaver")] ScreensaverQueryInfo(screensaver::QueryInfoRequest), #[cfg(feature = "screensaver")] ScreensaverSelectInput(screensaver::SelectInputRequest), #[cfg(feature = "screensaver")] ScreensaverSetAttributes(screensaver::SetAttributesRequest<'input>), #[cfg(feature = "screensaver")] ScreensaverUnsetAttributes(screensaver::UnsetAttributesRequest), #[cfg(feature = "screensaver")] ScreensaverSuspend(screensaver::SuspendRequest), #[cfg(feature = "shape")] ShapeQueryVersion(shape::QueryVersionRequest), #[cfg(feature = "shape")] ShapeRectangles(shape::RectanglesRequest<'input>), #[cfg(feature = "shape")] ShapeMask(shape::MaskRequest), #[cfg(feature = "shape")] ShapeCombine(shape::CombineRequest), #[cfg(feature = "shape")] ShapeOffset(shape::OffsetRequest), #[cfg(feature = "shape")] ShapeQueryExtents(shape::QueryExtentsRequest), #[cfg(feature = "shape")] ShapeSelectInput(shape::SelectInputRequest), #[cfg(feature = "shape")] ShapeInputSelected(shape::InputSelectedRequest), #[cfg(feature = "shape")] ShapeGetRectangles(shape::GetRectanglesRequest), #[cfg(feature = "shm")] ShmQueryVersion(shm::QueryVersionRequest), #[cfg(feature = "shm")] ShmAttach(shm::AttachRequest), #[cfg(feature = "shm")] ShmDetach(shm::DetachRequest), #[cfg(feature = "shm")] ShmPutImage(shm::PutImageRequest), #[cfg(feature = "shm")] ShmGetImage(shm::GetImageRequest), #[cfg(feature = "shm")] ShmCreatePixmap(shm::CreatePixmapRequest), #[cfg(feature = "shm")] ShmAttachFd(shm::AttachFdRequest), #[cfg(feature = "shm")] ShmCreateSegment(shm::CreateSegmentRequest), #[cfg(feature = "sync")] SyncInitialize(sync::InitializeRequest), #[cfg(feature = "sync")] SyncListSystemCounters(sync::ListSystemCountersRequest), #[cfg(feature = "sync")] SyncCreateCounter(sync::CreateCounterRequest), #[cfg(feature = "sync")] SyncDestroyCounter(sync::DestroyCounterRequest), #[cfg(feature = "sync")] SyncQueryCounter(sync::QueryCounterRequest), #[cfg(feature = "sync")] SyncAwait(sync::AwaitRequest<'input>), #[cfg(feature = "sync")] SyncChangeCounter(sync::ChangeCounterRequest), #[cfg(feature = "sync")] SyncSetCounter(sync::SetCounterRequest), #[cfg(feature = "sync")] SyncCreateAlarm(sync::CreateAlarmRequest<'input>), #[cfg(feature = "sync")] SyncChangeAlarm(sync::ChangeAlarmRequest<'input>), #[cfg(feature = "sync")] SyncDestroyAlarm(sync::DestroyAlarmRequest), #[cfg(feature = "sync")] SyncQueryAlarm(sync::QueryAlarmRequest), #[cfg(feature = "sync")] SyncSetPriority(sync::SetPriorityRequest), #[cfg(feature = "sync")] SyncGetPriority(sync::GetPriorityRequest), #[cfg(feature = "sync")] SyncCreateFence(sync::CreateFenceRequest), #[cfg(feature = "sync")] SyncTriggerFence(sync::TriggerFenceRequest), #[cfg(feature = "sync")] SyncResetFence(sync::ResetFenceRequest), #[cfg(feature = "sync")] SyncDestroyFence(sync::DestroyFenceRequest), #[cfg(feature = "sync")] SyncQueryFence(sync::QueryFenceRequest), #[cfg(feature = "sync")] SyncAwaitFence(sync::AwaitFenceRequest<'input>), XcMiscGetVersion(xc_misc::GetVersionRequest), XcMiscGetXIDRange(xc_misc::GetXIDRangeRequest), XcMiscGetXIDList(xc_misc::GetXIDListRequest), #[cfg(feature = "xevie")] XevieQueryVersion(xevie::QueryVersionRequest), #[cfg(feature = "xevie")] XevieStart(xevie::StartRequest), #[cfg(feature = "xevie")] XevieEnd(xevie::EndRequest), #[cfg(feature = "xevie")] XevieSend(xevie::SendRequest), #[cfg(feature = "xevie")] XevieSelectInput(xevie::SelectInputRequest), #[cfg(feature = "xf86dri")] Xf86driQueryVersion(xf86dri::QueryVersionRequest), #[cfg(feature = "xf86dri")] Xf86driQueryDirectRenderingCapable(xf86dri::QueryDirectRenderingCapableRequest), #[cfg(feature = "xf86dri")] Xf86driOpenConnection(xf86dri::OpenConnectionRequest), #[cfg(feature = "xf86dri")] Xf86driCloseConnection(xf86dri::CloseConnectionRequest), #[cfg(feature = "xf86dri")] Xf86driGetClientDriverName(xf86dri::GetClientDriverNameRequest), #[cfg(feature = "xf86dri")] Xf86driCreateContext(xf86dri::CreateContextRequest), #[cfg(feature = "xf86dri")] Xf86driDestroyContext(xf86dri::DestroyContextRequest), #[cfg(feature = "xf86dri")] Xf86driCreateDrawable(xf86dri::CreateDrawableRequest), #[cfg(feature = "xf86dri")] Xf86driDestroyDrawable(xf86dri::DestroyDrawableRequest), #[cfg(feature = "xf86dri")] Xf86driGetDrawableInfo(xf86dri::GetDrawableInfoRequest), #[cfg(feature = "xf86dri")] Xf86driGetDeviceInfo(xf86dri::GetDeviceInfoRequest), #[cfg(feature = "xf86dri")] Xf86driAuthConnection(xf86dri::AuthConnectionRequest), #[cfg(feature = "xf86vidmode")] Xf86vidmodeQueryVersion(xf86vidmode::QueryVersionRequest), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetModeLine(xf86vidmode::GetModeLineRequest), #[cfg(feature = "xf86vidmode")] Xf86vidmodeModModeLine(xf86vidmode::ModModeLineRequest<'input>), #[cfg(feature = "xf86vidmode")] Xf86vidmodeSwitchMode(xf86vidmode::SwitchModeRequest), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetMonitor(xf86vidmode::GetMonitorRequest), #[cfg(feature = "xf86vidmode")] Xf86vidmodeLockModeSwitch(xf86vidmode::LockModeSwitchRequest), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetAllModeLines(xf86vidmode::GetAllModeLinesRequest), #[cfg(feature = "xf86vidmode")] Xf86vidmodeAddModeLine(xf86vidmode::AddModeLineRequest<'input>), #[cfg(feature = "xf86vidmode")] Xf86vidmodeDeleteModeLine(xf86vidmode::DeleteModeLineRequest<'input>), #[cfg(feature = "xf86vidmode")] Xf86vidmodeValidateModeLine(xf86vidmode::ValidateModeLineRequest<'input>), #[cfg(feature = "xf86vidmode")] Xf86vidmodeSwitchToMode(xf86vidmode::SwitchToModeRequest<'input>), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetViewPort(xf86vidmode::GetViewPortRequest), #[cfg(feature = "xf86vidmode")] Xf86vidmodeSetViewPort(xf86vidmode::SetViewPortRequest), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetDotClocks(xf86vidmode::GetDotClocksRequest), #[cfg(feature = "xf86vidmode")] Xf86vidmodeSetClientVersion(xf86vidmode::SetClientVersionRequest), #[cfg(feature = "xf86vidmode")] Xf86vidmodeSetGamma(xf86vidmode::SetGammaRequest), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetGamma(xf86vidmode::GetGammaRequest), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetGammaRamp(xf86vidmode::GetGammaRampRequest), #[cfg(feature = "xf86vidmode")] Xf86vidmodeSetGammaRamp(xf86vidmode::SetGammaRampRequest<'input>), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetGammaRampSize(xf86vidmode::GetGammaRampSizeRequest), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetPermissions(xf86vidmode::GetPermissionsRequest), #[cfg(feature = "xfixes")] XfixesQueryVersion(xfixes::QueryVersionRequest), #[cfg(feature = "xfixes")] XfixesChangeSaveSet(xfixes::ChangeSaveSetRequest), #[cfg(feature = "xfixes")] XfixesSelectSelectionInput(xfixes::SelectSelectionInputRequest), #[cfg(feature = "xfixes")] XfixesSelectCursorInput(xfixes::SelectCursorInputRequest), #[cfg(feature = "xfixes")] XfixesGetCursorImage(xfixes::GetCursorImageRequest), #[cfg(feature = "xfixes")] XfixesCreateRegion(xfixes::CreateRegionRequest<'input>), #[cfg(feature = "xfixes")] XfixesCreateRegionFromBitmap(xfixes::CreateRegionFromBitmapRequest), #[cfg(feature = "xfixes")] XfixesCreateRegionFromWindow(xfixes::CreateRegionFromWindowRequest), #[cfg(feature = "xfixes")] XfixesCreateRegionFromGC(xfixes::CreateRegionFromGCRequest), #[cfg(feature = "xfixes")] XfixesCreateRegionFromPicture(xfixes::CreateRegionFromPictureRequest), #[cfg(feature = "xfixes")] XfixesDestroyRegion(xfixes::DestroyRegionRequest), #[cfg(feature = "xfixes")] XfixesSetRegion(xfixes::SetRegionRequest<'input>), #[cfg(feature = "xfixes")] XfixesCopyRegion(xfixes::CopyRegionRequest), #[cfg(feature = "xfixes")] XfixesUnionRegion(xfixes::UnionRegionRequest), #[cfg(feature = "xfixes")] XfixesIntersectRegion(xfixes::IntersectRegionRequest), #[cfg(feature = "xfixes")] XfixesSubtractRegion(xfixes::SubtractRegionRequest), #[cfg(feature = "xfixes")] XfixesInvertRegion(xfixes::InvertRegionRequest), #[cfg(feature = "xfixes")] XfixesTranslateRegion(xfixes::TranslateRegionRequest), #[cfg(feature = "xfixes")] XfixesRegionExtents(xfixes::RegionExtentsRequest), #[cfg(feature = "xfixes")] XfixesFetchRegion(xfixes::FetchRegionRequest), #[cfg(feature = "xfixes")] XfixesSetGCClipRegion(xfixes::SetGCClipRegionRequest), #[cfg(feature = "xfixes")] XfixesSetWindowShapeRegion(xfixes::SetWindowShapeRegionRequest), #[cfg(feature = "xfixes")] XfixesSetPictureClipRegion(xfixes::SetPictureClipRegionRequest), #[cfg(feature = "xfixes")] XfixesSetCursorName(xfixes::SetCursorNameRequest<'input>), #[cfg(feature = "xfixes")] XfixesGetCursorName(xfixes::GetCursorNameRequest), #[cfg(feature = "xfixes")] XfixesGetCursorImageAndName(xfixes::GetCursorImageAndNameRequest), #[cfg(feature = "xfixes")] XfixesChangeCursor(xfixes::ChangeCursorRequest), #[cfg(feature = "xfixes")] XfixesChangeCursorByName(xfixes::ChangeCursorByNameRequest<'input>), #[cfg(feature = "xfixes")] XfixesExpandRegion(xfixes::ExpandRegionRequest), #[cfg(feature = "xfixes")] XfixesHideCursor(xfixes::HideCursorRequest), #[cfg(feature = "xfixes")] XfixesShowCursor(xfixes::ShowCursorRequest), #[cfg(feature = "xfixes")] XfixesCreatePointerBarrier(xfixes::CreatePointerBarrierRequest<'input>), #[cfg(feature = "xfixes")] XfixesDeletePointerBarrier(xfixes::DeletePointerBarrierRequest), #[cfg(feature = "xfixes")] XfixesSetClientDisconnectMode(xfixes::SetClientDisconnectModeRequest), #[cfg(feature = "xfixes")] XfixesGetClientDisconnectMode(xfixes::GetClientDisconnectModeRequest), #[cfg(feature = "xinerama")] XineramaQueryVersion(xinerama::QueryVersionRequest), #[cfg(feature = "xinerama")] XineramaGetState(xinerama::GetStateRequest), #[cfg(feature = "xinerama")] XineramaGetScreenCount(xinerama::GetScreenCountRequest), #[cfg(feature = "xinerama")] XineramaGetScreenSize(xinerama::GetScreenSizeRequest), #[cfg(feature = "xinerama")] XineramaIsActive(xinerama::IsActiveRequest), #[cfg(feature = "xinerama")] XineramaQueryScreens(xinerama::QueryScreensRequest), #[cfg(feature = "xinput")] XinputGetExtensionVersion(xinput::GetExtensionVersionRequest<'input>), #[cfg(feature = "xinput")] XinputListInputDevices(xinput::ListInputDevicesRequest), #[cfg(feature = "xinput")] XinputOpenDevice(xinput::OpenDeviceRequest), #[cfg(feature = "xinput")] XinputCloseDevice(xinput::CloseDeviceRequest), #[cfg(feature = "xinput")] XinputSetDeviceMode(xinput::SetDeviceModeRequest), #[cfg(feature = "xinput")] XinputSelectExtensionEvent(xinput::SelectExtensionEventRequest<'input>), #[cfg(feature = "xinput")] XinputGetSelectedExtensionEvents(xinput::GetSelectedExtensionEventsRequest), #[cfg(feature = "xinput")] XinputChangeDeviceDontPropagateList(xinput::ChangeDeviceDontPropagateListRequest<'input>), #[cfg(feature = "xinput")] XinputGetDeviceDontPropagateList(xinput::GetDeviceDontPropagateListRequest), #[cfg(feature = "xinput")] XinputGetDeviceMotionEvents(xinput::GetDeviceMotionEventsRequest), #[cfg(feature = "xinput")] XinputChangeKeyboardDevice(xinput::ChangeKeyboardDeviceRequest), #[cfg(feature = "xinput")] XinputChangePointerDevice(xinput::ChangePointerDeviceRequest), #[cfg(feature = "xinput")] XinputGrabDevice(xinput::GrabDeviceRequest<'input>), #[cfg(feature = "xinput")] XinputUngrabDevice(xinput::UngrabDeviceRequest), #[cfg(feature = "xinput")] XinputGrabDeviceKey(xinput::GrabDeviceKeyRequest<'input>), #[cfg(feature = "xinput")] XinputUngrabDeviceKey(xinput::UngrabDeviceKeyRequest), #[cfg(feature = "xinput")] XinputGrabDeviceButton(xinput::GrabDeviceButtonRequest<'input>), #[cfg(feature = "xinput")] XinputUngrabDeviceButton(xinput::UngrabDeviceButtonRequest), #[cfg(feature = "xinput")] XinputAllowDeviceEvents(xinput::AllowDeviceEventsRequest), #[cfg(feature = "xinput")] XinputGetDeviceFocus(xinput::GetDeviceFocusRequest), #[cfg(feature = "xinput")] XinputSetDeviceFocus(xinput::SetDeviceFocusRequest), #[cfg(feature = "xinput")] XinputGetFeedbackControl(xinput::GetFeedbackControlRequest), #[cfg(feature = "xinput")] XinputChangeFeedbackControl(xinput::ChangeFeedbackControlRequest), #[cfg(feature = "xinput")] XinputGetDeviceKeyMapping(xinput::GetDeviceKeyMappingRequest), #[cfg(feature = "xinput")] XinputChangeDeviceKeyMapping(xinput::ChangeDeviceKeyMappingRequest<'input>), #[cfg(feature = "xinput")] XinputGetDeviceModifierMapping(xinput::GetDeviceModifierMappingRequest), #[cfg(feature = "xinput")] XinputSetDeviceModifierMapping(xinput::SetDeviceModifierMappingRequest<'input>), #[cfg(feature = "xinput")] XinputGetDeviceButtonMapping(xinput::GetDeviceButtonMappingRequest), #[cfg(feature = "xinput")] XinputSetDeviceButtonMapping(xinput::SetDeviceButtonMappingRequest<'input>), #[cfg(feature = "xinput")] XinputQueryDeviceState(xinput::QueryDeviceStateRequest), #[cfg(feature = "xinput")] XinputDeviceBell(xinput::DeviceBellRequest), #[cfg(feature = "xinput")] XinputSetDeviceValuators(xinput::SetDeviceValuatorsRequest<'input>), #[cfg(feature = "xinput")] XinputGetDeviceControl(xinput::GetDeviceControlRequest), #[cfg(feature = "xinput")] XinputChangeDeviceControl(xinput::ChangeDeviceControlRequest), #[cfg(feature = "xinput")] XinputListDeviceProperties(xinput::ListDevicePropertiesRequest), #[cfg(feature = "xinput")] XinputChangeDeviceProperty(xinput::ChangeDevicePropertyRequest<'input>), #[cfg(feature = "xinput")] XinputDeleteDeviceProperty(xinput::DeleteDevicePropertyRequest), #[cfg(feature = "xinput")] XinputGetDeviceProperty(xinput::GetDevicePropertyRequest), #[cfg(feature = "xinput")] XinputXIQueryPointer(xinput::XIQueryPointerRequest), #[cfg(feature = "xinput")] XinputXIWarpPointer(xinput::XIWarpPointerRequest), #[cfg(feature = "xinput")] XinputXIChangeCursor(xinput::XIChangeCursorRequest), #[cfg(feature = "xinput")] XinputXIChangeHierarchy(xinput::XIChangeHierarchyRequest<'input>), #[cfg(feature = "xinput")] XinputXISetClientPointer(xinput::XISetClientPointerRequest), #[cfg(feature = "xinput")] XinputXIGetClientPointer(xinput::XIGetClientPointerRequest), #[cfg(feature = "xinput")] XinputXISelectEvents(xinput::XISelectEventsRequest<'input>), #[cfg(feature = "xinput")] XinputXIQueryVersion(xinput::XIQueryVersionRequest), #[cfg(feature = "xinput")] XinputXIQueryDevice(xinput::XIQueryDeviceRequest), #[cfg(feature = "xinput")] XinputXISetFocus(xinput::XISetFocusRequest), #[cfg(feature = "xinput")] XinputXIGetFocus(xinput::XIGetFocusRequest), #[cfg(feature = "xinput")] XinputXIGrabDevice(xinput::XIGrabDeviceRequest<'input>), #[cfg(feature = "xinput")] XinputXIUngrabDevice(xinput::XIUngrabDeviceRequest), #[cfg(feature = "xinput")] XinputXIAllowEvents(xinput::XIAllowEventsRequest), #[cfg(feature = "xinput")] XinputXIPassiveGrabDevice(xinput::XIPassiveGrabDeviceRequest<'input>), #[cfg(feature = "xinput")] XinputXIPassiveUngrabDevice(xinput::XIPassiveUngrabDeviceRequest<'input>), #[cfg(feature = "xinput")] XinputXIListProperties(xinput::XIListPropertiesRequest), #[cfg(feature = "xinput")] XinputXIChangeProperty(xinput::XIChangePropertyRequest<'input>), #[cfg(feature = "xinput")] XinputXIDeleteProperty(xinput::XIDeletePropertyRequest), #[cfg(feature = "xinput")] XinputXIGetProperty(xinput::XIGetPropertyRequest), #[cfg(feature = "xinput")] XinputXIGetSelectedEvents(xinput::XIGetSelectedEventsRequest), #[cfg(feature = "xinput")] XinputXIBarrierReleasePointer(xinput::XIBarrierReleasePointerRequest<'input>), #[cfg(feature = "xinput")] XinputSendExtensionEvent(xinput::SendExtensionEventRequest<'input>), #[cfg(feature = "xkb")] XkbUseExtension(xkb::UseExtensionRequest), #[cfg(feature = "xkb")] XkbSelectEvents(xkb::SelectEventsRequest<'input>), #[cfg(feature = "xkb")] XkbBell(xkb::BellRequest), #[cfg(feature = "xkb")] XkbGetState(xkb::GetStateRequest), #[cfg(feature = "xkb")] XkbLatchLockState(xkb::LatchLockStateRequest), #[cfg(feature = "xkb")] XkbGetControls(xkb::GetControlsRequest), #[cfg(feature = "xkb")] XkbSetControls(xkb::SetControlsRequest<'input>), #[cfg(feature = "xkb")] XkbGetMap(xkb::GetMapRequest), #[cfg(feature = "xkb")] XkbSetMap(xkb::SetMapRequest<'input>), #[cfg(feature = "xkb")] XkbGetCompatMap(xkb::GetCompatMapRequest), #[cfg(feature = "xkb")] XkbSetCompatMap(xkb::SetCompatMapRequest<'input>), #[cfg(feature = "xkb")] XkbGetIndicatorState(xkb::GetIndicatorStateRequest), #[cfg(feature = "xkb")] XkbGetIndicatorMap(xkb::GetIndicatorMapRequest), #[cfg(feature = "xkb")] XkbSetIndicatorMap(xkb::SetIndicatorMapRequest<'input>), #[cfg(feature = "xkb")] XkbGetNamedIndicator(xkb::GetNamedIndicatorRequest), #[cfg(feature = "xkb")] XkbSetNamedIndicator(xkb::SetNamedIndicatorRequest), #[cfg(feature = "xkb")] XkbGetNames(xkb::GetNamesRequest), #[cfg(feature = "xkb")] XkbSetNames(xkb::SetNamesRequest<'input>), #[cfg(feature = "xkb")] XkbPerClientFlags(xkb::PerClientFlagsRequest), #[cfg(feature = "xkb")] XkbListComponents(xkb::ListComponentsRequest), #[cfg(feature = "xkb")] XkbGetKbdByName(xkb::GetKbdByNameRequest), #[cfg(feature = "xkb")] XkbGetDeviceInfo(xkb::GetDeviceInfoRequest), #[cfg(feature = "xkb")] XkbSetDeviceInfo(xkb::SetDeviceInfoRequest<'input>), #[cfg(feature = "xkb")] XkbSetDebuggingFlags(xkb::SetDebuggingFlagsRequest<'input>), #[cfg(feature = "xprint")] XprintPrintQueryVersion(xprint::PrintQueryVersionRequest), #[cfg(feature = "xprint")] XprintPrintGetPrinterList(xprint::PrintGetPrinterListRequest<'input>), #[cfg(feature = "xprint")] XprintPrintRehashPrinterList(xprint::PrintRehashPrinterListRequest), #[cfg(feature = "xprint")] XprintCreateContext(xprint::CreateContextRequest<'input>), #[cfg(feature = "xprint")] XprintPrintSetContext(xprint::PrintSetContextRequest), #[cfg(feature = "xprint")] XprintPrintGetContext(xprint::PrintGetContextRequest), #[cfg(feature = "xprint")] XprintPrintDestroyContext(xprint::PrintDestroyContextRequest), #[cfg(feature = "xprint")] XprintPrintGetScreenOfContext(xprint::PrintGetScreenOfContextRequest), #[cfg(feature = "xprint")] XprintPrintStartJob(xprint::PrintStartJobRequest), #[cfg(feature = "xprint")] XprintPrintEndJob(xprint::PrintEndJobRequest), #[cfg(feature = "xprint")] XprintPrintStartDoc(xprint::PrintStartDocRequest), #[cfg(feature = "xprint")] XprintPrintEndDoc(xprint::PrintEndDocRequest), #[cfg(feature = "xprint")] XprintPrintPutDocumentData(xprint::PrintPutDocumentDataRequest<'input>), #[cfg(feature = "xprint")] XprintPrintGetDocumentData(xprint::PrintGetDocumentDataRequest), #[cfg(feature = "xprint")] XprintPrintStartPage(xprint::PrintStartPageRequest), #[cfg(feature = "xprint")] XprintPrintEndPage(xprint::PrintEndPageRequest), #[cfg(feature = "xprint")] XprintPrintSelectInput(xprint::PrintSelectInputRequest), #[cfg(feature = "xprint")] XprintPrintInputSelected(xprint::PrintInputSelectedRequest), #[cfg(feature = "xprint")] XprintPrintGetAttributes(xprint::PrintGetAttributesRequest), #[cfg(feature = "xprint")] XprintPrintGetOneAttributes(xprint::PrintGetOneAttributesRequest<'input>), #[cfg(feature = "xprint")] XprintPrintSetAttributes(xprint::PrintSetAttributesRequest<'input>), #[cfg(feature = "xprint")] XprintPrintGetPageDimensions(xprint::PrintGetPageDimensionsRequest), #[cfg(feature = "xprint")] XprintPrintQueryScreens(xprint::PrintQueryScreensRequest), #[cfg(feature = "xprint")] XprintPrintSetImageResolution(xprint::PrintSetImageResolutionRequest), #[cfg(feature = "xprint")] XprintPrintGetImageResolution(xprint::PrintGetImageResolutionRequest), #[cfg(feature = "xselinux")] XselinuxQueryVersion(xselinux::QueryVersionRequest), #[cfg(feature = "xselinux")] XselinuxSetDeviceCreateContext(xselinux::SetDeviceCreateContextRequest<'input>), #[cfg(feature = "xselinux")] XselinuxGetDeviceCreateContext(xselinux::GetDeviceCreateContextRequest), #[cfg(feature = "xselinux")] XselinuxSetDeviceContext(xselinux::SetDeviceContextRequest<'input>), #[cfg(feature = "xselinux")] XselinuxGetDeviceContext(xselinux::GetDeviceContextRequest), #[cfg(feature = "xselinux")] XselinuxSetWindowCreateContext(xselinux::SetWindowCreateContextRequest<'input>), #[cfg(feature = "xselinux")] XselinuxGetWindowCreateContext(xselinux::GetWindowCreateContextRequest), #[cfg(feature = "xselinux")] XselinuxGetWindowContext(xselinux::GetWindowContextRequest), #[cfg(feature = "xselinux")] XselinuxSetPropertyCreateContext(xselinux::SetPropertyCreateContextRequest<'input>), #[cfg(feature = "xselinux")] XselinuxGetPropertyCreateContext(xselinux::GetPropertyCreateContextRequest), #[cfg(feature = "xselinux")] XselinuxSetPropertyUseContext(xselinux::SetPropertyUseContextRequest<'input>), #[cfg(feature = "xselinux")] XselinuxGetPropertyUseContext(xselinux::GetPropertyUseContextRequest), #[cfg(feature = "xselinux")] XselinuxGetPropertyContext(xselinux::GetPropertyContextRequest), #[cfg(feature = "xselinux")] XselinuxGetPropertyDataContext(xselinux::GetPropertyDataContextRequest), #[cfg(feature = "xselinux")] XselinuxListProperties(xselinux::ListPropertiesRequest), #[cfg(feature = "xselinux")] XselinuxSetSelectionCreateContext(xselinux::SetSelectionCreateContextRequest<'input>), #[cfg(feature = "xselinux")] XselinuxGetSelectionCreateContext(xselinux::GetSelectionCreateContextRequest), #[cfg(feature = "xselinux")] XselinuxSetSelectionUseContext(xselinux::SetSelectionUseContextRequest<'input>), #[cfg(feature = "xselinux")] XselinuxGetSelectionUseContext(xselinux::GetSelectionUseContextRequest), #[cfg(feature = "xselinux")] XselinuxGetSelectionContext(xselinux::GetSelectionContextRequest), #[cfg(feature = "xselinux")] XselinuxGetSelectionDataContext(xselinux::GetSelectionDataContextRequest), #[cfg(feature = "xselinux")] XselinuxListSelections(xselinux::ListSelectionsRequest), #[cfg(feature = "xselinux")] XselinuxGetClientContext(xselinux::GetClientContextRequest), #[cfg(feature = "xtest")] XtestGetVersion(xtest::GetVersionRequest), #[cfg(feature = "xtest")] XtestCompareCursor(xtest::CompareCursorRequest), #[cfg(feature = "xtest")] XtestFakeInput(xtest::FakeInputRequest), #[cfg(feature = "xtest")] XtestGrabControl(xtest::GrabControlRequest), #[cfg(feature = "xv")] XvQueryExtension(xv::QueryExtensionRequest), #[cfg(feature = "xv")] XvQueryAdaptors(xv::QueryAdaptorsRequest), #[cfg(feature = "xv")] XvQueryEncodings(xv::QueryEncodingsRequest), #[cfg(feature = "xv")] XvGrabPort(xv::GrabPortRequest), #[cfg(feature = "xv")] XvUngrabPort(xv::UngrabPortRequest), #[cfg(feature = "xv")] XvPutVideo(xv::PutVideoRequest), #[cfg(feature = "xv")] XvPutStill(xv::PutStillRequest), #[cfg(feature = "xv")] XvGetVideo(xv::GetVideoRequest), #[cfg(feature = "xv")] XvGetStill(xv::GetStillRequest), #[cfg(feature = "xv")] XvStopVideo(xv::StopVideoRequest), #[cfg(feature = "xv")] XvSelectVideoNotify(xv::SelectVideoNotifyRequest), #[cfg(feature = "xv")] XvSelectPortNotify(xv::SelectPortNotifyRequest), #[cfg(feature = "xv")] XvQueryBestSize(xv::QueryBestSizeRequest), #[cfg(feature = "xv")] XvSetPortAttribute(xv::SetPortAttributeRequest), #[cfg(feature = "xv")] XvGetPortAttribute(xv::GetPortAttributeRequest), #[cfg(feature = "xv")] XvQueryPortAttributes(xv::QueryPortAttributesRequest), #[cfg(feature = "xv")] XvListImageFormats(xv::ListImageFormatsRequest), #[cfg(feature = "xv")] XvQueryImageAttributes(xv::QueryImageAttributesRequest), #[cfg(feature = "xv")] XvPutImage(xv::PutImageRequest<'input>), #[cfg(feature = "xv")] XvShmPutImage(xv::ShmPutImageRequest), #[cfg(feature = "xvmc")] XvmcQueryVersion(xvmc::QueryVersionRequest), #[cfg(feature = "xvmc")] XvmcListSurfaceTypes(xvmc::ListSurfaceTypesRequest), #[cfg(feature = "xvmc")] XvmcCreateContext(xvmc::CreateContextRequest), #[cfg(feature = "xvmc")] XvmcDestroyContext(xvmc::DestroyContextRequest), #[cfg(feature = "xvmc")] XvmcCreateSurface(xvmc::CreateSurfaceRequest), #[cfg(feature = "xvmc")] XvmcDestroySurface(xvmc::DestroySurfaceRequest), #[cfg(feature = "xvmc")] XvmcCreateSubpicture(xvmc::CreateSubpictureRequest), #[cfg(feature = "xvmc")] XvmcDestroySubpicture(xvmc::DestroySubpictureRequest), #[cfg(feature = "xvmc")] XvmcListSubpictureTypes(xvmc::ListSubpictureTypesRequest), } impl<'input> Request<'input> { // Parse a X11 request into a concrete type #[allow(clippy::cognitive_complexity, clippy::single_match)] #[cfg(feature = "request-parsing")] pub fn parse( header: RequestHeader, body: &'input [u8], // Might not be used if none of the extensions that use FD passing is enabled #[allow(unused_variables, clippy::ptr_arg)] fds: &mut Vec, ext_info_provider: &dyn ExtInfoProvider, ) -> Result { let remaining = body; // Check if this is a core protocol request. match header.major_opcode { xproto::CREATE_WINDOW_REQUEST => return Ok(Request::CreateWindow(xproto::CreateWindowRequest::try_parse_request(header, remaining)?)), xproto::CHANGE_WINDOW_ATTRIBUTES_REQUEST => return Ok(Request::ChangeWindowAttributes(xproto::ChangeWindowAttributesRequest::try_parse_request(header, remaining)?)), xproto::GET_WINDOW_ATTRIBUTES_REQUEST => return Ok(Request::GetWindowAttributes(xproto::GetWindowAttributesRequest::try_parse_request(header, remaining)?)), xproto::DESTROY_WINDOW_REQUEST => return Ok(Request::DestroyWindow(xproto::DestroyWindowRequest::try_parse_request(header, remaining)?)), xproto::DESTROY_SUBWINDOWS_REQUEST => return Ok(Request::DestroySubwindows(xproto::DestroySubwindowsRequest::try_parse_request(header, remaining)?)), xproto::CHANGE_SAVE_SET_REQUEST => return Ok(Request::ChangeSaveSet(xproto::ChangeSaveSetRequest::try_parse_request(header, remaining)?)), xproto::REPARENT_WINDOW_REQUEST => return Ok(Request::ReparentWindow(xproto::ReparentWindowRequest::try_parse_request(header, remaining)?)), xproto::MAP_WINDOW_REQUEST => return Ok(Request::MapWindow(xproto::MapWindowRequest::try_parse_request(header, remaining)?)), xproto::MAP_SUBWINDOWS_REQUEST => return Ok(Request::MapSubwindows(xproto::MapSubwindowsRequest::try_parse_request(header, remaining)?)), xproto::UNMAP_WINDOW_REQUEST => return Ok(Request::UnmapWindow(xproto::UnmapWindowRequest::try_parse_request(header, remaining)?)), xproto::UNMAP_SUBWINDOWS_REQUEST => return Ok(Request::UnmapSubwindows(xproto::UnmapSubwindowsRequest::try_parse_request(header, remaining)?)), xproto::CONFIGURE_WINDOW_REQUEST => return Ok(Request::ConfigureWindow(xproto::ConfigureWindowRequest::try_parse_request(header, remaining)?)), xproto::CIRCULATE_WINDOW_REQUEST => return Ok(Request::CirculateWindow(xproto::CirculateWindowRequest::try_parse_request(header, remaining)?)), xproto::GET_GEOMETRY_REQUEST => return Ok(Request::GetGeometry(xproto::GetGeometryRequest::try_parse_request(header, remaining)?)), xproto::QUERY_TREE_REQUEST => return Ok(Request::QueryTree(xproto::QueryTreeRequest::try_parse_request(header, remaining)?)), xproto::INTERN_ATOM_REQUEST => return Ok(Request::InternAtom(xproto::InternAtomRequest::try_parse_request(header, remaining)?)), xproto::GET_ATOM_NAME_REQUEST => return Ok(Request::GetAtomName(xproto::GetAtomNameRequest::try_parse_request(header, remaining)?)), xproto::CHANGE_PROPERTY_REQUEST => return Ok(Request::ChangeProperty(xproto::ChangePropertyRequest::try_parse_request(header, remaining)?)), xproto::DELETE_PROPERTY_REQUEST => return Ok(Request::DeleteProperty(xproto::DeletePropertyRequest::try_parse_request(header, remaining)?)), xproto::GET_PROPERTY_REQUEST => return Ok(Request::GetProperty(xproto::GetPropertyRequest::try_parse_request(header, remaining)?)), xproto::LIST_PROPERTIES_REQUEST => return Ok(Request::ListProperties(xproto::ListPropertiesRequest::try_parse_request(header, remaining)?)), xproto::SET_SELECTION_OWNER_REQUEST => return Ok(Request::SetSelectionOwner(xproto::SetSelectionOwnerRequest::try_parse_request(header, remaining)?)), xproto::GET_SELECTION_OWNER_REQUEST => return Ok(Request::GetSelectionOwner(xproto::GetSelectionOwnerRequest::try_parse_request(header, remaining)?)), xproto::CONVERT_SELECTION_REQUEST => return Ok(Request::ConvertSelection(xproto::ConvertSelectionRequest::try_parse_request(header, remaining)?)), xproto::SEND_EVENT_REQUEST => return Ok(Request::SendEvent(xproto::SendEventRequest::try_parse_request(header, remaining)?)), xproto::GRAB_POINTER_REQUEST => return Ok(Request::GrabPointer(xproto::GrabPointerRequest::try_parse_request(header, remaining)?)), xproto::UNGRAB_POINTER_REQUEST => return Ok(Request::UngrabPointer(xproto::UngrabPointerRequest::try_parse_request(header, remaining)?)), xproto::GRAB_BUTTON_REQUEST => return Ok(Request::GrabButton(xproto::GrabButtonRequest::try_parse_request(header, remaining)?)), xproto::UNGRAB_BUTTON_REQUEST => return Ok(Request::UngrabButton(xproto::UngrabButtonRequest::try_parse_request(header, remaining)?)), xproto::CHANGE_ACTIVE_POINTER_GRAB_REQUEST => return Ok(Request::ChangeActivePointerGrab(xproto::ChangeActivePointerGrabRequest::try_parse_request(header, remaining)?)), xproto::GRAB_KEYBOARD_REQUEST => return Ok(Request::GrabKeyboard(xproto::GrabKeyboardRequest::try_parse_request(header, remaining)?)), xproto::UNGRAB_KEYBOARD_REQUEST => return Ok(Request::UngrabKeyboard(xproto::UngrabKeyboardRequest::try_parse_request(header, remaining)?)), xproto::GRAB_KEY_REQUEST => return Ok(Request::GrabKey(xproto::GrabKeyRequest::try_parse_request(header, remaining)?)), xproto::UNGRAB_KEY_REQUEST => return Ok(Request::UngrabKey(xproto::UngrabKeyRequest::try_parse_request(header, remaining)?)), xproto::ALLOW_EVENTS_REQUEST => return Ok(Request::AllowEvents(xproto::AllowEventsRequest::try_parse_request(header, remaining)?)), xproto::GRAB_SERVER_REQUEST => return Ok(Request::GrabServer(xproto::GrabServerRequest::try_parse_request(header, remaining)?)), xproto::UNGRAB_SERVER_REQUEST => return Ok(Request::UngrabServer(xproto::UngrabServerRequest::try_parse_request(header, remaining)?)), xproto::QUERY_POINTER_REQUEST => return Ok(Request::QueryPointer(xproto::QueryPointerRequest::try_parse_request(header, remaining)?)), xproto::GET_MOTION_EVENTS_REQUEST => return Ok(Request::GetMotionEvents(xproto::GetMotionEventsRequest::try_parse_request(header, remaining)?)), xproto::TRANSLATE_COORDINATES_REQUEST => return Ok(Request::TranslateCoordinates(xproto::TranslateCoordinatesRequest::try_parse_request(header, remaining)?)), xproto::WARP_POINTER_REQUEST => return Ok(Request::WarpPointer(xproto::WarpPointerRequest::try_parse_request(header, remaining)?)), xproto::SET_INPUT_FOCUS_REQUEST => return Ok(Request::SetInputFocus(xproto::SetInputFocusRequest::try_parse_request(header, remaining)?)), xproto::GET_INPUT_FOCUS_REQUEST => return Ok(Request::GetInputFocus(xproto::GetInputFocusRequest::try_parse_request(header, remaining)?)), xproto::QUERY_KEYMAP_REQUEST => return Ok(Request::QueryKeymap(xproto::QueryKeymapRequest::try_parse_request(header, remaining)?)), xproto::OPEN_FONT_REQUEST => return Ok(Request::OpenFont(xproto::OpenFontRequest::try_parse_request(header, remaining)?)), xproto::CLOSE_FONT_REQUEST => return Ok(Request::CloseFont(xproto::CloseFontRequest::try_parse_request(header, remaining)?)), xproto::QUERY_FONT_REQUEST => return Ok(Request::QueryFont(xproto::QueryFontRequest::try_parse_request(header, remaining)?)), xproto::QUERY_TEXT_EXTENTS_REQUEST => return Ok(Request::QueryTextExtents(xproto::QueryTextExtentsRequest::try_parse_request(header, remaining)?)), xproto::LIST_FONTS_REQUEST => return Ok(Request::ListFonts(xproto::ListFontsRequest::try_parse_request(header, remaining)?)), xproto::LIST_FONTS_WITH_INFO_REQUEST => return Ok(Request::ListFontsWithInfo(xproto::ListFontsWithInfoRequest::try_parse_request(header, remaining)?)), xproto::SET_FONT_PATH_REQUEST => return Ok(Request::SetFontPath(xproto::SetFontPathRequest::try_parse_request(header, remaining)?)), xproto::GET_FONT_PATH_REQUEST => return Ok(Request::GetFontPath(xproto::GetFontPathRequest::try_parse_request(header, remaining)?)), xproto::CREATE_PIXMAP_REQUEST => return Ok(Request::CreatePixmap(xproto::CreatePixmapRequest::try_parse_request(header, remaining)?)), xproto::FREE_PIXMAP_REQUEST => return Ok(Request::FreePixmap(xproto::FreePixmapRequest::try_parse_request(header, remaining)?)), xproto::CREATE_GC_REQUEST => return Ok(Request::CreateGC(xproto::CreateGCRequest::try_parse_request(header, remaining)?)), xproto::CHANGE_GC_REQUEST => return Ok(Request::ChangeGC(xproto::ChangeGCRequest::try_parse_request(header, remaining)?)), xproto::COPY_GC_REQUEST => return Ok(Request::CopyGC(xproto::CopyGCRequest::try_parse_request(header, remaining)?)), xproto::SET_DASHES_REQUEST => return Ok(Request::SetDashes(xproto::SetDashesRequest::try_parse_request(header, remaining)?)), xproto::SET_CLIP_RECTANGLES_REQUEST => return Ok(Request::SetClipRectangles(xproto::SetClipRectanglesRequest::try_parse_request(header, remaining)?)), xproto::FREE_GC_REQUEST => return Ok(Request::FreeGC(xproto::FreeGCRequest::try_parse_request(header, remaining)?)), xproto::CLEAR_AREA_REQUEST => return Ok(Request::ClearArea(xproto::ClearAreaRequest::try_parse_request(header, remaining)?)), xproto::COPY_AREA_REQUEST => return Ok(Request::CopyArea(xproto::CopyAreaRequest::try_parse_request(header, remaining)?)), xproto::COPY_PLANE_REQUEST => return Ok(Request::CopyPlane(xproto::CopyPlaneRequest::try_parse_request(header, remaining)?)), xproto::POLY_POINT_REQUEST => return Ok(Request::PolyPoint(xproto::PolyPointRequest::try_parse_request(header, remaining)?)), xproto::POLY_LINE_REQUEST => return Ok(Request::PolyLine(xproto::PolyLineRequest::try_parse_request(header, remaining)?)), xproto::POLY_SEGMENT_REQUEST => return Ok(Request::PolySegment(xproto::PolySegmentRequest::try_parse_request(header, remaining)?)), xproto::POLY_RECTANGLE_REQUEST => return Ok(Request::PolyRectangle(xproto::PolyRectangleRequest::try_parse_request(header, remaining)?)), xproto::POLY_ARC_REQUEST => return Ok(Request::PolyArc(xproto::PolyArcRequest::try_parse_request(header, remaining)?)), xproto::FILL_POLY_REQUEST => return Ok(Request::FillPoly(xproto::FillPolyRequest::try_parse_request(header, remaining)?)), xproto::POLY_FILL_RECTANGLE_REQUEST => return Ok(Request::PolyFillRectangle(xproto::PolyFillRectangleRequest::try_parse_request(header, remaining)?)), xproto::POLY_FILL_ARC_REQUEST => return Ok(Request::PolyFillArc(xproto::PolyFillArcRequest::try_parse_request(header, remaining)?)), xproto::PUT_IMAGE_REQUEST => return Ok(Request::PutImage(xproto::PutImageRequest::try_parse_request(header, remaining)?)), xproto::GET_IMAGE_REQUEST => return Ok(Request::GetImage(xproto::GetImageRequest::try_parse_request(header, remaining)?)), xproto::POLY_TEXT8_REQUEST => return Ok(Request::PolyText8(xproto::PolyText8Request::try_parse_request(header, remaining)?)), xproto::POLY_TEXT16_REQUEST => return Ok(Request::PolyText16(xproto::PolyText16Request::try_parse_request(header, remaining)?)), xproto::IMAGE_TEXT8_REQUEST => return Ok(Request::ImageText8(xproto::ImageText8Request::try_parse_request(header, remaining)?)), xproto::IMAGE_TEXT16_REQUEST => return Ok(Request::ImageText16(xproto::ImageText16Request::try_parse_request(header, remaining)?)), xproto::CREATE_COLORMAP_REQUEST => return Ok(Request::CreateColormap(xproto::CreateColormapRequest::try_parse_request(header, remaining)?)), xproto::FREE_COLORMAP_REQUEST => return Ok(Request::FreeColormap(xproto::FreeColormapRequest::try_parse_request(header, remaining)?)), xproto::COPY_COLORMAP_AND_FREE_REQUEST => return Ok(Request::CopyColormapAndFree(xproto::CopyColormapAndFreeRequest::try_parse_request(header, remaining)?)), xproto::INSTALL_COLORMAP_REQUEST => return Ok(Request::InstallColormap(xproto::InstallColormapRequest::try_parse_request(header, remaining)?)), xproto::UNINSTALL_COLORMAP_REQUEST => return Ok(Request::UninstallColormap(xproto::UninstallColormapRequest::try_parse_request(header, remaining)?)), xproto::LIST_INSTALLED_COLORMAPS_REQUEST => return Ok(Request::ListInstalledColormaps(xproto::ListInstalledColormapsRequest::try_parse_request(header, remaining)?)), xproto::ALLOC_COLOR_REQUEST => return Ok(Request::AllocColor(xproto::AllocColorRequest::try_parse_request(header, remaining)?)), xproto::ALLOC_NAMED_COLOR_REQUEST => return Ok(Request::AllocNamedColor(xproto::AllocNamedColorRequest::try_parse_request(header, remaining)?)), xproto::ALLOC_COLOR_CELLS_REQUEST => return Ok(Request::AllocColorCells(xproto::AllocColorCellsRequest::try_parse_request(header, remaining)?)), xproto::ALLOC_COLOR_PLANES_REQUEST => return Ok(Request::AllocColorPlanes(xproto::AllocColorPlanesRequest::try_parse_request(header, remaining)?)), xproto::FREE_COLORS_REQUEST => return Ok(Request::FreeColors(xproto::FreeColorsRequest::try_parse_request(header, remaining)?)), xproto::STORE_COLORS_REQUEST => return Ok(Request::StoreColors(xproto::StoreColorsRequest::try_parse_request(header, remaining)?)), xproto::STORE_NAMED_COLOR_REQUEST => return Ok(Request::StoreNamedColor(xproto::StoreNamedColorRequest::try_parse_request(header, remaining)?)), xproto::QUERY_COLORS_REQUEST => return Ok(Request::QueryColors(xproto::QueryColorsRequest::try_parse_request(header, remaining)?)), xproto::LOOKUP_COLOR_REQUEST => return Ok(Request::LookupColor(xproto::LookupColorRequest::try_parse_request(header, remaining)?)), xproto::CREATE_CURSOR_REQUEST => return Ok(Request::CreateCursor(xproto::CreateCursorRequest::try_parse_request(header, remaining)?)), xproto::CREATE_GLYPH_CURSOR_REQUEST => return Ok(Request::CreateGlyphCursor(xproto::CreateGlyphCursorRequest::try_parse_request(header, remaining)?)), xproto::FREE_CURSOR_REQUEST => return Ok(Request::FreeCursor(xproto::FreeCursorRequest::try_parse_request(header, remaining)?)), xproto::RECOLOR_CURSOR_REQUEST => return Ok(Request::RecolorCursor(xproto::RecolorCursorRequest::try_parse_request(header, remaining)?)), xproto::QUERY_BEST_SIZE_REQUEST => return Ok(Request::QueryBestSize(xproto::QueryBestSizeRequest::try_parse_request(header, remaining)?)), xproto::QUERY_EXTENSION_REQUEST => return Ok(Request::QueryExtension(xproto::QueryExtensionRequest::try_parse_request(header, remaining)?)), xproto::LIST_EXTENSIONS_REQUEST => return Ok(Request::ListExtensions(xproto::ListExtensionsRequest::try_parse_request(header, remaining)?)), xproto::CHANGE_KEYBOARD_MAPPING_REQUEST => return Ok(Request::ChangeKeyboardMapping(xproto::ChangeKeyboardMappingRequest::try_parse_request(header, remaining)?)), xproto::GET_KEYBOARD_MAPPING_REQUEST => return Ok(Request::GetKeyboardMapping(xproto::GetKeyboardMappingRequest::try_parse_request(header, remaining)?)), xproto::CHANGE_KEYBOARD_CONTROL_REQUEST => return Ok(Request::ChangeKeyboardControl(xproto::ChangeKeyboardControlRequest::try_parse_request(header, remaining)?)), xproto::GET_KEYBOARD_CONTROL_REQUEST => return Ok(Request::GetKeyboardControl(xproto::GetKeyboardControlRequest::try_parse_request(header, remaining)?)), xproto::BELL_REQUEST => return Ok(Request::Bell(xproto::BellRequest::try_parse_request(header, remaining)?)), xproto::CHANGE_POINTER_CONTROL_REQUEST => return Ok(Request::ChangePointerControl(xproto::ChangePointerControlRequest::try_parse_request(header, remaining)?)), xproto::GET_POINTER_CONTROL_REQUEST => return Ok(Request::GetPointerControl(xproto::GetPointerControlRequest::try_parse_request(header, remaining)?)), xproto::SET_SCREEN_SAVER_REQUEST => return Ok(Request::SetScreenSaver(xproto::SetScreenSaverRequest::try_parse_request(header, remaining)?)), xproto::GET_SCREEN_SAVER_REQUEST => return Ok(Request::GetScreenSaver(xproto::GetScreenSaverRequest::try_parse_request(header, remaining)?)), xproto::CHANGE_HOSTS_REQUEST => return Ok(Request::ChangeHosts(xproto::ChangeHostsRequest::try_parse_request(header, remaining)?)), xproto::LIST_HOSTS_REQUEST => return Ok(Request::ListHosts(xproto::ListHostsRequest::try_parse_request(header, remaining)?)), xproto::SET_ACCESS_CONTROL_REQUEST => return Ok(Request::SetAccessControl(xproto::SetAccessControlRequest::try_parse_request(header, remaining)?)), xproto::SET_CLOSE_DOWN_MODE_REQUEST => return Ok(Request::SetCloseDownMode(xproto::SetCloseDownModeRequest::try_parse_request(header, remaining)?)), xproto::KILL_CLIENT_REQUEST => return Ok(Request::KillClient(xproto::KillClientRequest::try_parse_request(header, remaining)?)), xproto::ROTATE_PROPERTIES_REQUEST => return Ok(Request::RotateProperties(xproto::RotatePropertiesRequest::try_parse_request(header, remaining)?)), xproto::FORCE_SCREEN_SAVER_REQUEST => return Ok(Request::ForceScreenSaver(xproto::ForceScreenSaverRequest::try_parse_request(header, remaining)?)), xproto::SET_POINTER_MAPPING_REQUEST => return Ok(Request::SetPointerMapping(xproto::SetPointerMappingRequest::try_parse_request(header, remaining)?)), xproto::GET_POINTER_MAPPING_REQUEST => return Ok(Request::GetPointerMapping(xproto::GetPointerMappingRequest::try_parse_request(header, remaining)?)), xproto::SET_MODIFIER_MAPPING_REQUEST => return Ok(Request::SetModifierMapping(xproto::SetModifierMappingRequest::try_parse_request(header, remaining)?)), xproto::GET_MODIFIER_MAPPING_REQUEST => return Ok(Request::GetModifierMapping(xproto::GetModifierMappingRequest::try_parse_request(header, remaining)?)), xproto::NO_OPERATION_REQUEST => return Ok(Request::NoOperation(xproto::NoOperationRequest::try_parse_request(header, remaining)?)), _ => (), } // Find the extension that this request could belong to let ext_info = ext_info_provider.get_from_major_opcode(header.major_opcode); match ext_info { Some((bigreq::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { bigreq::ENABLE_REQUEST => return Ok(Request::BigreqEnable(bigreq::EnableRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "composite")] Some((composite::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { composite::QUERY_VERSION_REQUEST => return Ok(Request::CompositeQueryVersion(composite::QueryVersionRequest::try_parse_request(header, remaining)?)), composite::REDIRECT_WINDOW_REQUEST => return Ok(Request::CompositeRedirectWindow(composite::RedirectWindowRequest::try_parse_request(header, remaining)?)), composite::REDIRECT_SUBWINDOWS_REQUEST => return Ok(Request::CompositeRedirectSubwindows(composite::RedirectSubwindowsRequest::try_parse_request(header, remaining)?)), composite::UNREDIRECT_WINDOW_REQUEST => return Ok(Request::CompositeUnredirectWindow(composite::UnredirectWindowRequest::try_parse_request(header, remaining)?)), composite::UNREDIRECT_SUBWINDOWS_REQUEST => return Ok(Request::CompositeUnredirectSubwindows(composite::UnredirectSubwindowsRequest::try_parse_request(header, remaining)?)), composite::CREATE_REGION_FROM_BORDER_CLIP_REQUEST => return Ok(Request::CompositeCreateRegionFromBorderClip(composite::CreateRegionFromBorderClipRequest::try_parse_request(header, remaining)?)), composite::NAME_WINDOW_PIXMAP_REQUEST => return Ok(Request::CompositeNameWindowPixmap(composite::NameWindowPixmapRequest::try_parse_request(header, remaining)?)), composite::GET_OVERLAY_WINDOW_REQUEST => return Ok(Request::CompositeGetOverlayWindow(composite::GetOverlayWindowRequest::try_parse_request(header, remaining)?)), composite::RELEASE_OVERLAY_WINDOW_REQUEST => return Ok(Request::CompositeReleaseOverlayWindow(composite::ReleaseOverlayWindowRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "damage")] Some((damage::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { damage::QUERY_VERSION_REQUEST => return Ok(Request::DamageQueryVersion(damage::QueryVersionRequest::try_parse_request(header, remaining)?)), damage::CREATE_REQUEST => return Ok(Request::DamageCreate(damage::CreateRequest::try_parse_request(header, remaining)?)), damage::DESTROY_REQUEST => return Ok(Request::DamageDestroy(damage::DestroyRequest::try_parse_request(header, remaining)?)), damage::SUBTRACT_REQUEST => return Ok(Request::DamageSubtract(damage::SubtractRequest::try_parse_request(header, remaining)?)), damage::ADD_REQUEST => return Ok(Request::DamageAdd(damage::AddRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "dbe")] Some((dbe::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { dbe::QUERY_VERSION_REQUEST => return Ok(Request::DbeQueryVersion(dbe::QueryVersionRequest::try_parse_request(header, remaining)?)), dbe::ALLOCATE_BACK_BUFFER_REQUEST => return Ok(Request::DbeAllocateBackBuffer(dbe::AllocateBackBufferRequest::try_parse_request(header, remaining)?)), dbe::DEALLOCATE_BACK_BUFFER_REQUEST => return Ok(Request::DbeDeallocateBackBuffer(dbe::DeallocateBackBufferRequest::try_parse_request(header, remaining)?)), dbe::SWAP_BUFFERS_REQUEST => return Ok(Request::DbeSwapBuffers(dbe::SwapBuffersRequest::try_parse_request(header, remaining)?)), dbe::BEGIN_IDIOM_REQUEST => return Ok(Request::DbeBeginIdiom(dbe::BeginIdiomRequest::try_parse_request(header, remaining)?)), dbe::END_IDIOM_REQUEST => return Ok(Request::DbeEndIdiom(dbe::EndIdiomRequest::try_parse_request(header, remaining)?)), dbe::GET_VISUAL_INFO_REQUEST => return Ok(Request::DbeGetVisualInfo(dbe::GetVisualInfoRequest::try_parse_request(header, remaining)?)), dbe::GET_BACK_BUFFER_ATTRIBUTES_REQUEST => return Ok(Request::DbeGetBackBufferAttributes(dbe::GetBackBufferAttributesRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "dpms")] Some((dpms::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { dpms::GET_VERSION_REQUEST => return Ok(Request::DpmsGetVersion(dpms::GetVersionRequest::try_parse_request(header, remaining)?)), dpms::CAPABLE_REQUEST => return Ok(Request::DpmsCapable(dpms::CapableRequest::try_parse_request(header, remaining)?)), dpms::GET_TIMEOUTS_REQUEST => return Ok(Request::DpmsGetTimeouts(dpms::GetTimeoutsRequest::try_parse_request(header, remaining)?)), dpms::SET_TIMEOUTS_REQUEST => return Ok(Request::DpmsSetTimeouts(dpms::SetTimeoutsRequest::try_parse_request(header, remaining)?)), dpms::ENABLE_REQUEST => return Ok(Request::DpmsEnable(dpms::EnableRequest::try_parse_request(header, remaining)?)), dpms::DISABLE_REQUEST => return Ok(Request::DpmsDisable(dpms::DisableRequest::try_parse_request(header, remaining)?)), dpms::FORCE_LEVEL_REQUEST => return Ok(Request::DpmsForceLevel(dpms::ForceLevelRequest::try_parse_request(header, remaining)?)), dpms::INFO_REQUEST => return Ok(Request::DpmsInfo(dpms::InfoRequest::try_parse_request(header, remaining)?)), dpms::SELECT_INPUT_REQUEST => return Ok(Request::DpmsSelectInput(dpms::SelectInputRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "dri2")] Some((dri2::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { dri2::QUERY_VERSION_REQUEST => return Ok(Request::Dri2QueryVersion(dri2::QueryVersionRequest::try_parse_request(header, remaining)?)), dri2::CONNECT_REQUEST => return Ok(Request::Dri2Connect(dri2::ConnectRequest::try_parse_request(header, remaining)?)), dri2::AUTHENTICATE_REQUEST => return Ok(Request::Dri2Authenticate(dri2::AuthenticateRequest::try_parse_request(header, remaining)?)), dri2::CREATE_DRAWABLE_REQUEST => return Ok(Request::Dri2CreateDrawable(dri2::CreateDrawableRequest::try_parse_request(header, remaining)?)), dri2::DESTROY_DRAWABLE_REQUEST => return Ok(Request::Dri2DestroyDrawable(dri2::DestroyDrawableRequest::try_parse_request(header, remaining)?)), dri2::GET_BUFFERS_REQUEST => return Ok(Request::Dri2GetBuffers(dri2::GetBuffersRequest::try_parse_request(header, remaining)?)), dri2::COPY_REGION_REQUEST => return Ok(Request::Dri2CopyRegion(dri2::CopyRegionRequest::try_parse_request(header, remaining)?)), dri2::GET_BUFFERS_WITH_FORMAT_REQUEST => return Ok(Request::Dri2GetBuffersWithFormat(dri2::GetBuffersWithFormatRequest::try_parse_request(header, remaining)?)), dri2::SWAP_BUFFERS_REQUEST => return Ok(Request::Dri2SwapBuffers(dri2::SwapBuffersRequest::try_parse_request(header, remaining)?)), dri2::GET_MSC_REQUEST => return Ok(Request::Dri2GetMSC(dri2::GetMSCRequest::try_parse_request(header, remaining)?)), dri2::WAIT_MSC_REQUEST => return Ok(Request::Dri2WaitMSC(dri2::WaitMSCRequest::try_parse_request(header, remaining)?)), dri2::WAIT_SBC_REQUEST => return Ok(Request::Dri2WaitSBC(dri2::WaitSBCRequest::try_parse_request(header, remaining)?)), dri2::SWAP_INTERVAL_REQUEST => return Ok(Request::Dri2SwapInterval(dri2::SwapIntervalRequest::try_parse_request(header, remaining)?)), dri2::GET_PARAM_REQUEST => return Ok(Request::Dri2GetParam(dri2::GetParamRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "dri3")] Some((dri3::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { dri3::QUERY_VERSION_REQUEST => return Ok(Request::Dri3QueryVersion(dri3::QueryVersionRequest::try_parse_request(header, remaining)?)), dri3::OPEN_REQUEST => return Ok(Request::Dri3Open(dri3::OpenRequest::try_parse_request(header, remaining)?)), dri3::PIXMAP_FROM_BUFFER_REQUEST => return Ok(Request::Dri3PixmapFromBuffer(dri3::PixmapFromBufferRequest::try_parse_request_fd(header, remaining, fds)?)), dri3::BUFFER_FROM_PIXMAP_REQUEST => return Ok(Request::Dri3BufferFromPixmap(dri3::BufferFromPixmapRequest::try_parse_request(header, remaining)?)), dri3::FENCE_FROM_FD_REQUEST => return Ok(Request::Dri3FenceFromFD(dri3::FenceFromFDRequest::try_parse_request_fd(header, remaining, fds)?)), dri3::FD_FROM_FENCE_REQUEST => return Ok(Request::Dri3FDFromFence(dri3::FDFromFenceRequest::try_parse_request(header, remaining)?)), dri3::GET_SUPPORTED_MODIFIERS_REQUEST => return Ok(Request::Dri3GetSupportedModifiers(dri3::GetSupportedModifiersRequest::try_parse_request(header, remaining)?)), dri3::PIXMAP_FROM_BUFFERS_REQUEST => return Ok(Request::Dri3PixmapFromBuffers(dri3::PixmapFromBuffersRequest::try_parse_request_fd(header, remaining, fds)?)), dri3::BUFFERS_FROM_PIXMAP_REQUEST => return Ok(Request::Dri3BuffersFromPixmap(dri3::BuffersFromPixmapRequest::try_parse_request(header, remaining)?)), dri3::SET_DRM_DEVICE_IN_USE_REQUEST => return Ok(Request::Dri3SetDRMDeviceInUse(dri3::SetDRMDeviceInUseRequest::try_parse_request(header, remaining)?)), dri3::IMPORT_SYNCOBJ_REQUEST => return Ok(Request::Dri3ImportSyncobj(dri3::ImportSyncobjRequest::try_parse_request_fd(header, remaining, fds)?)), dri3::FREE_SYNCOBJ_REQUEST => return Ok(Request::Dri3FreeSyncobj(dri3::FreeSyncobjRequest::try_parse_request(header, remaining)?)), _ => (), } } Some((ge::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { ge::QUERY_VERSION_REQUEST => return Ok(Request::GeQueryVersion(ge::QueryVersionRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "glx")] Some((glx::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { glx::RENDER_REQUEST => return Ok(Request::GlxRender(glx::RenderRequest::try_parse_request(header, remaining)?)), glx::RENDER_LARGE_REQUEST => return Ok(Request::GlxRenderLarge(glx::RenderLargeRequest::try_parse_request(header, remaining)?)), glx::CREATE_CONTEXT_REQUEST => return Ok(Request::GlxCreateContext(glx::CreateContextRequest::try_parse_request(header, remaining)?)), glx::DESTROY_CONTEXT_REQUEST => return Ok(Request::GlxDestroyContext(glx::DestroyContextRequest::try_parse_request(header, remaining)?)), glx::MAKE_CURRENT_REQUEST => return Ok(Request::GlxMakeCurrent(glx::MakeCurrentRequest::try_parse_request(header, remaining)?)), glx::IS_DIRECT_REQUEST => return Ok(Request::GlxIsDirect(glx::IsDirectRequest::try_parse_request(header, remaining)?)), glx::QUERY_VERSION_REQUEST => return Ok(Request::GlxQueryVersion(glx::QueryVersionRequest::try_parse_request(header, remaining)?)), glx::WAIT_GL_REQUEST => return Ok(Request::GlxWaitGL(glx::WaitGLRequest::try_parse_request(header, remaining)?)), glx::WAIT_X_REQUEST => return Ok(Request::GlxWaitX(glx::WaitXRequest::try_parse_request(header, remaining)?)), glx::COPY_CONTEXT_REQUEST => return Ok(Request::GlxCopyContext(glx::CopyContextRequest::try_parse_request(header, remaining)?)), glx::SWAP_BUFFERS_REQUEST => return Ok(Request::GlxSwapBuffers(glx::SwapBuffersRequest::try_parse_request(header, remaining)?)), glx::USE_X_FONT_REQUEST => return Ok(Request::GlxUseXFont(glx::UseXFontRequest::try_parse_request(header, remaining)?)), glx::CREATE_GLX_PIXMAP_REQUEST => return Ok(Request::GlxCreateGLXPixmap(glx::CreateGLXPixmapRequest::try_parse_request(header, remaining)?)), glx::GET_VISUAL_CONFIGS_REQUEST => return Ok(Request::GlxGetVisualConfigs(glx::GetVisualConfigsRequest::try_parse_request(header, remaining)?)), glx::DESTROY_GLX_PIXMAP_REQUEST => return Ok(Request::GlxDestroyGLXPixmap(glx::DestroyGLXPixmapRequest::try_parse_request(header, remaining)?)), glx::VENDOR_PRIVATE_REQUEST => return Ok(Request::GlxVendorPrivate(glx::VendorPrivateRequest::try_parse_request(header, remaining)?)), glx::VENDOR_PRIVATE_WITH_REPLY_REQUEST => return Ok(Request::GlxVendorPrivateWithReply(glx::VendorPrivateWithReplyRequest::try_parse_request(header, remaining)?)), glx::QUERY_EXTENSIONS_STRING_REQUEST => return Ok(Request::GlxQueryExtensionsString(glx::QueryExtensionsStringRequest::try_parse_request(header, remaining)?)), glx::QUERY_SERVER_STRING_REQUEST => return Ok(Request::GlxQueryServerString(glx::QueryServerStringRequest::try_parse_request(header, remaining)?)), glx::CLIENT_INFO_REQUEST => return Ok(Request::GlxClientInfo(glx::ClientInfoRequest::try_parse_request(header, remaining)?)), glx::GET_FB_CONFIGS_REQUEST => return Ok(Request::GlxGetFBConfigs(glx::GetFBConfigsRequest::try_parse_request(header, remaining)?)), glx::CREATE_PIXMAP_REQUEST => return Ok(Request::GlxCreatePixmap(glx::CreatePixmapRequest::try_parse_request(header, remaining)?)), glx::DESTROY_PIXMAP_REQUEST => return Ok(Request::GlxDestroyPixmap(glx::DestroyPixmapRequest::try_parse_request(header, remaining)?)), glx::CREATE_NEW_CONTEXT_REQUEST => return Ok(Request::GlxCreateNewContext(glx::CreateNewContextRequest::try_parse_request(header, remaining)?)), glx::QUERY_CONTEXT_REQUEST => return Ok(Request::GlxQueryContext(glx::QueryContextRequest::try_parse_request(header, remaining)?)), glx::MAKE_CONTEXT_CURRENT_REQUEST => return Ok(Request::GlxMakeContextCurrent(glx::MakeContextCurrentRequest::try_parse_request(header, remaining)?)), glx::CREATE_PBUFFER_REQUEST => return Ok(Request::GlxCreatePbuffer(glx::CreatePbufferRequest::try_parse_request(header, remaining)?)), glx::DESTROY_PBUFFER_REQUEST => return Ok(Request::GlxDestroyPbuffer(glx::DestroyPbufferRequest::try_parse_request(header, remaining)?)), glx::GET_DRAWABLE_ATTRIBUTES_REQUEST => return Ok(Request::GlxGetDrawableAttributes(glx::GetDrawableAttributesRequest::try_parse_request(header, remaining)?)), glx::CHANGE_DRAWABLE_ATTRIBUTES_REQUEST => return Ok(Request::GlxChangeDrawableAttributes(glx::ChangeDrawableAttributesRequest::try_parse_request(header, remaining)?)), glx::CREATE_WINDOW_REQUEST => return Ok(Request::GlxCreateWindow(glx::CreateWindowRequest::try_parse_request(header, remaining)?)), glx::DELETE_WINDOW_REQUEST => return Ok(Request::GlxDeleteWindow(glx::DeleteWindowRequest::try_parse_request(header, remaining)?)), glx::SET_CLIENT_INFO_ARB_REQUEST => return Ok(Request::GlxSetClientInfoARB(glx::SetClientInfoARBRequest::try_parse_request(header, remaining)?)), glx::CREATE_CONTEXT_ATTRIBS_ARB_REQUEST => return Ok(Request::GlxCreateContextAttribsARB(glx::CreateContextAttribsARBRequest::try_parse_request(header, remaining)?)), glx::SET_CLIENT_INFO2_ARB_REQUEST => return Ok(Request::GlxSetClientInfo2ARB(glx::SetClientInfo2ARBRequest::try_parse_request(header, remaining)?)), glx::NEW_LIST_REQUEST => return Ok(Request::GlxNewList(glx::NewListRequest::try_parse_request(header, remaining)?)), glx::END_LIST_REQUEST => return Ok(Request::GlxEndList(glx::EndListRequest::try_parse_request(header, remaining)?)), glx::DELETE_LISTS_REQUEST => return Ok(Request::GlxDeleteLists(glx::DeleteListsRequest::try_parse_request(header, remaining)?)), glx::GEN_LISTS_REQUEST => return Ok(Request::GlxGenLists(glx::GenListsRequest::try_parse_request(header, remaining)?)), glx::FEEDBACK_BUFFER_REQUEST => return Ok(Request::GlxFeedbackBuffer(glx::FeedbackBufferRequest::try_parse_request(header, remaining)?)), glx::SELECT_BUFFER_REQUEST => return Ok(Request::GlxSelectBuffer(glx::SelectBufferRequest::try_parse_request(header, remaining)?)), glx::RENDER_MODE_REQUEST => return Ok(Request::GlxRenderMode(glx::RenderModeRequest::try_parse_request(header, remaining)?)), glx::FINISH_REQUEST => return Ok(Request::GlxFinish(glx::FinishRequest::try_parse_request(header, remaining)?)), glx::PIXEL_STOREF_REQUEST => return Ok(Request::GlxPixelStoref(glx::PixelStorefRequest::try_parse_request(header, remaining)?)), glx::PIXEL_STOREI_REQUEST => return Ok(Request::GlxPixelStorei(glx::PixelStoreiRequest::try_parse_request(header, remaining)?)), glx::READ_PIXELS_REQUEST => return Ok(Request::GlxReadPixels(glx::ReadPixelsRequest::try_parse_request(header, remaining)?)), glx::GET_BOOLEANV_REQUEST => return Ok(Request::GlxGetBooleanv(glx::GetBooleanvRequest::try_parse_request(header, remaining)?)), glx::GET_CLIP_PLANE_REQUEST => return Ok(Request::GlxGetClipPlane(glx::GetClipPlaneRequest::try_parse_request(header, remaining)?)), glx::GET_DOUBLEV_REQUEST => return Ok(Request::GlxGetDoublev(glx::GetDoublevRequest::try_parse_request(header, remaining)?)), glx::GET_ERROR_REQUEST => return Ok(Request::GlxGetError(glx::GetErrorRequest::try_parse_request(header, remaining)?)), glx::GET_FLOATV_REQUEST => return Ok(Request::GlxGetFloatv(glx::GetFloatvRequest::try_parse_request(header, remaining)?)), glx::GET_INTEGERV_REQUEST => return Ok(Request::GlxGetIntegerv(glx::GetIntegervRequest::try_parse_request(header, remaining)?)), glx::GET_LIGHTFV_REQUEST => return Ok(Request::GlxGetLightfv(glx::GetLightfvRequest::try_parse_request(header, remaining)?)), glx::GET_LIGHTIV_REQUEST => return Ok(Request::GlxGetLightiv(glx::GetLightivRequest::try_parse_request(header, remaining)?)), glx::GET_MAPDV_REQUEST => return Ok(Request::GlxGetMapdv(glx::GetMapdvRequest::try_parse_request(header, remaining)?)), glx::GET_MAPFV_REQUEST => return Ok(Request::GlxGetMapfv(glx::GetMapfvRequest::try_parse_request(header, remaining)?)), glx::GET_MAPIV_REQUEST => return Ok(Request::GlxGetMapiv(glx::GetMapivRequest::try_parse_request(header, remaining)?)), glx::GET_MATERIALFV_REQUEST => return Ok(Request::GlxGetMaterialfv(glx::GetMaterialfvRequest::try_parse_request(header, remaining)?)), glx::GET_MATERIALIV_REQUEST => return Ok(Request::GlxGetMaterialiv(glx::GetMaterialivRequest::try_parse_request(header, remaining)?)), glx::GET_PIXEL_MAPFV_REQUEST => return Ok(Request::GlxGetPixelMapfv(glx::GetPixelMapfvRequest::try_parse_request(header, remaining)?)), glx::GET_PIXEL_MAPUIV_REQUEST => return Ok(Request::GlxGetPixelMapuiv(glx::GetPixelMapuivRequest::try_parse_request(header, remaining)?)), glx::GET_PIXEL_MAPUSV_REQUEST => return Ok(Request::GlxGetPixelMapusv(glx::GetPixelMapusvRequest::try_parse_request(header, remaining)?)), glx::GET_POLYGON_STIPPLE_REQUEST => return Ok(Request::GlxGetPolygonStipple(glx::GetPolygonStippleRequest::try_parse_request(header, remaining)?)), glx::GET_STRING_REQUEST => return Ok(Request::GlxGetString(glx::GetStringRequest::try_parse_request(header, remaining)?)), glx::GET_TEX_ENVFV_REQUEST => return Ok(Request::GlxGetTexEnvfv(glx::GetTexEnvfvRequest::try_parse_request(header, remaining)?)), glx::GET_TEX_ENVIV_REQUEST => return Ok(Request::GlxGetTexEnviv(glx::GetTexEnvivRequest::try_parse_request(header, remaining)?)), glx::GET_TEX_GENDV_REQUEST => return Ok(Request::GlxGetTexGendv(glx::GetTexGendvRequest::try_parse_request(header, remaining)?)), glx::GET_TEX_GENFV_REQUEST => return Ok(Request::GlxGetTexGenfv(glx::GetTexGenfvRequest::try_parse_request(header, remaining)?)), glx::GET_TEX_GENIV_REQUEST => return Ok(Request::GlxGetTexGeniv(glx::GetTexGenivRequest::try_parse_request(header, remaining)?)), glx::GET_TEX_IMAGE_REQUEST => return Ok(Request::GlxGetTexImage(glx::GetTexImageRequest::try_parse_request(header, remaining)?)), glx::GET_TEX_PARAMETERFV_REQUEST => return Ok(Request::GlxGetTexParameterfv(glx::GetTexParameterfvRequest::try_parse_request(header, remaining)?)), glx::GET_TEX_PARAMETERIV_REQUEST => return Ok(Request::GlxGetTexParameteriv(glx::GetTexParameterivRequest::try_parse_request(header, remaining)?)), glx::GET_TEX_LEVEL_PARAMETERFV_REQUEST => return Ok(Request::GlxGetTexLevelParameterfv(glx::GetTexLevelParameterfvRequest::try_parse_request(header, remaining)?)), glx::GET_TEX_LEVEL_PARAMETERIV_REQUEST => return Ok(Request::GlxGetTexLevelParameteriv(glx::GetTexLevelParameterivRequest::try_parse_request(header, remaining)?)), glx::IS_ENABLED_REQUEST => return Ok(Request::GlxIsEnabled(glx::IsEnabledRequest::try_parse_request(header, remaining)?)), glx::IS_LIST_REQUEST => return Ok(Request::GlxIsList(glx::IsListRequest::try_parse_request(header, remaining)?)), glx::FLUSH_REQUEST => return Ok(Request::GlxFlush(glx::FlushRequest::try_parse_request(header, remaining)?)), glx::ARE_TEXTURES_RESIDENT_REQUEST => return Ok(Request::GlxAreTexturesResident(glx::AreTexturesResidentRequest::try_parse_request(header, remaining)?)), glx::DELETE_TEXTURES_REQUEST => return Ok(Request::GlxDeleteTextures(glx::DeleteTexturesRequest::try_parse_request(header, remaining)?)), glx::GEN_TEXTURES_REQUEST => return Ok(Request::GlxGenTextures(glx::GenTexturesRequest::try_parse_request(header, remaining)?)), glx::IS_TEXTURE_REQUEST => return Ok(Request::GlxIsTexture(glx::IsTextureRequest::try_parse_request(header, remaining)?)), glx::GET_COLOR_TABLE_REQUEST => return Ok(Request::GlxGetColorTable(glx::GetColorTableRequest::try_parse_request(header, remaining)?)), glx::GET_COLOR_TABLE_PARAMETERFV_REQUEST => return Ok(Request::GlxGetColorTableParameterfv(glx::GetColorTableParameterfvRequest::try_parse_request(header, remaining)?)), glx::GET_COLOR_TABLE_PARAMETERIV_REQUEST => return Ok(Request::GlxGetColorTableParameteriv(glx::GetColorTableParameterivRequest::try_parse_request(header, remaining)?)), glx::GET_CONVOLUTION_FILTER_REQUEST => return Ok(Request::GlxGetConvolutionFilter(glx::GetConvolutionFilterRequest::try_parse_request(header, remaining)?)), glx::GET_CONVOLUTION_PARAMETERFV_REQUEST => return Ok(Request::GlxGetConvolutionParameterfv(glx::GetConvolutionParameterfvRequest::try_parse_request(header, remaining)?)), glx::GET_CONVOLUTION_PARAMETERIV_REQUEST => return Ok(Request::GlxGetConvolutionParameteriv(glx::GetConvolutionParameterivRequest::try_parse_request(header, remaining)?)), glx::GET_SEPARABLE_FILTER_REQUEST => return Ok(Request::GlxGetSeparableFilter(glx::GetSeparableFilterRequest::try_parse_request(header, remaining)?)), glx::GET_HISTOGRAM_REQUEST => return Ok(Request::GlxGetHistogram(glx::GetHistogramRequest::try_parse_request(header, remaining)?)), glx::GET_HISTOGRAM_PARAMETERFV_REQUEST => return Ok(Request::GlxGetHistogramParameterfv(glx::GetHistogramParameterfvRequest::try_parse_request(header, remaining)?)), glx::GET_HISTOGRAM_PARAMETERIV_REQUEST => return Ok(Request::GlxGetHistogramParameteriv(glx::GetHistogramParameterivRequest::try_parse_request(header, remaining)?)), glx::GET_MINMAX_REQUEST => return Ok(Request::GlxGetMinmax(glx::GetMinmaxRequest::try_parse_request(header, remaining)?)), glx::GET_MINMAX_PARAMETERFV_REQUEST => return Ok(Request::GlxGetMinmaxParameterfv(glx::GetMinmaxParameterfvRequest::try_parse_request(header, remaining)?)), glx::GET_MINMAX_PARAMETERIV_REQUEST => return Ok(Request::GlxGetMinmaxParameteriv(glx::GetMinmaxParameterivRequest::try_parse_request(header, remaining)?)), glx::GET_COMPRESSED_TEX_IMAGE_ARB_REQUEST => return Ok(Request::GlxGetCompressedTexImageARB(glx::GetCompressedTexImageARBRequest::try_parse_request(header, remaining)?)), glx::DELETE_QUERIES_ARB_REQUEST => return Ok(Request::GlxDeleteQueriesARB(glx::DeleteQueriesARBRequest::try_parse_request(header, remaining)?)), glx::GEN_QUERIES_ARB_REQUEST => return Ok(Request::GlxGenQueriesARB(glx::GenQueriesARBRequest::try_parse_request(header, remaining)?)), glx::IS_QUERY_ARB_REQUEST => return Ok(Request::GlxIsQueryARB(glx::IsQueryARBRequest::try_parse_request(header, remaining)?)), glx::GET_QUERYIV_ARB_REQUEST => return Ok(Request::GlxGetQueryivARB(glx::GetQueryivARBRequest::try_parse_request(header, remaining)?)), glx::GET_QUERY_OBJECTIV_ARB_REQUEST => return Ok(Request::GlxGetQueryObjectivARB(glx::GetQueryObjectivARBRequest::try_parse_request(header, remaining)?)), glx::GET_QUERY_OBJECTUIV_ARB_REQUEST => return Ok(Request::GlxGetQueryObjectuivARB(glx::GetQueryObjectuivARBRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "present")] Some((present::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { present::QUERY_VERSION_REQUEST => return Ok(Request::PresentQueryVersion(present::QueryVersionRequest::try_parse_request(header, remaining)?)), present::PIXMAP_REQUEST => return Ok(Request::PresentPixmap(present::PixmapRequest::try_parse_request(header, remaining)?)), present::NOTIFY_MSC_REQUEST => return Ok(Request::PresentNotifyMSC(present::NotifyMSCRequest::try_parse_request(header, remaining)?)), present::SELECT_INPUT_REQUEST => return Ok(Request::PresentSelectInput(present::SelectInputRequest::try_parse_request(header, remaining)?)), present::QUERY_CAPABILITIES_REQUEST => return Ok(Request::PresentQueryCapabilities(present::QueryCapabilitiesRequest::try_parse_request(header, remaining)?)), present::PIXMAP_SYNCED_REQUEST => return Ok(Request::PresentPixmapSynced(present::PixmapSyncedRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "randr")] Some((randr::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { randr::QUERY_VERSION_REQUEST => return Ok(Request::RandrQueryVersion(randr::QueryVersionRequest::try_parse_request(header, remaining)?)), randr::SET_SCREEN_CONFIG_REQUEST => return Ok(Request::RandrSetScreenConfig(randr::SetScreenConfigRequest::try_parse_request(header, remaining)?)), randr::SELECT_INPUT_REQUEST => return Ok(Request::RandrSelectInput(randr::SelectInputRequest::try_parse_request(header, remaining)?)), randr::GET_SCREEN_INFO_REQUEST => return Ok(Request::RandrGetScreenInfo(randr::GetScreenInfoRequest::try_parse_request(header, remaining)?)), randr::GET_SCREEN_SIZE_RANGE_REQUEST => return Ok(Request::RandrGetScreenSizeRange(randr::GetScreenSizeRangeRequest::try_parse_request(header, remaining)?)), randr::SET_SCREEN_SIZE_REQUEST => return Ok(Request::RandrSetScreenSize(randr::SetScreenSizeRequest::try_parse_request(header, remaining)?)), randr::GET_SCREEN_RESOURCES_REQUEST => return Ok(Request::RandrGetScreenResources(randr::GetScreenResourcesRequest::try_parse_request(header, remaining)?)), randr::GET_OUTPUT_INFO_REQUEST => return Ok(Request::RandrGetOutputInfo(randr::GetOutputInfoRequest::try_parse_request(header, remaining)?)), randr::LIST_OUTPUT_PROPERTIES_REQUEST => return Ok(Request::RandrListOutputProperties(randr::ListOutputPropertiesRequest::try_parse_request(header, remaining)?)), randr::QUERY_OUTPUT_PROPERTY_REQUEST => return Ok(Request::RandrQueryOutputProperty(randr::QueryOutputPropertyRequest::try_parse_request(header, remaining)?)), randr::CONFIGURE_OUTPUT_PROPERTY_REQUEST => return Ok(Request::RandrConfigureOutputProperty(randr::ConfigureOutputPropertyRequest::try_parse_request(header, remaining)?)), randr::CHANGE_OUTPUT_PROPERTY_REQUEST => return Ok(Request::RandrChangeOutputProperty(randr::ChangeOutputPropertyRequest::try_parse_request(header, remaining)?)), randr::DELETE_OUTPUT_PROPERTY_REQUEST => return Ok(Request::RandrDeleteOutputProperty(randr::DeleteOutputPropertyRequest::try_parse_request(header, remaining)?)), randr::GET_OUTPUT_PROPERTY_REQUEST => return Ok(Request::RandrGetOutputProperty(randr::GetOutputPropertyRequest::try_parse_request(header, remaining)?)), randr::CREATE_MODE_REQUEST => return Ok(Request::RandrCreateMode(randr::CreateModeRequest::try_parse_request(header, remaining)?)), randr::DESTROY_MODE_REQUEST => return Ok(Request::RandrDestroyMode(randr::DestroyModeRequest::try_parse_request(header, remaining)?)), randr::ADD_OUTPUT_MODE_REQUEST => return Ok(Request::RandrAddOutputMode(randr::AddOutputModeRequest::try_parse_request(header, remaining)?)), randr::DELETE_OUTPUT_MODE_REQUEST => return Ok(Request::RandrDeleteOutputMode(randr::DeleteOutputModeRequest::try_parse_request(header, remaining)?)), randr::GET_CRTC_INFO_REQUEST => return Ok(Request::RandrGetCrtcInfo(randr::GetCrtcInfoRequest::try_parse_request(header, remaining)?)), randr::SET_CRTC_CONFIG_REQUEST => return Ok(Request::RandrSetCrtcConfig(randr::SetCrtcConfigRequest::try_parse_request(header, remaining)?)), randr::GET_CRTC_GAMMA_SIZE_REQUEST => return Ok(Request::RandrGetCrtcGammaSize(randr::GetCrtcGammaSizeRequest::try_parse_request(header, remaining)?)), randr::GET_CRTC_GAMMA_REQUEST => return Ok(Request::RandrGetCrtcGamma(randr::GetCrtcGammaRequest::try_parse_request(header, remaining)?)), randr::SET_CRTC_GAMMA_REQUEST => return Ok(Request::RandrSetCrtcGamma(randr::SetCrtcGammaRequest::try_parse_request(header, remaining)?)), randr::GET_SCREEN_RESOURCES_CURRENT_REQUEST => return Ok(Request::RandrGetScreenResourcesCurrent(randr::GetScreenResourcesCurrentRequest::try_parse_request(header, remaining)?)), randr::SET_CRTC_TRANSFORM_REQUEST => return Ok(Request::RandrSetCrtcTransform(randr::SetCrtcTransformRequest::try_parse_request(header, remaining)?)), randr::GET_CRTC_TRANSFORM_REQUEST => return Ok(Request::RandrGetCrtcTransform(randr::GetCrtcTransformRequest::try_parse_request(header, remaining)?)), randr::GET_PANNING_REQUEST => return Ok(Request::RandrGetPanning(randr::GetPanningRequest::try_parse_request(header, remaining)?)), randr::SET_PANNING_REQUEST => return Ok(Request::RandrSetPanning(randr::SetPanningRequest::try_parse_request(header, remaining)?)), randr::SET_OUTPUT_PRIMARY_REQUEST => return Ok(Request::RandrSetOutputPrimary(randr::SetOutputPrimaryRequest::try_parse_request(header, remaining)?)), randr::GET_OUTPUT_PRIMARY_REQUEST => return Ok(Request::RandrGetOutputPrimary(randr::GetOutputPrimaryRequest::try_parse_request(header, remaining)?)), randr::GET_PROVIDERS_REQUEST => return Ok(Request::RandrGetProviders(randr::GetProvidersRequest::try_parse_request(header, remaining)?)), randr::GET_PROVIDER_INFO_REQUEST => return Ok(Request::RandrGetProviderInfo(randr::GetProviderInfoRequest::try_parse_request(header, remaining)?)), randr::SET_PROVIDER_OFFLOAD_SINK_REQUEST => return Ok(Request::RandrSetProviderOffloadSink(randr::SetProviderOffloadSinkRequest::try_parse_request(header, remaining)?)), randr::SET_PROVIDER_OUTPUT_SOURCE_REQUEST => return Ok(Request::RandrSetProviderOutputSource(randr::SetProviderOutputSourceRequest::try_parse_request(header, remaining)?)), randr::LIST_PROVIDER_PROPERTIES_REQUEST => return Ok(Request::RandrListProviderProperties(randr::ListProviderPropertiesRequest::try_parse_request(header, remaining)?)), randr::QUERY_PROVIDER_PROPERTY_REQUEST => return Ok(Request::RandrQueryProviderProperty(randr::QueryProviderPropertyRequest::try_parse_request(header, remaining)?)), randr::CONFIGURE_PROVIDER_PROPERTY_REQUEST => return Ok(Request::RandrConfigureProviderProperty(randr::ConfigureProviderPropertyRequest::try_parse_request(header, remaining)?)), randr::CHANGE_PROVIDER_PROPERTY_REQUEST => return Ok(Request::RandrChangeProviderProperty(randr::ChangeProviderPropertyRequest::try_parse_request(header, remaining)?)), randr::DELETE_PROVIDER_PROPERTY_REQUEST => return Ok(Request::RandrDeleteProviderProperty(randr::DeleteProviderPropertyRequest::try_parse_request(header, remaining)?)), randr::GET_PROVIDER_PROPERTY_REQUEST => return Ok(Request::RandrGetProviderProperty(randr::GetProviderPropertyRequest::try_parse_request(header, remaining)?)), randr::GET_MONITORS_REQUEST => return Ok(Request::RandrGetMonitors(randr::GetMonitorsRequest::try_parse_request(header, remaining)?)), randr::SET_MONITOR_REQUEST => return Ok(Request::RandrSetMonitor(randr::SetMonitorRequest::try_parse_request(header, remaining)?)), randr::DELETE_MONITOR_REQUEST => return Ok(Request::RandrDeleteMonitor(randr::DeleteMonitorRequest::try_parse_request(header, remaining)?)), randr::CREATE_LEASE_REQUEST => return Ok(Request::RandrCreateLease(randr::CreateLeaseRequest::try_parse_request(header, remaining)?)), randr::FREE_LEASE_REQUEST => return Ok(Request::RandrFreeLease(randr::FreeLeaseRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "record")] Some((record::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { record::QUERY_VERSION_REQUEST => return Ok(Request::RecordQueryVersion(record::QueryVersionRequest::try_parse_request(header, remaining)?)), record::CREATE_CONTEXT_REQUEST => return Ok(Request::RecordCreateContext(record::CreateContextRequest::try_parse_request(header, remaining)?)), record::REGISTER_CLIENTS_REQUEST => return Ok(Request::RecordRegisterClients(record::RegisterClientsRequest::try_parse_request(header, remaining)?)), record::UNREGISTER_CLIENTS_REQUEST => return Ok(Request::RecordUnregisterClients(record::UnregisterClientsRequest::try_parse_request(header, remaining)?)), record::GET_CONTEXT_REQUEST => return Ok(Request::RecordGetContext(record::GetContextRequest::try_parse_request(header, remaining)?)), record::ENABLE_CONTEXT_REQUEST => return Ok(Request::RecordEnableContext(record::EnableContextRequest::try_parse_request(header, remaining)?)), record::DISABLE_CONTEXT_REQUEST => return Ok(Request::RecordDisableContext(record::DisableContextRequest::try_parse_request(header, remaining)?)), record::FREE_CONTEXT_REQUEST => return Ok(Request::RecordFreeContext(record::FreeContextRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "render")] Some((render::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { render::QUERY_VERSION_REQUEST => return Ok(Request::RenderQueryVersion(render::QueryVersionRequest::try_parse_request(header, remaining)?)), render::QUERY_PICT_FORMATS_REQUEST => return Ok(Request::RenderQueryPictFormats(render::QueryPictFormatsRequest::try_parse_request(header, remaining)?)), render::QUERY_PICT_INDEX_VALUES_REQUEST => return Ok(Request::RenderQueryPictIndexValues(render::QueryPictIndexValuesRequest::try_parse_request(header, remaining)?)), render::CREATE_PICTURE_REQUEST => return Ok(Request::RenderCreatePicture(render::CreatePictureRequest::try_parse_request(header, remaining)?)), render::CHANGE_PICTURE_REQUEST => return Ok(Request::RenderChangePicture(render::ChangePictureRequest::try_parse_request(header, remaining)?)), render::SET_PICTURE_CLIP_RECTANGLES_REQUEST => return Ok(Request::RenderSetPictureClipRectangles(render::SetPictureClipRectanglesRequest::try_parse_request(header, remaining)?)), render::FREE_PICTURE_REQUEST => return Ok(Request::RenderFreePicture(render::FreePictureRequest::try_parse_request(header, remaining)?)), render::COMPOSITE_REQUEST => return Ok(Request::RenderComposite(render::CompositeRequest::try_parse_request(header, remaining)?)), render::TRAPEZOIDS_REQUEST => return Ok(Request::RenderTrapezoids(render::TrapezoidsRequest::try_parse_request(header, remaining)?)), render::TRIANGLES_REQUEST => return Ok(Request::RenderTriangles(render::TrianglesRequest::try_parse_request(header, remaining)?)), render::TRI_STRIP_REQUEST => return Ok(Request::RenderTriStrip(render::TriStripRequest::try_parse_request(header, remaining)?)), render::TRI_FAN_REQUEST => return Ok(Request::RenderTriFan(render::TriFanRequest::try_parse_request(header, remaining)?)), render::CREATE_GLYPH_SET_REQUEST => return Ok(Request::RenderCreateGlyphSet(render::CreateGlyphSetRequest::try_parse_request(header, remaining)?)), render::REFERENCE_GLYPH_SET_REQUEST => return Ok(Request::RenderReferenceGlyphSet(render::ReferenceGlyphSetRequest::try_parse_request(header, remaining)?)), render::FREE_GLYPH_SET_REQUEST => return Ok(Request::RenderFreeGlyphSet(render::FreeGlyphSetRequest::try_parse_request(header, remaining)?)), render::ADD_GLYPHS_REQUEST => return Ok(Request::RenderAddGlyphs(render::AddGlyphsRequest::try_parse_request(header, remaining)?)), render::FREE_GLYPHS_REQUEST => return Ok(Request::RenderFreeGlyphs(render::FreeGlyphsRequest::try_parse_request(header, remaining)?)), render::COMPOSITE_GLYPHS8_REQUEST => return Ok(Request::RenderCompositeGlyphs8(render::CompositeGlyphs8Request::try_parse_request(header, remaining)?)), render::COMPOSITE_GLYPHS16_REQUEST => return Ok(Request::RenderCompositeGlyphs16(render::CompositeGlyphs16Request::try_parse_request(header, remaining)?)), render::COMPOSITE_GLYPHS32_REQUEST => return Ok(Request::RenderCompositeGlyphs32(render::CompositeGlyphs32Request::try_parse_request(header, remaining)?)), render::FILL_RECTANGLES_REQUEST => return Ok(Request::RenderFillRectangles(render::FillRectanglesRequest::try_parse_request(header, remaining)?)), render::CREATE_CURSOR_REQUEST => return Ok(Request::RenderCreateCursor(render::CreateCursorRequest::try_parse_request(header, remaining)?)), render::SET_PICTURE_TRANSFORM_REQUEST => return Ok(Request::RenderSetPictureTransform(render::SetPictureTransformRequest::try_parse_request(header, remaining)?)), render::QUERY_FILTERS_REQUEST => return Ok(Request::RenderQueryFilters(render::QueryFiltersRequest::try_parse_request(header, remaining)?)), render::SET_PICTURE_FILTER_REQUEST => return Ok(Request::RenderSetPictureFilter(render::SetPictureFilterRequest::try_parse_request(header, remaining)?)), render::CREATE_ANIM_CURSOR_REQUEST => return Ok(Request::RenderCreateAnimCursor(render::CreateAnimCursorRequest::try_parse_request(header, remaining)?)), render::ADD_TRAPS_REQUEST => return Ok(Request::RenderAddTraps(render::AddTrapsRequest::try_parse_request(header, remaining)?)), render::CREATE_SOLID_FILL_REQUEST => return Ok(Request::RenderCreateSolidFill(render::CreateSolidFillRequest::try_parse_request(header, remaining)?)), render::CREATE_LINEAR_GRADIENT_REQUEST => return Ok(Request::RenderCreateLinearGradient(render::CreateLinearGradientRequest::try_parse_request(header, remaining)?)), render::CREATE_RADIAL_GRADIENT_REQUEST => return Ok(Request::RenderCreateRadialGradient(render::CreateRadialGradientRequest::try_parse_request(header, remaining)?)), render::CREATE_CONICAL_GRADIENT_REQUEST => return Ok(Request::RenderCreateConicalGradient(render::CreateConicalGradientRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "res")] Some((res::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { res::QUERY_VERSION_REQUEST => return Ok(Request::ResQueryVersion(res::QueryVersionRequest::try_parse_request(header, remaining)?)), res::QUERY_CLIENTS_REQUEST => return Ok(Request::ResQueryClients(res::QueryClientsRequest::try_parse_request(header, remaining)?)), res::QUERY_CLIENT_RESOURCES_REQUEST => return Ok(Request::ResQueryClientResources(res::QueryClientResourcesRequest::try_parse_request(header, remaining)?)), res::QUERY_CLIENT_PIXMAP_BYTES_REQUEST => return Ok(Request::ResQueryClientPixmapBytes(res::QueryClientPixmapBytesRequest::try_parse_request(header, remaining)?)), res::QUERY_CLIENT_IDS_REQUEST => return Ok(Request::ResQueryClientIds(res::QueryClientIdsRequest::try_parse_request(header, remaining)?)), res::QUERY_RESOURCE_BYTES_REQUEST => return Ok(Request::ResQueryResourceBytes(res::QueryResourceBytesRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "screensaver")] Some((screensaver::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { screensaver::QUERY_VERSION_REQUEST => return Ok(Request::ScreensaverQueryVersion(screensaver::QueryVersionRequest::try_parse_request(header, remaining)?)), screensaver::QUERY_INFO_REQUEST => return Ok(Request::ScreensaverQueryInfo(screensaver::QueryInfoRequest::try_parse_request(header, remaining)?)), screensaver::SELECT_INPUT_REQUEST => return Ok(Request::ScreensaverSelectInput(screensaver::SelectInputRequest::try_parse_request(header, remaining)?)), screensaver::SET_ATTRIBUTES_REQUEST => return Ok(Request::ScreensaverSetAttributes(screensaver::SetAttributesRequest::try_parse_request(header, remaining)?)), screensaver::UNSET_ATTRIBUTES_REQUEST => return Ok(Request::ScreensaverUnsetAttributes(screensaver::UnsetAttributesRequest::try_parse_request(header, remaining)?)), screensaver::SUSPEND_REQUEST => return Ok(Request::ScreensaverSuspend(screensaver::SuspendRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "shape")] Some((shape::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { shape::QUERY_VERSION_REQUEST => return Ok(Request::ShapeQueryVersion(shape::QueryVersionRequest::try_parse_request(header, remaining)?)), shape::RECTANGLES_REQUEST => return Ok(Request::ShapeRectangles(shape::RectanglesRequest::try_parse_request(header, remaining)?)), shape::MASK_REQUEST => return Ok(Request::ShapeMask(shape::MaskRequest::try_parse_request(header, remaining)?)), shape::COMBINE_REQUEST => return Ok(Request::ShapeCombine(shape::CombineRequest::try_parse_request(header, remaining)?)), shape::OFFSET_REQUEST => return Ok(Request::ShapeOffset(shape::OffsetRequest::try_parse_request(header, remaining)?)), shape::QUERY_EXTENTS_REQUEST => return Ok(Request::ShapeQueryExtents(shape::QueryExtentsRequest::try_parse_request(header, remaining)?)), shape::SELECT_INPUT_REQUEST => return Ok(Request::ShapeSelectInput(shape::SelectInputRequest::try_parse_request(header, remaining)?)), shape::INPUT_SELECTED_REQUEST => return Ok(Request::ShapeInputSelected(shape::InputSelectedRequest::try_parse_request(header, remaining)?)), shape::GET_RECTANGLES_REQUEST => return Ok(Request::ShapeGetRectangles(shape::GetRectanglesRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "shm")] Some((shm::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { shm::QUERY_VERSION_REQUEST => return Ok(Request::ShmQueryVersion(shm::QueryVersionRequest::try_parse_request(header, remaining)?)), shm::ATTACH_REQUEST => return Ok(Request::ShmAttach(shm::AttachRequest::try_parse_request(header, remaining)?)), shm::DETACH_REQUEST => return Ok(Request::ShmDetach(shm::DetachRequest::try_parse_request(header, remaining)?)), shm::PUT_IMAGE_REQUEST => return Ok(Request::ShmPutImage(shm::PutImageRequest::try_parse_request(header, remaining)?)), shm::GET_IMAGE_REQUEST => return Ok(Request::ShmGetImage(shm::GetImageRequest::try_parse_request(header, remaining)?)), shm::CREATE_PIXMAP_REQUEST => return Ok(Request::ShmCreatePixmap(shm::CreatePixmapRequest::try_parse_request(header, remaining)?)), shm::ATTACH_FD_REQUEST => return Ok(Request::ShmAttachFd(shm::AttachFdRequest::try_parse_request_fd(header, remaining, fds)?)), shm::CREATE_SEGMENT_REQUEST => return Ok(Request::ShmCreateSegment(shm::CreateSegmentRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "sync")] Some((sync::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { sync::INITIALIZE_REQUEST => return Ok(Request::SyncInitialize(sync::InitializeRequest::try_parse_request(header, remaining)?)), sync::LIST_SYSTEM_COUNTERS_REQUEST => return Ok(Request::SyncListSystemCounters(sync::ListSystemCountersRequest::try_parse_request(header, remaining)?)), sync::CREATE_COUNTER_REQUEST => return Ok(Request::SyncCreateCounter(sync::CreateCounterRequest::try_parse_request(header, remaining)?)), sync::DESTROY_COUNTER_REQUEST => return Ok(Request::SyncDestroyCounter(sync::DestroyCounterRequest::try_parse_request(header, remaining)?)), sync::QUERY_COUNTER_REQUEST => return Ok(Request::SyncQueryCounter(sync::QueryCounterRequest::try_parse_request(header, remaining)?)), sync::AWAIT_REQUEST => return Ok(Request::SyncAwait(sync::AwaitRequest::try_parse_request(header, remaining)?)), sync::CHANGE_COUNTER_REQUEST => return Ok(Request::SyncChangeCounter(sync::ChangeCounterRequest::try_parse_request(header, remaining)?)), sync::SET_COUNTER_REQUEST => return Ok(Request::SyncSetCounter(sync::SetCounterRequest::try_parse_request(header, remaining)?)), sync::CREATE_ALARM_REQUEST => return Ok(Request::SyncCreateAlarm(sync::CreateAlarmRequest::try_parse_request(header, remaining)?)), sync::CHANGE_ALARM_REQUEST => return Ok(Request::SyncChangeAlarm(sync::ChangeAlarmRequest::try_parse_request(header, remaining)?)), sync::DESTROY_ALARM_REQUEST => return Ok(Request::SyncDestroyAlarm(sync::DestroyAlarmRequest::try_parse_request(header, remaining)?)), sync::QUERY_ALARM_REQUEST => return Ok(Request::SyncQueryAlarm(sync::QueryAlarmRequest::try_parse_request(header, remaining)?)), sync::SET_PRIORITY_REQUEST => return Ok(Request::SyncSetPriority(sync::SetPriorityRequest::try_parse_request(header, remaining)?)), sync::GET_PRIORITY_REQUEST => return Ok(Request::SyncGetPriority(sync::GetPriorityRequest::try_parse_request(header, remaining)?)), sync::CREATE_FENCE_REQUEST => return Ok(Request::SyncCreateFence(sync::CreateFenceRequest::try_parse_request(header, remaining)?)), sync::TRIGGER_FENCE_REQUEST => return Ok(Request::SyncTriggerFence(sync::TriggerFenceRequest::try_parse_request(header, remaining)?)), sync::RESET_FENCE_REQUEST => return Ok(Request::SyncResetFence(sync::ResetFenceRequest::try_parse_request(header, remaining)?)), sync::DESTROY_FENCE_REQUEST => return Ok(Request::SyncDestroyFence(sync::DestroyFenceRequest::try_parse_request(header, remaining)?)), sync::QUERY_FENCE_REQUEST => return Ok(Request::SyncQueryFence(sync::QueryFenceRequest::try_parse_request(header, remaining)?)), sync::AWAIT_FENCE_REQUEST => return Ok(Request::SyncAwaitFence(sync::AwaitFenceRequest::try_parse_request(header, remaining)?)), _ => (), } } Some((xc_misc::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { xc_misc::GET_VERSION_REQUEST => return Ok(Request::XcMiscGetVersion(xc_misc::GetVersionRequest::try_parse_request(header, remaining)?)), xc_misc::GET_XID_RANGE_REQUEST => return Ok(Request::XcMiscGetXIDRange(xc_misc::GetXIDRangeRequest::try_parse_request(header, remaining)?)), xc_misc::GET_XID_LIST_REQUEST => return Ok(Request::XcMiscGetXIDList(xc_misc::GetXIDListRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "xevie")] Some((xevie::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { xevie::QUERY_VERSION_REQUEST => return Ok(Request::XevieQueryVersion(xevie::QueryVersionRequest::try_parse_request(header, remaining)?)), xevie::START_REQUEST => return Ok(Request::XevieStart(xevie::StartRequest::try_parse_request(header, remaining)?)), xevie::END_REQUEST => return Ok(Request::XevieEnd(xevie::EndRequest::try_parse_request(header, remaining)?)), xevie::SEND_REQUEST => return Ok(Request::XevieSend(xevie::SendRequest::try_parse_request(header, remaining)?)), xevie::SELECT_INPUT_REQUEST => return Ok(Request::XevieSelectInput(xevie::SelectInputRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "xf86dri")] Some((xf86dri::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { xf86dri::QUERY_VERSION_REQUEST => return Ok(Request::Xf86driQueryVersion(xf86dri::QueryVersionRequest::try_parse_request(header, remaining)?)), xf86dri::QUERY_DIRECT_RENDERING_CAPABLE_REQUEST => return Ok(Request::Xf86driQueryDirectRenderingCapable(xf86dri::QueryDirectRenderingCapableRequest::try_parse_request(header, remaining)?)), xf86dri::OPEN_CONNECTION_REQUEST => return Ok(Request::Xf86driOpenConnection(xf86dri::OpenConnectionRequest::try_parse_request(header, remaining)?)), xf86dri::CLOSE_CONNECTION_REQUEST => return Ok(Request::Xf86driCloseConnection(xf86dri::CloseConnectionRequest::try_parse_request(header, remaining)?)), xf86dri::GET_CLIENT_DRIVER_NAME_REQUEST => return Ok(Request::Xf86driGetClientDriverName(xf86dri::GetClientDriverNameRequest::try_parse_request(header, remaining)?)), xf86dri::CREATE_CONTEXT_REQUEST => return Ok(Request::Xf86driCreateContext(xf86dri::CreateContextRequest::try_parse_request(header, remaining)?)), xf86dri::DESTROY_CONTEXT_REQUEST => return Ok(Request::Xf86driDestroyContext(xf86dri::DestroyContextRequest::try_parse_request(header, remaining)?)), xf86dri::CREATE_DRAWABLE_REQUEST => return Ok(Request::Xf86driCreateDrawable(xf86dri::CreateDrawableRequest::try_parse_request(header, remaining)?)), xf86dri::DESTROY_DRAWABLE_REQUEST => return Ok(Request::Xf86driDestroyDrawable(xf86dri::DestroyDrawableRequest::try_parse_request(header, remaining)?)), xf86dri::GET_DRAWABLE_INFO_REQUEST => return Ok(Request::Xf86driGetDrawableInfo(xf86dri::GetDrawableInfoRequest::try_parse_request(header, remaining)?)), xf86dri::GET_DEVICE_INFO_REQUEST => return Ok(Request::Xf86driGetDeviceInfo(xf86dri::GetDeviceInfoRequest::try_parse_request(header, remaining)?)), xf86dri::AUTH_CONNECTION_REQUEST => return Ok(Request::Xf86driAuthConnection(xf86dri::AuthConnectionRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "xf86vidmode")] Some((xf86vidmode::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { xf86vidmode::QUERY_VERSION_REQUEST => return Ok(Request::Xf86vidmodeQueryVersion(xf86vidmode::QueryVersionRequest::try_parse_request(header, remaining)?)), xf86vidmode::GET_MODE_LINE_REQUEST => return Ok(Request::Xf86vidmodeGetModeLine(xf86vidmode::GetModeLineRequest::try_parse_request(header, remaining)?)), xf86vidmode::MOD_MODE_LINE_REQUEST => return Ok(Request::Xf86vidmodeModModeLine(xf86vidmode::ModModeLineRequest::try_parse_request(header, remaining)?)), xf86vidmode::SWITCH_MODE_REQUEST => return Ok(Request::Xf86vidmodeSwitchMode(xf86vidmode::SwitchModeRequest::try_parse_request(header, remaining)?)), xf86vidmode::GET_MONITOR_REQUEST => return Ok(Request::Xf86vidmodeGetMonitor(xf86vidmode::GetMonitorRequest::try_parse_request(header, remaining)?)), xf86vidmode::LOCK_MODE_SWITCH_REQUEST => return Ok(Request::Xf86vidmodeLockModeSwitch(xf86vidmode::LockModeSwitchRequest::try_parse_request(header, remaining)?)), xf86vidmode::GET_ALL_MODE_LINES_REQUEST => return Ok(Request::Xf86vidmodeGetAllModeLines(xf86vidmode::GetAllModeLinesRequest::try_parse_request(header, remaining)?)), xf86vidmode::ADD_MODE_LINE_REQUEST => return Ok(Request::Xf86vidmodeAddModeLine(xf86vidmode::AddModeLineRequest::try_parse_request(header, remaining)?)), xf86vidmode::DELETE_MODE_LINE_REQUEST => return Ok(Request::Xf86vidmodeDeleteModeLine(xf86vidmode::DeleteModeLineRequest::try_parse_request(header, remaining)?)), xf86vidmode::VALIDATE_MODE_LINE_REQUEST => return Ok(Request::Xf86vidmodeValidateModeLine(xf86vidmode::ValidateModeLineRequest::try_parse_request(header, remaining)?)), xf86vidmode::SWITCH_TO_MODE_REQUEST => return Ok(Request::Xf86vidmodeSwitchToMode(xf86vidmode::SwitchToModeRequest::try_parse_request(header, remaining)?)), xf86vidmode::GET_VIEW_PORT_REQUEST => return Ok(Request::Xf86vidmodeGetViewPort(xf86vidmode::GetViewPortRequest::try_parse_request(header, remaining)?)), xf86vidmode::SET_VIEW_PORT_REQUEST => return Ok(Request::Xf86vidmodeSetViewPort(xf86vidmode::SetViewPortRequest::try_parse_request(header, remaining)?)), xf86vidmode::GET_DOT_CLOCKS_REQUEST => return Ok(Request::Xf86vidmodeGetDotClocks(xf86vidmode::GetDotClocksRequest::try_parse_request(header, remaining)?)), xf86vidmode::SET_CLIENT_VERSION_REQUEST => return Ok(Request::Xf86vidmodeSetClientVersion(xf86vidmode::SetClientVersionRequest::try_parse_request(header, remaining)?)), xf86vidmode::SET_GAMMA_REQUEST => return Ok(Request::Xf86vidmodeSetGamma(xf86vidmode::SetGammaRequest::try_parse_request(header, remaining)?)), xf86vidmode::GET_GAMMA_REQUEST => return Ok(Request::Xf86vidmodeGetGamma(xf86vidmode::GetGammaRequest::try_parse_request(header, remaining)?)), xf86vidmode::GET_GAMMA_RAMP_REQUEST => return Ok(Request::Xf86vidmodeGetGammaRamp(xf86vidmode::GetGammaRampRequest::try_parse_request(header, remaining)?)), xf86vidmode::SET_GAMMA_RAMP_REQUEST => return Ok(Request::Xf86vidmodeSetGammaRamp(xf86vidmode::SetGammaRampRequest::try_parse_request(header, remaining)?)), xf86vidmode::GET_GAMMA_RAMP_SIZE_REQUEST => return Ok(Request::Xf86vidmodeGetGammaRampSize(xf86vidmode::GetGammaRampSizeRequest::try_parse_request(header, remaining)?)), xf86vidmode::GET_PERMISSIONS_REQUEST => return Ok(Request::Xf86vidmodeGetPermissions(xf86vidmode::GetPermissionsRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "xfixes")] Some((xfixes::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { xfixes::QUERY_VERSION_REQUEST => return Ok(Request::XfixesQueryVersion(xfixes::QueryVersionRequest::try_parse_request(header, remaining)?)), xfixes::CHANGE_SAVE_SET_REQUEST => return Ok(Request::XfixesChangeSaveSet(xfixes::ChangeSaveSetRequest::try_parse_request(header, remaining)?)), xfixes::SELECT_SELECTION_INPUT_REQUEST => return Ok(Request::XfixesSelectSelectionInput(xfixes::SelectSelectionInputRequest::try_parse_request(header, remaining)?)), xfixes::SELECT_CURSOR_INPUT_REQUEST => return Ok(Request::XfixesSelectCursorInput(xfixes::SelectCursorInputRequest::try_parse_request(header, remaining)?)), xfixes::GET_CURSOR_IMAGE_REQUEST => return Ok(Request::XfixesGetCursorImage(xfixes::GetCursorImageRequest::try_parse_request(header, remaining)?)), xfixes::CREATE_REGION_REQUEST => return Ok(Request::XfixesCreateRegion(xfixes::CreateRegionRequest::try_parse_request(header, remaining)?)), xfixes::CREATE_REGION_FROM_BITMAP_REQUEST => return Ok(Request::XfixesCreateRegionFromBitmap(xfixes::CreateRegionFromBitmapRequest::try_parse_request(header, remaining)?)), xfixes::CREATE_REGION_FROM_WINDOW_REQUEST => return Ok(Request::XfixesCreateRegionFromWindow(xfixes::CreateRegionFromWindowRequest::try_parse_request(header, remaining)?)), xfixes::CREATE_REGION_FROM_GC_REQUEST => return Ok(Request::XfixesCreateRegionFromGC(xfixes::CreateRegionFromGCRequest::try_parse_request(header, remaining)?)), xfixes::CREATE_REGION_FROM_PICTURE_REQUEST => return Ok(Request::XfixesCreateRegionFromPicture(xfixes::CreateRegionFromPictureRequest::try_parse_request(header, remaining)?)), xfixes::DESTROY_REGION_REQUEST => return Ok(Request::XfixesDestroyRegion(xfixes::DestroyRegionRequest::try_parse_request(header, remaining)?)), xfixes::SET_REGION_REQUEST => return Ok(Request::XfixesSetRegion(xfixes::SetRegionRequest::try_parse_request(header, remaining)?)), xfixes::COPY_REGION_REQUEST => return Ok(Request::XfixesCopyRegion(xfixes::CopyRegionRequest::try_parse_request(header, remaining)?)), xfixes::UNION_REGION_REQUEST => return Ok(Request::XfixesUnionRegion(xfixes::UnionRegionRequest::try_parse_request(header, remaining)?)), xfixes::INTERSECT_REGION_REQUEST => return Ok(Request::XfixesIntersectRegion(xfixes::IntersectRegionRequest::try_parse_request(header, remaining)?)), xfixes::SUBTRACT_REGION_REQUEST => return Ok(Request::XfixesSubtractRegion(xfixes::SubtractRegionRequest::try_parse_request(header, remaining)?)), xfixes::INVERT_REGION_REQUEST => return Ok(Request::XfixesInvertRegion(xfixes::InvertRegionRequest::try_parse_request(header, remaining)?)), xfixes::TRANSLATE_REGION_REQUEST => return Ok(Request::XfixesTranslateRegion(xfixes::TranslateRegionRequest::try_parse_request(header, remaining)?)), xfixes::REGION_EXTENTS_REQUEST => return Ok(Request::XfixesRegionExtents(xfixes::RegionExtentsRequest::try_parse_request(header, remaining)?)), xfixes::FETCH_REGION_REQUEST => return Ok(Request::XfixesFetchRegion(xfixes::FetchRegionRequest::try_parse_request(header, remaining)?)), xfixes::SET_GC_CLIP_REGION_REQUEST => return Ok(Request::XfixesSetGCClipRegion(xfixes::SetGCClipRegionRequest::try_parse_request(header, remaining)?)), xfixes::SET_WINDOW_SHAPE_REGION_REQUEST => return Ok(Request::XfixesSetWindowShapeRegion(xfixes::SetWindowShapeRegionRequest::try_parse_request(header, remaining)?)), xfixes::SET_PICTURE_CLIP_REGION_REQUEST => return Ok(Request::XfixesSetPictureClipRegion(xfixes::SetPictureClipRegionRequest::try_parse_request(header, remaining)?)), xfixes::SET_CURSOR_NAME_REQUEST => return Ok(Request::XfixesSetCursorName(xfixes::SetCursorNameRequest::try_parse_request(header, remaining)?)), xfixes::GET_CURSOR_NAME_REQUEST => return Ok(Request::XfixesGetCursorName(xfixes::GetCursorNameRequest::try_parse_request(header, remaining)?)), xfixes::GET_CURSOR_IMAGE_AND_NAME_REQUEST => return Ok(Request::XfixesGetCursorImageAndName(xfixes::GetCursorImageAndNameRequest::try_parse_request(header, remaining)?)), xfixes::CHANGE_CURSOR_REQUEST => return Ok(Request::XfixesChangeCursor(xfixes::ChangeCursorRequest::try_parse_request(header, remaining)?)), xfixes::CHANGE_CURSOR_BY_NAME_REQUEST => return Ok(Request::XfixesChangeCursorByName(xfixes::ChangeCursorByNameRequest::try_parse_request(header, remaining)?)), xfixes::EXPAND_REGION_REQUEST => return Ok(Request::XfixesExpandRegion(xfixes::ExpandRegionRequest::try_parse_request(header, remaining)?)), xfixes::HIDE_CURSOR_REQUEST => return Ok(Request::XfixesHideCursor(xfixes::HideCursorRequest::try_parse_request(header, remaining)?)), xfixes::SHOW_CURSOR_REQUEST => return Ok(Request::XfixesShowCursor(xfixes::ShowCursorRequest::try_parse_request(header, remaining)?)), xfixes::CREATE_POINTER_BARRIER_REQUEST => return Ok(Request::XfixesCreatePointerBarrier(xfixes::CreatePointerBarrierRequest::try_parse_request(header, remaining)?)), xfixes::DELETE_POINTER_BARRIER_REQUEST => return Ok(Request::XfixesDeletePointerBarrier(xfixes::DeletePointerBarrierRequest::try_parse_request(header, remaining)?)), xfixes::SET_CLIENT_DISCONNECT_MODE_REQUEST => return Ok(Request::XfixesSetClientDisconnectMode(xfixes::SetClientDisconnectModeRequest::try_parse_request(header, remaining)?)), xfixes::GET_CLIENT_DISCONNECT_MODE_REQUEST => return Ok(Request::XfixesGetClientDisconnectMode(xfixes::GetClientDisconnectModeRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "xinerama")] Some((xinerama::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { xinerama::QUERY_VERSION_REQUEST => return Ok(Request::XineramaQueryVersion(xinerama::QueryVersionRequest::try_parse_request(header, remaining)?)), xinerama::GET_STATE_REQUEST => return Ok(Request::XineramaGetState(xinerama::GetStateRequest::try_parse_request(header, remaining)?)), xinerama::GET_SCREEN_COUNT_REQUEST => return Ok(Request::XineramaGetScreenCount(xinerama::GetScreenCountRequest::try_parse_request(header, remaining)?)), xinerama::GET_SCREEN_SIZE_REQUEST => return Ok(Request::XineramaGetScreenSize(xinerama::GetScreenSizeRequest::try_parse_request(header, remaining)?)), xinerama::IS_ACTIVE_REQUEST => return Ok(Request::XineramaIsActive(xinerama::IsActiveRequest::try_parse_request(header, remaining)?)), xinerama::QUERY_SCREENS_REQUEST => return Ok(Request::XineramaQueryScreens(xinerama::QueryScreensRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "xinput")] Some((xinput::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { xinput::GET_EXTENSION_VERSION_REQUEST => return Ok(Request::XinputGetExtensionVersion(xinput::GetExtensionVersionRequest::try_parse_request(header, remaining)?)), xinput::LIST_INPUT_DEVICES_REQUEST => return Ok(Request::XinputListInputDevices(xinput::ListInputDevicesRequest::try_parse_request(header, remaining)?)), xinput::OPEN_DEVICE_REQUEST => return Ok(Request::XinputOpenDevice(xinput::OpenDeviceRequest::try_parse_request(header, remaining)?)), xinput::CLOSE_DEVICE_REQUEST => return Ok(Request::XinputCloseDevice(xinput::CloseDeviceRequest::try_parse_request(header, remaining)?)), xinput::SET_DEVICE_MODE_REQUEST => return Ok(Request::XinputSetDeviceMode(xinput::SetDeviceModeRequest::try_parse_request(header, remaining)?)), xinput::SELECT_EXTENSION_EVENT_REQUEST => return Ok(Request::XinputSelectExtensionEvent(xinput::SelectExtensionEventRequest::try_parse_request(header, remaining)?)), xinput::GET_SELECTED_EXTENSION_EVENTS_REQUEST => return Ok(Request::XinputGetSelectedExtensionEvents(xinput::GetSelectedExtensionEventsRequest::try_parse_request(header, remaining)?)), xinput::CHANGE_DEVICE_DONT_PROPAGATE_LIST_REQUEST => return Ok(Request::XinputChangeDeviceDontPropagateList(xinput::ChangeDeviceDontPropagateListRequest::try_parse_request(header, remaining)?)), xinput::GET_DEVICE_DONT_PROPAGATE_LIST_REQUEST => return Ok(Request::XinputGetDeviceDontPropagateList(xinput::GetDeviceDontPropagateListRequest::try_parse_request(header, remaining)?)), xinput::GET_DEVICE_MOTION_EVENTS_REQUEST => return Ok(Request::XinputGetDeviceMotionEvents(xinput::GetDeviceMotionEventsRequest::try_parse_request(header, remaining)?)), xinput::CHANGE_KEYBOARD_DEVICE_REQUEST => return Ok(Request::XinputChangeKeyboardDevice(xinput::ChangeKeyboardDeviceRequest::try_parse_request(header, remaining)?)), xinput::CHANGE_POINTER_DEVICE_REQUEST => return Ok(Request::XinputChangePointerDevice(xinput::ChangePointerDeviceRequest::try_parse_request(header, remaining)?)), xinput::GRAB_DEVICE_REQUEST => return Ok(Request::XinputGrabDevice(xinput::GrabDeviceRequest::try_parse_request(header, remaining)?)), xinput::UNGRAB_DEVICE_REQUEST => return Ok(Request::XinputUngrabDevice(xinput::UngrabDeviceRequest::try_parse_request(header, remaining)?)), xinput::GRAB_DEVICE_KEY_REQUEST => return Ok(Request::XinputGrabDeviceKey(xinput::GrabDeviceKeyRequest::try_parse_request(header, remaining)?)), xinput::UNGRAB_DEVICE_KEY_REQUEST => return Ok(Request::XinputUngrabDeviceKey(xinput::UngrabDeviceKeyRequest::try_parse_request(header, remaining)?)), xinput::GRAB_DEVICE_BUTTON_REQUEST => return Ok(Request::XinputGrabDeviceButton(xinput::GrabDeviceButtonRequest::try_parse_request(header, remaining)?)), xinput::UNGRAB_DEVICE_BUTTON_REQUEST => return Ok(Request::XinputUngrabDeviceButton(xinput::UngrabDeviceButtonRequest::try_parse_request(header, remaining)?)), xinput::ALLOW_DEVICE_EVENTS_REQUEST => return Ok(Request::XinputAllowDeviceEvents(xinput::AllowDeviceEventsRequest::try_parse_request(header, remaining)?)), xinput::GET_DEVICE_FOCUS_REQUEST => return Ok(Request::XinputGetDeviceFocus(xinput::GetDeviceFocusRequest::try_parse_request(header, remaining)?)), xinput::SET_DEVICE_FOCUS_REQUEST => return Ok(Request::XinputSetDeviceFocus(xinput::SetDeviceFocusRequest::try_parse_request(header, remaining)?)), xinput::GET_FEEDBACK_CONTROL_REQUEST => return Ok(Request::XinputGetFeedbackControl(xinput::GetFeedbackControlRequest::try_parse_request(header, remaining)?)), xinput::CHANGE_FEEDBACK_CONTROL_REQUEST => return Ok(Request::XinputChangeFeedbackControl(xinput::ChangeFeedbackControlRequest::try_parse_request(header, remaining)?)), xinput::GET_DEVICE_KEY_MAPPING_REQUEST => return Ok(Request::XinputGetDeviceKeyMapping(xinput::GetDeviceKeyMappingRequest::try_parse_request(header, remaining)?)), xinput::CHANGE_DEVICE_KEY_MAPPING_REQUEST => return Ok(Request::XinputChangeDeviceKeyMapping(xinput::ChangeDeviceKeyMappingRequest::try_parse_request(header, remaining)?)), xinput::GET_DEVICE_MODIFIER_MAPPING_REQUEST => return Ok(Request::XinputGetDeviceModifierMapping(xinput::GetDeviceModifierMappingRequest::try_parse_request(header, remaining)?)), xinput::SET_DEVICE_MODIFIER_MAPPING_REQUEST => return Ok(Request::XinputSetDeviceModifierMapping(xinput::SetDeviceModifierMappingRequest::try_parse_request(header, remaining)?)), xinput::GET_DEVICE_BUTTON_MAPPING_REQUEST => return Ok(Request::XinputGetDeviceButtonMapping(xinput::GetDeviceButtonMappingRequest::try_parse_request(header, remaining)?)), xinput::SET_DEVICE_BUTTON_MAPPING_REQUEST => return Ok(Request::XinputSetDeviceButtonMapping(xinput::SetDeviceButtonMappingRequest::try_parse_request(header, remaining)?)), xinput::QUERY_DEVICE_STATE_REQUEST => return Ok(Request::XinputQueryDeviceState(xinput::QueryDeviceStateRequest::try_parse_request(header, remaining)?)), xinput::DEVICE_BELL_REQUEST => return Ok(Request::XinputDeviceBell(xinput::DeviceBellRequest::try_parse_request(header, remaining)?)), xinput::SET_DEVICE_VALUATORS_REQUEST => return Ok(Request::XinputSetDeviceValuators(xinput::SetDeviceValuatorsRequest::try_parse_request(header, remaining)?)), xinput::GET_DEVICE_CONTROL_REQUEST => return Ok(Request::XinputGetDeviceControl(xinput::GetDeviceControlRequest::try_parse_request(header, remaining)?)), xinput::CHANGE_DEVICE_CONTROL_REQUEST => return Ok(Request::XinputChangeDeviceControl(xinput::ChangeDeviceControlRequest::try_parse_request(header, remaining)?)), xinput::LIST_DEVICE_PROPERTIES_REQUEST => return Ok(Request::XinputListDeviceProperties(xinput::ListDevicePropertiesRequest::try_parse_request(header, remaining)?)), xinput::CHANGE_DEVICE_PROPERTY_REQUEST => return Ok(Request::XinputChangeDeviceProperty(xinput::ChangeDevicePropertyRequest::try_parse_request(header, remaining)?)), xinput::DELETE_DEVICE_PROPERTY_REQUEST => return Ok(Request::XinputDeleteDeviceProperty(xinput::DeleteDevicePropertyRequest::try_parse_request(header, remaining)?)), xinput::GET_DEVICE_PROPERTY_REQUEST => return Ok(Request::XinputGetDeviceProperty(xinput::GetDevicePropertyRequest::try_parse_request(header, remaining)?)), xinput::XI_QUERY_POINTER_REQUEST => return Ok(Request::XinputXIQueryPointer(xinput::XIQueryPointerRequest::try_parse_request(header, remaining)?)), xinput::XI_WARP_POINTER_REQUEST => return Ok(Request::XinputXIWarpPointer(xinput::XIWarpPointerRequest::try_parse_request(header, remaining)?)), xinput::XI_CHANGE_CURSOR_REQUEST => return Ok(Request::XinputXIChangeCursor(xinput::XIChangeCursorRequest::try_parse_request(header, remaining)?)), xinput::XI_CHANGE_HIERARCHY_REQUEST => return Ok(Request::XinputXIChangeHierarchy(xinput::XIChangeHierarchyRequest::try_parse_request(header, remaining)?)), xinput::XI_SET_CLIENT_POINTER_REQUEST => return Ok(Request::XinputXISetClientPointer(xinput::XISetClientPointerRequest::try_parse_request(header, remaining)?)), xinput::XI_GET_CLIENT_POINTER_REQUEST => return Ok(Request::XinputXIGetClientPointer(xinput::XIGetClientPointerRequest::try_parse_request(header, remaining)?)), xinput::XI_SELECT_EVENTS_REQUEST => return Ok(Request::XinputXISelectEvents(xinput::XISelectEventsRequest::try_parse_request(header, remaining)?)), xinput::XI_QUERY_VERSION_REQUEST => return Ok(Request::XinputXIQueryVersion(xinput::XIQueryVersionRequest::try_parse_request(header, remaining)?)), xinput::XI_QUERY_DEVICE_REQUEST => return Ok(Request::XinputXIQueryDevice(xinput::XIQueryDeviceRequest::try_parse_request(header, remaining)?)), xinput::XI_SET_FOCUS_REQUEST => return Ok(Request::XinputXISetFocus(xinput::XISetFocusRequest::try_parse_request(header, remaining)?)), xinput::XI_GET_FOCUS_REQUEST => return Ok(Request::XinputXIGetFocus(xinput::XIGetFocusRequest::try_parse_request(header, remaining)?)), xinput::XI_GRAB_DEVICE_REQUEST => return Ok(Request::XinputXIGrabDevice(xinput::XIGrabDeviceRequest::try_parse_request(header, remaining)?)), xinput::XI_UNGRAB_DEVICE_REQUEST => return Ok(Request::XinputXIUngrabDevice(xinput::XIUngrabDeviceRequest::try_parse_request(header, remaining)?)), xinput::XI_ALLOW_EVENTS_REQUEST => return Ok(Request::XinputXIAllowEvents(xinput::XIAllowEventsRequest::try_parse_request(header, remaining)?)), xinput::XI_PASSIVE_GRAB_DEVICE_REQUEST => return Ok(Request::XinputXIPassiveGrabDevice(xinput::XIPassiveGrabDeviceRequest::try_parse_request(header, remaining)?)), xinput::XI_PASSIVE_UNGRAB_DEVICE_REQUEST => return Ok(Request::XinputXIPassiveUngrabDevice(xinput::XIPassiveUngrabDeviceRequest::try_parse_request(header, remaining)?)), xinput::XI_LIST_PROPERTIES_REQUEST => return Ok(Request::XinputXIListProperties(xinput::XIListPropertiesRequest::try_parse_request(header, remaining)?)), xinput::XI_CHANGE_PROPERTY_REQUEST => return Ok(Request::XinputXIChangeProperty(xinput::XIChangePropertyRequest::try_parse_request(header, remaining)?)), xinput::XI_DELETE_PROPERTY_REQUEST => return Ok(Request::XinputXIDeleteProperty(xinput::XIDeletePropertyRequest::try_parse_request(header, remaining)?)), xinput::XI_GET_PROPERTY_REQUEST => return Ok(Request::XinputXIGetProperty(xinput::XIGetPropertyRequest::try_parse_request(header, remaining)?)), xinput::XI_GET_SELECTED_EVENTS_REQUEST => return Ok(Request::XinputXIGetSelectedEvents(xinput::XIGetSelectedEventsRequest::try_parse_request(header, remaining)?)), xinput::XI_BARRIER_RELEASE_POINTER_REQUEST => return Ok(Request::XinputXIBarrierReleasePointer(xinput::XIBarrierReleasePointerRequest::try_parse_request(header, remaining)?)), xinput::SEND_EXTENSION_EVENT_REQUEST => return Ok(Request::XinputSendExtensionEvent(xinput::SendExtensionEventRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "xkb")] Some((xkb::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { xkb::USE_EXTENSION_REQUEST => return Ok(Request::XkbUseExtension(xkb::UseExtensionRequest::try_parse_request(header, remaining)?)), xkb::SELECT_EVENTS_REQUEST => return Ok(Request::XkbSelectEvents(xkb::SelectEventsRequest::try_parse_request(header, remaining)?)), xkb::BELL_REQUEST => return Ok(Request::XkbBell(xkb::BellRequest::try_parse_request(header, remaining)?)), xkb::GET_STATE_REQUEST => return Ok(Request::XkbGetState(xkb::GetStateRequest::try_parse_request(header, remaining)?)), xkb::LATCH_LOCK_STATE_REQUEST => return Ok(Request::XkbLatchLockState(xkb::LatchLockStateRequest::try_parse_request(header, remaining)?)), xkb::GET_CONTROLS_REQUEST => return Ok(Request::XkbGetControls(xkb::GetControlsRequest::try_parse_request(header, remaining)?)), xkb::SET_CONTROLS_REQUEST => return Ok(Request::XkbSetControls(xkb::SetControlsRequest::try_parse_request(header, remaining)?)), xkb::GET_MAP_REQUEST => return Ok(Request::XkbGetMap(xkb::GetMapRequest::try_parse_request(header, remaining)?)), xkb::SET_MAP_REQUEST => return Ok(Request::XkbSetMap(xkb::SetMapRequest::try_parse_request(header, remaining)?)), xkb::GET_COMPAT_MAP_REQUEST => return Ok(Request::XkbGetCompatMap(xkb::GetCompatMapRequest::try_parse_request(header, remaining)?)), xkb::SET_COMPAT_MAP_REQUEST => return Ok(Request::XkbSetCompatMap(xkb::SetCompatMapRequest::try_parse_request(header, remaining)?)), xkb::GET_INDICATOR_STATE_REQUEST => return Ok(Request::XkbGetIndicatorState(xkb::GetIndicatorStateRequest::try_parse_request(header, remaining)?)), xkb::GET_INDICATOR_MAP_REQUEST => return Ok(Request::XkbGetIndicatorMap(xkb::GetIndicatorMapRequest::try_parse_request(header, remaining)?)), xkb::SET_INDICATOR_MAP_REQUEST => return Ok(Request::XkbSetIndicatorMap(xkb::SetIndicatorMapRequest::try_parse_request(header, remaining)?)), xkb::GET_NAMED_INDICATOR_REQUEST => return Ok(Request::XkbGetNamedIndicator(xkb::GetNamedIndicatorRequest::try_parse_request(header, remaining)?)), xkb::SET_NAMED_INDICATOR_REQUEST => return Ok(Request::XkbSetNamedIndicator(xkb::SetNamedIndicatorRequest::try_parse_request(header, remaining)?)), xkb::GET_NAMES_REQUEST => return Ok(Request::XkbGetNames(xkb::GetNamesRequest::try_parse_request(header, remaining)?)), xkb::SET_NAMES_REQUEST => return Ok(Request::XkbSetNames(xkb::SetNamesRequest::try_parse_request(header, remaining)?)), xkb::PER_CLIENT_FLAGS_REQUEST => return Ok(Request::XkbPerClientFlags(xkb::PerClientFlagsRequest::try_parse_request(header, remaining)?)), xkb::LIST_COMPONENTS_REQUEST => return Ok(Request::XkbListComponents(xkb::ListComponentsRequest::try_parse_request(header, remaining)?)), xkb::GET_KBD_BY_NAME_REQUEST => return Ok(Request::XkbGetKbdByName(xkb::GetKbdByNameRequest::try_parse_request(header, remaining)?)), xkb::GET_DEVICE_INFO_REQUEST => return Ok(Request::XkbGetDeviceInfo(xkb::GetDeviceInfoRequest::try_parse_request(header, remaining)?)), xkb::SET_DEVICE_INFO_REQUEST => return Ok(Request::XkbSetDeviceInfo(xkb::SetDeviceInfoRequest::try_parse_request(header, remaining)?)), xkb::SET_DEBUGGING_FLAGS_REQUEST => return Ok(Request::XkbSetDebuggingFlags(xkb::SetDebuggingFlagsRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "xprint")] Some((xprint::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { xprint::PRINT_QUERY_VERSION_REQUEST => return Ok(Request::XprintPrintQueryVersion(xprint::PrintQueryVersionRequest::try_parse_request(header, remaining)?)), xprint::PRINT_GET_PRINTER_LIST_REQUEST => return Ok(Request::XprintPrintGetPrinterList(xprint::PrintGetPrinterListRequest::try_parse_request(header, remaining)?)), xprint::PRINT_REHASH_PRINTER_LIST_REQUEST => return Ok(Request::XprintPrintRehashPrinterList(xprint::PrintRehashPrinterListRequest::try_parse_request(header, remaining)?)), xprint::CREATE_CONTEXT_REQUEST => return Ok(Request::XprintCreateContext(xprint::CreateContextRequest::try_parse_request(header, remaining)?)), xprint::PRINT_SET_CONTEXT_REQUEST => return Ok(Request::XprintPrintSetContext(xprint::PrintSetContextRequest::try_parse_request(header, remaining)?)), xprint::PRINT_GET_CONTEXT_REQUEST => return Ok(Request::XprintPrintGetContext(xprint::PrintGetContextRequest::try_parse_request(header, remaining)?)), xprint::PRINT_DESTROY_CONTEXT_REQUEST => return Ok(Request::XprintPrintDestroyContext(xprint::PrintDestroyContextRequest::try_parse_request(header, remaining)?)), xprint::PRINT_GET_SCREEN_OF_CONTEXT_REQUEST => return Ok(Request::XprintPrintGetScreenOfContext(xprint::PrintGetScreenOfContextRequest::try_parse_request(header, remaining)?)), xprint::PRINT_START_JOB_REQUEST => return Ok(Request::XprintPrintStartJob(xprint::PrintStartJobRequest::try_parse_request(header, remaining)?)), xprint::PRINT_END_JOB_REQUEST => return Ok(Request::XprintPrintEndJob(xprint::PrintEndJobRequest::try_parse_request(header, remaining)?)), xprint::PRINT_START_DOC_REQUEST => return Ok(Request::XprintPrintStartDoc(xprint::PrintStartDocRequest::try_parse_request(header, remaining)?)), xprint::PRINT_END_DOC_REQUEST => return Ok(Request::XprintPrintEndDoc(xprint::PrintEndDocRequest::try_parse_request(header, remaining)?)), xprint::PRINT_PUT_DOCUMENT_DATA_REQUEST => return Ok(Request::XprintPrintPutDocumentData(xprint::PrintPutDocumentDataRequest::try_parse_request(header, remaining)?)), xprint::PRINT_GET_DOCUMENT_DATA_REQUEST => return Ok(Request::XprintPrintGetDocumentData(xprint::PrintGetDocumentDataRequest::try_parse_request(header, remaining)?)), xprint::PRINT_START_PAGE_REQUEST => return Ok(Request::XprintPrintStartPage(xprint::PrintStartPageRequest::try_parse_request(header, remaining)?)), xprint::PRINT_END_PAGE_REQUEST => return Ok(Request::XprintPrintEndPage(xprint::PrintEndPageRequest::try_parse_request(header, remaining)?)), xprint::PRINT_SELECT_INPUT_REQUEST => return Ok(Request::XprintPrintSelectInput(xprint::PrintSelectInputRequest::try_parse_request(header, remaining)?)), xprint::PRINT_INPUT_SELECTED_REQUEST => return Ok(Request::XprintPrintInputSelected(xprint::PrintInputSelectedRequest::try_parse_request(header, remaining)?)), xprint::PRINT_GET_ATTRIBUTES_REQUEST => return Ok(Request::XprintPrintGetAttributes(xprint::PrintGetAttributesRequest::try_parse_request(header, remaining)?)), xprint::PRINT_GET_ONE_ATTRIBUTES_REQUEST => return Ok(Request::XprintPrintGetOneAttributes(xprint::PrintGetOneAttributesRequest::try_parse_request(header, remaining)?)), xprint::PRINT_SET_ATTRIBUTES_REQUEST => return Ok(Request::XprintPrintSetAttributes(xprint::PrintSetAttributesRequest::try_parse_request(header, remaining)?)), xprint::PRINT_GET_PAGE_DIMENSIONS_REQUEST => return Ok(Request::XprintPrintGetPageDimensions(xprint::PrintGetPageDimensionsRequest::try_parse_request(header, remaining)?)), xprint::PRINT_QUERY_SCREENS_REQUEST => return Ok(Request::XprintPrintQueryScreens(xprint::PrintQueryScreensRequest::try_parse_request(header, remaining)?)), xprint::PRINT_SET_IMAGE_RESOLUTION_REQUEST => return Ok(Request::XprintPrintSetImageResolution(xprint::PrintSetImageResolutionRequest::try_parse_request(header, remaining)?)), xprint::PRINT_GET_IMAGE_RESOLUTION_REQUEST => return Ok(Request::XprintPrintGetImageResolution(xprint::PrintGetImageResolutionRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "xselinux")] Some((xselinux::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { xselinux::QUERY_VERSION_REQUEST => return Ok(Request::XselinuxQueryVersion(xselinux::QueryVersionRequest::try_parse_request(header, remaining)?)), xselinux::SET_DEVICE_CREATE_CONTEXT_REQUEST => return Ok(Request::XselinuxSetDeviceCreateContext(xselinux::SetDeviceCreateContextRequest::try_parse_request(header, remaining)?)), xselinux::GET_DEVICE_CREATE_CONTEXT_REQUEST => return Ok(Request::XselinuxGetDeviceCreateContext(xselinux::GetDeviceCreateContextRequest::try_parse_request(header, remaining)?)), xselinux::SET_DEVICE_CONTEXT_REQUEST => return Ok(Request::XselinuxSetDeviceContext(xselinux::SetDeviceContextRequest::try_parse_request(header, remaining)?)), xselinux::GET_DEVICE_CONTEXT_REQUEST => return Ok(Request::XselinuxGetDeviceContext(xselinux::GetDeviceContextRequest::try_parse_request(header, remaining)?)), xselinux::SET_WINDOW_CREATE_CONTEXT_REQUEST => return Ok(Request::XselinuxSetWindowCreateContext(xselinux::SetWindowCreateContextRequest::try_parse_request(header, remaining)?)), xselinux::GET_WINDOW_CREATE_CONTEXT_REQUEST => return Ok(Request::XselinuxGetWindowCreateContext(xselinux::GetWindowCreateContextRequest::try_parse_request(header, remaining)?)), xselinux::GET_WINDOW_CONTEXT_REQUEST => return Ok(Request::XselinuxGetWindowContext(xselinux::GetWindowContextRequest::try_parse_request(header, remaining)?)), xselinux::SET_PROPERTY_CREATE_CONTEXT_REQUEST => return Ok(Request::XselinuxSetPropertyCreateContext(xselinux::SetPropertyCreateContextRequest::try_parse_request(header, remaining)?)), xselinux::GET_PROPERTY_CREATE_CONTEXT_REQUEST => return Ok(Request::XselinuxGetPropertyCreateContext(xselinux::GetPropertyCreateContextRequest::try_parse_request(header, remaining)?)), xselinux::SET_PROPERTY_USE_CONTEXT_REQUEST => return Ok(Request::XselinuxSetPropertyUseContext(xselinux::SetPropertyUseContextRequest::try_parse_request(header, remaining)?)), xselinux::GET_PROPERTY_USE_CONTEXT_REQUEST => return Ok(Request::XselinuxGetPropertyUseContext(xselinux::GetPropertyUseContextRequest::try_parse_request(header, remaining)?)), xselinux::GET_PROPERTY_CONTEXT_REQUEST => return Ok(Request::XselinuxGetPropertyContext(xselinux::GetPropertyContextRequest::try_parse_request(header, remaining)?)), xselinux::GET_PROPERTY_DATA_CONTEXT_REQUEST => return Ok(Request::XselinuxGetPropertyDataContext(xselinux::GetPropertyDataContextRequest::try_parse_request(header, remaining)?)), xselinux::LIST_PROPERTIES_REQUEST => return Ok(Request::XselinuxListProperties(xselinux::ListPropertiesRequest::try_parse_request(header, remaining)?)), xselinux::SET_SELECTION_CREATE_CONTEXT_REQUEST => return Ok(Request::XselinuxSetSelectionCreateContext(xselinux::SetSelectionCreateContextRequest::try_parse_request(header, remaining)?)), xselinux::GET_SELECTION_CREATE_CONTEXT_REQUEST => return Ok(Request::XselinuxGetSelectionCreateContext(xselinux::GetSelectionCreateContextRequest::try_parse_request(header, remaining)?)), xselinux::SET_SELECTION_USE_CONTEXT_REQUEST => return Ok(Request::XselinuxSetSelectionUseContext(xselinux::SetSelectionUseContextRequest::try_parse_request(header, remaining)?)), xselinux::GET_SELECTION_USE_CONTEXT_REQUEST => return Ok(Request::XselinuxGetSelectionUseContext(xselinux::GetSelectionUseContextRequest::try_parse_request(header, remaining)?)), xselinux::GET_SELECTION_CONTEXT_REQUEST => return Ok(Request::XselinuxGetSelectionContext(xselinux::GetSelectionContextRequest::try_parse_request(header, remaining)?)), xselinux::GET_SELECTION_DATA_CONTEXT_REQUEST => return Ok(Request::XselinuxGetSelectionDataContext(xselinux::GetSelectionDataContextRequest::try_parse_request(header, remaining)?)), xselinux::LIST_SELECTIONS_REQUEST => return Ok(Request::XselinuxListSelections(xselinux::ListSelectionsRequest::try_parse_request(header, remaining)?)), xselinux::GET_CLIENT_CONTEXT_REQUEST => return Ok(Request::XselinuxGetClientContext(xselinux::GetClientContextRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "xtest")] Some((xtest::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { xtest::GET_VERSION_REQUEST => return Ok(Request::XtestGetVersion(xtest::GetVersionRequest::try_parse_request(header, remaining)?)), xtest::COMPARE_CURSOR_REQUEST => return Ok(Request::XtestCompareCursor(xtest::CompareCursorRequest::try_parse_request(header, remaining)?)), xtest::FAKE_INPUT_REQUEST => return Ok(Request::XtestFakeInput(xtest::FakeInputRequest::try_parse_request(header, remaining)?)), xtest::GRAB_CONTROL_REQUEST => return Ok(Request::XtestGrabControl(xtest::GrabControlRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "xv")] Some((xv::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { xv::QUERY_EXTENSION_REQUEST => return Ok(Request::XvQueryExtension(xv::QueryExtensionRequest::try_parse_request(header, remaining)?)), xv::QUERY_ADAPTORS_REQUEST => return Ok(Request::XvQueryAdaptors(xv::QueryAdaptorsRequest::try_parse_request(header, remaining)?)), xv::QUERY_ENCODINGS_REQUEST => return Ok(Request::XvQueryEncodings(xv::QueryEncodingsRequest::try_parse_request(header, remaining)?)), xv::GRAB_PORT_REQUEST => return Ok(Request::XvGrabPort(xv::GrabPortRequest::try_parse_request(header, remaining)?)), xv::UNGRAB_PORT_REQUEST => return Ok(Request::XvUngrabPort(xv::UngrabPortRequest::try_parse_request(header, remaining)?)), xv::PUT_VIDEO_REQUEST => return Ok(Request::XvPutVideo(xv::PutVideoRequest::try_parse_request(header, remaining)?)), xv::PUT_STILL_REQUEST => return Ok(Request::XvPutStill(xv::PutStillRequest::try_parse_request(header, remaining)?)), xv::GET_VIDEO_REQUEST => return Ok(Request::XvGetVideo(xv::GetVideoRequest::try_parse_request(header, remaining)?)), xv::GET_STILL_REQUEST => return Ok(Request::XvGetStill(xv::GetStillRequest::try_parse_request(header, remaining)?)), xv::STOP_VIDEO_REQUEST => return Ok(Request::XvStopVideo(xv::StopVideoRequest::try_parse_request(header, remaining)?)), xv::SELECT_VIDEO_NOTIFY_REQUEST => return Ok(Request::XvSelectVideoNotify(xv::SelectVideoNotifyRequest::try_parse_request(header, remaining)?)), xv::SELECT_PORT_NOTIFY_REQUEST => return Ok(Request::XvSelectPortNotify(xv::SelectPortNotifyRequest::try_parse_request(header, remaining)?)), xv::QUERY_BEST_SIZE_REQUEST => return Ok(Request::XvQueryBestSize(xv::QueryBestSizeRequest::try_parse_request(header, remaining)?)), xv::SET_PORT_ATTRIBUTE_REQUEST => return Ok(Request::XvSetPortAttribute(xv::SetPortAttributeRequest::try_parse_request(header, remaining)?)), xv::GET_PORT_ATTRIBUTE_REQUEST => return Ok(Request::XvGetPortAttribute(xv::GetPortAttributeRequest::try_parse_request(header, remaining)?)), xv::QUERY_PORT_ATTRIBUTES_REQUEST => return Ok(Request::XvQueryPortAttributes(xv::QueryPortAttributesRequest::try_parse_request(header, remaining)?)), xv::LIST_IMAGE_FORMATS_REQUEST => return Ok(Request::XvListImageFormats(xv::ListImageFormatsRequest::try_parse_request(header, remaining)?)), xv::QUERY_IMAGE_ATTRIBUTES_REQUEST => return Ok(Request::XvQueryImageAttributes(xv::QueryImageAttributesRequest::try_parse_request(header, remaining)?)), xv::PUT_IMAGE_REQUEST => return Ok(Request::XvPutImage(xv::PutImageRequest::try_parse_request(header, remaining)?)), xv::SHM_PUT_IMAGE_REQUEST => return Ok(Request::XvShmPutImage(xv::ShmPutImageRequest::try_parse_request(header, remaining)?)), _ => (), } } #[cfg(feature = "xvmc")] Some((xvmc::X11_EXTENSION_NAME, _)) => { match header.minor_opcode { xvmc::QUERY_VERSION_REQUEST => return Ok(Request::XvmcQueryVersion(xvmc::QueryVersionRequest::try_parse_request(header, remaining)?)), xvmc::LIST_SURFACE_TYPES_REQUEST => return Ok(Request::XvmcListSurfaceTypes(xvmc::ListSurfaceTypesRequest::try_parse_request(header, remaining)?)), xvmc::CREATE_CONTEXT_REQUEST => return Ok(Request::XvmcCreateContext(xvmc::CreateContextRequest::try_parse_request(header, remaining)?)), xvmc::DESTROY_CONTEXT_REQUEST => return Ok(Request::XvmcDestroyContext(xvmc::DestroyContextRequest::try_parse_request(header, remaining)?)), xvmc::CREATE_SURFACE_REQUEST => return Ok(Request::XvmcCreateSurface(xvmc::CreateSurfaceRequest::try_parse_request(header, remaining)?)), xvmc::DESTROY_SURFACE_REQUEST => return Ok(Request::XvmcDestroySurface(xvmc::DestroySurfaceRequest::try_parse_request(header, remaining)?)), xvmc::CREATE_SUBPICTURE_REQUEST => return Ok(Request::XvmcCreateSubpicture(xvmc::CreateSubpictureRequest::try_parse_request(header, remaining)?)), xvmc::DESTROY_SUBPICTURE_REQUEST => return Ok(Request::XvmcDestroySubpicture(xvmc::DestroySubpictureRequest::try_parse_request(header, remaining)?)), xvmc::LIST_SUBPICTURE_TYPES_REQUEST => return Ok(Request::XvmcListSubpictureTypes(xvmc::ListSubpictureTypesRequest::try_parse_request(header, remaining)?)), _ => (), } } _ => (), } Ok(Request::Unknown(header, Cow::Borrowed(remaining))) } /// Get the matching reply parser (if any) for this request. /// For `Request::Unknown`, `None` is also returned. pub fn reply_parser(&self) -> Option { match self { Request::Unknown(_, _) => None, Request::CreateWindow(_) => None, Request::ChangeWindowAttributes(_) => None, Request::GetWindowAttributes(_) => Some(parse_reply::), Request::DestroyWindow(_) => None, Request::DestroySubwindows(_) => None, Request::ChangeSaveSet(_) => None, Request::ReparentWindow(_) => None, Request::MapWindow(_) => None, Request::MapSubwindows(_) => None, Request::UnmapWindow(_) => None, Request::UnmapSubwindows(_) => None, Request::ConfigureWindow(_) => None, Request::CirculateWindow(_) => None, Request::GetGeometry(_) => Some(parse_reply::), Request::QueryTree(_) => Some(parse_reply::), Request::InternAtom(_) => Some(parse_reply::>), Request::GetAtomName(_) => Some(parse_reply::), Request::ChangeProperty(_) => None, Request::DeleteProperty(_) => None, Request::GetProperty(_) => Some(parse_reply::), Request::ListProperties(_) => Some(parse_reply::), Request::SetSelectionOwner(_) => None, Request::GetSelectionOwner(_) => Some(parse_reply::), Request::ConvertSelection(_) => None, Request::SendEvent(_) => None, Request::GrabPointer(_) => Some(parse_reply::), Request::UngrabPointer(_) => None, Request::GrabButton(_) => None, Request::UngrabButton(_) => None, Request::ChangeActivePointerGrab(_) => None, Request::GrabKeyboard(_) => Some(parse_reply::), Request::UngrabKeyboard(_) => None, Request::GrabKey(_) => None, Request::UngrabKey(_) => None, Request::AllowEvents(_) => None, Request::GrabServer(_) => None, Request::UngrabServer(_) => None, Request::QueryPointer(_) => Some(parse_reply::), Request::GetMotionEvents(_) => Some(parse_reply::), Request::TranslateCoordinates(_) => Some(parse_reply::), Request::WarpPointer(_) => None, Request::SetInputFocus(_) => None, Request::GetInputFocus(_) => Some(parse_reply::), Request::QueryKeymap(_) => Some(parse_reply::), Request::OpenFont(_) => None, Request::CloseFont(_) => None, Request::QueryFont(_) => Some(parse_reply::), Request::QueryTextExtents(_) => Some(parse_reply::>), Request::ListFonts(_) => Some(parse_reply::>), Request::ListFontsWithInfo(_) => Some(parse_reply::>), Request::SetFontPath(_) => None, Request::GetFontPath(_) => Some(parse_reply::), Request::CreatePixmap(_) => None, Request::FreePixmap(_) => None, Request::CreateGC(_) => None, Request::ChangeGC(_) => None, Request::CopyGC(_) => None, Request::SetDashes(_) => None, Request::SetClipRectangles(_) => None, Request::FreeGC(_) => None, Request::ClearArea(_) => None, Request::CopyArea(_) => None, Request::CopyPlane(_) => None, Request::PolyPoint(_) => None, Request::PolyLine(_) => None, Request::PolySegment(_) => None, Request::PolyRectangle(_) => None, Request::PolyArc(_) => None, Request::FillPoly(_) => None, Request::PolyFillRectangle(_) => None, Request::PolyFillArc(_) => None, Request::PutImage(_) => None, Request::GetImage(_) => Some(parse_reply::), Request::PolyText8(_) => None, Request::PolyText16(_) => None, Request::ImageText8(_) => None, Request::ImageText16(_) => None, Request::CreateColormap(_) => None, Request::FreeColormap(_) => None, Request::CopyColormapAndFree(_) => None, Request::InstallColormap(_) => None, Request::UninstallColormap(_) => None, Request::ListInstalledColormaps(_) => Some(parse_reply::), Request::AllocColor(_) => Some(parse_reply::), Request::AllocNamedColor(_) => Some(parse_reply::>), Request::AllocColorCells(_) => Some(parse_reply::), Request::AllocColorPlanes(_) => Some(parse_reply::), Request::FreeColors(_) => None, Request::StoreColors(_) => None, Request::StoreNamedColor(_) => None, Request::QueryColors(_) => Some(parse_reply::>), Request::LookupColor(_) => Some(parse_reply::>), Request::CreateCursor(_) => None, Request::CreateGlyphCursor(_) => None, Request::FreeCursor(_) => None, Request::RecolorCursor(_) => None, Request::QueryBestSize(_) => Some(parse_reply::), Request::QueryExtension(_) => Some(parse_reply::>), Request::ListExtensions(_) => Some(parse_reply::), Request::ChangeKeyboardMapping(_) => None, Request::GetKeyboardMapping(_) => Some(parse_reply::), Request::ChangeKeyboardControl(_) => None, Request::GetKeyboardControl(_) => Some(parse_reply::), Request::Bell(_) => None, Request::ChangePointerControl(_) => None, Request::GetPointerControl(_) => Some(parse_reply::), Request::SetScreenSaver(_) => None, Request::GetScreenSaver(_) => Some(parse_reply::), Request::ChangeHosts(_) => None, Request::ListHosts(_) => Some(parse_reply::), Request::SetAccessControl(_) => None, Request::SetCloseDownMode(_) => None, Request::KillClient(_) => None, Request::RotateProperties(_) => None, Request::ForceScreenSaver(_) => None, Request::SetPointerMapping(_) => Some(parse_reply::>), Request::GetPointerMapping(_) => Some(parse_reply::), Request::SetModifierMapping(_) => Some(parse_reply::>), Request::GetModifierMapping(_) => Some(parse_reply::), Request::NoOperation(_) => None, Request::BigreqEnable(_) => Some(parse_reply::), #[cfg(feature = "composite")] Request::CompositeQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "composite")] Request::CompositeRedirectWindow(_) => None, #[cfg(feature = "composite")] Request::CompositeRedirectSubwindows(_) => None, #[cfg(feature = "composite")] Request::CompositeUnredirectWindow(_) => None, #[cfg(feature = "composite")] Request::CompositeUnredirectSubwindows(_) => None, #[cfg(feature = "composite")] Request::CompositeCreateRegionFromBorderClip(_) => None, #[cfg(feature = "composite")] Request::CompositeNameWindowPixmap(_) => None, #[cfg(feature = "composite")] Request::CompositeGetOverlayWindow(_) => Some(parse_reply::), #[cfg(feature = "composite")] Request::CompositeReleaseOverlayWindow(_) => None, #[cfg(feature = "damage")] Request::DamageQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "damage")] Request::DamageCreate(_) => None, #[cfg(feature = "damage")] Request::DamageDestroy(_) => None, #[cfg(feature = "damage")] Request::DamageSubtract(_) => None, #[cfg(feature = "damage")] Request::DamageAdd(_) => None, #[cfg(feature = "dbe")] Request::DbeQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "dbe")] Request::DbeAllocateBackBuffer(_) => None, #[cfg(feature = "dbe")] Request::DbeDeallocateBackBuffer(_) => None, #[cfg(feature = "dbe")] Request::DbeSwapBuffers(_) => None, #[cfg(feature = "dbe")] Request::DbeBeginIdiom(_) => None, #[cfg(feature = "dbe")] Request::DbeEndIdiom(_) => None, #[cfg(feature = "dbe")] Request::DbeGetVisualInfo(_) => Some(parse_reply::>), #[cfg(feature = "dbe")] Request::DbeGetBackBufferAttributes(_) => Some(parse_reply::), #[cfg(feature = "dpms")] Request::DpmsGetVersion(_) => Some(parse_reply::), #[cfg(feature = "dpms")] Request::DpmsCapable(_) => Some(parse_reply::), #[cfg(feature = "dpms")] Request::DpmsGetTimeouts(_) => Some(parse_reply::), #[cfg(feature = "dpms")] Request::DpmsSetTimeouts(_) => None, #[cfg(feature = "dpms")] Request::DpmsEnable(_) => None, #[cfg(feature = "dpms")] Request::DpmsDisable(_) => None, #[cfg(feature = "dpms")] Request::DpmsForceLevel(_) => None, #[cfg(feature = "dpms")] Request::DpmsInfo(_) => Some(parse_reply::), #[cfg(feature = "dpms")] Request::DpmsSelectInput(_) => None, #[cfg(feature = "dri2")] Request::Dri2QueryVersion(_) => Some(parse_reply::), #[cfg(feature = "dri2")] Request::Dri2Connect(_) => Some(parse_reply::), #[cfg(feature = "dri2")] Request::Dri2Authenticate(_) => Some(parse_reply::), #[cfg(feature = "dri2")] Request::Dri2CreateDrawable(_) => None, #[cfg(feature = "dri2")] Request::Dri2DestroyDrawable(_) => None, #[cfg(feature = "dri2")] Request::Dri2GetBuffers(_) => Some(parse_reply::>), #[cfg(feature = "dri2")] Request::Dri2CopyRegion(_) => Some(parse_reply::), #[cfg(feature = "dri2")] Request::Dri2GetBuffersWithFormat(_) => Some(parse_reply::>), #[cfg(feature = "dri2")] Request::Dri2SwapBuffers(_) => Some(parse_reply::), #[cfg(feature = "dri2")] Request::Dri2GetMSC(_) => Some(parse_reply::), #[cfg(feature = "dri2")] Request::Dri2WaitMSC(_) => Some(parse_reply::), #[cfg(feature = "dri2")] Request::Dri2WaitSBC(_) => Some(parse_reply::), #[cfg(feature = "dri2")] Request::Dri2SwapInterval(_) => None, #[cfg(feature = "dri2")] Request::Dri2GetParam(_) => Some(parse_reply::), #[cfg(feature = "dri3")] Request::Dri3QueryVersion(_) => Some(parse_reply::), #[cfg(feature = "dri3")] Request::Dri3Open(_) => Some(parse_reply_fds::), #[cfg(feature = "dri3")] Request::Dri3PixmapFromBuffer(_) => None, #[cfg(feature = "dri3")] Request::Dri3BufferFromPixmap(_) => Some(parse_reply_fds::), #[cfg(feature = "dri3")] Request::Dri3FenceFromFD(_) => None, #[cfg(feature = "dri3")] Request::Dri3FDFromFence(_) => Some(parse_reply_fds::), #[cfg(feature = "dri3")] Request::Dri3GetSupportedModifiers(_) => Some(parse_reply::), #[cfg(feature = "dri3")] Request::Dri3PixmapFromBuffers(_) => None, #[cfg(feature = "dri3")] Request::Dri3BuffersFromPixmap(_) => Some(parse_reply_fds::), #[cfg(feature = "dri3")] Request::Dri3SetDRMDeviceInUse(_) => None, #[cfg(feature = "dri3")] Request::Dri3ImportSyncobj(_) => None, #[cfg(feature = "dri3")] Request::Dri3FreeSyncobj(_) => None, Request::GeQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxRender(_) => None, #[cfg(feature = "glx")] Request::GlxRenderLarge(_) => None, #[cfg(feature = "glx")] Request::GlxCreateContext(_) => None, #[cfg(feature = "glx")] Request::GlxDestroyContext(_) => None, #[cfg(feature = "glx")] Request::GlxMakeCurrent(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxIsDirect(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxWaitGL(_) => None, #[cfg(feature = "glx")] Request::GlxWaitX(_) => None, #[cfg(feature = "glx")] Request::GlxCopyContext(_) => None, #[cfg(feature = "glx")] Request::GlxSwapBuffers(_) => None, #[cfg(feature = "glx")] Request::GlxUseXFont(_) => None, #[cfg(feature = "glx")] Request::GlxCreateGLXPixmap(_) => None, #[cfg(feature = "glx")] Request::GlxGetVisualConfigs(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxDestroyGLXPixmap(_) => None, #[cfg(feature = "glx")] Request::GlxVendorPrivate(_) => None, #[cfg(feature = "glx")] Request::GlxVendorPrivateWithReply(_) => Some(parse_reply::>), #[cfg(feature = "glx")] Request::GlxQueryExtensionsString(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxQueryServerString(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxClientInfo(_) => None, #[cfg(feature = "glx")] Request::GlxGetFBConfigs(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxCreatePixmap(_) => None, #[cfg(feature = "glx")] Request::GlxDestroyPixmap(_) => None, #[cfg(feature = "glx")] Request::GlxCreateNewContext(_) => None, #[cfg(feature = "glx")] Request::GlxQueryContext(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxMakeContextCurrent(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxCreatePbuffer(_) => None, #[cfg(feature = "glx")] Request::GlxDestroyPbuffer(_) => None, #[cfg(feature = "glx")] Request::GlxGetDrawableAttributes(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxChangeDrawableAttributes(_) => None, #[cfg(feature = "glx")] Request::GlxCreateWindow(_) => None, #[cfg(feature = "glx")] Request::GlxDeleteWindow(_) => None, #[cfg(feature = "glx")] Request::GlxSetClientInfoARB(_) => None, #[cfg(feature = "glx")] Request::GlxCreateContextAttribsARB(_) => None, #[cfg(feature = "glx")] Request::GlxSetClientInfo2ARB(_) => None, #[cfg(feature = "glx")] Request::GlxNewList(_) => None, #[cfg(feature = "glx")] Request::GlxEndList(_) => None, #[cfg(feature = "glx")] Request::GlxDeleteLists(_) => None, #[cfg(feature = "glx")] Request::GlxGenLists(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxFeedbackBuffer(_) => None, #[cfg(feature = "glx")] Request::GlxSelectBuffer(_) => None, #[cfg(feature = "glx")] Request::GlxRenderMode(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxFinish(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxPixelStoref(_) => None, #[cfg(feature = "glx")] Request::GlxPixelStorei(_) => None, #[cfg(feature = "glx")] Request::GlxReadPixels(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetBooleanv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetClipPlane(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetDoublev(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetError(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetFloatv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetIntegerv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetLightfv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetLightiv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetMapdv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetMapfv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetMapiv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetMaterialfv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetMaterialiv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetPixelMapfv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetPixelMapuiv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetPixelMapusv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetPolygonStipple(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetString(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetTexEnvfv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetTexEnviv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetTexGendv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetTexGenfv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetTexGeniv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetTexImage(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetTexParameterfv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetTexParameteriv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetTexLevelParameterfv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetTexLevelParameteriv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxIsEnabled(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxIsList(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxFlush(_) => None, #[cfg(feature = "glx")] Request::GlxAreTexturesResident(_) => Some(parse_reply::>), #[cfg(feature = "glx")] Request::GlxDeleteTextures(_) => None, #[cfg(feature = "glx")] Request::GlxGenTextures(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxIsTexture(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetColorTable(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetColorTableParameterfv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetColorTableParameteriv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetConvolutionFilter(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetConvolutionParameterfv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetConvolutionParameteriv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetSeparableFilter(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetHistogram(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetHistogramParameterfv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetHistogramParameteriv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetMinmax(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetMinmaxParameterfv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetMinmaxParameteriv(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetCompressedTexImageARB(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxDeleteQueriesARB(_) => None, #[cfg(feature = "glx")] Request::GlxGenQueriesARB(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxIsQueryARB(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetQueryivARB(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetQueryObjectivARB(_) => Some(parse_reply::), #[cfg(feature = "glx")] Request::GlxGetQueryObjectuivARB(_) => Some(parse_reply::), #[cfg(feature = "present")] Request::PresentQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "present")] Request::PresentPixmap(_) => None, #[cfg(feature = "present")] Request::PresentNotifyMSC(_) => None, #[cfg(feature = "present")] Request::PresentSelectInput(_) => None, #[cfg(feature = "present")] Request::PresentQueryCapabilities(_) => Some(parse_reply::), #[cfg(feature = "present")] Request::PresentPixmapSynced(_) => None, #[cfg(feature = "randr")] Request::RandrQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrSetScreenConfig(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrSelectInput(_) => None, #[cfg(feature = "randr")] Request::RandrGetScreenInfo(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrGetScreenSizeRange(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrSetScreenSize(_) => None, #[cfg(feature = "randr")] Request::RandrGetScreenResources(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrGetOutputInfo(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrListOutputProperties(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrQueryOutputProperty(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrConfigureOutputProperty(_) => None, #[cfg(feature = "randr")] Request::RandrChangeOutputProperty(_) => None, #[cfg(feature = "randr")] Request::RandrDeleteOutputProperty(_) => None, #[cfg(feature = "randr")] Request::RandrGetOutputProperty(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrCreateMode(_) => Some(parse_reply::>), #[cfg(feature = "randr")] Request::RandrDestroyMode(_) => None, #[cfg(feature = "randr")] Request::RandrAddOutputMode(_) => None, #[cfg(feature = "randr")] Request::RandrDeleteOutputMode(_) => None, #[cfg(feature = "randr")] Request::RandrGetCrtcInfo(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrSetCrtcConfig(_) => Some(parse_reply::>), #[cfg(feature = "randr")] Request::RandrGetCrtcGammaSize(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrGetCrtcGamma(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrSetCrtcGamma(_) => None, #[cfg(feature = "randr")] Request::RandrGetScreenResourcesCurrent(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrSetCrtcTransform(_) => None, #[cfg(feature = "randr")] Request::RandrGetCrtcTransform(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrGetPanning(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrSetPanning(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrSetOutputPrimary(_) => None, #[cfg(feature = "randr")] Request::RandrGetOutputPrimary(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrGetProviders(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrGetProviderInfo(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrSetProviderOffloadSink(_) => None, #[cfg(feature = "randr")] Request::RandrSetProviderOutputSource(_) => None, #[cfg(feature = "randr")] Request::RandrListProviderProperties(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrQueryProviderProperty(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrConfigureProviderProperty(_) => None, #[cfg(feature = "randr")] Request::RandrChangeProviderProperty(_) => None, #[cfg(feature = "randr")] Request::RandrDeleteProviderProperty(_) => None, #[cfg(feature = "randr")] Request::RandrGetProviderProperty(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrGetMonitors(_) => Some(parse_reply::), #[cfg(feature = "randr")] Request::RandrSetMonitor(_) => None, #[cfg(feature = "randr")] Request::RandrDeleteMonitor(_) => None, #[cfg(feature = "randr")] Request::RandrCreateLease(_) => Some(parse_reply_fds::>), #[cfg(feature = "randr")] Request::RandrFreeLease(_) => None, #[cfg(feature = "record")] Request::RecordQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "record")] Request::RecordCreateContext(_) => None, #[cfg(feature = "record")] Request::RecordRegisterClients(_) => None, #[cfg(feature = "record")] Request::RecordUnregisterClients(_) => None, #[cfg(feature = "record")] Request::RecordGetContext(_) => Some(parse_reply::), #[cfg(feature = "record")] Request::RecordEnableContext(_) => Some(parse_reply::), #[cfg(feature = "record")] Request::RecordDisableContext(_) => None, #[cfg(feature = "record")] Request::RecordFreeContext(_) => None, #[cfg(feature = "render")] Request::RenderQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "render")] Request::RenderQueryPictFormats(_) => Some(parse_reply::), #[cfg(feature = "render")] Request::RenderQueryPictIndexValues(_) => Some(parse_reply::), #[cfg(feature = "render")] Request::RenderCreatePicture(_) => None, #[cfg(feature = "render")] Request::RenderChangePicture(_) => None, #[cfg(feature = "render")] Request::RenderSetPictureClipRectangles(_) => None, #[cfg(feature = "render")] Request::RenderFreePicture(_) => None, #[cfg(feature = "render")] Request::RenderComposite(_) => None, #[cfg(feature = "render")] Request::RenderTrapezoids(_) => None, #[cfg(feature = "render")] Request::RenderTriangles(_) => None, #[cfg(feature = "render")] Request::RenderTriStrip(_) => None, #[cfg(feature = "render")] Request::RenderTriFan(_) => None, #[cfg(feature = "render")] Request::RenderCreateGlyphSet(_) => None, #[cfg(feature = "render")] Request::RenderReferenceGlyphSet(_) => None, #[cfg(feature = "render")] Request::RenderFreeGlyphSet(_) => None, #[cfg(feature = "render")] Request::RenderAddGlyphs(_) => None, #[cfg(feature = "render")] Request::RenderFreeGlyphs(_) => None, #[cfg(feature = "render")] Request::RenderCompositeGlyphs8(_) => None, #[cfg(feature = "render")] Request::RenderCompositeGlyphs16(_) => None, #[cfg(feature = "render")] Request::RenderCompositeGlyphs32(_) => None, #[cfg(feature = "render")] Request::RenderFillRectangles(_) => None, #[cfg(feature = "render")] Request::RenderCreateCursor(_) => None, #[cfg(feature = "render")] Request::RenderSetPictureTransform(_) => None, #[cfg(feature = "render")] Request::RenderQueryFilters(_) => Some(parse_reply::), #[cfg(feature = "render")] Request::RenderSetPictureFilter(_) => None, #[cfg(feature = "render")] Request::RenderCreateAnimCursor(_) => None, #[cfg(feature = "render")] Request::RenderAddTraps(_) => None, #[cfg(feature = "render")] Request::RenderCreateSolidFill(_) => None, #[cfg(feature = "render")] Request::RenderCreateLinearGradient(_) => None, #[cfg(feature = "render")] Request::RenderCreateRadialGradient(_) => None, #[cfg(feature = "render")] Request::RenderCreateConicalGradient(_) => None, #[cfg(feature = "res")] Request::ResQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "res")] Request::ResQueryClients(_) => Some(parse_reply::), #[cfg(feature = "res")] Request::ResQueryClientResources(_) => Some(parse_reply::), #[cfg(feature = "res")] Request::ResQueryClientPixmapBytes(_) => Some(parse_reply::), #[cfg(feature = "res")] Request::ResQueryClientIds(_) => Some(parse_reply::>), #[cfg(feature = "res")] Request::ResQueryResourceBytes(_) => Some(parse_reply::>), #[cfg(feature = "screensaver")] Request::ScreensaverQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "screensaver")] Request::ScreensaverQueryInfo(_) => Some(parse_reply::), #[cfg(feature = "screensaver")] Request::ScreensaverSelectInput(_) => None, #[cfg(feature = "screensaver")] Request::ScreensaverSetAttributes(_) => None, #[cfg(feature = "screensaver")] Request::ScreensaverUnsetAttributes(_) => None, #[cfg(feature = "screensaver")] Request::ScreensaverSuspend(_) => None, #[cfg(feature = "shape")] Request::ShapeQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "shape")] Request::ShapeRectangles(_) => None, #[cfg(feature = "shape")] Request::ShapeMask(_) => None, #[cfg(feature = "shape")] Request::ShapeCombine(_) => None, #[cfg(feature = "shape")] Request::ShapeOffset(_) => None, #[cfg(feature = "shape")] Request::ShapeQueryExtents(_) => Some(parse_reply::), #[cfg(feature = "shape")] Request::ShapeSelectInput(_) => None, #[cfg(feature = "shape")] Request::ShapeInputSelected(_) => Some(parse_reply::), #[cfg(feature = "shape")] Request::ShapeGetRectangles(_) => Some(parse_reply::), #[cfg(feature = "shm")] Request::ShmQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "shm")] Request::ShmAttach(_) => None, #[cfg(feature = "shm")] Request::ShmDetach(_) => None, #[cfg(feature = "shm")] Request::ShmPutImage(_) => None, #[cfg(feature = "shm")] Request::ShmGetImage(_) => Some(parse_reply::), #[cfg(feature = "shm")] Request::ShmCreatePixmap(_) => None, #[cfg(feature = "shm")] Request::ShmAttachFd(_) => None, #[cfg(feature = "shm")] Request::ShmCreateSegment(_) => Some(parse_reply_fds::), #[cfg(feature = "sync")] Request::SyncInitialize(_) => Some(parse_reply::), #[cfg(feature = "sync")] Request::SyncListSystemCounters(_) => Some(parse_reply::), #[cfg(feature = "sync")] Request::SyncCreateCounter(_) => None, #[cfg(feature = "sync")] Request::SyncDestroyCounter(_) => None, #[cfg(feature = "sync")] Request::SyncQueryCounter(_) => Some(parse_reply::), #[cfg(feature = "sync")] Request::SyncAwait(_) => None, #[cfg(feature = "sync")] Request::SyncChangeCounter(_) => None, #[cfg(feature = "sync")] Request::SyncSetCounter(_) => None, #[cfg(feature = "sync")] Request::SyncCreateAlarm(_) => None, #[cfg(feature = "sync")] Request::SyncChangeAlarm(_) => None, #[cfg(feature = "sync")] Request::SyncDestroyAlarm(_) => None, #[cfg(feature = "sync")] Request::SyncQueryAlarm(_) => Some(parse_reply::), #[cfg(feature = "sync")] Request::SyncSetPriority(_) => None, #[cfg(feature = "sync")] Request::SyncGetPriority(_) => Some(parse_reply::), #[cfg(feature = "sync")] Request::SyncCreateFence(_) => None, #[cfg(feature = "sync")] Request::SyncTriggerFence(_) => None, #[cfg(feature = "sync")] Request::SyncResetFence(_) => None, #[cfg(feature = "sync")] Request::SyncDestroyFence(_) => None, #[cfg(feature = "sync")] Request::SyncQueryFence(_) => Some(parse_reply::), #[cfg(feature = "sync")] Request::SyncAwaitFence(_) => None, Request::XcMiscGetVersion(_) => Some(parse_reply::), Request::XcMiscGetXIDRange(_) => Some(parse_reply::), Request::XcMiscGetXIDList(_) => Some(parse_reply::), #[cfg(feature = "xevie")] Request::XevieQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "xevie")] Request::XevieStart(_) => Some(parse_reply::), #[cfg(feature = "xevie")] Request::XevieEnd(_) => Some(parse_reply::), #[cfg(feature = "xevie")] Request::XevieSend(_) => Some(parse_reply::), #[cfg(feature = "xevie")] Request::XevieSelectInput(_) => Some(parse_reply::), #[cfg(feature = "xf86dri")] Request::Xf86driQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "xf86dri")] Request::Xf86driQueryDirectRenderingCapable(_) => Some(parse_reply::), #[cfg(feature = "xf86dri")] Request::Xf86driOpenConnection(_) => Some(parse_reply::), #[cfg(feature = "xf86dri")] Request::Xf86driCloseConnection(_) => None, #[cfg(feature = "xf86dri")] Request::Xf86driGetClientDriverName(_) => Some(parse_reply::), #[cfg(feature = "xf86dri")] Request::Xf86driCreateContext(_) => Some(parse_reply::), #[cfg(feature = "xf86dri")] Request::Xf86driDestroyContext(_) => None, #[cfg(feature = "xf86dri")] Request::Xf86driCreateDrawable(_) => Some(parse_reply::), #[cfg(feature = "xf86dri")] Request::Xf86driDestroyDrawable(_) => None, #[cfg(feature = "xf86dri")] Request::Xf86driGetDrawableInfo(_) => Some(parse_reply::), #[cfg(feature = "xf86dri")] Request::Xf86driGetDeviceInfo(_) => Some(parse_reply::), #[cfg(feature = "xf86dri")] Request::Xf86driAuthConnection(_) => Some(parse_reply::), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetModeLine(_) => Some(parse_reply::), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeModModeLine(_) => None, #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeSwitchMode(_) => None, #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetMonitor(_) => Some(parse_reply::), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeLockModeSwitch(_) => None, #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetAllModeLines(_) => Some(parse_reply::), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeAddModeLine(_) => None, #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeDeleteModeLine(_) => None, #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeValidateModeLine(_) => Some(parse_reply::>), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeSwitchToMode(_) => None, #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetViewPort(_) => Some(parse_reply::), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeSetViewPort(_) => None, #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetDotClocks(_) => Some(parse_reply::), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeSetClientVersion(_) => None, #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeSetGamma(_) => None, #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetGamma(_) => Some(parse_reply::), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetGammaRamp(_) => Some(parse_reply::), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeSetGammaRamp(_) => None, #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetGammaRampSize(_) => Some(parse_reply::), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetPermissions(_) => Some(parse_reply::), #[cfg(feature = "xfixes")] Request::XfixesQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "xfixes")] Request::XfixesChangeSaveSet(_) => None, #[cfg(feature = "xfixes")] Request::XfixesSelectSelectionInput(_) => None, #[cfg(feature = "xfixes")] Request::XfixesSelectCursorInput(_) => None, #[cfg(feature = "xfixes")] Request::XfixesGetCursorImage(_) => Some(parse_reply::), #[cfg(feature = "xfixes")] Request::XfixesCreateRegion(_) => None, #[cfg(feature = "xfixes")] Request::XfixesCreateRegionFromBitmap(_) => None, #[cfg(feature = "xfixes")] Request::XfixesCreateRegionFromWindow(_) => None, #[cfg(feature = "xfixes")] Request::XfixesCreateRegionFromGC(_) => None, #[cfg(feature = "xfixes")] Request::XfixesCreateRegionFromPicture(_) => None, #[cfg(feature = "xfixes")] Request::XfixesDestroyRegion(_) => None, #[cfg(feature = "xfixes")] Request::XfixesSetRegion(_) => None, #[cfg(feature = "xfixes")] Request::XfixesCopyRegion(_) => None, #[cfg(feature = "xfixes")] Request::XfixesUnionRegion(_) => None, #[cfg(feature = "xfixes")] Request::XfixesIntersectRegion(_) => None, #[cfg(feature = "xfixes")] Request::XfixesSubtractRegion(_) => None, #[cfg(feature = "xfixes")] Request::XfixesInvertRegion(_) => None, #[cfg(feature = "xfixes")] Request::XfixesTranslateRegion(_) => None, #[cfg(feature = "xfixes")] Request::XfixesRegionExtents(_) => None, #[cfg(feature = "xfixes")] Request::XfixesFetchRegion(_) => Some(parse_reply::), #[cfg(feature = "xfixes")] Request::XfixesSetGCClipRegion(_) => None, #[cfg(feature = "xfixes")] Request::XfixesSetWindowShapeRegion(_) => None, #[cfg(feature = "xfixes")] Request::XfixesSetPictureClipRegion(_) => None, #[cfg(feature = "xfixes")] Request::XfixesSetCursorName(_) => None, #[cfg(feature = "xfixes")] Request::XfixesGetCursorName(_) => Some(parse_reply::), #[cfg(feature = "xfixes")] Request::XfixesGetCursorImageAndName(_) => Some(parse_reply::), #[cfg(feature = "xfixes")] Request::XfixesChangeCursor(_) => None, #[cfg(feature = "xfixes")] Request::XfixesChangeCursorByName(_) => None, #[cfg(feature = "xfixes")] Request::XfixesExpandRegion(_) => None, #[cfg(feature = "xfixes")] Request::XfixesHideCursor(_) => None, #[cfg(feature = "xfixes")] Request::XfixesShowCursor(_) => None, #[cfg(feature = "xfixes")] Request::XfixesCreatePointerBarrier(_) => None, #[cfg(feature = "xfixes")] Request::XfixesDeletePointerBarrier(_) => None, #[cfg(feature = "xfixes")] Request::XfixesSetClientDisconnectMode(_) => None, #[cfg(feature = "xfixes")] Request::XfixesGetClientDisconnectMode(_) => Some(parse_reply::), #[cfg(feature = "xinerama")] Request::XineramaQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "xinerama")] Request::XineramaGetState(_) => Some(parse_reply::), #[cfg(feature = "xinerama")] Request::XineramaGetScreenCount(_) => Some(parse_reply::), #[cfg(feature = "xinerama")] Request::XineramaGetScreenSize(_) => Some(parse_reply::), #[cfg(feature = "xinerama")] Request::XineramaIsActive(_) => Some(parse_reply::), #[cfg(feature = "xinerama")] Request::XineramaQueryScreens(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputGetExtensionVersion(_) => Some(parse_reply::>), #[cfg(feature = "xinput")] Request::XinputListInputDevices(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputOpenDevice(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputCloseDevice(_) => None, #[cfg(feature = "xinput")] Request::XinputSetDeviceMode(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputSelectExtensionEvent(_) => None, #[cfg(feature = "xinput")] Request::XinputGetSelectedExtensionEvents(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputChangeDeviceDontPropagateList(_) => None, #[cfg(feature = "xinput")] Request::XinputGetDeviceDontPropagateList(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputGetDeviceMotionEvents(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputChangeKeyboardDevice(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputChangePointerDevice(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputGrabDevice(_) => Some(parse_reply::>), #[cfg(feature = "xinput")] Request::XinputUngrabDevice(_) => None, #[cfg(feature = "xinput")] Request::XinputGrabDeviceKey(_) => None, #[cfg(feature = "xinput")] Request::XinputUngrabDeviceKey(_) => None, #[cfg(feature = "xinput")] Request::XinputGrabDeviceButton(_) => None, #[cfg(feature = "xinput")] Request::XinputUngrabDeviceButton(_) => None, #[cfg(feature = "xinput")] Request::XinputAllowDeviceEvents(_) => None, #[cfg(feature = "xinput")] Request::XinputGetDeviceFocus(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputSetDeviceFocus(_) => None, #[cfg(feature = "xinput")] Request::XinputGetFeedbackControl(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputChangeFeedbackControl(_) => None, #[cfg(feature = "xinput")] Request::XinputGetDeviceKeyMapping(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputChangeDeviceKeyMapping(_) => None, #[cfg(feature = "xinput")] Request::XinputGetDeviceModifierMapping(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputSetDeviceModifierMapping(_) => Some(parse_reply::>), #[cfg(feature = "xinput")] Request::XinputGetDeviceButtonMapping(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputSetDeviceButtonMapping(_) => Some(parse_reply::>), #[cfg(feature = "xinput")] Request::XinputQueryDeviceState(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputDeviceBell(_) => None, #[cfg(feature = "xinput")] Request::XinputSetDeviceValuators(_) => Some(parse_reply::>), #[cfg(feature = "xinput")] Request::XinputGetDeviceControl(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputChangeDeviceControl(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputListDeviceProperties(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputChangeDeviceProperty(_) => None, #[cfg(feature = "xinput")] Request::XinputDeleteDeviceProperty(_) => None, #[cfg(feature = "xinput")] Request::XinputGetDeviceProperty(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputXIQueryPointer(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputXIWarpPointer(_) => None, #[cfg(feature = "xinput")] Request::XinputXIChangeCursor(_) => None, #[cfg(feature = "xinput")] Request::XinputXIChangeHierarchy(_) => None, #[cfg(feature = "xinput")] Request::XinputXISetClientPointer(_) => None, #[cfg(feature = "xinput")] Request::XinputXIGetClientPointer(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputXISelectEvents(_) => None, #[cfg(feature = "xinput")] Request::XinputXIQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputXIQueryDevice(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputXISetFocus(_) => None, #[cfg(feature = "xinput")] Request::XinputXIGetFocus(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputXIGrabDevice(_) => Some(parse_reply::>), #[cfg(feature = "xinput")] Request::XinputXIUngrabDevice(_) => None, #[cfg(feature = "xinput")] Request::XinputXIAllowEvents(_) => None, #[cfg(feature = "xinput")] Request::XinputXIPassiveGrabDevice(_) => Some(parse_reply::>), #[cfg(feature = "xinput")] Request::XinputXIPassiveUngrabDevice(_) => None, #[cfg(feature = "xinput")] Request::XinputXIListProperties(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputXIChangeProperty(_) => None, #[cfg(feature = "xinput")] Request::XinputXIDeleteProperty(_) => None, #[cfg(feature = "xinput")] Request::XinputXIGetProperty(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputXIGetSelectedEvents(_) => Some(parse_reply::), #[cfg(feature = "xinput")] Request::XinputXIBarrierReleasePointer(_) => None, #[cfg(feature = "xinput")] Request::XinputSendExtensionEvent(_) => None, #[cfg(feature = "xkb")] Request::XkbUseExtension(_) => Some(parse_reply::), #[cfg(feature = "xkb")] Request::XkbSelectEvents(_) => None, #[cfg(feature = "xkb")] Request::XkbBell(_) => None, #[cfg(feature = "xkb")] Request::XkbGetState(_) => Some(parse_reply::), #[cfg(feature = "xkb")] Request::XkbLatchLockState(_) => None, #[cfg(feature = "xkb")] Request::XkbGetControls(_) => Some(parse_reply::), #[cfg(feature = "xkb")] Request::XkbSetControls(_) => None, #[cfg(feature = "xkb")] Request::XkbGetMap(_) => Some(parse_reply::), #[cfg(feature = "xkb")] Request::XkbSetMap(_) => None, #[cfg(feature = "xkb")] Request::XkbGetCompatMap(_) => Some(parse_reply::), #[cfg(feature = "xkb")] Request::XkbSetCompatMap(_) => None, #[cfg(feature = "xkb")] Request::XkbGetIndicatorState(_) => Some(parse_reply::), #[cfg(feature = "xkb")] Request::XkbGetIndicatorMap(_) => Some(parse_reply::), #[cfg(feature = "xkb")] Request::XkbSetIndicatorMap(_) => None, #[cfg(feature = "xkb")] Request::XkbGetNamedIndicator(_) => Some(parse_reply::), #[cfg(feature = "xkb")] Request::XkbSetNamedIndicator(_) => None, #[cfg(feature = "xkb")] Request::XkbGetNames(_) => Some(parse_reply::), #[cfg(feature = "xkb")] Request::XkbSetNames(_) => None, #[cfg(feature = "xkb")] Request::XkbPerClientFlags(_) => Some(parse_reply::), #[cfg(feature = "xkb")] Request::XkbListComponents(_) => Some(parse_reply::), #[cfg(feature = "xkb")] Request::XkbGetKbdByName(_) => Some(parse_reply::), #[cfg(feature = "xkb")] Request::XkbGetDeviceInfo(_) => Some(parse_reply::), #[cfg(feature = "xkb")] Request::XkbSetDeviceInfo(_) => None, #[cfg(feature = "xkb")] Request::XkbSetDebuggingFlags(_) => Some(parse_reply::>), #[cfg(feature = "xprint")] Request::XprintPrintQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "xprint")] Request::XprintPrintGetPrinterList(_) => Some(parse_reply::>), #[cfg(feature = "xprint")] Request::XprintPrintRehashPrinterList(_) => None, #[cfg(feature = "xprint")] Request::XprintCreateContext(_) => None, #[cfg(feature = "xprint")] Request::XprintPrintSetContext(_) => None, #[cfg(feature = "xprint")] Request::XprintPrintGetContext(_) => Some(parse_reply::), #[cfg(feature = "xprint")] Request::XprintPrintDestroyContext(_) => None, #[cfg(feature = "xprint")] Request::XprintPrintGetScreenOfContext(_) => Some(parse_reply::), #[cfg(feature = "xprint")] Request::XprintPrintStartJob(_) => None, #[cfg(feature = "xprint")] Request::XprintPrintEndJob(_) => None, #[cfg(feature = "xprint")] Request::XprintPrintStartDoc(_) => None, #[cfg(feature = "xprint")] Request::XprintPrintEndDoc(_) => None, #[cfg(feature = "xprint")] Request::XprintPrintPutDocumentData(_) => None, #[cfg(feature = "xprint")] Request::XprintPrintGetDocumentData(_) => Some(parse_reply::), #[cfg(feature = "xprint")] Request::XprintPrintStartPage(_) => None, #[cfg(feature = "xprint")] Request::XprintPrintEndPage(_) => None, #[cfg(feature = "xprint")] Request::XprintPrintSelectInput(_) => None, #[cfg(feature = "xprint")] Request::XprintPrintInputSelected(_) => Some(parse_reply::), #[cfg(feature = "xprint")] Request::XprintPrintGetAttributes(_) => Some(parse_reply::), #[cfg(feature = "xprint")] Request::XprintPrintGetOneAttributes(_) => Some(parse_reply::>), #[cfg(feature = "xprint")] Request::XprintPrintSetAttributes(_) => None, #[cfg(feature = "xprint")] Request::XprintPrintGetPageDimensions(_) => Some(parse_reply::), #[cfg(feature = "xprint")] Request::XprintPrintQueryScreens(_) => Some(parse_reply::), #[cfg(feature = "xprint")] Request::XprintPrintSetImageResolution(_) => Some(parse_reply::), #[cfg(feature = "xprint")] Request::XprintPrintGetImageResolution(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxSetDeviceCreateContext(_) => None, #[cfg(feature = "xselinux")] Request::XselinuxGetDeviceCreateContext(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxSetDeviceContext(_) => None, #[cfg(feature = "xselinux")] Request::XselinuxGetDeviceContext(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxSetWindowCreateContext(_) => None, #[cfg(feature = "xselinux")] Request::XselinuxGetWindowCreateContext(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxGetWindowContext(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxSetPropertyCreateContext(_) => None, #[cfg(feature = "xselinux")] Request::XselinuxGetPropertyCreateContext(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxSetPropertyUseContext(_) => None, #[cfg(feature = "xselinux")] Request::XselinuxGetPropertyUseContext(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxGetPropertyContext(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxGetPropertyDataContext(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxListProperties(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxSetSelectionCreateContext(_) => None, #[cfg(feature = "xselinux")] Request::XselinuxGetSelectionCreateContext(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxSetSelectionUseContext(_) => None, #[cfg(feature = "xselinux")] Request::XselinuxGetSelectionUseContext(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxGetSelectionContext(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxGetSelectionDataContext(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxListSelections(_) => Some(parse_reply::), #[cfg(feature = "xselinux")] Request::XselinuxGetClientContext(_) => Some(parse_reply::), #[cfg(feature = "xtest")] Request::XtestGetVersion(_) => Some(parse_reply::), #[cfg(feature = "xtest")] Request::XtestCompareCursor(_) => Some(parse_reply::), #[cfg(feature = "xtest")] Request::XtestFakeInput(_) => None, #[cfg(feature = "xtest")] Request::XtestGrabControl(_) => None, #[cfg(feature = "xv")] Request::XvQueryExtension(_) => Some(parse_reply::), #[cfg(feature = "xv")] Request::XvQueryAdaptors(_) => Some(parse_reply::), #[cfg(feature = "xv")] Request::XvQueryEncodings(_) => Some(parse_reply::), #[cfg(feature = "xv")] Request::XvGrabPort(_) => Some(parse_reply::), #[cfg(feature = "xv")] Request::XvUngrabPort(_) => None, #[cfg(feature = "xv")] Request::XvPutVideo(_) => None, #[cfg(feature = "xv")] Request::XvPutStill(_) => None, #[cfg(feature = "xv")] Request::XvGetVideo(_) => None, #[cfg(feature = "xv")] Request::XvGetStill(_) => None, #[cfg(feature = "xv")] Request::XvStopVideo(_) => None, #[cfg(feature = "xv")] Request::XvSelectVideoNotify(_) => None, #[cfg(feature = "xv")] Request::XvSelectPortNotify(_) => None, #[cfg(feature = "xv")] Request::XvQueryBestSize(_) => Some(parse_reply::), #[cfg(feature = "xv")] Request::XvSetPortAttribute(_) => None, #[cfg(feature = "xv")] Request::XvGetPortAttribute(_) => Some(parse_reply::), #[cfg(feature = "xv")] Request::XvQueryPortAttributes(_) => Some(parse_reply::), #[cfg(feature = "xv")] Request::XvListImageFormats(_) => Some(parse_reply::), #[cfg(feature = "xv")] Request::XvQueryImageAttributes(_) => Some(parse_reply::), #[cfg(feature = "xv")] Request::XvPutImage(_) => None, #[cfg(feature = "xv")] Request::XvShmPutImage(_) => None, #[cfg(feature = "xvmc")] Request::XvmcQueryVersion(_) => Some(parse_reply::), #[cfg(feature = "xvmc")] Request::XvmcListSurfaceTypes(_) => Some(parse_reply::), #[cfg(feature = "xvmc")] Request::XvmcCreateContext(_) => Some(parse_reply::), #[cfg(feature = "xvmc")] Request::XvmcDestroyContext(_) => None, #[cfg(feature = "xvmc")] Request::XvmcCreateSurface(_) => Some(parse_reply::), #[cfg(feature = "xvmc")] Request::XvmcDestroySurface(_) => None, #[cfg(feature = "xvmc")] Request::XvmcCreateSubpicture(_) => Some(parse_reply::), #[cfg(feature = "xvmc")] Request::XvmcDestroySubpicture(_) => None, #[cfg(feature = "xvmc")] Request::XvmcListSubpictureTypes(_) => Some(parse_reply::), } } /// Convert this Request into an owned version with no borrows. pub fn into_owned(self) -> Request<'static> { match self { Request::Unknown(header, body) => Request::Unknown(header, Cow::Owned(body.into_owned())), Request::CreateWindow(req) => Request::CreateWindow(req.into_owned()), Request::ChangeWindowAttributes(req) => Request::ChangeWindowAttributes(req.into_owned()), Request::GetWindowAttributes(req) => Request::GetWindowAttributes(req), Request::DestroyWindow(req) => Request::DestroyWindow(req), Request::DestroySubwindows(req) => Request::DestroySubwindows(req), Request::ChangeSaveSet(req) => Request::ChangeSaveSet(req), Request::ReparentWindow(req) => Request::ReparentWindow(req), Request::MapWindow(req) => Request::MapWindow(req), Request::MapSubwindows(req) => Request::MapSubwindows(req), Request::UnmapWindow(req) => Request::UnmapWindow(req), Request::UnmapSubwindows(req) => Request::UnmapSubwindows(req), Request::ConfigureWindow(req) => Request::ConfigureWindow(req.into_owned()), Request::CirculateWindow(req) => Request::CirculateWindow(req), Request::GetGeometry(req) => Request::GetGeometry(req), Request::QueryTree(req) => Request::QueryTree(req), Request::InternAtom(req) => Request::InternAtom(req.into_owned()), Request::GetAtomName(req) => Request::GetAtomName(req), Request::ChangeProperty(req) => Request::ChangeProperty(req.into_owned()), Request::DeleteProperty(req) => Request::DeleteProperty(req), Request::GetProperty(req) => Request::GetProperty(req), Request::ListProperties(req) => Request::ListProperties(req), Request::SetSelectionOwner(req) => Request::SetSelectionOwner(req), Request::GetSelectionOwner(req) => Request::GetSelectionOwner(req), Request::ConvertSelection(req) => Request::ConvertSelection(req), Request::SendEvent(req) => Request::SendEvent(req.into_owned()), Request::GrabPointer(req) => Request::GrabPointer(req), Request::UngrabPointer(req) => Request::UngrabPointer(req), Request::GrabButton(req) => Request::GrabButton(req), Request::UngrabButton(req) => Request::UngrabButton(req), Request::ChangeActivePointerGrab(req) => Request::ChangeActivePointerGrab(req), Request::GrabKeyboard(req) => Request::GrabKeyboard(req), Request::UngrabKeyboard(req) => Request::UngrabKeyboard(req), Request::GrabKey(req) => Request::GrabKey(req), Request::UngrabKey(req) => Request::UngrabKey(req), Request::AllowEvents(req) => Request::AllowEvents(req), Request::GrabServer(req) => Request::GrabServer(req), Request::UngrabServer(req) => Request::UngrabServer(req), Request::QueryPointer(req) => Request::QueryPointer(req), Request::GetMotionEvents(req) => Request::GetMotionEvents(req), Request::TranslateCoordinates(req) => Request::TranslateCoordinates(req), Request::WarpPointer(req) => Request::WarpPointer(req), Request::SetInputFocus(req) => Request::SetInputFocus(req), Request::GetInputFocus(req) => Request::GetInputFocus(req), Request::QueryKeymap(req) => Request::QueryKeymap(req), Request::OpenFont(req) => Request::OpenFont(req.into_owned()), Request::CloseFont(req) => Request::CloseFont(req), Request::QueryFont(req) => Request::QueryFont(req), Request::QueryTextExtents(req) => Request::QueryTextExtents(req.into_owned()), Request::ListFonts(req) => Request::ListFonts(req.into_owned()), Request::ListFontsWithInfo(req) => Request::ListFontsWithInfo(req.into_owned()), Request::SetFontPath(req) => Request::SetFontPath(req.into_owned()), Request::GetFontPath(req) => Request::GetFontPath(req), Request::CreatePixmap(req) => Request::CreatePixmap(req), Request::FreePixmap(req) => Request::FreePixmap(req), Request::CreateGC(req) => Request::CreateGC(req.into_owned()), Request::ChangeGC(req) => Request::ChangeGC(req.into_owned()), Request::CopyGC(req) => Request::CopyGC(req), Request::SetDashes(req) => Request::SetDashes(req.into_owned()), Request::SetClipRectangles(req) => Request::SetClipRectangles(req.into_owned()), Request::FreeGC(req) => Request::FreeGC(req), Request::ClearArea(req) => Request::ClearArea(req), Request::CopyArea(req) => Request::CopyArea(req), Request::CopyPlane(req) => Request::CopyPlane(req), Request::PolyPoint(req) => Request::PolyPoint(req.into_owned()), Request::PolyLine(req) => Request::PolyLine(req.into_owned()), Request::PolySegment(req) => Request::PolySegment(req.into_owned()), Request::PolyRectangle(req) => Request::PolyRectangle(req.into_owned()), Request::PolyArc(req) => Request::PolyArc(req.into_owned()), Request::FillPoly(req) => Request::FillPoly(req.into_owned()), Request::PolyFillRectangle(req) => Request::PolyFillRectangle(req.into_owned()), Request::PolyFillArc(req) => Request::PolyFillArc(req.into_owned()), Request::PutImage(req) => Request::PutImage(req.into_owned()), Request::GetImage(req) => Request::GetImage(req), Request::PolyText8(req) => Request::PolyText8(req.into_owned()), Request::PolyText16(req) => Request::PolyText16(req.into_owned()), Request::ImageText8(req) => Request::ImageText8(req.into_owned()), Request::ImageText16(req) => Request::ImageText16(req.into_owned()), Request::CreateColormap(req) => Request::CreateColormap(req), Request::FreeColormap(req) => Request::FreeColormap(req), Request::CopyColormapAndFree(req) => Request::CopyColormapAndFree(req), Request::InstallColormap(req) => Request::InstallColormap(req), Request::UninstallColormap(req) => Request::UninstallColormap(req), Request::ListInstalledColormaps(req) => Request::ListInstalledColormaps(req), Request::AllocColor(req) => Request::AllocColor(req), Request::AllocNamedColor(req) => Request::AllocNamedColor(req.into_owned()), Request::AllocColorCells(req) => Request::AllocColorCells(req), Request::AllocColorPlanes(req) => Request::AllocColorPlanes(req), Request::FreeColors(req) => Request::FreeColors(req.into_owned()), Request::StoreColors(req) => Request::StoreColors(req.into_owned()), Request::StoreNamedColor(req) => Request::StoreNamedColor(req.into_owned()), Request::QueryColors(req) => Request::QueryColors(req.into_owned()), Request::LookupColor(req) => Request::LookupColor(req.into_owned()), Request::CreateCursor(req) => Request::CreateCursor(req), Request::CreateGlyphCursor(req) => Request::CreateGlyphCursor(req), Request::FreeCursor(req) => Request::FreeCursor(req), Request::RecolorCursor(req) => Request::RecolorCursor(req), Request::QueryBestSize(req) => Request::QueryBestSize(req), Request::QueryExtension(req) => Request::QueryExtension(req.into_owned()), Request::ListExtensions(req) => Request::ListExtensions(req), Request::ChangeKeyboardMapping(req) => Request::ChangeKeyboardMapping(req.into_owned()), Request::GetKeyboardMapping(req) => Request::GetKeyboardMapping(req), Request::ChangeKeyboardControl(req) => Request::ChangeKeyboardControl(req.into_owned()), Request::GetKeyboardControl(req) => Request::GetKeyboardControl(req), Request::Bell(req) => Request::Bell(req), Request::ChangePointerControl(req) => Request::ChangePointerControl(req), Request::GetPointerControl(req) => Request::GetPointerControl(req), Request::SetScreenSaver(req) => Request::SetScreenSaver(req), Request::GetScreenSaver(req) => Request::GetScreenSaver(req), Request::ChangeHosts(req) => Request::ChangeHosts(req.into_owned()), Request::ListHosts(req) => Request::ListHosts(req), Request::SetAccessControl(req) => Request::SetAccessControl(req), Request::SetCloseDownMode(req) => Request::SetCloseDownMode(req), Request::KillClient(req) => Request::KillClient(req), Request::RotateProperties(req) => Request::RotateProperties(req.into_owned()), Request::ForceScreenSaver(req) => Request::ForceScreenSaver(req), Request::SetPointerMapping(req) => Request::SetPointerMapping(req.into_owned()), Request::GetPointerMapping(req) => Request::GetPointerMapping(req), Request::SetModifierMapping(req) => Request::SetModifierMapping(req.into_owned()), Request::GetModifierMapping(req) => Request::GetModifierMapping(req), Request::NoOperation(req) => Request::NoOperation(req), Request::BigreqEnable(req) => Request::BigreqEnable(req), #[cfg(feature = "composite")] Request::CompositeQueryVersion(req) => Request::CompositeQueryVersion(req), #[cfg(feature = "composite")] Request::CompositeRedirectWindow(req) => Request::CompositeRedirectWindow(req), #[cfg(feature = "composite")] Request::CompositeRedirectSubwindows(req) => Request::CompositeRedirectSubwindows(req), #[cfg(feature = "composite")] Request::CompositeUnredirectWindow(req) => Request::CompositeUnredirectWindow(req), #[cfg(feature = "composite")] Request::CompositeUnredirectSubwindows(req) => Request::CompositeUnredirectSubwindows(req), #[cfg(feature = "composite")] Request::CompositeCreateRegionFromBorderClip(req) => Request::CompositeCreateRegionFromBorderClip(req), #[cfg(feature = "composite")] Request::CompositeNameWindowPixmap(req) => Request::CompositeNameWindowPixmap(req), #[cfg(feature = "composite")] Request::CompositeGetOverlayWindow(req) => Request::CompositeGetOverlayWindow(req), #[cfg(feature = "composite")] Request::CompositeReleaseOverlayWindow(req) => Request::CompositeReleaseOverlayWindow(req), #[cfg(feature = "damage")] Request::DamageQueryVersion(req) => Request::DamageQueryVersion(req), #[cfg(feature = "damage")] Request::DamageCreate(req) => Request::DamageCreate(req), #[cfg(feature = "damage")] Request::DamageDestroy(req) => Request::DamageDestroy(req), #[cfg(feature = "damage")] Request::DamageSubtract(req) => Request::DamageSubtract(req), #[cfg(feature = "damage")] Request::DamageAdd(req) => Request::DamageAdd(req), #[cfg(feature = "dbe")] Request::DbeQueryVersion(req) => Request::DbeQueryVersion(req), #[cfg(feature = "dbe")] Request::DbeAllocateBackBuffer(req) => Request::DbeAllocateBackBuffer(req), #[cfg(feature = "dbe")] Request::DbeDeallocateBackBuffer(req) => Request::DbeDeallocateBackBuffer(req), #[cfg(feature = "dbe")] Request::DbeSwapBuffers(req) => Request::DbeSwapBuffers(req.into_owned()), #[cfg(feature = "dbe")] Request::DbeBeginIdiom(req) => Request::DbeBeginIdiom(req), #[cfg(feature = "dbe")] Request::DbeEndIdiom(req) => Request::DbeEndIdiom(req), #[cfg(feature = "dbe")] Request::DbeGetVisualInfo(req) => Request::DbeGetVisualInfo(req.into_owned()), #[cfg(feature = "dbe")] Request::DbeGetBackBufferAttributes(req) => Request::DbeGetBackBufferAttributes(req), #[cfg(feature = "dpms")] Request::DpmsGetVersion(req) => Request::DpmsGetVersion(req), #[cfg(feature = "dpms")] Request::DpmsCapable(req) => Request::DpmsCapable(req), #[cfg(feature = "dpms")] Request::DpmsGetTimeouts(req) => Request::DpmsGetTimeouts(req), #[cfg(feature = "dpms")] Request::DpmsSetTimeouts(req) => Request::DpmsSetTimeouts(req), #[cfg(feature = "dpms")] Request::DpmsEnable(req) => Request::DpmsEnable(req), #[cfg(feature = "dpms")] Request::DpmsDisable(req) => Request::DpmsDisable(req), #[cfg(feature = "dpms")] Request::DpmsForceLevel(req) => Request::DpmsForceLevel(req), #[cfg(feature = "dpms")] Request::DpmsInfo(req) => Request::DpmsInfo(req), #[cfg(feature = "dpms")] Request::DpmsSelectInput(req) => Request::DpmsSelectInput(req), #[cfg(feature = "dri2")] Request::Dri2QueryVersion(req) => Request::Dri2QueryVersion(req), #[cfg(feature = "dri2")] Request::Dri2Connect(req) => Request::Dri2Connect(req), #[cfg(feature = "dri2")] Request::Dri2Authenticate(req) => Request::Dri2Authenticate(req), #[cfg(feature = "dri2")] Request::Dri2CreateDrawable(req) => Request::Dri2CreateDrawable(req), #[cfg(feature = "dri2")] Request::Dri2DestroyDrawable(req) => Request::Dri2DestroyDrawable(req), #[cfg(feature = "dri2")] Request::Dri2GetBuffers(req) => Request::Dri2GetBuffers(req.into_owned()), #[cfg(feature = "dri2")] Request::Dri2CopyRegion(req) => Request::Dri2CopyRegion(req), #[cfg(feature = "dri2")] Request::Dri2GetBuffersWithFormat(req) => Request::Dri2GetBuffersWithFormat(req.into_owned()), #[cfg(feature = "dri2")] Request::Dri2SwapBuffers(req) => Request::Dri2SwapBuffers(req), #[cfg(feature = "dri2")] Request::Dri2GetMSC(req) => Request::Dri2GetMSC(req), #[cfg(feature = "dri2")] Request::Dri2WaitMSC(req) => Request::Dri2WaitMSC(req), #[cfg(feature = "dri2")] Request::Dri2WaitSBC(req) => Request::Dri2WaitSBC(req), #[cfg(feature = "dri2")] Request::Dri2SwapInterval(req) => Request::Dri2SwapInterval(req), #[cfg(feature = "dri2")] Request::Dri2GetParam(req) => Request::Dri2GetParam(req), #[cfg(feature = "dri3")] Request::Dri3QueryVersion(req) => Request::Dri3QueryVersion(req), #[cfg(feature = "dri3")] Request::Dri3Open(req) => Request::Dri3Open(req), #[cfg(feature = "dri3")] Request::Dri3PixmapFromBuffer(req) => Request::Dri3PixmapFromBuffer(req), #[cfg(feature = "dri3")] Request::Dri3BufferFromPixmap(req) => Request::Dri3BufferFromPixmap(req), #[cfg(feature = "dri3")] Request::Dri3FenceFromFD(req) => Request::Dri3FenceFromFD(req), #[cfg(feature = "dri3")] Request::Dri3FDFromFence(req) => Request::Dri3FDFromFence(req), #[cfg(feature = "dri3")] Request::Dri3GetSupportedModifiers(req) => Request::Dri3GetSupportedModifiers(req), #[cfg(feature = "dri3")] Request::Dri3PixmapFromBuffers(req) => Request::Dri3PixmapFromBuffers(req), #[cfg(feature = "dri3")] Request::Dri3BuffersFromPixmap(req) => Request::Dri3BuffersFromPixmap(req), #[cfg(feature = "dri3")] Request::Dri3SetDRMDeviceInUse(req) => Request::Dri3SetDRMDeviceInUse(req), #[cfg(feature = "dri3")] Request::Dri3ImportSyncobj(req) => Request::Dri3ImportSyncobj(req), #[cfg(feature = "dri3")] Request::Dri3FreeSyncobj(req) => Request::Dri3FreeSyncobj(req), Request::GeQueryVersion(req) => Request::GeQueryVersion(req), #[cfg(feature = "glx")] Request::GlxRender(req) => Request::GlxRender(req.into_owned()), #[cfg(feature = "glx")] Request::GlxRenderLarge(req) => Request::GlxRenderLarge(req.into_owned()), #[cfg(feature = "glx")] Request::GlxCreateContext(req) => Request::GlxCreateContext(req), #[cfg(feature = "glx")] Request::GlxDestroyContext(req) => Request::GlxDestroyContext(req), #[cfg(feature = "glx")] Request::GlxMakeCurrent(req) => Request::GlxMakeCurrent(req), #[cfg(feature = "glx")] Request::GlxIsDirect(req) => Request::GlxIsDirect(req), #[cfg(feature = "glx")] Request::GlxQueryVersion(req) => Request::GlxQueryVersion(req), #[cfg(feature = "glx")] Request::GlxWaitGL(req) => Request::GlxWaitGL(req), #[cfg(feature = "glx")] Request::GlxWaitX(req) => Request::GlxWaitX(req), #[cfg(feature = "glx")] Request::GlxCopyContext(req) => Request::GlxCopyContext(req), #[cfg(feature = "glx")] Request::GlxSwapBuffers(req) => Request::GlxSwapBuffers(req), #[cfg(feature = "glx")] Request::GlxUseXFont(req) => Request::GlxUseXFont(req), #[cfg(feature = "glx")] Request::GlxCreateGLXPixmap(req) => Request::GlxCreateGLXPixmap(req), #[cfg(feature = "glx")] Request::GlxGetVisualConfigs(req) => Request::GlxGetVisualConfigs(req), #[cfg(feature = "glx")] Request::GlxDestroyGLXPixmap(req) => Request::GlxDestroyGLXPixmap(req), #[cfg(feature = "glx")] Request::GlxVendorPrivate(req) => Request::GlxVendorPrivate(req.into_owned()), #[cfg(feature = "glx")] Request::GlxVendorPrivateWithReply(req) => Request::GlxVendorPrivateWithReply(req.into_owned()), #[cfg(feature = "glx")] Request::GlxQueryExtensionsString(req) => Request::GlxQueryExtensionsString(req), #[cfg(feature = "glx")] Request::GlxQueryServerString(req) => Request::GlxQueryServerString(req), #[cfg(feature = "glx")] Request::GlxClientInfo(req) => Request::GlxClientInfo(req.into_owned()), #[cfg(feature = "glx")] Request::GlxGetFBConfigs(req) => Request::GlxGetFBConfigs(req), #[cfg(feature = "glx")] Request::GlxCreatePixmap(req) => Request::GlxCreatePixmap(req.into_owned()), #[cfg(feature = "glx")] Request::GlxDestroyPixmap(req) => Request::GlxDestroyPixmap(req), #[cfg(feature = "glx")] Request::GlxCreateNewContext(req) => Request::GlxCreateNewContext(req), #[cfg(feature = "glx")] Request::GlxQueryContext(req) => Request::GlxQueryContext(req), #[cfg(feature = "glx")] Request::GlxMakeContextCurrent(req) => Request::GlxMakeContextCurrent(req), #[cfg(feature = "glx")] Request::GlxCreatePbuffer(req) => Request::GlxCreatePbuffer(req.into_owned()), #[cfg(feature = "glx")] Request::GlxDestroyPbuffer(req) => Request::GlxDestroyPbuffer(req), #[cfg(feature = "glx")] Request::GlxGetDrawableAttributes(req) => Request::GlxGetDrawableAttributes(req), #[cfg(feature = "glx")] Request::GlxChangeDrawableAttributes(req) => Request::GlxChangeDrawableAttributes(req.into_owned()), #[cfg(feature = "glx")] Request::GlxCreateWindow(req) => Request::GlxCreateWindow(req.into_owned()), #[cfg(feature = "glx")] Request::GlxDeleteWindow(req) => Request::GlxDeleteWindow(req), #[cfg(feature = "glx")] Request::GlxSetClientInfoARB(req) => Request::GlxSetClientInfoARB(req.into_owned()), #[cfg(feature = "glx")] Request::GlxCreateContextAttribsARB(req) => Request::GlxCreateContextAttribsARB(req.into_owned()), #[cfg(feature = "glx")] Request::GlxSetClientInfo2ARB(req) => Request::GlxSetClientInfo2ARB(req.into_owned()), #[cfg(feature = "glx")] Request::GlxNewList(req) => Request::GlxNewList(req), #[cfg(feature = "glx")] Request::GlxEndList(req) => Request::GlxEndList(req), #[cfg(feature = "glx")] Request::GlxDeleteLists(req) => Request::GlxDeleteLists(req), #[cfg(feature = "glx")] Request::GlxGenLists(req) => Request::GlxGenLists(req), #[cfg(feature = "glx")] Request::GlxFeedbackBuffer(req) => Request::GlxFeedbackBuffer(req), #[cfg(feature = "glx")] Request::GlxSelectBuffer(req) => Request::GlxSelectBuffer(req), #[cfg(feature = "glx")] Request::GlxRenderMode(req) => Request::GlxRenderMode(req), #[cfg(feature = "glx")] Request::GlxFinish(req) => Request::GlxFinish(req), #[cfg(feature = "glx")] Request::GlxPixelStoref(req) => Request::GlxPixelStoref(req), #[cfg(feature = "glx")] Request::GlxPixelStorei(req) => Request::GlxPixelStorei(req), #[cfg(feature = "glx")] Request::GlxReadPixels(req) => Request::GlxReadPixels(req), #[cfg(feature = "glx")] Request::GlxGetBooleanv(req) => Request::GlxGetBooleanv(req), #[cfg(feature = "glx")] Request::GlxGetClipPlane(req) => Request::GlxGetClipPlane(req), #[cfg(feature = "glx")] Request::GlxGetDoublev(req) => Request::GlxGetDoublev(req), #[cfg(feature = "glx")] Request::GlxGetError(req) => Request::GlxGetError(req), #[cfg(feature = "glx")] Request::GlxGetFloatv(req) => Request::GlxGetFloatv(req), #[cfg(feature = "glx")] Request::GlxGetIntegerv(req) => Request::GlxGetIntegerv(req), #[cfg(feature = "glx")] Request::GlxGetLightfv(req) => Request::GlxGetLightfv(req), #[cfg(feature = "glx")] Request::GlxGetLightiv(req) => Request::GlxGetLightiv(req), #[cfg(feature = "glx")] Request::GlxGetMapdv(req) => Request::GlxGetMapdv(req), #[cfg(feature = "glx")] Request::GlxGetMapfv(req) => Request::GlxGetMapfv(req), #[cfg(feature = "glx")] Request::GlxGetMapiv(req) => Request::GlxGetMapiv(req), #[cfg(feature = "glx")] Request::GlxGetMaterialfv(req) => Request::GlxGetMaterialfv(req), #[cfg(feature = "glx")] Request::GlxGetMaterialiv(req) => Request::GlxGetMaterialiv(req), #[cfg(feature = "glx")] Request::GlxGetPixelMapfv(req) => Request::GlxGetPixelMapfv(req), #[cfg(feature = "glx")] Request::GlxGetPixelMapuiv(req) => Request::GlxGetPixelMapuiv(req), #[cfg(feature = "glx")] Request::GlxGetPixelMapusv(req) => Request::GlxGetPixelMapusv(req), #[cfg(feature = "glx")] Request::GlxGetPolygonStipple(req) => Request::GlxGetPolygonStipple(req), #[cfg(feature = "glx")] Request::GlxGetString(req) => Request::GlxGetString(req), #[cfg(feature = "glx")] Request::GlxGetTexEnvfv(req) => Request::GlxGetTexEnvfv(req), #[cfg(feature = "glx")] Request::GlxGetTexEnviv(req) => Request::GlxGetTexEnviv(req), #[cfg(feature = "glx")] Request::GlxGetTexGendv(req) => Request::GlxGetTexGendv(req), #[cfg(feature = "glx")] Request::GlxGetTexGenfv(req) => Request::GlxGetTexGenfv(req), #[cfg(feature = "glx")] Request::GlxGetTexGeniv(req) => Request::GlxGetTexGeniv(req), #[cfg(feature = "glx")] Request::GlxGetTexImage(req) => Request::GlxGetTexImage(req), #[cfg(feature = "glx")] Request::GlxGetTexParameterfv(req) => Request::GlxGetTexParameterfv(req), #[cfg(feature = "glx")] Request::GlxGetTexParameteriv(req) => Request::GlxGetTexParameteriv(req), #[cfg(feature = "glx")] Request::GlxGetTexLevelParameterfv(req) => Request::GlxGetTexLevelParameterfv(req), #[cfg(feature = "glx")] Request::GlxGetTexLevelParameteriv(req) => Request::GlxGetTexLevelParameteriv(req), #[cfg(feature = "glx")] Request::GlxIsEnabled(req) => Request::GlxIsEnabled(req), #[cfg(feature = "glx")] Request::GlxIsList(req) => Request::GlxIsList(req), #[cfg(feature = "glx")] Request::GlxFlush(req) => Request::GlxFlush(req), #[cfg(feature = "glx")] Request::GlxAreTexturesResident(req) => Request::GlxAreTexturesResident(req.into_owned()), #[cfg(feature = "glx")] Request::GlxDeleteTextures(req) => Request::GlxDeleteTextures(req.into_owned()), #[cfg(feature = "glx")] Request::GlxGenTextures(req) => Request::GlxGenTextures(req), #[cfg(feature = "glx")] Request::GlxIsTexture(req) => Request::GlxIsTexture(req), #[cfg(feature = "glx")] Request::GlxGetColorTable(req) => Request::GlxGetColorTable(req), #[cfg(feature = "glx")] Request::GlxGetColorTableParameterfv(req) => Request::GlxGetColorTableParameterfv(req), #[cfg(feature = "glx")] Request::GlxGetColorTableParameteriv(req) => Request::GlxGetColorTableParameteriv(req), #[cfg(feature = "glx")] Request::GlxGetConvolutionFilter(req) => Request::GlxGetConvolutionFilter(req), #[cfg(feature = "glx")] Request::GlxGetConvolutionParameterfv(req) => Request::GlxGetConvolutionParameterfv(req), #[cfg(feature = "glx")] Request::GlxGetConvolutionParameteriv(req) => Request::GlxGetConvolutionParameteriv(req), #[cfg(feature = "glx")] Request::GlxGetSeparableFilter(req) => Request::GlxGetSeparableFilter(req), #[cfg(feature = "glx")] Request::GlxGetHistogram(req) => Request::GlxGetHistogram(req), #[cfg(feature = "glx")] Request::GlxGetHistogramParameterfv(req) => Request::GlxGetHistogramParameterfv(req), #[cfg(feature = "glx")] Request::GlxGetHistogramParameteriv(req) => Request::GlxGetHistogramParameteriv(req), #[cfg(feature = "glx")] Request::GlxGetMinmax(req) => Request::GlxGetMinmax(req), #[cfg(feature = "glx")] Request::GlxGetMinmaxParameterfv(req) => Request::GlxGetMinmaxParameterfv(req), #[cfg(feature = "glx")] Request::GlxGetMinmaxParameteriv(req) => Request::GlxGetMinmaxParameteriv(req), #[cfg(feature = "glx")] Request::GlxGetCompressedTexImageARB(req) => Request::GlxGetCompressedTexImageARB(req), #[cfg(feature = "glx")] Request::GlxDeleteQueriesARB(req) => Request::GlxDeleteQueriesARB(req.into_owned()), #[cfg(feature = "glx")] Request::GlxGenQueriesARB(req) => Request::GlxGenQueriesARB(req), #[cfg(feature = "glx")] Request::GlxIsQueryARB(req) => Request::GlxIsQueryARB(req), #[cfg(feature = "glx")] Request::GlxGetQueryivARB(req) => Request::GlxGetQueryivARB(req), #[cfg(feature = "glx")] Request::GlxGetQueryObjectivARB(req) => Request::GlxGetQueryObjectivARB(req), #[cfg(feature = "glx")] Request::GlxGetQueryObjectuivARB(req) => Request::GlxGetQueryObjectuivARB(req), #[cfg(feature = "present")] Request::PresentQueryVersion(req) => Request::PresentQueryVersion(req), #[cfg(feature = "present")] Request::PresentPixmap(req) => Request::PresentPixmap(req.into_owned()), #[cfg(feature = "present")] Request::PresentNotifyMSC(req) => Request::PresentNotifyMSC(req), #[cfg(feature = "present")] Request::PresentSelectInput(req) => Request::PresentSelectInput(req), #[cfg(feature = "present")] Request::PresentQueryCapabilities(req) => Request::PresentQueryCapabilities(req), #[cfg(feature = "present")] Request::PresentPixmapSynced(req) => Request::PresentPixmapSynced(req.into_owned()), #[cfg(feature = "randr")] Request::RandrQueryVersion(req) => Request::RandrQueryVersion(req), #[cfg(feature = "randr")] Request::RandrSetScreenConfig(req) => Request::RandrSetScreenConfig(req), #[cfg(feature = "randr")] Request::RandrSelectInput(req) => Request::RandrSelectInput(req), #[cfg(feature = "randr")] Request::RandrGetScreenInfo(req) => Request::RandrGetScreenInfo(req), #[cfg(feature = "randr")] Request::RandrGetScreenSizeRange(req) => Request::RandrGetScreenSizeRange(req), #[cfg(feature = "randr")] Request::RandrSetScreenSize(req) => Request::RandrSetScreenSize(req), #[cfg(feature = "randr")] Request::RandrGetScreenResources(req) => Request::RandrGetScreenResources(req), #[cfg(feature = "randr")] Request::RandrGetOutputInfo(req) => Request::RandrGetOutputInfo(req), #[cfg(feature = "randr")] Request::RandrListOutputProperties(req) => Request::RandrListOutputProperties(req), #[cfg(feature = "randr")] Request::RandrQueryOutputProperty(req) => Request::RandrQueryOutputProperty(req), #[cfg(feature = "randr")] Request::RandrConfigureOutputProperty(req) => Request::RandrConfigureOutputProperty(req.into_owned()), #[cfg(feature = "randr")] Request::RandrChangeOutputProperty(req) => Request::RandrChangeOutputProperty(req.into_owned()), #[cfg(feature = "randr")] Request::RandrDeleteOutputProperty(req) => Request::RandrDeleteOutputProperty(req), #[cfg(feature = "randr")] Request::RandrGetOutputProperty(req) => Request::RandrGetOutputProperty(req), #[cfg(feature = "randr")] Request::RandrCreateMode(req) => Request::RandrCreateMode(req.into_owned()), #[cfg(feature = "randr")] Request::RandrDestroyMode(req) => Request::RandrDestroyMode(req), #[cfg(feature = "randr")] Request::RandrAddOutputMode(req) => Request::RandrAddOutputMode(req), #[cfg(feature = "randr")] Request::RandrDeleteOutputMode(req) => Request::RandrDeleteOutputMode(req), #[cfg(feature = "randr")] Request::RandrGetCrtcInfo(req) => Request::RandrGetCrtcInfo(req), #[cfg(feature = "randr")] Request::RandrSetCrtcConfig(req) => Request::RandrSetCrtcConfig(req.into_owned()), #[cfg(feature = "randr")] Request::RandrGetCrtcGammaSize(req) => Request::RandrGetCrtcGammaSize(req), #[cfg(feature = "randr")] Request::RandrGetCrtcGamma(req) => Request::RandrGetCrtcGamma(req), #[cfg(feature = "randr")] Request::RandrSetCrtcGamma(req) => Request::RandrSetCrtcGamma(req.into_owned()), #[cfg(feature = "randr")] Request::RandrGetScreenResourcesCurrent(req) => Request::RandrGetScreenResourcesCurrent(req), #[cfg(feature = "randr")] Request::RandrSetCrtcTransform(req) => Request::RandrSetCrtcTransform(req.into_owned()), #[cfg(feature = "randr")] Request::RandrGetCrtcTransform(req) => Request::RandrGetCrtcTransform(req), #[cfg(feature = "randr")] Request::RandrGetPanning(req) => Request::RandrGetPanning(req), #[cfg(feature = "randr")] Request::RandrSetPanning(req) => Request::RandrSetPanning(req), #[cfg(feature = "randr")] Request::RandrSetOutputPrimary(req) => Request::RandrSetOutputPrimary(req), #[cfg(feature = "randr")] Request::RandrGetOutputPrimary(req) => Request::RandrGetOutputPrimary(req), #[cfg(feature = "randr")] Request::RandrGetProviders(req) => Request::RandrGetProviders(req), #[cfg(feature = "randr")] Request::RandrGetProviderInfo(req) => Request::RandrGetProviderInfo(req), #[cfg(feature = "randr")] Request::RandrSetProviderOffloadSink(req) => Request::RandrSetProviderOffloadSink(req), #[cfg(feature = "randr")] Request::RandrSetProviderOutputSource(req) => Request::RandrSetProviderOutputSource(req), #[cfg(feature = "randr")] Request::RandrListProviderProperties(req) => Request::RandrListProviderProperties(req), #[cfg(feature = "randr")] Request::RandrQueryProviderProperty(req) => Request::RandrQueryProviderProperty(req), #[cfg(feature = "randr")] Request::RandrConfigureProviderProperty(req) => Request::RandrConfigureProviderProperty(req.into_owned()), #[cfg(feature = "randr")] Request::RandrChangeProviderProperty(req) => Request::RandrChangeProviderProperty(req.into_owned()), #[cfg(feature = "randr")] Request::RandrDeleteProviderProperty(req) => Request::RandrDeleteProviderProperty(req), #[cfg(feature = "randr")] Request::RandrGetProviderProperty(req) => Request::RandrGetProviderProperty(req), #[cfg(feature = "randr")] Request::RandrGetMonitors(req) => Request::RandrGetMonitors(req), #[cfg(feature = "randr")] Request::RandrSetMonitor(req) => Request::RandrSetMonitor(req), #[cfg(feature = "randr")] Request::RandrDeleteMonitor(req) => Request::RandrDeleteMonitor(req), #[cfg(feature = "randr")] Request::RandrCreateLease(req) => Request::RandrCreateLease(req.into_owned()), #[cfg(feature = "randr")] Request::RandrFreeLease(req) => Request::RandrFreeLease(req), #[cfg(feature = "record")] Request::RecordQueryVersion(req) => Request::RecordQueryVersion(req), #[cfg(feature = "record")] Request::RecordCreateContext(req) => Request::RecordCreateContext(req.into_owned()), #[cfg(feature = "record")] Request::RecordRegisterClients(req) => Request::RecordRegisterClients(req.into_owned()), #[cfg(feature = "record")] Request::RecordUnregisterClients(req) => Request::RecordUnregisterClients(req.into_owned()), #[cfg(feature = "record")] Request::RecordGetContext(req) => Request::RecordGetContext(req), #[cfg(feature = "record")] Request::RecordEnableContext(req) => Request::RecordEnableContext(req), #[cfg(feature = "record")] Request::RecordDisableContext(req) => Request::RecordDisableContext(req), #[cfg(feature = "record")] Request::RecordFreeContext(req) => Request::RecordFreeContext(req), #[cfg(feature = "render")] Request::RenderQueryVersion(req) => Request::RenderQueryVersion(req), #[cfg(feature = "render")] Request::RenderQueryPictFormats(req) => Request::RenderQueryPictFormats(req), #[cfg(feature = "render")] Request::RenderQueryPictIndexValues(req) => Request::RenderQueryPictIndexValues(req), #[cfg(feature = "render")] Request::RenderCreatePicture(req) => Request::RenderCreatePicture(req.into_owned()), #[cfg(feature = "render")] Request::RenderChangePicture(req) => Request::RenderChangePicture(req.into_owned()), #[cfg(feature = "render")] Request::RenderSetPictureClipRectangles(req) => Request::RenderSetPictureClipRectangles(req.into_owned()), #[cfg(feature = "render")] Request::RenderFreePicture(req) => Request::RenderFreePicture(req), #[cfg(feature = "render")] Request::RenderComposite(req) => Request::RenderComposite(req), #[cfg(feature = "render")] Request::RenderTrapezoids(req) => Request::RenderTrapezoids(req.into_owned()), #[cfg(feature = "render")] Request::RenderTriangles(req) => Request::RenderTriangles(req.into_owned()), #[cfg(feature = "render")] Request::RenderTriStrip(req) => Request::RenderTriStrip(req.into_owned()), #[cfg(feature = "render")] Request::RenderTriFan(req) => Request::RenderTriFan(req.into_owned()), #[cfg(feature = "render")] Request::RenderCreateGlyphSet(req) => Request::RenderCreateGlyphSet(req), #[cfg(feature = "render")] Request::RenderReferenceGlyphSet(req) => Request::RenderReferenceGlyphSet(req), #[cfg(feature = "render")] Request::RenderFreeGlyphSet(req) => Request::RenderFreeGlyphSet(req), #[cfg(feature = "render")] Request::RenderAddGlyphs(req) => Request::RenderAddGlyphs(req.into_owned()), #[cfg(feature = "render")] Request::RenderFreeGlyphs(req) => Request::RenderFreeGlyphs(req.into_owned()), #[cfg(feature = "render")] Request::RenderCompositeGlyphs8(req) => Request::RenderCompositeGlyphs8(req.into_owned()), #[cfg(feature = "render")] Request::RenderCompositeGlyphs16(req) => Request::RenderCompositeGlyphs16(req.into_owned()), #[cfg(feature = "render")] Request::RenderCompositeGlyphs32(req) => Request::RenderCompositeGlyphs32(req.into_owned()), #[cfg(feature = "render")] Request::RenderFillRectangles(req) => Request::RenderFillRectangles(req.into_owned()), #[cfg(feature = "render")] Request::RenderCreateCursor(req) => Request::RenderCreateCursor(req), #[cfg(feature = "render")] Request::RenderSetPictureTransform(req) => Request::RenderSetPictureTransform(req), #[cfg(feature = "render")] Request::RenderQueryFilters(req) => Request::RenderQueryFilters(req), #[cfg(feature = "render")] Request::RenderSetPictureFilter(req) => Request::RenderSetPictureFilter(req.into_owned()), #[cfg(feature = "render")] Request::RenderCreateAnimCursor(req) => Request::RenderCreateAnimCursor(req.into_owned()), #[cfg(feature = "render")] Request::RenderAddTraps(req) => Request::RenderAddTraps(req.into_owned()), #[cfg(feature = "render")] Request::RenderCreateSolidFill(req) => Request::RenderCreateSolidFill(req), #[cfg(feature = "render")] Request::RenderCreateLinearGradient(req) => Request::RenderCreateLinearGradient(req.into_owned()), #[cfg(feature = "render")] Request::RenderCreateRadialGradient(req) => Request::RenderCreateRadialGradient(req.into_owned()), #[cfg(feature = "render")] Request::RenderCreateConicalGradient(req) => Request::RenderCreateConicalGradient(req.into_owned()), #[cfg(feature = "res")] Request::ResQueryVersion(req) => Request::ResQueryVersion(req), #[cfg(feature = "res")] Request::ResQueryClients(req) => Request::ResQueryClients(req), #[cfg(feature = "res")] Request::ResQueryClientResources(req) => Request::ResQueryClientResources(req), #[cfg(feature = "res")] Request::ResQueryClientPixmapBytes(req) => Request::ResQueryClientPixmapBytes(req), #[cfg(feature = "res")] Request::ResQueryClientIds(req) => Request::ResQueryClientIds(req.into_owned()), #[cfg(feature = "res")] Request::ResQueryResourceBytes(req) => Request::ResQueryResourceBytes(req.into_owned()), #[cfg(feature = "screensaver")] Request::ScreensaverQueryVersion(req) => Request::ScreensaverQueryVersion(req), #[cfg(feature = "screensaver")] Request::ScreensaverQueryInfo(req) => Request::ScreensaverQueryInfo(req), #[cfg(feature = "screensaver")] Request::ScreensaverSelectInput(req) => Request::ScreensaverSelectInput(req), #[cfg(feature = "screensaver")] Request::ScreensaverSetAttributes(req) => Request::ScreensaverSetAttributes(req.into_owned()), #[cfg(feature = "screensaver")] Request::ScreensaverUnsetAttributes(req) => Request::ScreensaverUnsetAttributes(req), #[cfg(feature = "screensaver")] Request::ScreensaverSuspend(req) => Request::ScreensaverSuspend(req), #[cfg(feature = "shape")] Request::ShapeQueryVersion(req) => Request::ShapeQueryVersion(req), #[cfg(feature = "shape")] Request::ShapeRectangles(req) => Request::ShapeRectangles(req.into_owned()), #[cfg(feature = "shape")] Request::ShapeMask(req) => Request::ShapeMask(req), #[cfg(feature = "shape")] Request::ShapeCombine(req) => Request::ShapeCombine(req), #[cfg(feature = "shape")] Request::ShapeOffset(req) => Request::ShapeOffset(req), #[cfg(feature = "shape")] Request::ShapeQueryExtents(req) => Request::ShapeQueryExtents(req), #[cfg(feature = "shape")] Request::ShapeSelectInput(req) => Request::ShapeSelectInput(req), #[cfg(feature = "shape")] Request::ShapeInputSelected(req) => Request::ShapeInputSelected(req), #[cfg(feature = "shape")] Request::ShapeGetRectangles(req) => Request::ShapeGetRectangles(req), #[cfg(feature = "shm")] Request::ShmQueryVersion(req) => Request::ShmQueryVersion(req), #[cfg(feature = "shm")] Request::ShmAttach(req) => Request::ShmAttach(req), #[cfg(feature = "shm")] Request::ShmDetach(req) => Request::ShmDetach(req), #[cfg(feature = "shm")] Request::ShmPutImage(req) => Request::ShmPutImage(req), #[cfg(feature = "shm")] Request::ShmGetImage(req) => Request::ShmGetImage(req), #[cfg(feature = "shm")] Request::ShmCreatePixmap(req) => Request::ShmCreatePixmap(req), #[cfg(feature = "shm")] Request::ShmAttachFd(req) => Request::ShmAttachFd(req), #[cfg(feature = "shm")] Request::ShmCreateSegment(req) => Request::ShmCreateSegment(req), #[cfg(feature = "sync")] Request::SyncInitialize(req) => Request::SyncInitialize(req), #[cfg(feature = "sync")] Request::SyncListSystemCounters(req) => Request::SyncListSystemCounters(req), #[cfg(feature = "sync")] Request::SyncCreateCounter(req) => Request::SyncCreateCounter(req), #[cfg(feature = "sync")] Request::SyncDestroyCounter(req) => Request::SyncDestroyCounter(req), #[cfg(feature = "sync")] Request::SyncQueryCounter(req) => Request::SyncQueryCounter(req), #[cfg(feature = "sync")] Request::SyncAwait(req) => Request::SyncAwait(req.into_owned()), #[cfg(feature = "sync")] Request::SyncChangeCounter(req) => Request::SyncChangeCounter(req), #[cfg(feature = "sync")] Request::SyncSetCounter(req) => Request::SyncSetCounter(req), #[cfg(feature = "sync")] Request::SyncCreateAlarm(req) => Request::SyncCreateAlarm(req.into_owned()), #[cfg(feature = "sync")] Request::SyncChangeAlarm(req) => Request::SyncChangeAlarm(req.into_owned()), #[cfg(feature = "sync")] Request::SyncDestroyAlarm(req) => Request::SyncDestroyAlarm(req), #[cfg(feature = "sync")] Request::SyncQueryAlarm(req) => Request::SyncQueryAlarm(req), #[cfg(feature = "sync")] Request::SyncSetPriority(req) => Request::SyncSetPriority(req), #[cfg(feature = "sync")] Request::SyncGetPriority(req) => Request::SyncGetPriority(req), #[cfg(feature = "sync")] Request::SyncCreateFence(req) => Request::SyncCreateFence(req), #[cfg(feature = "sync")] Request::SyncTriggerFence(req) => Request::SyncTriggerFence(req), #[cfg(feature = "sync")] Request::SyncResetFence(req) => Request::SyncResetFence(req), #[cfg(feature = "sync")] Request::SyncDestroyFence(req) => Request::SyncDestroyFence(req), #[cfg(feature = "sync")] Request::SyncQueryFence(req) => Request::SyncQueryFence(req), #[cfg(feature = "sync")] Request::SyncAwaitFence(req) => Request::SyncAwaitFence(req.into_owned()), Request::XcMiscGetVersion(req) => Request::XcMiscGetVersion(req), Request::XcMiscGetXIDRange(req) => Request::XcMiscGetXIDRange(req), Request::XcMiscGetXIDList(req) => Request::XcMiscGetXIDList(req), #[cfg(feature = "xevie")] Request::XevieQueryVersion(req) => Request::XevieQueryVersion(req), #[cfg(feature = "xevie")] Request::XevieStart(req) => Request::XevieStart(req), #[cfg(feature = "xevie")] Request::XevieEnd(req) => Request::XevieEnd(req), #[cfg(feature = "xevie")] Request::XevieSend(req) => Request::XevieSend(req), #[cfg(feature = "xevie")] Request::XevieSelectInput(req) => Request::XevieSelectInput(req), #[cfg(feature = "xf86dri")] Request::Xf86driQueryVersion(req) => Request::Xf86driQueryVersion(req), #[cfg(feature = "xf86dri")] Request::Xf86driQueryDirectRenderingCapable(req) => Request::Xf86driQueryDirectRenderingCapable(req), #[cfg(feature = "xf86dri")] Request::Xf86driOpenConnection(req) => Request::Xf86driOpenConnection(req), #[cfg(feature = "xf86dri")] Request::Xf86driCloseConnection(req) => Request::Xf86driCloseConnection(req), #[cfg(feature = "xf86dri")] Request::Xf86driGetClientDriverName(req) => Request::Xf86driGetClientDriverName(req), #[cfg(feature = "xf86dri")] Request::Xf86driCreateContext(req) => Request::Xf86driCreateContext(req), #[cfg(feature = "xf86dri")] Request::Xf86driDestroyContext(req) => Request::Xf86driDestroyContext(req), #[cfg(feature = "xf86dri")] Request::Xf86driCreateDrawable(req) => Request::Xf86driCreateDrawable(req), #[cfg(feature = "xf86dri")] Request::Xf86driDestroyDrawable(req) => Request::Xf86driDestroyDrawable(req), #[cfg(feature = "xf86dri")] Request::Xf86driGetDrawableInfo(req) => Request::Xf86driGetDrawableInfo(req), #[cfg(feature = "xf86dri")] Request::Xf86driGetDeviceInfo(req) => Request::Xf86driGetDeviceInfo(req), #[cfg(feature = "xf86dri")] Request::Xf86driAuthConnection(req) => Request::Xf86driAuthConnection(req), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeQueryVersion(req) => Request::Xf86vidmodeQueryVersion(req), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetModeLine(req) => Request::Xf86vidmodeGetModeLine(req), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeModModeLine(req) => Request::Xf86vidmodeModModeLine(req.into_owned()), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeSwitchMode(req) => Request::Xf86vidmodeSwitchMode(req), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetMonitor(req) => Request::Xf86vidmodeGetMonitor(req), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeLockModeSwitch(req) => Request::Xf86vidmodeLockModeSwitch(req), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetAllModeLines(req) => Request::Xf86vidmodeGetAllModeLines(req), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeAddModeLine(req) => Request::Xf86vidmodeAddModeLine(req.into_owned()), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeDeleteModeLine(req) => Request::Xf86vidmodeDeleteModeLine(req.into_owned()), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeValidateModeLine(req) => Request::Xf86vidmodeValidateModeLine(req.into_owned()), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeSwitchToMode(req) => Request::Xf86vidmodeSwitchToMode(req.into_owned()), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetViewPort(req) => Request::Xf86vidmodeGetViewPort(req), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeSetViewPort(req) => Request::Xf86vidmodeSetViewPort(req), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetDotClocks(req) => Request::Xf86vidmodeGetDotClocks(req), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeSetClientVersion(req) => Request::Xf86vidmodeSetClientVersion(req), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeSetGamma(req) => Request::Xf86vidmodeSetGamma(req), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetGamma(req) => Request::Xf86vidmodeGetGamma(req), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetGammaRamp(req) => Request::Xf86vidmodeGetGammaRamp(req), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeSetGammaRamp(req) => Request::Xf86vidmodeSetGammaRamp(req.into_owned()), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetGammaRampSize(req) => Request::Xf86vidmodeGetGammaRampSize(req), #[cfg(feature = "xf86vidmode")] Request::Xf86vidmodeGetPermissions(req) => Request::Xf86vidmodeGetPermissions(req), #[cfg(feature = "xfixes")] Request::XfixesQueryVersion(req) => Request::XfixesQueryVersion(req), #[cfg(feature = "xfixes")] Request::XfixesChangeSaveSet(req) => Request::XfixesChangeSaveSet(req), #[cfg(feature = "xfixes")] Request::XfixesSelectSelectionInput(req) => Request::XfixesSelectSelectionInput(req), #[cfg(feature = "xfixes")] Request::XfixesSelectCursorInput(req) => Request::XfixesSelectCursorInput(req), #[cfg(feature = "xfixes")] Request::XfixesGetCursorImage(req) => Request::XfixesGetCursorImage(req), #[cfg(feature = "xfixes")] Request::XfixesCreateRegion(req) => Request::XfixesCreateRegion(req.into_owned()), #[cfg(feature = "xfixes")] Request::XfixesCreateRegionFromBitmap(req) => Request::XfixesCreateRegionFromBitmap(req), #[cfg(feature = "xfixes")] Request::XfixesCreateRegionFromWindow(req) => Request::XfixesCreateRegionFromWindow(req), #[cfg(feature = "xfixes")] Request::XfixesCreateRegionFromGC(req) => Request::XfixesCreateRegionFromGC(req), #[cfg(feature = "xfixes")] Request::XfixesCreateRegionFromPicture(req) => Request::XfixesCreateRegionFromPicture(req), #[cfg(feature = "xfixes")] Request::XfixesDestroyRegion(req) => Request::XfixesDestroyRegion(req), #[cfg(feature = "xfixes")] Request::XfixesSetRegion(req) => Request::XfixesSetRegion(req.into_owned()), #[cfg(feature = "xfixes")] Request::XfixesCopyRegion(req) => Request::XfixesCopyRegion(req), #[cfg(feature = "xfixes")] Request::XfixesUnionRegion(req) => Request::XfixesUnionRegion(req), #[cfg(feature = "xfixes")] Request::XfixesIntersectRegion(req) => Request::XfixesIntersectRegion(req), #[cfg(feature = "xfixes")] Request::XfixesSubtractRegion(req) => Request::XfixesSubtractRegion(req), #[cfg(feature = "xfixes")] Request::XfixesInvertRegion(req) => Request::XfixesInvertRegion(req), #[cfg(feature = "xfixes")] Request::XfixesTranslateRegion(req) => Request::XfixesTranslateRegion(req), #[cfg(feature = "xfixes")] Request::XfixesRegionExtents(req) => Request::XfixesRegionExtents(req), #[cfg(feature = "xfixes")] Request::XfixesFetchRegion(req) => Request::XfixesFetchRegion(req), #[cfg(feature = "xfixes")] Request::XfixesSetGCClipRegion(req) => Request::XfixesSetGCClipRegion(req), #[cfg(feature = "xfixes")] Request::XfixesSetWindowShapeRegion(req) => Request::XfixesSetWindowShapeRegion(req), #[cfg(feature = "xfixes")] Request::XfixesSetPictureClipRegion(req) => Request::XfixesSetPictureClipRegion(req), #[cfg(feature = "xfixes")] Request::XfixesSetCursorName(req) => Request::XfixesSetCursorName(req.into_owned()), #[cfg(feature = "xfixes")] Request::XfixesGetCursorName(req) => Request::XfixesGetCursorName(req), #[cfg(feature = "xfixes")] Request::XfixesGetCursorImageAndName(req) => Request::XfixesGetCursorImageAndName(req), #[cfg(feature = "xfixes")] Request::XfixesChangeCursor(req) => Request::XfixesChangeCursor(req), #[cfg(feature = "xfixes")] Request::XfixesChangeCursorByName(req) => Request::XfixesChangeCursorByName(req.into_owned()), #[cfg(feature = "xfixes")] Request::XfixesExpandRegion(req) => Request::XfixesExpandRegion(req), #[cfg(feature = "xfixes")] Request::XfixesHideCursor(req) => Request::XfixesHideCursor(req), #[cfg(feature = "xfixes")] Request::XfixesShowCursor(req) => Request::XfixesShowCursor(req), #[cfg(feature = "xfixes")] Request::XfixesCreatePointerBarrier(req) => Request::XfixesCreatePointerBarrier(req.into_owned()), #[cfg(feature = "xfixes")] Request::XfixesDeletePointerBarrier(req) => Request::XfixesDeletePointerBarrier(req), #[cfg(feature = "xfixes")] Request::XfixesSetClientDisconnectMode(req) => Request::XfixesSetClientDisconnectMode(req), #[cfg(feature = "xfixes")] Request::XfixesGetClientDisconnectMode(req) => Request::XfixesGetClientDisconnectMode(req), #[cfg(feature = "xinerama")] Request::XineramaQueryVersion(req) => Request::XineramaQueryVersion(req), #[cfg(feature = "xinerama")] Request::XineramaGetState(req) => Request::XineramaGetState(req), #[cfg(feature = "xinerama")] Request::XineramaGetScreenCount(req) => Request::XineramaGetScreenCount(req), #[cfg(feature = "xinerama")] Request::XineramaGetScreenSize(req) => Request::XineramaGetScreenSize(req), #[cfg(feature = "xinerama")] Request::XineramaIsActive(req) => Request::XineramaIsActive(req), #[cfg(feature = "xinerama")] Request::XineramaQueryScreens(req) => Request::XineramaQueryScreens(req), #[cfg(feature = "xinput")] Request::XinputGetExtensionVersion(req) => Request::XinputGetExtensionVersion(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputListInputDevices(req) => Request::XinputListInputDevices(req), #[cfg(feature = "xinput")] Request::XinputOpenDevice(req) => Request::XinputOpenDevice(req), #[cfg(feature = "xinput")] Request::XinputCloseDevice(req) => Request::XinputCloseDevice(req), #[cfg(feature = "xinput")] Request::XinputSetDeviceMode(req) => Request::XinputSetDeviceMode(req), #[cfg(feature = "xinput")] Request::XinputSelectExtensionEvent(req) => Request::XinputSelectExtensionEvent(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputGetSelectedExtensionEvents(req) => Request::XinputGetSelectedExtensionEvents(req), #[cfg(feature = "xinput")] Request::XinputChangeDeviceDontPropagateList(req) => Request::XinputChangeDeviceDontPropagateList(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputGetDeviceDontPropagateList(req) => Request::XinputGetDeviceDontPropagateList(req), #[cfg(feature = "xinput")] Request::XinputGetDeviceMotionEvents(req) => Request::XinputGetDeviceMotionEvents(req), #[cfg(feature = "xinput")] Request::XinputChangeKeyboardDevice(req) => Request::XinputChangeKeyboardDevice(req), #[cfg(feature = "xinput")] Request::XinputChangePointerDevice(req) => Request::XinputChangePointerDevice(req), #[cfg(feature = "xinput")] Request::XinputGrabDevice(req) => Request::XinputGrabDevice(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputUngrabDevice(req) => Request::XinputUngrabDevice(req), #[cfg(feature = "xinput")] Request::XinputGrabDeviceKey(req) => Request::XinputGrabDeviceKey(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputUngrabDeviceKey(req) => Request::XinputUngrabDeviceKey(req), #[cfg(feature = "xinput")] Request::XinputGrabDeviceButton(req) => Request::XinputGrabDeviceButton(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputUngrabDeviceButton(req) => Request::XinputUngrabDeviceButton(req), #[cfg(feature = "xinput")] Request::XinputAllowDeviceEvents(req) => Request::XinputAllowDeviceEvents(req), #[cfg(feature = "xinput")] Request::XinputGetDeviceFocus(req) => Request::XinputGetDeviceFocus(req), #[cfg(feature = "xinput")] Request::XinputSetDeviceFocus(req) => Request::XinputSetDeviceFocus(req), #[cfg(feature = "xinput")] Request::XinputGetFeedbackControl(req) => Request::XinputGetFeedbackControl(req), #[cfg(feature = "xinput")] Request::XinputChangeFeedbackControl(req) => Request::XinputChangeFeedbackControl(req), #[cfg(feature = "xinput")] Request::XinputGetDeviceKeyMapping(req) => Request::XinputGetDeviceKeyMapping(req), #[cfg(feature = "xinput")] Request::XinputChangeDeviceKeyMapping(req) => Request::XinputChangeDeviceKeyMapping(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputGetDeviceModifierMapping(req) => Request::XinputGetDeviceModifierMapping(req), #[cfg(feature = "xinput")] Request::XinputSetDeviceModifierMapping(req) => Request::XinputSetDeviceModifierMapping(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputGetDeviceButtonMapping(req) => Request::XinputGetDeviceButtonMapping(req), #[cfg(feature = "xinput")] Request::XinputSetDeviceButtonMapping(req) => Request::XinputSetDeviceButtonMapping(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputQueryDeviceState(req) => Request::XinputQueryDeviceState(req), #[cfg(feature = "xinput")] Request::XinputDeviceBell(req) => Request::XinputDeviceBell(req), #[cfg(feature = "xinput")] Request::XinputSetDeviceValuators(req) => Request::XinputSetDeviceValuators(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputGetDeviceControl(req) => Request::XinputGetDeviceControl(req), #[cfg(feature = "xinput")] Request::XinputChangeDeviceControl(req) => Request::XinputChangeDeviceControl(req), #[cfg(feature = "xinput")] Request::XinputListDeviceProperties(req) => Request::XinputListDeviceProperties(req), #[cfg(feature = "xinput")] Request::XinputChangeDeviceProperty(req) => Request::XinputChangeDeviceProperty(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputDeleteDeviceProperty(req) => Request::XinputDeleteDeviceProperty(req), #[cfg(feature = "xinput")] Request::XinputGetDeviceProperty(req) => Request::XinputGetDeviceProperty(req), #[cfg(feature = "xinput")] Request::XinputXIQueryPointer(req) => Request::XinputXIQueryPointer(req), #[cfg(feature = "xinput")] Request::XinputXIWarpPointer(req) => Request::XinputXIWarpPointer(req), #[cfg(feature = "xinput")] Request::XinputXIChangeCursor(req) => Request::XinputXIChangeCursor(req), #[cfg(feature = "xinput")] Request::XinputXIChangeHierarchy(req) => Request::XinputXIChangeHierarchy(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputXISetClientPointer(req) => Request::XinputXISetClientPointer(req), #[cfg(feature = "xinput")] Request::XinputXIGetClientPointer(req) => Request::XinputXIGetClientPointer(req), #[cfg(feature = "xinput")] Request::XinputXISelectEvents(req) => Request::XinputXISelectEvents(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputXIQueryVersion(req) => Request::XinputXIQueryVersion(req), #[cfg(feature = "xinput")] Request::XinputXIQueryDevice(req) => Request::XinputXIQueryDevice(req), #[cfg(feature = "xinput")] Request::XinputXISetFocus(req) => Request::XinputXISetFocus(req), #[cfg(feature = "xinput")] Request::XinputXIGetFocus(req) => Request::XinputXIGetFocus(req), #[cfg(feature = "xinput")] Request::XinputXIGrabDevice(req) => Request::XinputXIGrabDevice(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputXIUngrabDevice(req) => Request::XinputXIUngrabDevice(req), #[cfg(feature = "xinput")] Request::XinputXIAllowEvents(req) => Request::XinputXIAllowEvents(req), #[cfg(feature = "xinput")] Request::XinputXIPassiveGrabDevice(req) => Request::XinputXIPassiveGrabDevice(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputXIPassiveUngrabDevice(req) => Request::XinputXIPassiveUngrabDevice(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputXIListProperties(req) => Request::XinputXIListProperties(req), #[cfg(feature = "xinput")] Request::XinputXIChangeProperty(req) => Request::XinputXIChangeProperty(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputXIDeleteProperty(req) => Request::XinputXIDeleteProperty(req), #[cfg(feature = "xinput")] Request::XinputXIGetProperty(req) => Request::XinputXIGetProperty(req), #[cfg(feature = "xinput")] Request::XinputXIGetSelectedEvents(req) => Request::XinputXIGetSelectedEvents(req), #[cfg(feature = "xinput")] Request::XinputXIBarrierReleasePointer(req) => Request::XinputXIBarrierReleasePointer(req.into_owned()), #[cfg(feature = "xinput")] Request::XinputSendExtensionEvent(req) => Request::XinputSendExtensionEvent(req.into_owned()), #[cfg(feature = "xkb")] Request::XkbUseExtension(req) => Request::XkbUseExtension(req), #[cfg(feature = "xkb")] Request::XkbSelectEvents(req) => Request::XkbSelectEvents(req.into_owned()), #[cfg(feature = "xkb")] Request::XkbBell(req) => Request::XkbBell(req), #[cfg(feature = "xkb")] Request::XkbGetState(req) => Request::XkbGetState(req), #[cfg(feature = "xkb")] Request::XkbLatchLockState(req) => Request::XkbLatchLockState(req), #[cfg(feature = "xkb")] Request::XkbGetControls(req) => Request::XkbGetControls(req), #[cfg(feature = "xkb")] Request::XkbSetControls(req) => Request::XkbSetControls(req.into_owned()), #[cfg(feature = "xkb")] Request::XkbGetMap(req) => Request::XkbGetMap(req), #[cfg(feature = "xkb")] Request::XkbSetMap(req) => Request::XkbSetMap(req.into_owned()), #[cfg(feature = "xkb")] Request::XkbGetCompatMap(req) => Request::XkbGetCompatMap(req), #[cfg(feature = "xkb")] Request::XkbSetCompatMap(req) => Request::XkbSetCompatMap(req.into_owned()), #[cfg(feature = "xkb")] Request::XkbGetIndicatorState(req) => Request::XkbGetIndicatorState(req), #[cfg(feature = "xkb")] Request::XkbGetIndicatorMap(req) => Request::XkbGetIndicatorMap(req), #[cfg(feature = "xkb")] Request::XkbSetIndicatorMap(req) => Request::XkbSetIndicatorMap(req.into_owned()), #[cfg(feature = "xkb")] Request::XkbGetNamedIndicator(req) => Request::XkbGetNamedIndicator(req), #[cfg(feature = "xkb")] Request::XkbSetNamedIndicator(req) => Request::XkbSetNamedIndicator(req), #[cfg(feature = "xkb")] Request::XkbGetNames(req) => Request::XkbGetNames(req), #[cfg(feature = "xkb")] Request::XkbSetNames(req) => Request::XkbSetNames(req.into_owned()), #[cfg(feature = "xkb")] Request::XkbPerClientFlags(req) => Request::XkbPerClientFlags(req), #[cfg(feature = "xkb")] Request::XkbListComponents(req) => Request::XkbListComponents(req), #[cfg(feature = "xkb")] Request::XkbGetKbdByName(req) => Request::XkbGetKbdByName(req), #[cfg(feature = "xkb")] Request::XkbGetDeviceInfo(req) => Request::XkbGetDeviceInfo(req), #[cfg(feature = "xkb")] Request::XkbSetDeviceInfo(req) => Request::XkbSetDeviceInfo(req.into_owned()), #[cfg(feature = "xkb")] Request::XkbSetDebuggingFlags(req) => Request::XkbSetDebuggingFlags(req.into_owned()), #[cfg(feature = "xprint")] Request::XprintPrintQueryVersion(req) => Request::XprintPrintQueryVersion(req), #[cfg(feature = "xprint")] Request::XprintPrintGetPrinterList(req) => Request::XprintPrintGetPrinterList(req.into_owned()), #[cfg(feature = "xprint")] Request::XprintPrintRehashPrinterList(req) => Request::XprintPrintRehashPrinterList(req), #[cfg(feature = "xprint")] Request::XprintCreateContext(req) => Request::XprintCreateContext(req.into_owned()), #[cfg(feature = "xprint")] Request::XprintPrintSetContext(req) => Request::XprintPrintSetContext(req), #[cfg(feature = "xprint")] Request::XprintPrintGetContext(req) => Request::XprintPrintGetContext(req), #[cfg(feature = "xprint")] Request::XprintPrintDestroyContext(req) => Request::XprintPrintDestroyContext(req), #[cfg(feature = "xprint")] Request::XprintPrintGetScreenOfContext(req) => Request::XprintPrintGetScreenOfContext(req), #[cfg(feature = "xprint")] Request::XprintPrintStartJob(req) => Request::XprintPrintStartJob(req), #[cfg(feature = "xprint")] Request::XprintPrintEndJob(req) => Request::XprintPrintEndJob(req), #[cfg(feature = "xprint")] Request::XprintPrintStartDoc(req) => Request::XprintPrintStartDoc(req), #[cfg(feature = "xprint")] Request::XprintPrintEndDoc(req) => Request::XprintPrintEndDoc(req), #[cfg(feature = "xprint")] Request::XprintPrintPutDocumentData(req) => Request::XprintPrintPutDocumentData(req.into_owned()), #[cfg(feature = "xprint")] Request::XprintPrintGetDocumentData(req) => Request::XprintPrintGetDocumentData(req), #[cfg(feature = "xprint")] Request::XprintPrintStartPage(req) => Request::XprintPrintStartPage(req), #[cfg(feature = "xprint")] Request::XprintPrintEndPage(req) => Request::XprintPrintEndPage(req), #[cfg(feature = "xprint")] Request::XprintPrintSelectInput(req) => Request::XprintPrintSelectInput(req), #[cfg(feature = "xprint")] Request::XprintPrintInputSelected(req) => Request::XprintPrintInputSelected(req), #[cfg(feature = "xprint")] Request::XprintPrintGetAttributes(req) => Request::XprintPrintGetAttributes(req), #[cfg(feature = "xprint")] Request::XprintPrintGetOneAttributes(req) => Request::XprintPrintGetOneAttributes(req.into_owned()), #[cfg(feature = "xprint")] Request::XprintPrintSetAttributes(req) => Request::XprintPrintSetAttributes(req.into_owned()), #[cfg(feature = "xprint")] Request::XprintPrintGetPageDimensions(req) => Request::XprintPrintGetPageDimensions(req), #[cfg(feature = "xprint")] Request::XprintPrintQueryScreens(req) => Request::XprintPrintQueryScreens(req), #[cfg(feature = "xprint")] Request::XprintPrintSetImageResolution(req) => Request::XprintPrintSetImageResolution(req), #[cfg(feature = "xprint")] Request::XprintPrintGetImageResolution(req) => Request::XprintPrintGetImageResolution(req), #[cfg(feature = "xselinux")] Request::XselinuxQueryVersion(req) => Request::XselinuxQueryVersion(req), #[cfg(feature = "xselinux")] Request::XselinuxSetDeviceCreateContext(req) => Request::XselinuxSetDeviceCreateContext(req.into_owned()), #[cfg(feature = "xselinux")] Request::XselinuxGetDeviceCreateContext(req) => Request::XselinuxGetDeviceCreateContext(req), #[cfg(feature = "xselinux")] Request::XselinuxSetDeviceContext(req) => Request::XselinuxSetDeviceContext(req.into_owned()), #[cfg(feature = "xselinux")] Request::XselinuxGetDeviceContext(req) => Request::XselinuxGetDeviceContext(req), #[cfg(feature = "xselinux")] Request::XselinuxSetWindowCreateContext(req) => Request::XselinuxSetWindowCreateContext(req.into_owned()), #[cfg(feature = "xselinux")] Request::XselinuxGetWindowCreateContext(req) => Request::XselinuxGetWindowCreateContext(req), #[cfg(feature = "xselinux")] Request::XselinuxGetWindowContext(req) => Request::XselinuxGetWindowContext(req), #[cfg(feature = "xselinux")] Request::XselinuxSetPropertyCreateContext(req) => Request::XselinuxSetPropertyCreateContext(req.into_owned()), #[cfg(feature = "xselinux")] Request::XselinuxGetPropertyCreateContext(req) => Request::XselinuxGetPropertyCreateContext(req), #[cfg(feature = "xselinux")] Request::XselinuxSetPropertyUseContext(req) => Request::XselinuxSetPropertyUseContext(req.into_owned()), #[cfg(feature = "xselinux")] Request::XselinuxGetPropertyUseContext(req) => Request::XselinuxGetPropertyUseContext(req), #[cfg(feature = "xselinux")] Request::XselinuxGetPropertyContext(req) => Request::XselinuxGetPropertyContext(req), #[cfg(feature = "xselinux")] Request::XselinuxGetPropertyDataContext(req) => Request::XselinuxGetPropertyDataContext(req), #[cfg(feature = "xselinux")] Request::XselinuxListProperties(req) => Request::XselinuxListProperties(req), #[cfg(feature = "xselinux")] Request::XselinuxSetSelectionCreateContext(req) => Request::XselinuxSetSelectionCreateContext(req.into_owned()), #[cfg(feature = "xselinux")] Request::XselinuxGetSelectionCreateContext(req) => Request::XselinuxGetSelectionCreateContext(req), #[cfg(feature = "xselinux")] Request::XselinuxSetSelectionUseContext(req) => Request::XselinuxSetSelectionUseContext(req.into_owned()), #[cfg(feature = "xselinux")] Request::XselinuxGetSelectionUseContext(req) => Request::XselinuxGetSelectionUseContext(req), #[cfg(feature = "xselinux")] Request::XselinuxGetSelectionContext(req) => Request::XselinuxGetSelectionContext(req), #[cfg(feature = "xselinux")] Request::XselinuxGetSelectionDataContext(req) => Request::XselinuxGetSelectionDataContext(req), #[cfg(feature = "xselinux")] Request::XselinuxListSelections(req) => Request::XselinuxListSelections(req), #[cfg(feature = "xselinux")] Request::XselinuxGetClientContext(req) => Request::XselinuxGetClientContext(req), #[cfg(feature = "xtest")] Request::XtestGetVersion(req) => Request::XtestGetVersion(req), #[cfg(feature = "xtest")] Request::XtestCompareCursor(req) => Request::XtestCompareCursor(req), #[cfg(feature = "xtest")] Request::XtestFakeInput(req) => Request::XtestFakeInput(req), #[cfg(feature = "xtest")] Request::XtestGrabControl(req) => Request::XtestGrabControl(req), #[cfg(feature = "xv")] Request::XvQueryExtension(req) => Request::XvQueryExtension(req), #[cfg(feature = "xv")] Request::XvQueryAdaptors(req) => Request::XvQueryAdaptors(req), #[cfg(feature = "xv")] Request::XvQueryEncodings(req) => Request::XvQueryEncodings(req), #[cfg(feature = "xv")] Request::XvGrabPort(req) => Request::XvGrabPort(req), #[cfg(feature = "xv")] Request::XvUngrabPort(req) => Request::XvUngrabPort(req), #[cfg(feature = "xv")] Request::XvPutVideo(req) => Request::XvPutVideo(req), #[cfg(feature = "xv")] Request::XvPutStill(req) => Request::XvPutStill(req), #[cfg(feature = "xv")] Request::XvGetVideo(req) => Request::XvGetVideo(req), #[cfg(feature = "xv")] Request::XvGetStill(req) => Request::XvGetStill(req), #[cfg(feature = "xv")] Request::XvStopVideo(req) => Request::XvStopVideo(req), #[cfg(feature = "xv")] Request::XvSelectVideoNotify(req) => Request::XvSelectVideoNotify(req), #[cfg(feature = "xv")] Request::XvSelectPortNotify(req) => Request::XvSelectPortNotify(req), #[cfg(feature = "xv")] Request::XvQueryBestSize(req) => Request::XvQueryBestSize(req), #[cfg(feature = "xv")] Request::XvSetPortAttribute(req) => Request::XvSetPortAttribute(req), #[cfg(feature = "xv")] Request::XvGetPortAttribute(req) => Request::XvGetPortAttribute(req), #[cfg(feature = "xv")] Request::XvQueryPortAttributes(req) => Request::XvQueryPortAttributes(req), #[cfg(feature = "xv")] Request::XvListImageFormats(req) => Request::XvListImageFormats(req), #[cfg(feature = "xv")] Request::XvQueryImageAttributes(req) => Request::XvQueryImageAttributes(req), #[cfg(feature = "xv")] Request::XvPutImage(req) => Request::XvPutImage(req.into_owned()), #[cfg(feature = "xv")] Request::XvShmPutImage(req) => Request::XvShmPutImage(req), #[cfg(feature = "xvmc")] Request::XvmcQueryVersion(req) => Request::XvmcQueryVersion(req), #[cfg(feature = "xvmc")] Request::XvmcListSurfaceTypes(req) => Request::XvmcListSurfaceTypes(req), #[cfg(feature = "xvmc")] Request::XvmcCreateContext(req) => Request::XvmcCreateContext(req), #[cfg(feature = "xvmc")] Request::XvmcDestroyContext(req) => Request::XvmcDestroyContext(req), #[cfg(feature = "xvmc")] Request::XvmcCreateSurface(req) => Request::XvmcCreateSurface(req), #[cfg(feature = "xvmc")] Request::XvmcDestroySurface(req) => Request::XvmcDestroySurface(req), #[cfg(feature = "xvmc")] Request::XvmcCreateSubpicture(req) => Request::XvmcCreateSubpicture(req), #[cfg(feature = "xvmc")] Request::XvmcDestroySubpicture(req) => Request::XvmcDestroySubpicture(req), #[cfg(feature = "xvmc")] Request::XvmcListSubpictureTypes(req) => Request::XvmcListSubpictureTypes(req), } } } /// Enumeration of all possible X11 replies. #[derive(Debug)] #[allow(clippy::large_enum_variant)] #[non_exhaustive] pub enum Reply { Void, GetWindowAttributes(xproto::GetWindowAttributesReply), GetGeometry(xproto::GetGeometryReply), QueryTree(xproto::QueryTreeReply), InternAtom(xproto::InternAtomReply), GetAtomName(xproto::GetAtomNameReply), GetProperty(xproto::GetPropertyReply), ListProperties(xproto::ListPropertiesReply), GetSelectionOwner(xproto::GetSelectionOwnerReply), GrabPointer(xproto::GrabPointerReply), GrabKeyboard(xproto::GrabKeyboardReply), QueryPointer(xproto::QueryPointerReply), GetMotionEvents(xproto::GetMotionEventsReply), TranslateCoordinates(xproto::TranslateCoordinatesReply), GetInputFocus(xproto::GetInputFocusReply), QueryKeymap(xproto::QueryKeymapReply), QueryFont(xproto::QueryFontReply), QueryTextExtents(xproto::QueryTextExtentsReply), ListFonts(xproto::ListFontsReply), ListFontsWithInfo(xproto::ListFontsWithInfoReply), GetFontPath(xproto::GetFontPathReply), GetImage(xproto::GetImageReply), ListInstalledColormaps(xproto::ListInstalledColormapsReply), AllocColor(xproto::AllocColorReply), AllocNamedColor(xproto::AllocNamedColorReply), AllocColorCells(xproto::AllocColorCellsReply), AllocColorPlanes(xproto::AllocColorPlanesReply), QueryColors(xproto::QueryColorsReply), LookupColor(xproto::LookupColorReply), QueryBestSize(xproto::QueryBestSizeReply), QueryExtension(xproto::QueryExtensionReply), ListExtensions(xproto::ListExtensionsReply), GetKeyboardMapping(xproto::GetKeyboardMappingReply), GetKeyboardControl(xproto::GetKeyboardControlReply), GetPointerControl(xproto::GetPointerControlReply), GetScreenSaver(xproto::GetScreenSaverReply), ListHosts(xproto::ListHostsReply), SetPointerMapping(xproto::SetPointerMappingReply), GetPointerMapping(xproto::GetPointerMappingReply), SetModifierMapping(xproto::SetModifierMappingReply), GetModifierMapping(xproto::GetModifierMappingReply), BigreqEnable(bigreq::EnableReply), #[cfg(feature = "composite")] CompositeQueryVersion(composite::QueryVersionReply), #[cfg(feature = "composite")] CompositeGetOverlayWindow(composite::GetOverlayWindowReply), #[cfg(feature = "damage")] DamageQueryVersion(damage::QueryVersionReply), #[cfg(feature = "dbe")] DbeQueryVersion(dbe::QueryVersionReply), #[cfg(feature = "dbe")] DbeGetVisualInfo(dbe::GetVisualInfoReply), #[cfg(feature = "dbe")] DbeGetBackBufferAttributes(dbe::GetBackBufferAttributesReply), #[cfg(feature = "dpms")] DpmsGetVersion(dpms::GetVersionReply), #[cfg(feature = "dpms")] DpmsCapable(dpms::CapableReply), #[cfg(feature = "dpms")] DpmsGetTimeouts(dpms::GetTimeoutsReply), #[cfg(feature = "dpms")] DpmsInfo(dpms::InfoReply), #[cfg(feature = "dri2")] Dri2QueryVersion(dri2::QueryVersionReply), #[cfg(feature = "dri2")] Dri2Connect(dri2::ConnectReply), #[cfg(feature = "dri2")] Dri2Authenticate(dri2::AuthenticateReply), #[cfg(feature = "dri2")] Dri2GetBuffers(dri2::GetBuffersReply), #[cfg(feature = "dri2")] Dri2CopyRegion(dri2::CopyRegionReply), #[cfg(feature = "dri2")] Dri2GetBuffersWithFormat(dri2::GetBuffersWithFormatReply), #[cfg(feature = "dri2")] Dri2SwapBuffers(dri2::SwapBuffersReply), #[cfg(feature = "dri2")] Dri2GetMSC(dri2::GetMSCReply), #[cfg(feature = "dri2")] Dri2WaitMSC(dri2::WaitMSCReply), #[cfg(feature = "dri2")] Dri2WaitSBC(dri2::WaitSBCReply), #[cfg(feature = "dri2")] Dri2GetParam(dri2::GetParamReply), #[cfg(feature = "dri3")] Dri3QueryVersion(dri3::QueryVersionReply), #[cfg(feature = "dri3")] Dri3Open(dri3::OpenReply), #[cfg(feature = "dri3")] Dri3BufferFromPixmap(dri3::BufferFromPixmapReply), #[cfg(feature = "dri3")] Dri3FDFromFence(dri3::FDFromFenceReply), #[cfg(feature = "dri3")] Dri3GetSupportedModifiers(dri3::GetSupportedModifiersReply), #[cfg(feature = "dri3")] Dri3BuffersFromPixmap(dri3::BuffersFromPixmapReply), GeQueryVersion(ge::QueryVersionReply), #[cfg(feature = "glx")] GlxMakeCurrent(glx::MakeCurrentReply), #[cfg(feature = "glx")] GlxIsDirect(glx::IsDirectReply), #[cfg(feature = "glx")] GlxQueryVersion(glx::QueryVersionReply), #[cfg(feature = "glx")] GlxGetVisualConfigs(glx::GetVisualConfigsReply), #[cfg(feature = "glx")] GlxVendorPrivateWithReply(glx::VendorPrivateWithReplyReply), #[cfg(feature = "glx")] GlxQueryExtensionsString(glx::QueryExtensionsStringReply), #[cfg(feature = "glx")] GlxQueryServerString(glx::QueryServerStringReply), #[cfg(feature = "glx")] GlxGetFBConfigs(glx::GetFBConfigsReply), #[cfg(feature = "glx")] GlxQueryContext(glx::QueryContextReply), #[cfg(feature = "glx")] GlxMakeContextCurrent(glx::MakeContextCurrentReply), #[cfg(feature = "glx")] GlxGetDrawableAttributes(glx::GetDrawableAttributesReply), #[cfg(feature = "glx")] GlxGenLists(glx::GenListsReply), #[cfg(feature = "glx")] GlxRenderMode(glx::RenderModeReply), #[cfg(feature = "glx")] GlxFinish(glx::FinishReply), #[cfg(feature = "glx")] GlxReadPixels(glx::ReadPixelsReply), #[cfg(feature = "glx")] GlxGetBooleanv(glx::GetBooleanvReply), #[cfg(feature = "glx")] GlxGetClipPlane(glx::GetClipPlaneReply), #[cfg(feature = "glx")] GlxGetDoublev(glx::GetDoublevReply), #[cfg(feature = "glx")] GlxGetError(glx::GetErrorReply), #[cfg(feature = "glx")] GlxGetFloatv(glx::GetFloatvReply), #[cfg(feature = "glx")] GlxGetIntegerv(glx::GetIntegervReply), #[cfg(feature = "glx")] GlxGetLightfv(glx::GetLightfvReply), #[cfg(feature = "glx")] GlxGetLightiv(glx::GetLightivReply), #[cfg(feature = "glx")] GlxGetMapdv(glx::GetMapdvReply), #[cfg(feature = "glx")] GlxGetMapfv(glx::GetMapfvReply), #[cfg(feature = "glx")] GlxGetMapiv(glx::GetMapivReply), #[cfg(feature = "glx")] GlxGetMaterialfv(glx::GetMaterialfvReply), #[cfg(feature = "glx")] GlxGetMaterialiv(glx::GetMaterialivReply), #[cfg(feature = "glx")] GlxGetPixelMapfv(glx::GetPixelMapfvReply), #[cfg(feature = "glx")] GlxGetPixelMapuiv(glx::GetPixelMapuivReply), #[cfg(feature = "glx")] GlxGetPixelMapusv(glx::GetPixelMapusvReply), #[cfg(feature = "glx")] GlxGetPolygonStipple(glx::GetPolygonStippleReply), #[cfg(feature = "glx")] GlxGetString(glx::GetStringReply), #[cfg(feature = "glx")] GlxGetTexEnvfv(glx::GetTexEnvfvReply), #[cfg(feature = "glx")] GlxGetTexEnviv(glx::GetTexEnvivReply), #[cfg(feature = "glx")] GlxGetTexGendv(glx::GetTexGendvReply), #[cfg(feature = "glx")] GlxGetTexGenfv(glx::GetTexGenfvReply), #[cfg(feature = "glx")] GlxGetTexGeniv(glx::GetTexGenivReply), #[cfg(feature = "glx")] GlxGetTexImage(glx::GetTexImageReply), #[cfg(feature = "glx")] GlxGetTexParameterfv(glx::GetTexParameterfvReply), #[cfg(feature = "glx")] GlxGetTexParameteriv(glx::GetTexParameterivReply), #[cfg(feature = "glx")] GlxGetTexLevelParameterfv(glx::GetTexLevelParameterfvReply), #[cfg(feature = "glx")] GlxGetTexLevelParameteriv(glx::GetTexLevelParameterivReply), #[cfg(feature = "glx")] GlxIsEnabled(glx::IsEnabledReply), #[cfg(feature = "glx")] GlxIsList(glx::IsListReply), #[cfg(feature = "glx")] GlxAreTexturesResident(glx::AreTexturesResidentReply), #[cfg(feature = "glx")] GlxGenTextures(glx::GenTexturesReply), #[cfg(feature = "glx")] GlxIsTexture(glx::IsTextureReply), #[cfg(feature = "glx")] GlxGetColorTable(glx::GetColorTableReply), #[cfg(feature = "glx")] GlxGetColorTableParameterfv(glx::GetColorTableParameterfvReply), #[cfg(feature = "glx")] GlxGetColorTableParameteriv(glx::GetColorTableParameterivReply), #[cfg(feature = "glx")] GlxGetConvolutionFilter(glx::GetConvolutionFilterReply), #[cfg(feature = "glx")] GlxGetConvolutionParameterfv(glx::GetConvolutionParameterfvReply), #[cfg(feature = "glx")] GlxGetConvolutionParameteriv(glx::GetConvolutionParameterivReply), #[cfg(feature = "glx")] GlxGetSeparableFilter(glx::GetSeparableFilterReply), #[cfg(feature = "glx")] GlxGetHistogram(glx::GetHistogramReply), #[cfg(feature = "glx")] GlxGetHistogramParameterfv(glx::GetHistogramParameterfvReply), #[cfg(feature = "glx")] GlxGetHistogramParameteriv(glx::GetHistogramParameterivReply), #[cfg(feature = "glx")] GlxGetMinmax(glx::GetMinmaxReply), #[cfg(feature = "glx")] GlxGetMinmaxParameterfv(glx::GetMinmaxParameterfvReply), #[cfg(feature = "glx")] GlxGetMinmaxParameteriv(glx::GetMinmaxParameterivReply), #[cfg(feature = "glx")] GlxGetCompressedTexImageARB(glx::GetCompressedTexImageARBReply), #[cfg(feature = "glx")] GlxGenQueriesARB(glx::GenQueriesARBReply), #[cfg(feature = "glx")] GlxIsQueryARB(glx::IsQueryARBReply), #[cfg(feature = "glx")] GlxGetQueryivARB(glx::GetQueryivARBReply), #[cfg(feature = "glx")] GlxGetQueryObjectivARB(glx::GetQueryObjectivARBReply), #[cfg(feature = "glx")] GlxGetQueryObjectuivARB(glx::GetQueryObjectuivARBReply), #[cfg(feature = "present")] PresentQueryVersion(present::QueryVersionReply), #[cfg(feature = "present")] PresentQueryCapabilities(present::QueryCapabilitiesReply), #[cfg(feature = "randr")] RandrQueryVersion(randr::QueryVersionReply), #[cfg(feature = "randr")] RandrSetScreenConfig(randr::SetScreenConfigReply), #[cfg(feature = "randr")] RandrGetScreenInfo(randr::GetScreenInfoReply), #[cfg(feature = "randr")] RandrGetScreenSizeRange(randr::GetScreenSizeRangeReply), #[cfg(feature = "randr")] RandrGetScreenResources(randr::GetScreenResourcesReply), #[cfg(feature = "randr")] RandrGetOutputInfo(randr::GetOutputInfoReply), #[cfg(feature = "randr")] RandrListOutputProperties(randr::ListOutputPropertiesReply), #[cfg(feature = "randr")] RandrQueryOutputProperty(randr::QueryOutputPropertyReply), #[cfg(feature = "randr")] RandrGetOutputProperty(randr::GetOutputPropertyReply), #[cfg(feature = "randr")] RandrCreateMode(randr::CreateModeReply), #[cfg(feature = "randr")] RandrGetCrtcInfo(randr::GetCrtcInfoReply), #[cfg(feature = "randr")] RandrSetCrtcConfig(randr::SetCrtcConfigReply), #[cfg(feature = "randr")] RandrGetCrtcGammaSize(randr::GetCrtcGammaSizeReply), #[cfg(feature = "randr")] RandrGetCrtcGamma(randr::GetCrtcGammaReply), #[cfg(feature = "randr")] RandrGetScreenResourcesCurrent(randr::GetScreenResourcesCurrentReply), #[cfg(feature = "randr")] RandrGetCrtcTransform(randr::GetCrtcTransformReply), #[cfg(feature = "randr")] RandrGetPanning(randr::GetPanningReply), #[cfg(feature = "randr")] RandrSetPanning(randr::SetPanningReply), #[cfg(feature = "randr")] RandrGetOutputPrimary(randr::GetOutputPrimaryReply), #[cfg(feature = "randr")] RandrGetProviders(randr::GetProvidersReply), #[cfg(feature = "randr")] RandrGetProviderInfo(randr::GetProviderInfoReply), #[cfg(feature = "randr")] RandrListProviderProperties(randr::ListProviderPropertiesReply), #[cfg(feature = "randr")] RandrQueryProviderProperty(randr::QueryProviderPropertyReply), #[cfg(feature = "randr")] RandrGetProviderProperty(randr::GetProviderPropertyReply), #[cfg(feature = "randr")] RandrGetMonitors(randr::GetMonitorsReply), #[cfg(feature = "randr")] RandrCreateLease(randr::CreateLeaseReply), #[cfg(feature = "record")] RecordQueryVersion(record::QueryVersionReply), #[cfg(feature = "record")] RecordGetContext(record::GetContextReply), #[cfg(feature = "record")] RecordEnableContext(record::EnableContextReply), #[cfg(feature = "render")] RenderQueryVersion(render::QueryVersionReply), #[cfg(feature = "render")] RenderQueryPictFormats(render::QueryPictFormatsReply), #[cfg(feature = "render")] RenderQueryPictIndexValues(render::QueryPictIndexValuesReply), #[cfg(feature = "render")] RenderQueryFilters(render::QueryFiltersReply), #[cfg(feature = "res")] ResQueryVersion(res::QueryVersionReply), #[cfg(feature = "res")] ResQueryClients(res::QueryClientsReply), #[cfg(feature = "res")] ResQueryClientResources(res::QueryClientResourcesReply), #[cfg(feature = "res")] ResQueryClientPixmapBytes(res::QueryClientPixmapBytesReply), #[cfg(feature = "res")] ResQueryClientIds(res::QueryClientIdsReply), #[cfg(feature = "res")] ResQueryResourceBytes(res::QueryResourceBytesReply), #[cfg(feature = "screensaver")] ScreensaverQueryVersion(screensaver::QueryVersionReply), #[cfg(feature = "screensaver")] ScreensaverQueryInfo(screensaver::QueryInfoReply), #[cfg(feature = "shape")] ShapeQueryVersion(shape::QueryVersionReply), #[cfg(feature = "shape")] ShapeQueryExtents(shape::QueryExtentsReply), #[cfg(feature = "shape")] ShapeInputSelected(shape::InputSelectedReply), #[cfg(feature = "shape")] ShapeGetRectangles(shape::GetRectanglesReply), #[cfg(feature = "shm")] ShmQueryVersion(shm::QueryVersionReply), #[cfg(feature = "shm")] ShmGetImage(shm::GetImageReply), #[cfg(feature = "shm")] ShmCreateSegment(shm::CreateSegmentReply), #[cfg(feature = "sync")] SyncInitialize(sync::InitializeReply), #[cfg(feature = "sync")] SyncListSystemCounters(sync::ListSystemCountersReply), #[cfg(feature = "sync")] SyncQueryCounter(sync::QueryCounterReply), #[cfg(feature = "sync")] SyncQueryAlarm(sync::QueryAlarmReply), #[cfg(feature = "sync")] SyncGetPriority(sync::GetPriorityReply), #[cfg(feature = "sync")] SyncQueryFence(sync::QueryFenceReply), XcMiscGetVersion(xc_misc::GetVersionReply), XcMiscGetXIDRange(xc_misc::GetXIDRangeReply), XcMiscGetXIDList(xc_misc::GetXIDListReply), #[cfg(feature = "xevie")] XevieQueryVersion(xevie::QueryVersionReply), #[cfg(feature = "xevie")] XevieStart(xevie::StartReply), #[cfg(feature = "xevie")] XevieEnd(xevie::EndReply), #[cfg(feature = "xevie")] XevieSend(xevie::SendReply), #[cfg(feature = "xevie")] XevieSelectInput(xevie::SelectInputReply), #[cfg(feature = "xf86dri")] Xf86driQueryVersion(xf86dri::QueryVersionReply), #[cfg(feature = "xf86dri")] Xf86driQueryDirectRenderingCapable(xf86dri::QueryDirectRenderingCapableReply), #[cfg(feature = "xf86dri")] Xf86driOpenConnection(xf86dri::OpenConnectionReply), #[cfg(feature = "xf86dri")] Xf86driGetClientDriverName(xf86dri::GetClientDriverNameReply), #[cfg(feature = "xf86dri")] Xf86driCreateContext(xf86dri::CreateContextReply), #[cfg(feature = "xf86dri")] Xf86driCreateDrawable(xf86dri::CreateDrawableReply), #[cfg(feature = "xf86dri")] Xf86driGetDrawableInfo(xf86dri::GetDrawableInfoReply), #[cfg(feature = "xf86dri")] Xf86driGetDeviceInfo(xf86dri::GetDeviceInfoReply), #[cfg(feature = "xf86dri")] Xf86driAuthConnection(xf86dri::AuthConnectionReply), #[cfg(feature = "xf86vidmode")] Xf86vidmodeQueryVersion(xf86vidmode::QueryVersionReply), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetModeLine(xf86vidmode::GetModeLineReply), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetMonitor(xf86vidmode::GetMonitorReply), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetAllModeLines(xf86vidmode::GetAllModeLinesReply), #[cfg(feature = "xf86vidmode")] Xf86vidmodeValidateModeLine(xf86vidmode::ValidateModeLineReply), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetViewPort(xf86vidmode::GetViewPortReply), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetDotClocks(xf86vidmode::GetDotClocksReply), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetGamma(xf86vidmode::GetGammaReply), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetGammaRamp(xf86vidmode::GetGammaRampReply), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetGammaRampSize(xf86vidmode::GetGammaRampSizeReply), #[cfg(feature = "xf86vidmode")] Xf86vidmodeGetPermissions(xf86vidmode::GetPermissionsReply), #[cfg(feature = "xfixes")] XfixesQueryVersion(xfixes::QueryVersionReply), #[cfg(feature = "xfixes")] XfixesGetCursorImage(xfixes::GetCursorImageReply), #[cfg(feature = "xfixes")] XfixesFetchRegion(xfixes::FetchRegionReply), #[cfg(feature = "xfixes")] XfixesGetCursorName(xfixes::GetCursorNameReply), #[cfg(feature = "xfixes")] XfixesGetCursorImageAndName(xfixes::GetCursorImageAndNameReply), #[cfg(feature = "xfixes")] XfixesGetClientDisconnectMode(xfixes::GetClientDisconnectModeReply), #[cfg(feature = "xinerama")] XineramaQueryVersion(xinerama::QueryVersionReply), #[cfg(feature = "xinerama")] XineramaGetState(xinerama::GetStateReply), #[cfg(feature = "xinerama")] XineramaGetScreenCount(xinerama::GetScreenCountReply), #[cfg(feature = "xinerama")] XineramaGetScreenSize(xinerama::GetScreenSizeReply), #[cfg(feature = "xinerama")] XineramaIsActive(xinerama::IsActiveReply), #[cfg(feature = "xinerama")] XineramaQueryScreens(xinerama::QueryScreensReply), #[cfg(feature = "xinput")] XinputGetExtensionVersion(xinput::GetExtensionVersionReply), #[cfg(feature = "xinput")] XinputListInputDevices(xinput::ListInputDevicesReply), #[cfg(feature = "xinput")] XinputOpenDevice(xinput::OpenDeviceReply), #[cfg(feature = "xinput")] XinputSetDeviceMode(xinput::SetDeviceModeReply), #[cfg(feature = "xinput")] XinputGetSelectedExtensionEvents(xinput::GetSelectedExtensionEventsReply), #[cfg(feature = "xinput")] XinputGetDeviceDontPropagateList(xinput::GetDeviceDontPropagateListReply), #[cfg(feature = "xinput")] XinputGetDeviceMotionEvents(xinput::GetDeviceMotionEventsReply), #[cfg(feature = "xinput")] XinputChangeKeyboardDevice(xinput::ChangeKeyboardDeviceReply), #[cfg(feature = "xinput")] XinputChangePointerDevice(xinput::ChangePointerDeviceReply), #[cfg(feature = "xinput")] XinputGrabDevice(xinput::GrabDeviceReply), #[cfg(feature = "xinput")] XinputGetDeviceFocus(xinput::GetDeviceFocusReply), #[cfg(feature = "xinput")] XinputGetFeedbackControl(xinput::GetFeedbackControlReply), #[cfg(feature = "xinput")] XinputGetDeviceKeyMapping(xinput::GetDeviceKeyMappingReply), #[cfg(feature = "xinput")] XinputGetDeviceModifierMapping(xinput::GetDeviceModifierMappingReply), #[cfg(feature = "xinput")] XinputSetDeviceModifierMapping(xinput::SetDeviceModifierMappingReply), #[cfg(feature = "xinput")] XinputGetDeviceButtonMapping(xinput::GetDeviceButtonMappingReply), #[cfg(feature = "xinput")] XinputSetDeviceButtonMapping(xinput::SetDeviceButtonMappingReply), #[cfg(feature = "xinput")] XinputQueryDeviceState(xinput::QueryDeviceStateReply), #[cfg(feature = "xinput")] XinputSetDeviceValuators(xinput::SetDeviceValuatorsReply), #[cfg(feature = "xinput")] XinputGetDeviceControl(xinput::GetDeviceControlReply), #[cfg(feature = "xinput")] XinputChangeDeviceControl(xinput::ChangeDeviceControlReply), #[cfg(feature = "xinput")] XinputListDeviceProperties(xinput::ListDevicePropertiesReply), #[cfg(feature = "xinput")] XinputGetDeviceProperty(xinput::GetDevicePropertyReply), #[cfg(feature = "xinput")] XinputXIQueryPointer(xinput::XIQueryPointerReply), #[cfg(feature = "xinput")] XinputXIGetClientPointer(xinput::XIGetClientPointerReply), #[cfg(feature = "xinput")] XinputXIQueryVersion(xinput::XIQueryVersionReply), #[cfg(feature = "xinput")] XinputXIQueryDevice(xinput::XIQueryDeviceReply), #[cfg(feature = "xinput")] XinputXIGetFocus(xinput::XIGetFocusReply), #[cfg(feature = "xinput")] XinputXIGrabDevice(xinput::XIGrabDeviceReply), #[cfg(feature = "xinput")] XinputXIPassiveGrabDevice(xinput::XIPassiveGrabDeviceReply), #[cfg(feature = "xinput")] XinputXIListProperties(xinput::XIListPropertiesReply), #[cfg(feature = "xinput")] XinputXIGetProperty(xinput::XIGetPropertyReply), #[cfg(feature = "xinput")] XinputXIGetSelectedEvents(xinput::XIGetSelectedEventsReply), #[cfg(feature = "xkb")] XkbUseExtension(xkb::UseExtensionReply), #[cfg(feature = "xkb")] XkbGetState(xkb::GetStateReply), #[cfg(feature = "xkb")] XkbGetControls(xkb::GetControlsReply), #[cfg(feature = "xkb")] XkbGetMap(xkb::GetMapReply), #[cfg(feature = "xkb")] XkbGetCompatMap(xkb::GetCompatMapReply), #[cfg(feature = "xkb")] XkbGetIndicatorState(xkb::GetIndicatorStateReply), #[cfg(feature = "xkb")] XkbGetIndicatorMap(xkb::GetIndicatorMapReply), #[cfg(feature = "xkb")] XkbGetNamedIndicator(xkb::GetNamedIndicatorReply), #[cfg(feature = "xkb")] XkbGetNames(xkb::GetNamesReply), #[cfg(feature = "xkb")] XkbPerClientFlags(xkb::PerClientFlagsReply), #[cfg(feature = "xkb")] XkbListComponents(xkb::ListComponentsReply), #[cfg(feature = "xkb")] XkbGetKbdByName(xkb::GetKbdByNameReply), #[cfg(feature = "xkb")] XkbGetDeviceInfo(xkb::GetDeviceInfoReply), #[cfg(feature = "xkb")] XkbSetDebuggingFlags(xkb::SetDebuggingFlagsReply), #[cfg(feature = "xprint")] XprintPrintQueryVersion(xprint::PrintQueryVersionReply), #[cfg(feature = "xprint")] XprintPrintGetPrinterList(xprint::PrintGetPrinterListReply), #[cfg(feature = "xprint")] XprintPrintGetContext(xprint::PrintGetContextReply), #[cfg(feature = "xprint")] XprintPrintGetScreenOfContext(xprint::PrintGetScreenOfContextReply), #[cfg(feature = "xprint")] XprintPrintGetDocumentData(xprint::PrintGetDocumentDataReply), #[cfg(feature = "xprint")] XprintPrintInputSelected(xprint::PrintInputSelectedReply), #[cfg(feature = "xprint")] XprintPrintGetAttributes(xprint::PrintGetAttributesReply), #[cfg(feature = "xprint")] XprintPrintGetOneAttributes(xprint::PrintGetOneAttributesReply), #[cfg(feature = "xprint")] XprintPrintGetPageDimensions(xprint::PrintGetPageDimensionsReply), #[cfg(feature = "xprint")] XprintPrintQueryScreens(xprint::PrintQueryScreensReply), #[cfg(feature = "xprint")] XprintPrintSetImageResolution(xprint::PrintSetImageResolutionReply), #[cfg(feature = "xprint")] XprintPrintGetImageResolution(xprint::PrintGetImageResolutionReply), #[cfg(feature = "xselinux")] XselinuxQueryVersion(xselinux::QueryVersionReply), #[cfg(feature = "xselinux")] XselinuxGetDeviceCreateContext(xselinux::GetDeviceCreateContextReply), #[cfg(feature = "xselinux")] XselinuxGetDeviceContext(xselinux::GetDeviceContextReply), #[cfg(feature = "xselinux")] XselinuxGetWindowCreateContext(xselinux::GetWindowCreateContextReply), #[cfg(feature = "xselinux")] XselinuxGetWindowContext(xselinux::GetWindowContextReply), #[cfg(feature = "xselinux")] XselinuxGetPropertyCreateContext(xselinux::GetPropertyCreateContextReply), #[cfg(feature = "xselinux")] XselinuxGetPropertyUseContext(xselinux::GetPropertyUseContextReply), #[cfg(feature = "xselinux")] XselinuxGetPropertyContext(xselinux::GetPropertyContextReply), #[cfg(feature = "xselinux")] XselinuxGetPropertyDataContext(xselinux::GetPropertyDataContextReply), #[cfg(feature = "xselinux")] XselinuxListProperties(xselinux::ListPropertiesReply), #[cfg(feature = "xselinux")] XselinuxGetSelectionCreateContext(xselinux::GetSelectionCreateContextReply), #[cfg(feature = "xselinux")] XselinuxGetSelectionUseContext(xselinux::GetSelectionUseContextReply), #[cfg(feature = "xselinux")] XselinuxGetSelectionContext(xselinux::GetSelectionContextReply), #[cfg(feature = "xselinux")] XselinuxGetSelectionDataContext(xselinux::GetSelectionDataContextReply), #[cfg(feature = "xselinux")] XselinuxListSelections(xselinux::ListSelectionsReply), #[cfg(feature = "xselinux")] XselinuxGetClientContext(xselinux::GetClientContextReply), #[cfg(feature = "xtest")] XtestGetVersion(xtest::GetVersionReply), #[cfg(feature = "xtest")] XtestCompareCursor(xtest::CompareCursorReply), #[cfg(feature = "xv")] XvQueryExtension(xv::QueryExtensionReply), #[cfg(feature = "xv")] XvQueryAdaptors(xv::QueryAdaptorsReply), #[cfg(feature = "xv")] XvQueryEncodings(xv::QueryEncodingsReply), #[cfg(feature = "xv")] XvGrabPort(xv::GrabPortReply), #[cfg(feature = "xv")] XvQueryBestSize(xv::QueryBestSizeReply), #[cfg(feature = "xv")] XvGetPortAttribute(xv::GetPortAttributeReply), #[cfg(feature = "xv")] XvQueryPortAttributes(xv::QueryPortAttributesReply), #[cfg(feature = "xv")] XvListImageFormats(xv::ListImageFormatsReply), #[cfg(feature = "xv")] XvQueryImageAttributes(xv::QueryImageAttributesReply), #[cfg(feature = "xvmc")] XvmcQueryVersion(xvmc::QueryVersionReply), #[cfg(feature = "xvmc")] XvmcListSurfaceTypes(xvmc::ListSurfaceTypesReply), #[cfg(feature = "xvmc")] XvmcCreateContext(xvmc::CreateContextReply), #[cfg(feature = "xvmc")] XvmcCreateSurface(xvmc::CreateSurfaceReply), #[cfg(feature = "xvmc")] XvmcCreateSubpicture(xvmc::CreateSubpictureReply), #[cfg(feature = "xvmc")] XvmcListSubpictureTypes(xvmc::ListSubpictureTypesReply), } impl From<()> for Reply { fn from(_: ()) -> Reply { Reply::Void } } impl From for Reply { fn from(reply: xproto::GetWindowAttributesReply) -> Reply { Reply::GetWindowAttributes(reply) } } impl From for Reply { fn from(reply: xproto::GetGeometryReply) -> Reply { Reply::GetGeometry(reply) } } impl From for Reply { fn from(reply: xproto::QueryTreeReply) -> Reply { Reply::QueryTree(reply) } } impl From for Reply { fn from(reply: xproto::InternAtomReply) -> Reply { Reply::InternAtom(reply) } } impl From for Reply { fn from(reply: xproto::GetAtomNameReply) -> Reply { Reply::GetAtomName(reply) } } impl From for Reply { fn from(reply: xproto::GetPropertyReply) -> Reply { Reply::GetProperty(reply) } } impl From for Reply { fn from(reply: xproto::ListPropertiesReply) -> Reply { Reply::ListProperties(reply) } } impl From for Reply { fn from(reply: xproto::GetSelectionOwnerReply) -> Reply { Reply::GetSelectionOwner(reply) } } impl From for Reply { fn from(reply: xproto::GrabPointerReply) -> Reply { Reply::GrabPointer(reply) } } impl From for Reply { fn from(reply: xproto::GrabKeyboardReply) -> Reply { Reply::GrabKeyboard(reply) } } impl From for Reply { fn from(reply: xproto::QueryPointerReply) -> Reply { Reply::QueryPointer(reply) } } impl From for Reply { fn from(reply: xproto::GetMotionEventsReply) -> Reply { Reply::GetMotionEvents(reply) } } impl From for Reply { fn from(reply: xproto::TranslateCoordinatesReply) -> Reply { Reply::TranslateCoordinates(reply) } } impl From for Reply { fn from(reply: xproto::GetInputFocusReply) -> Reply { Reply::GetInputFocus(reply) } } impl From for Reply { fn from(reply: xproto::QueryKeymapReply) -> Reply { Reply::QueryKeymap(reply) } } impl From for Reply { fn from(reply: xproto::QueryFontReply) -> Reply { Reply::QueryFont(reply) } } impl From for Reply { fn from(reply: xproto::QueryTextExtentsReply) -> Reply { Reply::QueryTextExtents(reply) } } impl From for Reply { fn from(reply: xproto::ListFontsReply) -> Reply { Reply::ListFonts(reply) } } impl From for Reply { fn from(reply: xproto::ListFontsWithInfoReply) -> Reply { Reply::ListFontsWithInfo(reply) } } impl From for Reply { fn from(reply: xproto::GetFontPathReply) -> Reply { Reply::GetFontPath(reply) } } impl From for Reply { fn from(reply: xproto::GetImageReply) -> Reply { Reply::GetImage(reply) } } impl From for Reply { fn from(reply: xproto::ListInstalledColormapsReply) -> Reply { Reply::ListInstalledColormaps(reply) } } impl From for Reply { fn from(reply: xproto::AllocColorReply) -> Reply { Reply::AllocColor(reply) } } impl From for Reply { fn from(reply: xproto::AllocNamedColorReply) -> Reply { Reply::AllocNamedColor(reply) } } impl From for Reply { fn from(reply: xproto::AllocColorCellsReply) -> Reply { Reply::AllocColorCells(reply) } } impl From for Reply { fn from(reply: xproto::AllocColorPlanesReply) -> Reply { Reply::AllocColorPlanes(reply) } } impl From for Reply { fn from(reply: xproto::QueryColorsReply) -> Reply { Reply::QueryColors(reply) } } impl From for Reply { fn from(reply: xproto::LookupColorReply) -> Reply { Reply::LookupColor(reply) } } impl From for Reply { fn from(reply: xproto::QueryBestSizeReply) -> Reply { Reply::QueryBestSize(reply) } } impl From for Reply { fn from(reply: xproto::QueryExtensionReply) -> Reply { Reply::QueryExtension(reply) } } impl From for Reply { fn from(reply: xproto::ListExtensionsReply) -> Reply { Reply::ListExtensions(reply) } } impl From for Reply { fn from(reply: xproto::GetKeyboardMappingReply) -> Reply { Reply::GetKeyboardMapping(reply) } } impl From for Reply { fn from(reply: xproto::GetKeyboardControlReply) -> Reply { Reply::GetKeyboardControl(reply) } } impl From for Reply { fn from(reply: xproto::GetPointerControlReply) -> Reply { Reply::GetPointerControl(reply) } } impl From for Reply { fn from(reply: xproto::GetScreenSaverReply) -> Reply { Reply::GetScreenSaver(reply) } } impl From for Reply { fn from(reply: xproto::ListHostsReply) -> Reply { Reply::ListHosts(reply) } } impl From for Reply { fn from(reply: xproto::SetPointerMappingReply) -> Reply { Reply::SetPointerMapping(reply) } } impl From for Reply { fn from(reply: xproto::GetPointerMappingReply) -> Reply { Reply::GetPointerMapping(reply) } } impl From for Reply { fn from(reply: xproto::SetModifierMappingReply) -> Reply { Reply::SetModifierMapping(reply) } } impl From for Reply { fn from(reply: xproto::GetModifierMappingReply) -> Reply { Reply::GetModifierMapping(reply) } } impl From for Reply { fn from(reply: bigreq::EnableReply) -> Reply { Reply::BigreqEnable(reply) } } #[cfg(feature = "composite")] impl From for Reply { fn from(reply: composite::QueryVersionReply) -> Reply { Reply::CompositeQueryVersion(reply) } } #[cfg(feature = "composite")] impl From for Reply { fn from(reply: composite::GetOverlayWindowReply) -> Reply { Reply::CompositeGetOverlayWindow(reply) } } #[cfg(feature = "damage")] impl From for Reply { fn from(reply: damage::QueryVersionReply) -> Reply { Reply::DamageQueryVersion(reply) } } #[cfg(feature = "dbe")] impl From for Reply { fn from(reply: dbe::QueryVersionReply) -> Reply { Reply::DbeQueryVersion(reply) } } #[cfg(feature = "dbe")] impl From for Reply { fn from(reply: dbe::GetVisualInfoReply) -> Reply { Reply::DbeGetVisualInfo(reply) } } #[cfg(feature = "dbe")] impl From for Reply { fn from(reply: dbe::GetBackBufferAttributesReply) -> Reply { Reply::DbeGetBackBufferAttributes(reply) } } #[cfg(feature = "dpms")] impl From for Reply { fn from(reply: dpms::GetVersionReply) -> Reply { Reply::DpmsGetVersion(reply) } } #[cfg(feature = "dpms")] impl From for Reply { fn from(reply: dpms::CapableReply) -> Reply { Reply::DpmsCapable(reply) } } #[cfg(feature = "dpms")] impl From for Reply { fn from(reply: dpms::GetTimeoutsReply) -> Reply { Reply::DpmsGetTimeouts(reply) } } #[cfg(feature = "dpms")] impl From for Reply { fn from(reply: dpms::InfoReply) -> Reply { Reply::DpmsInfo(reply) } } #[cfg(feature = "dri2")] impl From for Reply { fn from(reply: dri2::QueryVersionReply) -> Reply { Reply::Dri2QueryVersion(reply) } } #[cfg(feature = "dri2")] impl From for Reply { fn from(reply: dri2::ConnectReply) -> Reply { Reply::Dri2Connect(reply) } } #[cfg(feature = "dri2")] impl From for Reply { fn from(reply: dri2::AuthenticateReply) -> Reply { Reply::Dri2Authenticate(reply) } } #[cfg(feature = "dri2")] impl From for Reply { fn from(reply: dri2::GetBuffersReply) -> Reply { Reply::Dri2GetBuffers(reply) } } #[cfg(feature = "dri2")] impl From for Reply { fn from(reply: dri2::CopyRegionReply) -> Reply { Reply::Dri2CopyRegion(reply) } } #[cfg(feature = "dri2")] impl From for Reply { fn from(reply: dri2::GetBuffersWithFormatReply) -> Reply { Reply::Dri2GetBuffersWithFormat(reply) } } #[cfg(feature = "dri2")] impl From for Reply { fn from(reply: dri2::SwapBuffersReply) -> Reply { Reply::Dri2SwapBuffers(reply) } } #[cfg(feature = "dri2")] impl From for Reply { fn from(reply: dri2::GetMSCReply) -> Reply { Reply::Dri2GetMSC(reply) } } #[cfg(feature = "dri2")] impl From for Reply { fn from(reply: dri2::WaitMSCReply) -> Reply { Reply::Dri2WaitMSC(reply) } } #[cfg(feature = "dri2")] impl From for Reply { fn from(reply: dri2::WaitSBCReply) -> Reply { Reply::Dri2WaitSBC(reply) } } #[cfg(feature = "dri2")] impl From for Reply { fn from(reply: dri2::GetParamReply) -> Reply { Reply::Dri2GetParam(reply) } } #[cfg(feature = "dri3")] impl From for Reply { fn from(reply: dri3::QueryVersionReply) -> Reply { Reply::Dri3QueryVersion(reply) } } #[cfg(feature = "dri3")] impl From for Reply { fn from(reply: dri3::OpenReply) -> Reply { Reply::Dri3Open(reply) } } #[cfg(feature = "dri3")] impl From for Reply { fn from(reply: dri3::BufferFromPixmapReply) -> Reply { Reply::Dri3BufferFromPixmap(reply) } } #[cfg(feature = "dri3")] impl From for Reply { fn from(reply: dri3::FDFromFenceReply) -> Reply { Reply::Dri3FDFromFence(reply) } } #[cfg(feature = "dri3")] impl From for Reply { fn from(reply: dri3::GetSupportedModifiersReply) -> Reply { Reply::Dri3GetSupportedModifiers(reply) } } #[cfg(feature = "dri3")] impl From for Reply { fn from(reply: dri3::BuffersFromPixmapReply) -> Reply { Reply::Dri3BuffersFromPixmap(reply) } } impl From for Reply { fn from(reply: ge::QueryVersionReply) -> Reply { Reply::GeQueryVersion(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::MakeCurrentReply) -> Reply { Reply::GlxMakeCurrent(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::IsDirectReply) -> Reply { Reply::GlxIsDirect(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::QueryVersionReply) -> Reply { Reply::GlxQueryVersion(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetVisualConfigsReply) -> Reply { Reply::GlxGetVisualConfigs(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::VendorPrivateWithReplyReply) -> Reply { Reply::GlxVendorPrivateWithReply(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::QueryExtensionsStringReply) -> Reply { Reply::GlxQueryExtensionsString(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::QueryServerStringReply) -> Reply { Reply::GlxQueryServerString(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetFBConfigsReply) -> Reply { Reply::GlxGetFBConfigs(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::QueryContextReply) -> Reply { Reply::GlxQueryContext(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::MakeContextCurrentReply) -> Reply { Reply::GlxMakeContextCurrent(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetDrawableAttributesReply) -> Reply { Reply::GlxGetDrawableAttributes(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GenListsReply) -> Reply { Reply::GlxGenLists(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::RenderModeReply) -> Reply { Reply::GlxRenderMode(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::FinishReply) -> Reply { Reply::GlxFinish(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::ReadPixelsReply) -> Reply { Reply::GlxReadPixels(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetBooleanvReply) -> Reply { Reply::GlxGetBooleanv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetClipPlaneReply) -> Reply { Reply::GlxGetClipPlane(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetDoublevReply) -> Reply { Reply::GlxGetDoublev(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetErrorReply) -> Reply { Reply::GlxGetError(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetFloatvReply) -> Reply { Reply::GlxGetFloatv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetIntegervReply) -> Reply { Reply::GlxGetIntegerv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetLightfvReply) -> Reply { Reply::GlxGetLightfv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetLightivReply) -> Reply { Reply::GlxGetLightiv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetMapdvReply) -> Reply { Reply::GlxGetMapdv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetMapfvReply) -> Reply { Reply::GlxGetMapfv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetMapivReply) -> Reply { Reply::GlxGetMapiv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetMaterialfvReply) -> Reply { Reply::GlxGetMaterialfv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetMaterialivReply) -> Reply { Reply::GlxGetMaterialiv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetPixelMapfvReply) -> Reply { Reply::GlxGetPixelMapfv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetPixelMapuivReply) -> Reply { Reply::GlxGetPixelMapuiv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetPixelMapusvReply) -> Reply { Reply::GlxGetPixelMapusv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetPolygonStippleReply) -> Reply { Reply::GlxGetPolygonStipple(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetStringReply) -> Reply { Reply::GlxGetString(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetTexEnvfvReply) -> Reply { Reply::GlxGetTexEnvfv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetTexEnvivReply) -> Reply { Reply::GlxGetTexEnviv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetTexGendvReply) -> Reply { Reply::GlxGetTexGendv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetTexGenfvReply) -> Reply { Reply::GlxGetTexGenfv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetTexGenivReply) -> Reply { Reply::GlxGetTexGeniv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetTexImageReply) -> Reply { Reply::GlxGetTexImage(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetTexParameterfvReply) -> Reply { Reply::GlxGetTexParameterfv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetTexParameterivReply) -> Reply { Reply::GlxGetTexParameteriv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetTexLevelParameterfvReply) -> Reply { Reply::GlxGetTexLevelParameterfv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetTexLevelParameterivReply) -> Reply { Reply::GlxGetTexLevelParameteriv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::IsEnabledReply) -> Reply { Reply::GlxIsEnabled(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::IsListReply) -> Reply { Reply::GlxIsList(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::AreTexturesResidentReply) -> Reply { Reply::GlxAreTexturesResident(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GenTexturesReply) -> Reply { Reply::GlxGenTextures(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::IsTextureReply) -> Reply { Reply::GlxIsTexture(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetColorTableReply) -> Reply { Reply::GlxGetColorTable(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetColorTableParameterfvReply) -> Reply { Reply::GlxGetColorTableParameterfv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetColorTableParameterivReply) -> Reply { Reply::GlxGetColorTableParameteriv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetConvolutionFilterReply) -> Reply { Reply::GlxGetConvolutionFilter(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetConvolutionParameterfvReply) -> Reply { Reply::GlxGetConvolutionParameterfv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetConvolutionParameterivReply) -> Reply { Reply::GlxGetConvolutionParameteriv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetSeparableFilterReply) -> Reply { Reply::GlxGetSeparableFilter(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetHistogramReply) -> Reply { Reply::GlxGetHistogram(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetHistogramParameterfvReply) -> Reply { Reply::GlxGetHistogramParameterfv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetHistogramParameterivReply) -> Reply { Reply::GlxGetHistogramParameteriv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetMinmaxReply) -> Reply { Reply::GlxGetMinmax(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetMinmaxParameterfvReply) -> Reply { Reply::GlxGetMinmaxParameterfv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetMinmaxParameterivReply) -> Reply { Reply::GlxGetMinmaxParameteriv(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetCompressedTexImageARBReply) -> Reply { Reply::GlxGetCompressedTexImageARB(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GenQueriesARBReply) -> Reply { Reply::GlxGenQueriesARB(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::IsQueryARBReply) -> Reply { Reply::GlxIsQueryARB(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetQueryivARBReply) -> Reply { Reply::GlxGetQueryivARB(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetQueryObjectivARBReply) -> Reply { Reply::GlxGetQueryObjectivARB(reply) } } #[cfg(feature = "glx")] impl From for Reply { fn from(reply: glx::GetQueryObjectuivARBReply) -> Reply { Reply::GlxGetQueryObjectuivARB(reply) } } #[cfg(feature = "present")] impl From for Reply { fn from(reply: present::QueryVersionReply) -> Reply { Reply::PresentQueryVersion(reply) } } #[cfg(feature = "present")] impl From for Reply { fn from(reply: present::QueryCapabilitiesReply) -> Reply { Reply::PresentQueryCapabilities(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::QueryVersionReply) -> Reply { Reply::RandrQueryVersion(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::SetScreenConfigReply) -> Reply { Reply::RandrSetScreenConfig(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetScreenInfoReply) -> Reply { Reply::RandrGetScreenInfo(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetScreenSizeRangeReply) -> Reply { Reply::RandrGetScreenSizeRange(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetScreenResourcesReply) -> Reply { Reply::RandrGetScreenResources(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetOutputInfoReply) -> Reply { Reply::RandrGetOutputInfo(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::ListOutputPropertiesReply) -> Reply { Reply::RandrListOutputProperties(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::QueryOutputPropertyReply) -> Reply { Reply::RandrQueryOutputProperty(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetOutputPropertyReply) -> Reply { Reply::RandrGetOutputProperty(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::CreateModeReply) -> Reply { Reply::RandrCreateMode(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetCrtcInfoReply) -> Reply { Reply::RandrGetCrtcInfo(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::SetCrtcConfigReply) -> Reply { Reply::RandrSetCrtcConfig(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetCrtcGammaSizeReply) -> Reply { Reply::RandrGetCrtcGammaSize(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetCrtcGammaReply) -> Reply { Reply::RandrGetCrtcGamma(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetScreenResourcesCurrentReply) -> Reply { Reply::RandrGetScreenResourcesCurrent(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetCrtcTransformReply) -> Reply { Reply::RandrGetCrtcTransform(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetPanningReply) -> Reply { Reply::RandrGetPanning(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::SetPanningReply) -> Reply { Reply::RandrSetPanning(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetOutputPrimaryReply) -> Reply { Reply::RandrGetOutputPrimary(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetProvidersReply) -> Reply { Reply::RandrGetProviders(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetProviderInfoReply) -> Reply { Reply::RandrGetProviderInfo(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::ListProviderPropertiesReply) -> Reply { Reply::RandrListProviderProperties(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::QueryProviderPropertyReply) -> Reply { Reply::RandrQueryProviderProperty(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetProviderPropertyReply) -> Reply { Reply::RandrGetProviderProperty(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::GetMonitorsReply) -> Reply { Reply::RandrGetMonitors(reply) } } #[cfg(feature = "randr")] impl From for Reply { fn from(reply: randr::CreateLeaseReply) -> Reply { Reply::RandrCreateLease(reply) } } #[cfg(feature = "record")] impl From for Reply { fn from(reply: record::QueryVersionReply) -> Reply { Reply::RecordQueryVersion(reply) } } #[cfg(feature = "record")] impl From for Reply { fn from(reply: record::GetContextReply) -> Reply { Reply::RecordGetContext(reply) } } #[cfg(feature = "record")] impl From for Reply { fn from(reply: record::EnableContextReply) -> Reply { Reply::RecordEnableContext(reply) } } #[cfg(feature = "render")] impl From for Reply { fn from(reply: render::QueryVersionReply) -> Reply { Reply::RenderQueryVersion(reply) } } #[cfg(feature = "render")] impl From for Reply { fn from(reply: render::QueryPictFormatsReply) -> Reply { Reply::RenderQueryPictFormats(reply) } } #[cfg(feature = "render")] impl From for Reply { fn from(reply: render::QueryPictIndexValuesReply) -> Reply { Reply::RenderQueryPictIndexValues(reply) } } #[cfg(feature = "render")] impl From for Reply { fn from(reply: render::QueryFiltersReply) -> Reply { Reply::RenderQueryFilters(reply) } } #[cfg(feature = "res")] impl From for Reply { fn from(reply: res::QueryVersionReply) -> Reply { Reply::ResQueryVersion(reply) } } #[cfg(feature = "res")] impl From for Reply { fn from(reply: res::QueryClientsReply) -> Reply { Reply::ResQueryClients(reply) } } #[cfg(feature = "res")] impl From for Reply { fn from(reply: res::QueryClientResourcesReply) -> Reply { Reply::ResQueryClientResources(reply) } } #[cfg(feature = "res")] impl From for Reply { fn from(reply: res::QueryClientPixmapBytesReply) -> Reply { Reply::ResQueryClientPixmapBytes(reply) } } #[cfg(feature = "res")] impl From for Reply { fn from(reply: res::QueryClientIdsReply) -> Reply { Reply::ResQueryClientIds(reply) } } #[cfg(feature = "res")] impl From for Reply { fn from(reply: res::QueryResourceBytesReply) -> Reply { Reply::ResQueryResourceBytes(reply) } } #[cfg(feature = "screensaver")] impl From for Reply { fn from(reply: screensaver::QueryVersionReply) -> Reply { Reply::ScreensaverQueryVersion(reply) } } #[cfg(feature = "screensaver")] impl From for Reply { fn from(reply: screensaver::QueryInfoReply) -> Reply { Reply::ScreensaverQueryInfo(reply) } } #[cfg(feature = "shape")] impl From for Reply { fn from(reply: shape::QueryVersionReply) -> Reply { Reply::ShapeQueryVersion(reply) } } #[cfg(feature = "shape")] impl From for Reply { fn from(reply: shape::QueryExtentsReply) -> Reply { Reply::ShapeQueryExtents(reply) } } #[cfg(feature = "shape")] impl From for Reply { fn from(reply: shape::InputSelectedReply) -> Reply { Reply::ShapeInputSelected(reply) } } #[cfg(feature = "shape")] impl From for Reply { fn from(reply: shape::GetRectanglesReply) -> Reply { Reply::ShapeGetRectangles(reply) } } #[cfg(feature = "shm")] impl From for Reply { fn from(reply: shm::QueryVersionReply) -> Reply { Reply::ShmQueryVersion(reply) } } #[cfg(feature = "shm")] impl From for Reply { fn from(reply: shm::GetImageReply) -> Reply { Reply::ShmGetImage(reply) } } #[cfg(feature = "shm")] impl From for Reply { fn from(reply: shm::CreateSegmentReply) -> Reply { Reply::ShmCreateSegment(reply) } } #[cfg(feature = "sync")] impl From for Reply { fn from(reply: sync::InitializeReply) -> Reply { Reply::SyncInitialize(reply) } } #[cfg(feature = "sync")] impl From for Reply { fn from(reply: sync::ListSystemCountersReply) -> Reply { Reply::SyncListSystemCounters(reply) } } #[cfg(feature = "sync")] impl From for Reply { fn from(reply: sync::QueryCounterReply) -> Reply { Reply::SyncQueryCounter(reply) } } #[cfg(feature = "sync")] impl From for Reply { fn from(reply: sync::QueryAlarmReply) -> Reply { Reply::SyncQueryAlarm(reply) } } #[cfg(feature = "sync")] impl From for Reply { fn from(reply: sync::GetPriorityReply) -> Reply { Reply::SyncGetPriority(reply) } } #[cfg(feature = "sync")] impl From for Reply { fn from(reply: sync::QueryFenceReply) -> Reply { Reply::SyncQueryFence(reply) } } impl From for Reply { fn from(reply: xc_misc::GetVersionReply) -> Reply { Reply::XcMiscGetVersion(reply) } } impl From for Reply { fn from(reply: xc_misc::GetXIDRangeReply) -> Reply { Reply::XcMiscGetXIDRange(reply) } } impl From for Reply { fn from(reply: xc_misc::GetXIDListReply) -> Reply { Reply::XcMiscGetXIDList(reply) } } #[cfg(feature = "xevie")] impl From for Reply { fn from(reply: xevie::QueryVersionReply) -> Reply { Reply::XevieQueryVersion(reply) } } #[cfg(feature = "xevie")] impl From for Reply { fn from(reply: xevie::StartReply) -> Reply { Reply::XevieStart(reply) } } #[cfg(feature = "xevie")] impl From for Reply { fn from(reply: xevie::EndReply) -> Reply { Reply::XevieEnd(reply) } } #[cfg(feature = "xevie")] impl From for Reply { fn from(reply: xevie::SendReply) -> Reply { Reply::XevieSend(reply) } } #[cfg(feature = "xevie")] impl From for Reply { fn from(reply: xevie::SelectInputReply) -> Reply { Reply::XevieSelectInput(reply) } } #[cfg(feature = "xf86dri")] impl From for Reply { fn from(reply: xf86dri::QueryVersionReply) -> Reply { Reply::Xf86driQueryVersion(reply) } } #[cfg(feature = "xf86dri")] impl From for Reply { fn from(reply: xf86dri::QueryDirectRenderingCapableReply) -> Reply { Reply::Xf86driQueryDirectRenderingCapable(reply) } } #[cfg(feature = "xf86dri")] impl From for Reply { fn from(reply: xf86dri::OpenConnectionReply) -> Reply { Reply::Xf86driOpenConnection(reply) } } #[cfg(feature = "xf86dri")] impl From for Reply { fn from(reply: xf86dri::GetClientDriverNameReply) -> Reply { Reply::Xf86driGetClientDriverName(reply) } } #[cfg(feature = "xf86dri")] impl From for Reply { fn from(reply: xf86dri::CreateContextReply) -> Reply { Reply::Xf86driCreateContext(reply) } } #[cfg(feature = "xf86dri")] impl From for Reply { fn from(reply: xf86dri::CreateDrawableReply) -> Reply { Reply::Xf86driCreateDrawable(reply) } } #[cfg(feature = "xf86dri")] impl From for Reply { fn from(reply: xf86dri::GetDrawableInfoReply) -> Reply { Reply::Xf86driGetDrawableInfo(reply) } } #[cfg(feature = "xf86dri")] impl From for Reply { fn from(reply: xf86dri::GetDeviceInfoReply) -> Reply { Reply::Xf86driGetDeviceInfo(reply) } } #[cfg(feature = "xf86dri")] impl From for Reply { fn from(reply: xf86dri::AuthConnectionReply) -> Reply { Reply::Xf86driAuthConnection(reply) } } #[cfg(feature = "xf86vidmode")] impl From for Reply { fn from(reply: xf86vidmode::QueryVersionReply) -> Reply { Reply::Xf86vidmodeQueryVersion(reply) } } #[cfg(feature = "xf86vidmode")] impl From for Reply { fn from(reply: xf86vidmode::GetModeLineReply) -> Reply { Reply::Xf86vidmodeGetModeLine(reply) } } #[cfg(feature = "xf86vidmode")] impl From for Reply { fn from(reply: xf86vidmode::GetMonitorReply) -> Reply { Reply::Xf86vidmodeGetMonitor(reply) } } #[cfg(feature = "xf86vidmode")] impl From for Reply { fn from(reply: xf86vidmode::GetAllModeLinesReply) -> Reply { Reply::Xf86vidmodeGetAllModeLines(reply) } } #[cfg(feature = "xf86vidmode")] impl From for Reply { fn from(reply: xf86vidmode::ValidateModeLineReply) -> Reply { Reply::Xf86vidmodeValidateModeLine(reply) } } #[cfg(feature = "xf86vidmode")] impl From for Reply { fn from(reply: xf86vidmode::GetViewPortReply) -> Reply { Reply::Xf86vidmodeGetViewPort(reply) } } #[cfg(feature = "xf86vidmode")] impl From for Reply { fn from(reply: xf86vidmode::GetDotClocksReply) -> Reply { Reply::Xf86vidmodeGetDotClocks(reply) } } #[cfg(feature = "xf86vidmode")] impl From for Reply { fn from(reply: xf86vidmode::GetGammaReply) -> Reply { Reply::Xf86vidmodeGetGamma(reply) } } #[cfg(feature = "xf86vidmode")] impl From for Reply { fn from(reply: xf86vidmode::GetGammaRampReply) -> Reply { Reply::Xf86vidmodeGetGammaRamp(reply) } } #[cfg(feature = "xf86vidmode")] impl From for Reply { fn from(reply: xf86vidmode::GetGammaRampSizeReply) -> Reply { Reply::Xf86vidmodeGetGammaRampSize(reply) } } #[cfg(feature = "xf86vidmode")] impl From for Reply { fn from(reply: xf86vidmode::GetPermissionsReply) -> Reply { Reply::Xf86vidmodeGetPermissions(reply) } } #[cfg(feature = "xfixes")] impl From for Reply { fn from(reply: xfixes::QueryVersionReply) -> Reply { Reply::XfixesQueryVersion(reply) } } #[cfg(feature = "xfixes")] impl From for Reply { fn from(reply: xfixes::GetCursorImageReply) -> Reply { Reply::XfixesGetCursorImage(reply) } } #[cfg(feature = "xfixes")] impl From for Reply { fn from(reply: xfixes::FetchRegionReply) -> Reply { Reply::XfixesFetchRegion(reply) } } #[cfg(feature = "xfixes")] impl From for Reply { fn from(reply: xfixes::GetCursorNameReply) -> Reply { Reply::XfixesGetCursorName(reply) } } #[cfg(feature = "xfixes")] impl From for Reply { fn from(reply: xfixes::GetCursorImageAndNameReply) -> Reply { Reply::XfixesGetCursorImageAndName(reply) } } #[cfg(feature = "xfixes")] impl From for Reply { fn from(reply: xfixes::GetClientDisconnectModeReply) -> Reply { Reply::XfixesGetClientDisconnectMode(reply) } } #[cfg(feature = "xinerama")] impl From for Reply { fn from(reply: xinerama::QueryVersionReply) -> Reply { Reply::XineramaQueryVersion(reply) } } #[cfg(feature = "xinerama")] impl From for Reply { fn from(reply: xinerama::GetStateReply) -> Reply { Reply::XineramaGetState(reply) } } #[cfg(feature = "xinerama")] impl From for Reply { fn from(reply: xinerama::GetScreenCountReply) -> Reply { Reply::XineramaGetScreenCount(reply) } } #[cfg(feature = "xinerama")] impl From for Reply { fn from(reply: xinerama::GetScreenSizeReply) -> Reply { Reply::XineramaGetScreenSize(reply) } } #[cfg(feature = "xinerama")] impl From for Reply { fn from(reply: xinerama::IsActiveReply) -> Reply { Reply::XineramaIsActive(reply) } } #[cfg(feature = "xinerama")] impl From for Reply { fn from(reply: xinerama::QueryScreensReply) -> Reply { Reply::XineramaQueryScreens(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::GetExtensionVersionReply) -> Reply { Reply::XinputGetExtensionVersion(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::ListInputDevicesReply) -> Reply { Reply::XinputListInputDevices(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::OpenDeviceReply) -> Reply { Reply::XinputOpenDevice(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::SetDeviceModeReply) -> Reply { Reply::XinputSetDeviceMode(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::GetSelectedExtensionEventsReply) -> Reply { Reply::XinputGetSelectedExtensionEvents(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::GetDeviceDontPropagateListReply) -> Reply { Reply::XinputGetDeviceDontPropagateList(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::GetDeviceMotionEventsReply) -> Reply { Reply::XinputGetDeviceMotionEvents(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::ChangeKeyboardDeviceReply) -> Reply { Reply::XinputChangeKeyboardDevice(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::ChangePointerDeviceReply) -> Reply { Reply::XinputChangePointerDevice(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::GrabDeviceReply) -> Reply { Reply::XinputGrabDevice(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::GetDeviceFocusReply) -> Reply { Reply::XinputGetDeviceFocus(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::GetFeedbackControlReply) -> Reply { Reply::XinputGetFeedbackControl(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::GetDeviceKeyMappingReply) -> Reply { Reply::XinputGetDeviceKeyMapping(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::GetDeviceModifierMappingReply) -> Reply { Reply::XinputGetDeviceModifierMapping(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::SetDeviceModifierMappingReply) -> Reply { Reply::XinputSetDeviceModifierMapping(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::GetDeviceButtonMappingReply) -> Reply { Reply::XinputGetDeviceButtonMapping(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::SetDeviceButtonMappingReply) -> Reply { Reply::XinputSetDeviceButtonMapping(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::QueryDeviceStateReply) -> Reply { Reply::XinputQueryDeviceState(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::SetDeviceValuatorsReply) -> Reply { Reply::XinputSetDeviceValuators(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::GetDeviceControlReply) -> Reply { Reply::XinputGetDeviceControl(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::ChangeDeviceControlReply) -> Reply { Reply::XinputChangeDeviceControl(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::ListDevicePropertiesReply) -> Reply { Reply::XinputListDeviceProperties(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::GetDevicePropertyReply) -> Reply { Reply::XinputGetDeviceProperty(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::XIQueryPointerReply) -> Reply { Reply::XinputXIQueryPointer(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::XIGetClientPointerReply) -> Reply { Reply::XinputXIGetClientPointer(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::XIQueryVersionReply) -> Reply { Reply::XinputXIQueryVersion(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::XIQueryDeviceReply) -> Reply { Reply::XinputXIQueryDevice(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::XIGetFocusReply) -> Reply { Reply::XinputXIGetFocus(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::XIGrabDeviceReply) -> Reply { Reply::XinputXIGrabDevice(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::XIPassiveGrabDeviceReply) -> Reply { Reply::XinputXIPassiveGrabDevice(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::XIListPropertiesReply) -> Reply { Reply::XinputXIListProperties(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::XIGetPropertyReply) -> Reply { Reply::XinputXIGetProperty(reply) } } #[cfg(feature = "xinput")] impl From for Reply { fn from(reply: xinput::XIGetSelectedEventsReply) -> Reply { Reply::XinputXIGetSelectedEvents(reply) } } #[cfg(feature = "xkb")] impl From for Reply { fn from(reply: xkb::UseExtensionReply) -> Reply { Reply::XkbUseExtension(reply) } } #[cfg(feature = "xkb")] impl From for Reply { fn from(reply: xkb::GetStateReply) -> Reply { Reply::XkbGetState(reply) } } #[cfg(feature = "xkb")] impl From for Reply { fn from(reply: xkb::GetControlsReply) -> Reply { Reply::XkbGetControls(reply) } } #[cfg(feature = "xkb")] impl From for Reply { fn from(reply: xkb::GetMapReply) -> Reply { Reply::XkbGetMap(reply) } } #[cfg(feature = "xkb")] impl From for Reply { fn from(reply: xkb::GetCompatMapReply) -> Reply { Reply::XkbGetCompatMap(reply) } } #[cfg(feature = "xkb")] impl From for Reply { fn from(reply: xkb::GetIndicatorStateReply) -> Reply { Reply::XkbGetIndicatorState(reply) } } #[cfg(feature = "xkb")] impl From for Reply { fn from(reply: xkb::GetIndicatorMapReply) -> Reply { Reply::XkbGetIndicatorMap(reply) } } #[cfg(feature = "xkb")] impl From for Reply { fn from(reply: xkb::GetNamedIndicatorReply) -> Reply { Reply::XkbGetNamedIndicator(reply) } } #[cfg(feature = "xkb")] impl From for Reply { fn from(reply: xkb::GetNamesReply) -> Reply { Reply::XkbGetNames(reply) } } #[cfg(feature = "xkb")] impl From for Reply { fn from(reply: xkb::PerClientFlagsReply) -> Reply { Reply::XkbPerClientFlags(reply) } } #[cfg(feature = "xkb")] impl From for Reply { fn from(reply: xkb::ListComponentsReply) -> Reply { Reply::XkbListComponents(reply) } } #[cfg(feature = "xkb")] impl From for Reply { fn from(reply: xkb::GetKbdByNameReply) -> Reply { Reply::XkbGetKbdByName(reply) } } #[cfg(feature = "xkb")] impl From for Reply { fn from(reply: xkb::GetDeviceInfoReply) -> Reply { Reply::XkbGetDeviceInfo(reply) } } #[cfg(feature = "xkb")] impl From for Reply { fn from(reply: xkb::SetDebuggingFlagsReply) -> Reply { Reply::XkbSetDebuggingFlags(reply) } } #[cfg(feature = "xprint")] impl From for Reply { fn from(reply: xprint::PrintQueryVersionReply) -> Reply { Reply::XprintPrintQueryVersion(reply) } } #[cfg(feature = "xprint")] impl From for Reply { fn from(reply: xprint::PrintGetPrinterListReply) -> Reply { Reply::XprintPrintGetPrinterList(reply) } } #[cfg(feature = "xprint")] impl From for Reply { fn from(reply: xprint::PrintGetContextReply) -> Reply { Reply::XprintPrintGetContext(reply) } } #[cfg(feature = "xprint")] impl From for Reply { fn from(reply: xprint::PrintGetScreenOfContextReply) -> Reply { Reply::XprintPrintGetScreenOfContext(reply) } } #[cfg(feature = "xprint")] impl From for Reply { fn from(reply: xprint::PrintGetDocumentDataReply) -> Reply { Reply::XprintPrintGetDocumentData(reply) } } #[cfg(feature = "xprint")] impl From for Reply { fn from(reply: xprint::PrintInputSelectedReply) -> Reply { Reply::XprintPrintInputSelected(reply) } } #[cfg(feature = "xprint")] impl From for Reply { fn from(reply: xprint::PrintGetAttributesReply) -> Reply { Reply::XprintPrintGetAttributes(reply) } } #[cfg(feature = "xprint")] impl From for Reply { fn from(reply: xprint::PrintGetOneAttributesReply) -> Reply { Reply::XprintPrintGetOneAttributes(reply) } } #[cfg(feature = "xprint")] impl From for Reply { fn from(reply: xprint::PrintGetPageDimensionsReply) -> Reply { Reply::XprintPrintGetPageDimensions(reply) } } #[cfg(feature = "xprint")] impl From for Reply { fn from(reply: xprint::PrintQueryScreensReply) -> Reply { Reply::XprintPrintQueryScreens(reply) } } #[cfg(feature = "xprint")] impl From for Reply { fn from(reply: xprint::PrintSetImageResolutionReply) -> Reply { Reply::XprintPrintSetImageResolution(reply) } } #[cfg(feature = "xprint")] impl From for Reply { fn from(reply: xprint::PrintGetImageResolutionReply) -> Reply { Reply::XprintPrintGetImageResolution(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::QueryVersionReply) -> Reply { Reply::XselinuxQueryVersion(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::GetDeviceCreateContextReply) -> Reply { Reply::XselinuxGetDeviceCreateContext(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::GetDeviceContextReply) -> Reply { Reply::XselinuxGetDeviceContext(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::GetWindowCreateContextReply) -> Reply { Reply::XselinuxGetWindowCreateContext(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::GetWindowContextReply) -> Reply { Reply::XselinuxGetWindowContext(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::GetPropertyCreateContextReply) -> Reply { Reply::XselinuxGetPropertyCreateContext(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::GetPropertyUseContextReply) -> Reply { Reply::XselinuxGetPropertyUseContext(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::GetPropertyContextReply) -> Reply { Reply::XselinuxGetPropertyContext(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::GetPropertyDataContextReply) -> Reply { Reply::XselinuxGetPropertyDataContext(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::ListPropertiesReply) -> Reply { Reply::XselinuxListProperties(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::GetSelectionCreateContextReply) -> Reply { Reply::XselinuxGetSelectionCreateContext(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::GetSelectionUseContextReply) -> Reply { Reply::XselinuxGetSelectionUseContext(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::GetSelectionContextReply) -> Reply { Reply::XselinuxGetSelectionContext(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::GetSelectionDataContextReply) -> Reply { Reply::XselinuxGetSelectionDataContext(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::ListSelectionsReply) -> Reply { Reply::XselinuxListSelections(reply) } } #[cfg(feature = "xselinux")] impl From for Reply { fn from(reply: xselinux::GetClientContextReply) -> Reply { Reply::XselinuxGetClientContext(reply) } } #[cfg(feature = "xtest")] impl From for Reply { fn from(reply: xtest::GetVersionReply) -> Reply { Reply::XtestGetVersion(reply) } } #[cfg(feature = "xtest")] impl From for Reply { fn from(reply: xtest::CompareCursorReply) -> Reply { Reply::XtestCompareCursor(reply) } } #[cfg(feature = "xv")] impl From for Reply { fn from(reply: xv::QueryExtensionReply) -> Reply { Reply::XvQueryExtension(reply) } } #[cfg(feature = "xv")] impl From for Reply { fn from(reply: xv::QueryAdaptorsReply) -> Reply { Reply::XvQueryAdaptors(reply) } } #[cfg(feature = "xv")] impl From for Reply { fn from(reply: xv::QueryEncodingsReply) -> Reply { Reply::XvQueryEncodings(reply) } } #[cfg(feature = "xv")] impl From for Reply { fn from(reply: xv::GrabPortReply) -> Reply { Reply::XvGrabPort(reply) } } #[cfg(feature = "xv")] impl From for Reply { fn from(reply: xv::QueryBestSizeReply) -> Reply { Reply::XvQueryBestSize(reply) } } #[cfg(feature = "xv")] impl From for Reply { fn from(reply: xv::GetPortAttributeReply) -> Reply { Reply::XvGetPortAttribute(reply) } } #[cfg(feature = "xv")] impl From for Reply { fn from(reply: xv::QueryPortAttributesReply) -> Reply { Reply::XvQueryPortAttributes(reply) } } #[cfg(feature = "xv")] impl From for Reply { fn from(reply: xv::ListImageFormatsReply) -> Reply { Reply::XvListImageFormats(reply) } } #[cfg(feature = "xv")] impl From for Reply { fn from(reply: xv::QueryImageAttributesReply) -> Reply { Reply::XvQueryImageAttributes(reply) } } #[cfg(feature = "xvmc")] impl From for Reply { fn from(reply: xvmc::QueryVersionReply) -> Reply { Reply::XvmcQueryVersion(reply) } } #[cfg(feature = "xvmc")] impl From for Reply { fn from(reply: xvmc::ListSurfaceTypesReply) -> Reply { Reply::XvmcListSurfaceTypes(reply) } } #[cfg(feature = "xvmc")] impl From for Reply { fn from(reply: xvmc::CreateContextReply) -> Reply { Reply::XvmcCreateContext(reply) } } #[cfg(feature = "xvmc")] impl From for Reply { fn from(reply: xvmc::CreateSurfaceReply) -> Reply { Reply::XvmcCreateSurface(reply) } } #[cfg(feature = "xvmc")] impl From for Reply { fn from(reply: xvmc::CreateSubpictureReply) -> Reply { Reply::XvmcCreateSubpicture(reply) } } #[cfg(feature = "xvmc")] impl From for Reply { fn from(reply: xvmc::ListSubpictureTypesReply) -> Reply { Reply::XvmcListSubpictureTypes(reply) } } /// Get the name of a request from its extension name and opcodes. /// /// First result is the name of the extension, second the name of the request. pub(crate) fn request_name(ext_info_provider: &dyn ExtInfoProvider, major_opcode: u8, minor_opcode: u16) -> (Option, Option<&'static str>) { // Don't ask me why X11 errors contain u16 for minor opcode, but requests are sent with u8. // We have to work around that incompatibility here. // From the X11 protocol reference manual: // Major opcodes 128 through 255 are reserved for extensions. let (ext, info) = if major_opcode < 128 || minor_opcode <= u16::from(u8::MAX) { get_request_name_internal(ext_info_provider, major_opcode, minor_opcode as u8) } else { let ext = ext_info_provider.get_from_major_opcode(major_opcode); return (ext.map(|(ext, _)| String::from(ext)), None); }; let ext = ext.map(String::from); let info = match info { RequestInfo::Xproto(request) => request.into(), RequestInfo::KnownExt(ext_and_request) => ext_and_request.split_once("::").map(|r| r.1), RequestInfo::UnknownRequest(_, _) => None, RequestInfo::UnknownExtension(_, _) => None, }; (ext, info) } /// Enumeration of all possible X11 error kinds. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[non_exhaustive] pub enum ErrorKind { Unknown(u8), Access, Alloc, Atom, Colormap, Cursor, Drawable, Font, GContext, IDChoice, Implementation, Length, Match, Name, Pixmap, Request, Value, Window, #[cfg(feature = "damage")] DamageBadDamage, #[cfg(feature = "dbe")] DbeBadBuffer, #[cfg(feature = "glx")] GlxBadContext, #[cfg(feature = "glx")] GlxBadContextState, #[cfg(feature = "glx")] GlxBadContextTag, #[cfg(feature = "glx")] GlxBadCurrentDrawable, #[cfg(feature = "glx")] GlxBadCurrentWindow, #[cfg(feature = "glx")] GlxBadDrawable, #[cfg(feature = "glx")] GlxBadFBConfig, #[cfg(feature = "glx")] GlxBadLargeRequest, #[cfg(feature = "glx")] GlxBadPbuffer, #[cfg(feature = "glx")] GlxBadPixmap, #[cfg(feature = "glx")] GlxBadRenderRequest, #[cfg(feature = "glx")] GlxBadWindow, #[cfg(feature = "glx")] GlxGLXBadProfileARB, #[cfg(feature = "glx")] GlxUnsupportedPrivateRequest, #[cfg(feature = "randr")] RandrBadCrtc, #[cfg(feature = "randr")] RandrBadMode, #[cfg(feature = "randr")] RandrBadOutput, #[cfg(feature = "randr")] RandrBadProvider, #[cfg(feature = "record")] RecordBadContext, #[cfg(feature = "render")] RenderGlyph, #[cfg(feature = "render")] RenderGlyphSet, #[cfg(feature = "render")] RenderPictFormat, #[cfg(feature = "render")] RenderPictOp, #[cfg(feature = "render")] RenderPicture, #[cfg(feature = "shm")] ShmBadSeg, #[cfg(feature = "sync")] SyncAlarm, #[cfg(feature = "sync")] SyncCounter, #[cfg(feature = "xf86vidmode")] Xf86vidmodeBadClock, #[cfg(feature = "xf86vidmode")] Xf86vidmodeBadHTimings, #[cfg(feature = "xf86vidmode")] Xf86vidmodeBadVTimings, #[cfg(feature = "xf86vidmode")] Xf86vidmodeClientNotLocal, #[cfg(feature = "xf86vidmode")] Xf86vidmodeExtensionDisabled, #[cfg(feature = "xf86vidmode")] Xf86vidmodeModeUnsuitable, #[cfg(feature = "xf86vidmode")] Xf86vidmodeZoomLocked, #[cfg(feature = "xfixes")] XfixesBadRegion, #[cfg(feature = "xinput")] XinputClass, #[cfg(feature = "xinput")] XinputDevice, #[cfg(feature = "xinput")] XinputDeviceBusy, #[cfg(feature = "xinput")] XinputEvent, #[cfg(feature = "xinput")] XinputMode, #[cfg(feature = "xkb")] XkbKeyboard, #[cfg(feature = "xprint")] XprintBadContext, #[cfg(feature = "xprint")] XprintBadSequence, #[cfg(feature = "xv")] XvBadControl, #[cfg(feature = "xv")] XvBadEncoding, #[cfg(feature = "xv")] XvBadPort, } impl ErrorKind { #[allow(clippy::match_single_binding)] pub fn from_wire_error_code( error_code: u8, ext_info_provider: &dyn ExtInfoProvider, ) -> Self { // Check if this is a core protocol error match error_code { xproto::ACCESS_ERROR => return Self::Access, xproto::ALLOC_ERROR => return Self::Alloc, xproto::ATOM_ERROR => return Self::Atom, xproto::COLORMAP_ERROR => return Self::Colormap, xproto::CURSOR_ERROR => return Self::Cursor, xproto::DRAWABLE_ERROR => return Self::Drawable, xproto::FONT_ERROR => return Self::Font, xproto::G_CONTEXT_ERROR => return Self::GContext, xproto::ID_CHOICE_ERROR => return Self::IDChoice, xproto::IMPLEMENTATION_ERROR => return Self::Implementation, xproto::LENGTH_ERROR => return Self::Length, xproto::MATCH_ERROR => return Self::Match, xproto::NAME_ERROR => return Self::Name, xproto::PIXMAP_ERROR => return Self::Pixmap, xproto::REQUEST_ERROR => return Self::Request, xproto::VALUE_ERROR => return Self::Value, xproto::WINDOW_ERROR => return Self::Window, _ => {} } // Find the extension that this error could belong to let ext_info = ext_info_provider.get_from_error_code(error_code); match ext_info { #[cfg(feature = "damage")] Some((damage::X11_EXTENSION_NAME, ext_info)) => { match error_code - ext_info.first_error { damage::BAD_DAMAGE_ERROR => Self::DamageBadDamage, _ => Self::Unknown(error_code), } } #[cfg(feature = "dbe")] Some((dbe::X11_EXTENSION_NAME, ext_info)) => { match error_code - ext_info.first_error { dbe::BAD_BUFFER_ERROR => Self::DbeBadBuffer, _ => Self::Unknown(error_code), } } #[cfg(feature = "glx")] Some((glx::X11_EXTENSION_NAME, ext_info)) => { match error_code - ext_info.first_error { glx::BAD_CONTEXT_ERROR => Self::GlxBadContext, glx::BAD_CONTEXT_STATE_ERROR => Self::GlxBadContextState, glx::BAD_CONTEXT_TAG_ERROR => Self::GlxBadContextTag, glx::BAD_CURRENT_DRAWABLE_ERROR => Self::GlxBadCurrentDrawable, glx::BAD_CURRENT_WINDOW_ERROR => Self::GlxBadCurrentWindow, glx::BAD_DRAWABLE_ERROR => Self::GlxBadDrawable, glx::BAD_FB_CONFIG_ERROR => Self::GlxBadFBConfig, glx::BAD_LARGE_REQUEST_ERROR => Self::GlxBadLargeRequest, glx::BAD_PBUFFER_ERROR => Self::GlxBadPbuffer, glx::BAD_PIXMAP_ERROR => Self::GlxBadPixmap, glx::BAD_RENDER_REQUEST_ERROR => Self::GlxBadRenderRequest, glx::BAD_WINDOW_ERROR => Self::GlxBadWindow, glx::GLX_BAD_PROFILE_ARB_ERROR => Self::GlxGLXBadProfileARB, glx::UNSUPPORTED_PRIVATE_REQUEST_ERROR => Self::GlxUnsupportedPrivateRequest, _ => Self::Unknown(error_code), } } #[cfg(feature = "randr")] Some((randr::X11_EXTENSION_NAME, ext_info)) => { match error_code - ext_info.first_error { randr::BAD_CRTC_ERROR => Self::RandrBadCrtc, randr::BAD_MODE_ERROR => Self::RandrBadMode, randr::BAD_OUTPUT_ERROR => Self::RandrBadOutput, randr::BAD_PROVIDER_ERROR => Self::RandrBadProvider, _ => Self::Unknown(error_code), } } #[cfg(feature = "record")] Some((record::X11_EXTENSION_NAME, ext_info)) => { match error_code - ext_info.first_error { record::BAD_CONTEXT_ERROR => Self::RecordBadContext, _ => Self::Unknown(error_code), } } #[cfg(feature = "render")] Some((render::X11_EXTENSION_NAME, ext_info)) => { match error_code - ext_info.first_error { render::GLYPH_ERROR => Self::RenderGlyph, render::GLYPH_SET_ERROR => Self::RenderGlyphSet, render::PICT_FORMAT_ERROR => Self::RenderPictFormat, render::PICT_OP_ERROR => Self::RenderPictOp, render::PICTURE_ERROR => Self::RenderPicture, _ => Self::Unknown(error_code), } } #[cfg(feature = "shm")] Some((shm::X11_EXTENSION_NAME, ext_info)) => { match error_code - ext_info.first_error { shm::BAD_SEG_ERROR => Self::ShmBadSeg, _ => Self::Unknown(error_code), } } #[cfg(feature = "sync")] Some((sync::X11_EXTENSION_NAME, ext_info)) => { match error_code - ext_info.first_error { sync::ALARM_ERROR => Self::SyncAlarm, sync::COUNTER_ERROR => Self::SyncCounter, _ => Self::Unknown(error_code), } } #[cfg(feature = "xf86vidmode")] Some((xf86vidmode::X11_EXTENSION_NAME, ext_info)) => { match error_code - ext_info.first_error { xf86vidmode::BAD_CLOCK_ERROR => Self::Xf86vidmodeBadClock, xf86vidmode::BAD_H_TIMINGS_ERROR => Self::Xf86vidmodeBadHTimings, xf86vidmode::BAD_V_TIMINGS_ERROR => Self::Xf86vidmodeBadVTimings, xf86vidmode::CLIENT_NOT_LOCAL_ERROR => Self::Xf86vidmodeClientNotLocal, xf86vidmode::EXTENSION_DISABLED_ERROR => Self::Xf86vidmodeExtensionDisabled, xf86vidmode::MODE_UNSUITABLE_ERROR => Self::Xf86vidmodeModeUnsuitable, xf86vidmode::ZOOM_LOCKED_ERROR => Self::Xf86vidmodeZoomLocked, _ => Self::Unknown(error_code), } } #[cfg(feature = "xfixes")] Some((xfixes::X11_EXTENSION_NAME, ext_info)) => { match error_code - ext_info.first_error { xfixes::BAD_REGION_ERROR => Self::XfixesBadRegion, _ => Self::Unknown(error_code), } } #[cfg(feature = "xinput")] Some((xinput::X11_EXTENSION_NAME, ext_info)) => { match error_code - ext_info.first_error { xinput::CLASS_ERROR => Self::XinputClass, xinput::DEVICE_ERROR => Self::XinputDevice, xinput::DEVICE_BUSY_ERROR => Self::XinputDeviceBusy, xinput::EVENT_ERROR => Self::XinputEvent, xinput::MODE_ERROR => Self::XinputMode, _ => Self::Unknown(error_code), } } #[cfg(feature = "xkb")] Some((xkb::X11_EXTENSION_NAME, ext_info)) => { match error_code - ext_info.first_error { xkb::KEYBOARD_ERROR => Self::XkbKeyboard, _ => Self::Unknown(error_code), } } #[cfg(feature = "xprint")] Some((xprint::X11_EXTENSION_NAME, ext_info)) => { match error_code - ext_info.first_error { xprint::BAD_CONTEXT_ERROR => Self::XprintBadContext, xprint::BAD_SEQUENCE_ERROR => Self::XprintBadSequence, _ => Self::Unknown(error_code), } } #[cfg(feature = "xv")] Some((xv::X11_EXTENSION_NAME, ext_info)) => { match error_code - ext_info.first_error { xv::BAD_CONTROL_ERROR => Self::XvBadControl, xv::BAD_ENCODING_ERROR => Self::XvBadEncoding, xv::BAD_PORT_ERROR => Self::XvBadPort, _ => Self::Unknown(error_code), } } _ => Self::Unknown(error_code), } } } /// Enumeration of all possible X11 events. #[derive(Debug, Clone)] #[non_exhaustive] pub enum Event { Unknown(Vec), Error(X11Error), ButtonPress(xproto::ButtonPressEvent), ButtonRelease(xproto::ButtonReleaseEvent), CirculateNotify(xproto::CirculateNotifyEvent), CirculateRequest(xproto::CirculateRequestEvent), ClientMessage(xproto::ClientMessageEvent), ColormapNotify(xproto::ColormapNotifyEvent), ConfigureNotify(xproto::ConfigureNotifyEvent), ConfigureRequest(xproto::ConfigureRequestEvent), CreateNotify(xproto::CreateNotifyEvent), DestroyNotify(xproto::DestroyNotifyEvent), EnterNotify(xproto::EnterNotifyEvent), Expose(xproto::ExposeEvent), FocusIn(xproto::FocusInEvent), FocusOut(xproto::FocusOutEvent), GeGeneric(xproto::GeGenericEvent), GraphicsExposure(xproto::GraphicsExposureEvent), GravityNotify(xproto::GravityNotifyEvent), KeyPress(xproto::KeyPressEvent), KeyRelease(xproto::KeyReleaseEvent), KeymapNotify(xproto::KeymapNotifyEvent), LeaveNotify(xproto::LeaveNotifyEvent), MapNotify(xproto::MapNotifyEvent), MapRequest(xproto::MapRequestEvent), MappingNotify(xproto::MappingNotifyEvent), MotionNotify(xproto::MotionNotifyEvent), NoExposure(xproto::NoExposureEvent), PropertyNotify(xproto::PropertyNotifyEvent), ReparentNotify(xproto::ReparentNotifyEvent), ResizeRequest(xproto::ResizeRequestEvent), SelectionClear(xproto::SelectionClearEvent), SelectionNotify(xproto::SelectionNotifyEvent), SelectionRequest(xproto::SelectionRequestEvent), UnmapNotify(xproto::UnmapNotifyEvent), VisibilityNotify(xproto::VisibilityNotifyEvent), #[cfg(feature = "damage")] DamageNotify(damage::NotifyEvent), #[cfg(feature = "dpms")] DpmsInfoNotify(dpms::InfoNotifyEvent), #[cfg(feature = "dri2")] Dri2BufferSwapComplete(dri2::BufferSwapCompleteEvent), #[cfg(feature = "dri2")] Dri2InvalidateBuffers(dri2::InvalidateBuffersEvent), #[cfg(feature = "glx")] GlxBufferSwapComplete(glx::BufferSwapCompleteEvent), #[cfg(feature = "glx")] GlxPbufferClobber(glx::PbufferClobberEvent), #[cfg(feature = "present")] PresentCompleteNotify(present::CompleteNotifyEvent), #[cfg(feature = "present")] PresentConfigureNotify(present::ConfigureNotifyEvent), #[cfg(feature = "present")] PresentGeneric(present::GenericEvent), #[cfg(feature = "present")] PresentIdleNotify(present::IdleNotifyEvent), #[cfg(feature = "present")] PresentRedirectNotify(present::RedirectNotifyEvent), #[cfg(feature = "randr")] RandrNotify(randr::NotifyEvent), #[cfg(feature = "randr")] RandrScreenChangeNotify(randr::ScreenChangeNotifyEvent), #[cfg(feature = "screensaver")] ScreensaverNotify(screensaver::NotifyEvent), #[cfg(feature = "shape")] ShapeNotify(shape::NotifyEvent), #[cfg(feature = "shm")] ShmCompletion(shm::CompletionEvent), #[cfg(feature = "sync")] SyncAlarmNotify(sync::AlarmNotifyEvent), #[cfg(feature = "sync")] SyncCounterNotify(sync::CounterNotifyEvent), #[cfg(feature = "xfixes")] XfixesCursorNotify(xfixes::CursorNotifyEvent), #[cfg(feature = "xfixes")] XfixesSelectionNotify(xfixes::SelectionNotifyEvent), #[cfg(feature = "xinput")] XinputBarrierHit(xinput::BarrierHitEvent), #[cfg(feature = "xinput")] XinputBarrierLeave(xinput::BarrierLeaveEvent), #[cfg(feature = "xinput")] XinputButtonPress(xinput::ButtonPressEvent), #[cfg(feature = "xinput")] XinputButtonRelease(xinput::ButtonReleaseEvent), #[cfg(feature = "xinput")] XinputChangeDeviceNotify(xinput::ChangeDeviceNotifyEvent), #[cfg(feature = "xinput")] XinputDeviceButtonPress(xinput::DeviceButtonPressEvent), #[cfg(feature = "xinput")] XinputDeviceButtonRelease(xinput::DeviceButtonReleaseEvent), #[cfg(feature = "xinput")] XinputDeviceButtonStateNotify(xinput::DeviceButtonStateNotifyEvent), #[cfg(feature = "xinput")] XinputDeviceChanged(xinput::DeviceChangedEvent), #[cfg(feature = "xinput")] XinputDeviceFocusIn(xinput::DeviceFocusInEvent), #[cfg(feature = "xinput")] XinputDeviceFocusOut(xinput::DeviceFocusOutEvent), #[cfg(feature = "xinput")] XinputDeviceKeyPress(xinput::DeviceKeyPressEvent), #[cfg(feature = "xinput")] XinputDeviceKeyRelease(xinput::DeviceKeyReleaseEvent), #[cfg(feature = "xinput")] XinputDeviceKeyStateNotify(xinput::DeviceKeyStateNotifyEvent), #[cfg(feature = "xinput")] XinputDeviceMappingNotify(xinput::DeviceMappingNotifyEvent), #[cfg(feature = "xinput")] XinputDeviceMotionNotify(xinput::DeviceMotionNotifyEvent), #[cfg(feature = "xinput")] XinputDevicePresenceNotify(xinput::DevicePresenceNotifyEvent), #[cfg(feature = "xinput")] XinputDevicePropertyNotify(xinput::DevicePropertyNotifyEvent), #[cfg(feature = "xinput")] XinputDeviceStateNotify(xinput::DeviceStateNotifyEvent), #[cfg(feature = "xinput")] XinputDeviceValuator(xinput::DeviceValuatorEvent), #[cfg(feature = "xinput")] XinputEnter(xinput::EnterEvent), #[cfg(feature = "xinput")] XinputFocusIn(xinput::FocusInEvent), #[cfg(feature = "xinput")] XinputFocusOut(xinput::FocusOutEvent), #[cfg(feature = "xinput")] XinputGesturePinchBegin(xinput::GesturePinchBeginEvent), #[cfg(feature = "xinput")] XinputGesturePinchEnd(xinput::GesturePinchEndEvent), #[cfg(feature = "xinput")] XinputGesturePinchUpdate(xinput::GesturePinchUpdateEvent), #[cfg(feature = "xinput")] XinputGestureSwipeBegin(xinput::GestureSwipeBeginEvent), #[cfg(feature = "xinput")] XinputGestureSwipeEnd(xinput::GestureSwipeEndEvent), #[cfg(feature = "xinput")] XinputGestureSwipeUpdate(xinput::GestureSwipeUpdateEvent), #[cfg(feature = "xinput")] XinputHierarchy(xinput::HierarchyEvent), #[cfg(feature = "xinput")] XinputKeyPress(xinput::KeyPressEvent), #[cfg(feature = "xinput")] XinputKeyRelease(xinput::KeyReleaseEvent), #[cfg(feature = "xinput")] XinputLeave(xinput::LeaveEvent), #[cfg(feature = "xinput")] XinputMotion(xinput::MotionEvent), #[cfg(feature = "xinput")] XinputProperty(xinput::PropertyEvent), #[cfg(feature = "xinput")] XinputProximityIn(xinput::ProximityInEvent), #[cfg(feature = "xinput")] XinputProximityOut(xinput::ProximityOutEvent), #[cfg(feature = "xinput")] XinputRawButtonPress(xinput::RawButtonPressEvent), #[cfg(feature = "xinput")] XinputRawButtonRelease(xinput::RawButtonReleaseEvent), #[cfg(feature = "xinput")] XinputRawKeyPress(xinput::RawKeyPressEvent), #[cfg(feature = "xinput")] XinputRawKeyRelease(xinput::RawKeyReleaseEvent), #[cfg(feature = "xinput")] XinputRawMotion(xinput::RawMotionEvent), #[cfg(feature = "xinput")] XinputRawTouchBegin(xinput::RawTouchBeginEvent), #[cfg(feature = "xinput")] XinputRawTouchEnd(xinput::RawTouchEndEvent), #[cfg(feature = "xinput")] XinputRawTouchUpdate(xinput::RawTouchUpdateEvent), #[cfg(feature = "xinput")] XinputTouchBegin(xinput::TouchBeginEvent), #[cfg(feature = "xinput")] XinputTouchEnd(xinput::TouchEndEvent), #[cfg(feature = "xinput")] XinputTouchOwnership(xinput::TouchOwnershipEvent), #[cfg(feature = "xinput")] XinputTouchUpdate(xinput::TouchUpdateEvent), #[cfg(feature = "xkb")] XkbAccessXNotify(xkb::AccessXNotifyEvent), #[cfg(feature = "xkb")] XkbActionMessage(xkb::ActionMessageEvent), #[cfg(feature = "xkb")] XkbBellNotify(xkb::BellNotifyEvent), #[cfg(feature = "xkb")] XkbCompatMapNotify(xkb::CompatMapNotifyEvent), #[cfg(feature = "xkb")] XkbControlsNotify(xkb::ControlsNotifyEvent), #[cfg(feature = "xkb")] XkbExtensionDeviceNotify(xkb::ExtensionDeviceNotifyEvent), #[cfg(feature = "xkb")] XkbIndicatorMapNotify(xkb::IndicatorMapNotifyEvent), #[cfg(feature = "xkb")] XkbIndicatorStateNotify(xkb::IndicatorStateNotifyEvent), #[cfg(feature = "xkb")] XkbMapNotify(xkb::MapNotifyEvent), #[cfg(feature = "xkb")] XkbNamesNotify(xkb::NamesNotifyEvent), #[cfg(feature = "xkb")] XkbNewKeyboardNotify(xkb::NewKeyboardNotifyEvent), #[cfg(feature = "xkb")] XkbStateNotify(xkb::StateNotifyEvent), #[cfg(feature = "xprint")] XprintAttributNotify(xprint::AttributNotifyEvent), #[cfg(feature = "xprint")] XprintNotify(xprint::NotifyEvent), #[cfg(feature = "xv")] XvPortNotify(xv::PortNotifyEvent), #[cfg(feature = "xv")] XvVideoNotify(xv::VideoNotifyEvent), } impl Event { /// Parse a generic X11 event into a concrete event type. #[allow(clippy::cognitive_complexity, clippy::match_single_binding)] pub fn parse( event: &[u8], ext_info_provider: &dyn ExtInfoProvider, ) -> Result { let event_code = response_type(event)?; // Check if this is a core protocol event or error, or from the generic event extension match event_code { 0 => return Ok(Self::Error(X11Error::try_parse(event, ext_info_provider)?)), xproto::BUTTON_PRESS_EVENT => return Ok(Self::ButtonPress(TryParse::try_parse(event)?.0)), xproto::BUTTON_RELEASE_EVENT => return Ok(Self::ButtonRelease(TryParse::try_parse(event)?.0)), xproto::CIRCULATE_NOTIFY_EVENT => return Ok(Self::CirculateNotify(TryParse::try_parse(event)?.0)), xproto::CIRCULATE_REQUEST_EVENT => return Ok(Self::CirculateRequest(TryParse::try_parse(event)?.0)), xproto::CLIENT_MESSAGE_EVENT => return Ok(Self::ClientMessage(TryParse::try_parse(event)?.0)), xproto::COLORMAP_NOTIFY_EVENT => return Ok(Self::ColormapNotify(TryParse::try_parse(event)?.0)), xproto::CONFIGURE_NOTIFY_EVENT => return Ok(Self::ConfigureNotify(TryParse::try_parse(event)?.0)), xproto::CONFIGURE_REQUEST_EVENT => return Ok(Self::ConfigureRequest(TryParse::try_parse(event)?.0)), xproto::CREATE_NOTIFY_EVENT => return Ok(Self::CreateNotify(TryParse::try_parse(event)?.0)), xproto::DESTROY_NOTIFY_EVENT => return Ok(Self::DestroyNotify(TryParse::try_parse(event)?.0)), xproto::ENTER_NOTIFY_EVENT => return Ok(Self::EnterNotify(TryParse::try_parse(event)?.0)), xproto::EXPOSE_EVENT => return Ok(Self::Expose(TryParse::try_parse(event)?.0)), xproto::FOCUS_IN_EVENT => return Ok(Self::FocusIn(TryParse::try_parse(event)?.0)), xproto::FOCUS_OUT_EVENT => return Ok(Self::FocusOut(TryParse::try_parse(event)?.0)), xproto::GRAPHICS_EXPOSURE_EVENT => return Ok(Self::GraphicsExposure(TryParse::try_parse(event)?.0)), xproto::GRAVITY_NOTIFY_EVENT => return Ok(Self::GravityNotify(TryParse::try_parse(event)?.0)), xproto::KEY_PRESS_EVENT => return Ok(Self::KeyPress(TryParse::try_parse(event)?.0)), xproto::KEY_RELEASE_EVENT => return Ok(Self::KeyRelease(TryParse::try_parse(event)?.0)), xproto::KEYMAP_NOTIFY_EVENT => return Ok(Self::KeymapNotify(TryParse::try_parse(event)?.0)), xproto::LEAVE_NOTIFY_EVENT => return Ok(Self::LeaveNotify(TryParse::try_parse(event)?.0)), xproto::MAP_NOTIFY_EVENT => return Ok(Self::MapNotify(TryParse::try_parse(event)?.0)), xproto::MAP_REQUEST_EVENT => return Ok(Self::MapRequest(TryParse::try_parse(event)?.0)), xproto::MAPPING_NOTIFY_EVENT => return Ok(Self::MappingNotify(TryParse::try_parse(event)?.0)), xproto::MOTION_NOTIFY_EVENT => return Ok(Self::MotionNotify(TryParse::try_parse(event)?.0)), xproto::NO_EXPOSURE_EVENT => return Ok(Self::NoExposure(TryParse::try_parse(event)?.0)), xproto::PROPERTY_NOTIFY_EVENT => return Ok(Self::PropertyNotify(TryParse::try_parse(event)?.0)), xproto::REPARENT_NOTIFY_EVENT => return Ok(Self::ReparentNotify(TryParse::try_parse(event)?.0)), xproto::RESIZE_REQUEST_EVENT => return Ok(Self::ResizeRequest(TryParse::try_parse(event)?.0)), xproto::SELECTION_CLEAR_EVENT => return Ok(Self::SelectionClear(TryParse::try_parse(event)?.0)), xproto::SELECTION_NOTIFY_EVENT => return Ok(Self::SelectionNotify(TryParse::try_parse(event)?.0)), xproto::SELECTION_REQUEST_EVENT => return Ok(Self::SelectionRequest(TryParse::try_parse(event)?.0)), xproto::UNMAP_NOTIFY_EVENT => return Ok(Self::UnmapNotify(TryParse::try_parse(event)?.0)), xproto::VISIBILITY_NOTIFY_EVENT => return Ok(Self::VisibilityNotify(TryParse::try_parse(event)?.0)), xproto::GE_GENERIC_EVENT => return Self::from_generic_event(event, ext_info_provider), _ => {} } // Find the extension that this event could belong to let ext_info = ext_info_provider.get_from_event_code(event_code); match ext_info { #[cfg(feature = "damage")] Some((damage::X11_EXTENSION_NAME, ext_info)) => { match event_code - ext_info.first_event { damage::NOTIFY_EVENT => Ok(Self::DamageNotify(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } #[cfg(feature = "dri2")] Some((dri2::X11_EXTENSION_NAME, ext_info)) => { match event_code - ext_info.first_event { dri2::BUFFER_SWAP_COMPLETE_EVENT => Ok(Self::Dri2BufferSwapComplete(TryParse::try_parse(event)?.0)), dri2::INVALIDATE_BUFFERS_EVENT => Ok(Self::Dri2InvalidateBuffers(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } #[cfg(feature = "glx")] Some((glx::X11_EXTENSION_NAME, ext_info)) => { match event_code - ext_info.first_event { glx::BUFFER_SWAP_COMPLETE_EVENT => Ok(Self::GlxBufferSwapComplete(TryParse::try_parse(event)?.0)), glx::PBUFFER_CLOBBER_EVENT => Ok(Self::GlxPbufferClobber(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } #[cfg(feature = "present")] Some((present::X11_EXTENSION_NAME, ext_info)) => { match event_code - ext_info.first_event { present::GENERIC_EVENT => Ok(Self::PresentGeneric(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } #[cfg(feature = "randr")] Some((randr::X11_EXTENSION_NAME, ext_info)) => { match event_code - ext_info.first_event { randr::NOTIFY_EVENT => Ok(Self::RandrNotify(TryParse::try_parse(event)?.0)), randr::SCREEN_CHANGE_NOTIFY_EVENT => Ok(Self::RandrScreenChangeNotify(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } #[cfg(feature = "screensaver")] Some((screensaver::X11_EXTENSION_NAME, ext_info)) => { match event_code - ext_info.first_event { screensaver::NOTIFY_EVENT => Ok(Self::ScreensaverNotify(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } #[cfg(feature = "shape")] Some((shape::X11_EXTENSION_NAME, ext_info)) => { match event_code - ext_info.first_event { shape::NOTIFY_EVENT => Ok(Self::ShapeNotify(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } #[cfg(feature = "shm")] Some((shm::X11_EXTENSION_NAME, ext_info)) => { match event_code - ext_info.first_event { shm::COMPLETION_EVENT => Ok(Self::ShmCompletion(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } #[cfg(feature = "sync")] Some((sync::X11_EXTENSION_NAME, ext_info)) => { match event_code - ext_info.first_event { sync::ALARM_NOTIFY_EVENT => Ok(Self::SyncAlarmNotify(TryParse::try_parse(event)?.0)), sync::COUNTER_NOTIFY_EVENT => Ok(Self::SyncCounterNotify(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } #[cfg(feature = "xfixes")] Some((xfixes::X11_EXTENSION_NAME, ext_info)) => { match event_code - ext_info.first_event { xfixes::CURSOR_NOTIFY_EVENT => Ok(Self::XfixesCursorNotify(TryParse::try_parse(event)?.0)), xfixes::SELECTION_NOTIFY_EVENT => Ok(Self::XfixesSelectionNotify(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } #[cfg(feature = "xinput")] Some((xinput::X11_EXTENSION_NAME, ext_info)) => { match event_code - ext_info.first_event { xinput::CHANGE_DEVICE_NOTIFY_EVENT => Ok(Self::XinputChangeDeviceNotify(TryParse::try_parse(event)?.0)), xinput::DEVICE_BUTTON_PRESS_EVENT => Ok(Self::XinputDeviceButtonPress(TryParse::try_parse(event)?.0)), xinput::DEVICE_BUTTON_RELEASE_EVENT => Ok(Self::XinputDeviceButtonRelease(TryParse::try_parse(event)?.0)), xinput::DEVICE_BUTTON_STATE_NOTIFY_EVENT => Ok(Self::XinputDeviceButtonStateNotify(TryParse::try_parse(event)?.0)), xinput::DEVICE_FOCUS_IN_EVENT => Ok(Self::XinputDeviceFocusIn(TryParse::try_parse(event)?.0)), xinput::DEVICE_FOCUS_OUT_EVENT => Ok(Self::XinputDeviceFocusOut(TryParse::try_parse(event)?.0)), xinput::DEVICE_KEY_PRESS_EVENT => Ok(Self::XinputDeviceKeyPress(TryParse::try_parse(event)?.0)), xinput::DEVICE_KEY_RELEASE_EVENT => Ok(Self::XinputDeviceKeyRelease(TryParse::try_parse(event)?.0)), xinput::DEVICE_KEY_STATE_NOTIFY_EVENT => Ok(Self::XinputDeviceKeyStateNotify(TryParse::try_parse(event)?.0)), xinput::DEVICE_MAPPING_NOTIFY_EVENT => Ok(Self::XinputDeviceMappingNotify(TryParse::try_parse(event)?.0)), xinput::DEVICE_MOTION_NOTIFY_EVENT => Ok(Self::XinputDeviceMotionNotify(TryParse::try_parse(event)?.0)), xinput::DEVICE_PRESENCE_NOTIFY_EVENT => Ok(Self::XinputDevicePresenceNotify(TryParse::try_parse(event)?.0)), xinput::DEVICE_PROPERTY_NOTIFY_EVENT => Ok(Self::XinputDevicePropertyNotify(TryParse::try_parse(event)?.0)), xinput::DEVICE_STATE_NOTIFY_EVENT => Ok(Self::XinputDeviceStateNotify(TryParse::try_parse(event)?.0)), xinput::DEVICE_VALUATOR_EVENT => Ok(Self::XinputDeviceValuator(TryParse::try_parse(event)?.0)), xinput::PROXIMITY_IN_EVENT => Ok(Self::XinputProximityIn(TryParse::try_parse(event)?.0)), xinput::PROXIMITY_OUT_EVENT => Ok(Self::XinputProximityOut(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } #[cfg(feature = "xkb")] Some((xkb::X11_EXTENSION_NAME, ext_info)) => { if event_code != ext_info.first_event { return Ok(Self::Unknown(event.to_vec())); } match *event.get(1).ok_or(ParseError::InsufficientData)? { xkb::ACCESS_X_NOTIFY_EVENT => Ok(Self::XkbAccessXNotify(TryParse::try_parse(event)?.0)), xkb::ACTION_MESSAGE_EVENT => Ok(Self::XkbActionMessage(TryParse::try_parse(event)?.0)), xkb::BELL_NOTIFY_EVENT => Ok(Self::XkbBellNotify(TryParse::try_parse(event)?.0)), xkb::COMPAT_MAP_NOTIFY_EVENT => Ok(Self::XkbCompatMapNotify(TryParse::try_parse(event)?.0)), xkb::CONTROLS_NOTIFY_EVENT => Ok(Self::XkbControlsNotify(TryParse::try_parse(event)?.0)), xkb::EXTENSION_DEVICE_NOTIFY_EVENT => Ok(Self::XkbExtensionDeviceNotify(TryParse::try_parse(event)?.0)), xkb::INDICATOR_MAP_NOTIFY_EVENT => Ok(Self::XkbIndicatorMapNotify(TryParse::try_parse(event)?.0)), xkb::INDICATOR_STATE_NOTIFY_EVENT => Ok(Self::XkbIndicatorStateNotify(TryParse::try_parse(event)?.0)), xkb::MAP_NOTIFY_EVENT => Ok(Self::XkbMapNotify(TryParse::try_parse(event)?.0)), xkb::NAMES_NOTIFY_EVENT => Ok(Self::XkbNamesNotify(TryParse::try_parse(event)?.0)), xkb::NEW_KEYBOARD_NOTIFY_EVENT => Ok(Self::XkbNewKeyboardNotify(TryParse::try_parse(event)?.0)), xkb::STATE_NOTIFY_EVENT => Ok(Self::XkbStateNotify(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } #[cfg(feature = "xprint")] Some((xprint::X11_EXTENSION_NAME, ext_info)) => { match event_code - ext_info.first_event { xprint::ATTRIBUT_NOTIFY_EVENT => Ok(Self::XprintAttributNotify(TryParse::try_parse(event)?.0)), xprint::NOTIFY_EVENT => Ok(Self::XprintNotify(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } #[cfg(feature = "xv")] Some((xv::X11_EXTENSION_NAME, ext_info)) => { match event_code - ext_info.first_event { xv::PORT_NOTIFY_EVENT => Ok(Self::XvPortNotify(TryParse::try_parse(event)?.0)), xv::VIDEO_NOTIFY_EVENT => Ok(Self::XvVideoNotify(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } _ => Ok(Self::Unknown(event.to_vec())), } } #[allow(clippy::match_single_binding)] fn from_generic_event( event: &[u8], ext_info_provider: &dyn ExtInfoProvider, ) -> Result { let ge_event = xproto::GeGenericEvent::try_parse(event)?.0; let ext_name = ext_info_provider .get_from_major_opcode(ge_event.extension) .map(|(name, _)| name); match ext_name { #[cfg(feature = "dpms")] Some(dpms::X11_EXTENSION_NAME) => { match ge_event.event_type { dpms::INFO_NOTIFY_EVENT => Ok(Self::DpmsInfoNotify(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } #[cfg(feature = "present")] Some(present::X11_EXTENSION_NAME) => { match ge_event.event_type { present::COMPLETE_NOTIFY_EVENT => Ok(Self::PresentCompleteNotify(TryParse::try_parse(event)?.0)), present::CONFIGURE_NOTIFY_EVENT => Ok(Self::PresentConfigureNotify(TryParse::try_parse(event)?.0)), present::IDLE_NOTIFY_EVENT => Ok(Self::PresentIdleNotify(TryParse::try_parse(event)?.0)), present::REDIRECT_NOTIFY_EVENT => Ok(Self::PresentRedirectNotify(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } #[cfg(feature = "xinput")] Some(xinput::X11_EXTENSION_NAME) => { match ge_event.event_type { xinput::BARRIER_HIT_EVENT => Ok(Self::XinputBarrierHit(TryParse::try_parse(event)?.0)), xinput::BARRIER_LEAVE_EVENT => Ok(Self::XinputBarrierLeave(TryParse::try_parse(event)?.0)), xinput::BUTTON_PRESS_EVENT => Ok(Self::XinputButtonPress(TryParse::try_parse(event)?.0)), xinput::BUTTON_RELEASE_EVENT => Ok(Self::XinputButtonRelease(TryParse::try_parse(event)?.0)), xinput::DEVICE_CHANGED_EVENT => Ok(Self::XinputDeviceChanged(TryParse::try_parse(event)?.0)), xinput::ENTER_EVENT => Ok(Self::XinputEnter(TryParse::try_parse(event)?.0)), xinput::FOCUS_IN_EVENT => Ok(Self::XinputFocusIn(TryParse::try_parse(event)?.0)), xinput::FOCUS_OUT_EVENT => Ok(Self::XinputFocusOut(TryParse::try_parse(event)?.0)), xinput::GESTURE_PINCH_BEGIN_EVENT => Ok(Self::XinputGesturePinchBegin(TryParse::try_parse(event)?.0)), xinput::GESTURE_PINCH_END_EVENT => Ok(Self::XinputGesturePinchEnd(TryParse::try_parse(event)?.0)), xinput::GESTURE_PINCH_UPDATE_EVENT => Ok(Self::XinputGesturePinchUpdate(TryParse::try_parse(event)?.0)), xinput::GESTURE_SWIPE_BEGIN_EVENT => Ok(Self::XinputGestureSwipeBegin(TryParse::try_parse(event)?.0)), xinput::GESTURE_SWIPE_END_EVENT => Ok(Self::XinputGestureSwipeEnd(TryParse::try_parse(event)?.0)), xinput::GESTURE_SWIPE_UPDATE_EVENT => Ok(Self::XinputGestureSwipeUpdate(TryParse::try_parse(event)?.0)), xinput::HIERARCHY_EVENT => Ok(Self::XinputHierarchy(TryParse::try_parse(event)?.0)), xinput::KEY_PRESS_EVENT => Ok(Self::XinputKeyPress(TryParse::try_parse(event)?.0)), xinput::KEY_RELEASE_EVENT => Ok(Self::XinputKeyRelease(TryParse::try_parse(event)?.0)), xinput::LEAVE_EVENT => Ok(Self::XinputLeave(TryParse::try_parse(event)?.0)), xinput::MOTION_EVENT => Ok(Self::XinputMotion(TryParse::try_parse(event)?.0)), xinput::PROPERTY_EVENT => Ok(Self::XinputProperty(TryParse::try_parse(event)?.0)), xinput::RAW_BUTTON_PRESS_EVENT => Ok(Self::XinputRawButtonPress(TryParse::try_parse(event)?.0)), xinput::RAW_BUTTON_RELEASE_EVENT => Ok(Self::XinputRawButtonRelease(TryParse::try_parse(event)?.0)), xinput::RAW_KEY_PRESS_EVENT => Ok(Self::XinputRawKeyPress(TryParse::try_parse(event)?.0)), xinput::RAW_KEY_RELEASE_EVENT => Ok(Self::XinputRawKeyRelease(TryParse::try_parse(event)?.0)), xinput::RAW_MOTION_EVENT => Ok(Self::XinputRawMotion(TryParse::try_parse(event)?.0)), xinput::RAW_TOUCH_BEGIN_EVENT => Ok(Self::XinputRawTouchBegin(TryParse::try_parse(event)?.0)), xinput::RAW_TOUCH_END_EVENT => Ok(Self::XinputRawTouchEnd(TryParse::try_parse(event)?.0)), xinput::RAW_TOUCH_UPDATE_EVENT => Ok(Self::XinputRawTouchUpdate(TryParse::try_parse(event)?.0)), xinput::TOUCH_BEGIN_EVENT => Ok(Self::XinputTouchBegin(TryParse::try_parse(event)?.0)), xinput::TOUCH_END_EVENT => Ok(Self::XinputTouchEnd(TryParse::try_parse(event)?.0)), xinput::TOUCH_OWNERSHIP_EVENT => Ok(Self::XinputTouchOwnership(TryParse::try_parse(event)?.0)), xinput::TOUCH_UPDATE_EVENT => Ok(Self::XinputTouchUpdate(TryParse::try_parse(event)?.0)), _ => Ok(Self::Unknown(event.to_vec())), } } _ => Ok(Self::Unknown(event.to_vec())), } } /// Get the sequence number contained in this X11 event pub fn wire_sequence_number(&self) -> Option { match self { Event::Unknown(value) => sequence_number(value).ok(), Event::Error(value) => Some(value.sequence), Event::ButtonPress(value) => Some(value.sequence), Event::ButtonRelease(value) => Some(value.sequence), Event::CirculateNotify(value) => Some(value.sequence), Event::CirculateRequest(value) => Some(value.sequence), Event::ClientMessage(value) => Some(value.sequence), Event::ColormapNotify(value) => Some(value.sequence), Event::ConfigureNotify(value) => Some(value.sequence), Event::ConfigureRequest(value) => Some(value.sequence), Event::CreateNotify(value) => Some(value.sequence), Event::DestroyNotify(value) => Some(value.sequence), Event::EnterNotify(value) => Some(value.sequence), Event::Expose(value) => Some(value.sequence), Event::FocusIn(value) => Some(value.sequence), Event::FocusOut(value) => Some(value.sequence), Event::GeGeneric(value) => Some(value.sequence), Event::GraphicsExposure(value) => Some(value.sequence), Event::GravityNotify(value) => Some(value.sequence), Event::KeyPress(value) => Some(value.sequence), Event::KeyRelease(value) => Some(value.sequence), Event::KeymapNotify(_) => None, Event::LeaveNotify(value) => Some(value.sequence), Event::MapNotify(value) => Some(value.sequence), Event::MapRequest(value) => Some(value.sequence), Event::MappingNotify(value) => Some(value.sequence), Event::MotionNotify(value) => Some(value.sequence), Event::NoExposure(value) => Some(value.sequence), Event::PropertyNotify(value) => Some(value.sequence), Event::ReparentNotify(value) => Some(value.sequence), Event::ResizeRequest(value) => Some(value.sequence), Event::SelectionClear(value) => Some(value.sequence), Event::SelectionNotify(value) => Some(value.sequence), Event::SelectionRequest(value) => Some(value.sequence), Event::UnmapNotify(value) => Some(value.sequence), Event::VisibilityNotify(value) => Some(value.sequence), #[cfg(feature = "damage")] Event::DamageNotify(value) => Some(value.sequence), #[cfg(feature = "dpms")] Event::DpmsInfoNotify(value) => Some(value.sequence), #[cfg(feature = "dri2")] Event::Dri2BufferSwapComplete(value) => Some(value.sequence), #[cfg(feature = "dri2")] Event::Dri2InvalidateBuffers(value) => Some(value.sequence), #[cfg(feature = "glx")] Event::GlxBufferSwapComplete(value) => Some(value.sequence), #[cfg(feature = "glx")] Event::GlxPbufferClobber(value) => Some(value.sequence), #[cfg(feature = "present")] Event::PresentCompleteNotify(value) => Some(value.sequence), #[cfg(feature = "present")] Event::PresentConfigureNotify(value) => Some(value.sequence), #[cfg(feature = "present")] Event::PresentGeneric(value) => Some(value.sequence), #[cfg(feature = "present")] Event::PresentIdleNotify(value) => Some(value.sequence), #[cfg(feature = "present")] Event::PresentRedirectNotify(value) => Some(value.sequence), #[cfg(feature = "randr")] Event::RandrNotify(value) => Some(value.sequence), #[cfg(feature = "randr")] Event::RandrScreenChangeNotify(value) => Some(value.sequence), #[cfg(feature = "screensaver")] Event::ScreensaverNotify(value) => Some(value.sequence), #[cfg(feature = "shape")] Event::ShapeNotify(value) => Some(value.sequence), #[cfg(feature = "shm")] Event::ShmCompletion(value) => Some(value.sequence), #[cfg(feature = "sync")] Event::SyncAlarmNotify(value) => Some(value.sequence), #[cfg(feature = "sync")] Event::SyncCounterNotify(value) => Some(value.sequence), #[cfg(feature = "xfixes")] Event::XfixesCursorNotify(value) => Some(value.sequence), #[cfg(feature = "xfixes")] Event::XfixesSelectionNotify(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputBarrierHit(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputBarrierLeave(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputButtonPress(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputButtonRelease(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputChangeDeviceNotify(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputDeviceButtonPress(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputDeviceButtonRelease(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputDeviceButtonStateNotify(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputDeviceChanged(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputDeviceFocusIn(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputDeviceFocusOut(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputDeviceKeyPress(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputDeviceKeyRelease(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputDeviceKeyStateNotify(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputDeviceMappingNotify(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputDeviceMotionNotify(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputDevicePresenceNotify(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputDevicePropertyNotify(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputDeviceStateNotify(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputDeviceValuator(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputEnter(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputFocusIn(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputFocusOut(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputGesturePinchBegin(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputGesturePinchEnd(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputGesturePinchUpdate(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputGestureSwipeBegin(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputGestureSwipeEnd(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputGestureSwipeUpdate(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputHierarchy(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputKeyPress(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputKeyRelease(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputLeave(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputMotion(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputProperty(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputProximityIn(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputProximityOut(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputRawButtonPress(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputRawButtonRelease(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputRawKeyPress(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputRawKeyRelease(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputRawMotion(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputRawTouchBegin(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputRawTouchEnd(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputRawTouchUpdate(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputTouchBegin(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputTouchEnd(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputTouchOwnership(value) => Some(value.sequence), #[cfg(feature = "xinput")] Event::XinputTouchUpdate(value) => Some(value.sequence), #[cfg(feature = "xkb")] Event::XkbAccessXNotify(value) => Some(value.sequence), #[cfg(feature = "xkb")] Event::XkbActionMessage(value) => Some(value.sequence), #[cfg(feature = "xkb")] Event::XkbBellNotify(value) => Some(value.sequence), #[cfg(feature = "xkb")] Event::XkbCompatMapNotify(value) => Some(value.sequence), #[cfg(feature = "xkb")] Event::XkbControlsNotify(value) => Some(value.sequence), #[cfg(feature = "xkb")] Event::XkbExtensionDeviceNotify(value) => Some(value.sequence), #[cfg(feature = "xkb")] Event::XkbIndicatorMapNotify(value) => Some(value.sequence), #[cfg(feature = "xkb")] Event::XkbIndicatorStateNotify(value) => Some(value.sequence), #[cfg(feature = "xkb")] Event::XkbMapNotify(value) => Some(value.sequence), #[cfg(feature = "xkb")] Event::XkbNamesNotify(value) => Some(value.sequence), #[cfg(feature = "xkb")] Event::XkbNewKeyboardNotify(value) => Some(value.sequence), #[cfg(feature = "xkb")] Event::XkbStateNotify(value) => Some(value.sequence), #[cfg(feature = "xprint")] Event::XprintAttributNotify(value) => Some(value.sequence), #[cfg(feature = "xprint")] Event::XprintNotify(value) => Some(value.sequence), #[cfg(feature = "xv")] Event::XvPortNotify(value) => Some(value.sequence), #[cfg(feature = "xv")] Event::XvVideoNotify(value) => Some(value.sequence), } } /// Get the raw response type of this X11 event /// /// Response types have seven bits in X11. The eight bit indicates whether /// the packet was generated through the `SendEvent` request. This function /// returns all eight bits. /// /// See also the `response_type()`, `server_generated()` and `sent_event()` methods. pub fn raw_response_type(&self) -> u8 { match self { Event::Unknown(value) => response_type(value).unwrap(), Event::Error(_) => 0, Event::ButtonPress(value) => value.response_type, Event::ButtonRelease(value) => value.response_type, Event::CirculateNotify(value) => value.response_type, Event::CirculateRequest(value) => value.response_type, Event::ClientMessage(value) => value.response_type, Event::ColormapNotify(value) => value.response_type, Event::ConfigureNotify(value) => value.response_type, Event::ConfigureRequest(value) => value.response_type, Event::CreateNotify(value) => value.response_type, Event::DestroyNotify(value) => value.response_type, Event::EnterNotify(value) => value.response_type, Event::Expose(value) => value.response_type, Event::FocusIn(value) => value.response_type, Event::FocusOut(value) => value.response_type, Event::GeGeneric(value) => value.response_type, Event::GraphicsExposure(value) => value.response_type, Event::GravityNotify(value) => value.response_type, Event::KeyPress(value) => value.response_type, Event::KeyRelease(value) => value.response_type, Event::KeymapNotify(value) => value.response_type, Event::LeaveNotify(value) => value.response_type, Event::MapNotify(value) => value.response_type, Event::MapRequest(value) => value.response_type, Event::MappingNotify(value) => value.response_type, Event::MotionNotify(value) => value.response_type, Event::NoExposure(value) => value.response_type, Event::PropertyNotify(value) => value.response_type, Event::ReparentNotify(value) => value.response_type, Event::ResizeRequest(value) => value.response_type, Event::SelectionClear(value) => value.response_type, Event::SelectionNotify(value) => value.response_type, Event::SelectionRequest(value) => value.response_type, Event::UnmapNotify(value) => value.response_type, Event::VisibilityNotify(value) => value.response_type, #[cfg(feature = "damage")] Event::DamageNotify(value) => value.response_type, #[cfg(feature = "dpms")] Event::DpmsInfoNotify(value) => value.response_type, #[cfg(feature = "dri2")] Event::Dri2BufferSwapComplete(value) => value.response_type, #[cfg(feature = "dri2")] Event::Dri2InvalidateBuffers(value) => value.response_type, #[cfg(feature = "glx")] Event::GlxBufferSwapComplete(value) => value.response_type, #[cfg(feature = "glx")] Event::GlxPbufferClobber(value) => value.response_type, #[cfg(feature = "present")] Event::PresentCompleteNotify(value) => value.response_type, #[cfg(feature = "present")] Event::PresentConfigureNotify(value) => value.response_type, #[cfg(feature = "present")] Event::PresentGeneric(value) => value.response_type, #[cfg(feature = "present")] Event::PresentIdleNotify(value) => value.response_type, #[cfg(feature = "present")] Event::PresentRedirectNotify(value) => value.response_type, #[cfg(feature = "randr")] Event::RandrNotify(value) => value.response_type, #[cfg(feature = "randr")] Event::RandrScreenChangeNotify(value) => value.response_type, #[cfg(feature = "screensaver")] Event::ScreensaverNotify(value) => value.response_type, #[cfg(feature = "shape")] Event::ShapeNotify(value) => value.response_type, #[cfg(feature = "shm")] Event::ShmCompletion(value) => value.response_type, #[cfg(feature = "sync")] Event::SyncAlarmNotify(value) => value.response_type, #[cfg(feature = "sync")] Event::SyncCounterNotify(value) => value.response_type, #[cfg(feature = "xfixes")] Event::XfixesCursorNotify(value) => value.response_type, #[cfg(feature = "xfixes")] Event::XfixesSelectionNotify(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputBarrierHit(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputBarrierLeave(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputButtonPress(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputButtonRelease(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputChangeDeviceNotify(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputDeviceButtonPress(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputDeviceButtonRelease(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputDeviceButtonStateNotify(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputDeviceChanged(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputDeviceFocusIn(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputDeviceFocusOut(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputDeviceKeyPress(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputDeviceKeyRelease(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputDeviceKeyStateNotify(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputDeviceMappingNotify(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputDeviceMotionNotify(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputDevicePresenceNotify(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputDevicePropertyNotify(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputDeviceStateNotify(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputDeviceValuator(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputEnter(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputFocusIn(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputFocusOut(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputGesturePinchBegin(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputGesturePinchEnd(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputGesturePinchUpdate(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputGestureSwipeBegin(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputGestureSwipeEnd(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputGestureSwipeUpdate(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputHierarchy(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputKeyPress(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputKeyRelease(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputLeave(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputMotion(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputProperty(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputProximityIn(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputProximityOut(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputRawButtonPress(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputRawButtonRelease(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputRawKeyPress(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputRawKeyRelease(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputRawMotion(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputRawTouchBegin(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputRawTouchEnd(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputRawTouchUpdate(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputTouchBegin(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputTouchEnd(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputTouchOwnership(value) => value.response_type, #[cfg(feature = "xinput")] Event::XinputTouchUpdate(value) => value.response_type, #[cfg(feature = "xkb")] Event::XkbAccessXNotify(value) => value.response_type, #[cfg(feature = "xkb")] Event::XkbActionMessage(value) => value.response_type, #[cfg(feature = "xkb")] Event::XkbBellNotify(value) => value.response_type, #[cfg(feature = "xkb")] Event::XkbCompatMapNotify(value) => value.response_type, #[cfg(feature = "xkb")] Event::XkbControlsNotify(value) => value.response_type, #[cfg(feature = "xkb")] Event::XkbExtensionDeviceNotify(value) => value.response_type, #[cfg(feature = "xkb")] Event::XkbIndicatorMapNotify(value) => value.response_type, #[cfg(feature = "xkb")] Event::XkbIndicatorStateNotify(value) => value.response_type, #[cfg(feature = "xkb")] Event::XkbMapNotify(value) => value.response_type, #[cfg(feature = "xkb")] Event::XkbNamesNotify(value) => value.response_type, #[cfg(feature = "xkb")] Event::XkbNewKeyboardNotify(value) => value.response_type, #[cfg(feature = "xkb")] Event::XkbStateNotify(value) => value.response_type, #[cfg(feature = "xprint")] Event::XprintAttributNotify(value) => value.response_type, #[cfg(feature = "xprint")] Event::XprintNotify(value) => value.response_type, #[cfg(feature = "xv")] Event::XvPortNotify(value) => value.response_type, #[cfg(feature = "xv")] Event::XvVideoNotify(value) => value.response_type, } } /// Get the response type of this X11 event pub fn response_type(&self) -> u8 { self.raw_response_type() & 0x7f } /// Was this event generated by the X11 server? /// /// If this function returns true, then this event comes from the X11 server. /// Otherwise, it was sent from another client via the `SendEvent` request. pub fn server_generated(&self) -> bool { self.raw_response_type() & 0x80 == 0 } /// Was this event generated by another X11 client? /// /// If this function returns true, then this event comes from another client via /// the `SendEvent` request. Otherwise, it was generated by the X11 server. pub fn sent_event(&self) -> bool { self.raw_response_type() & 0x80 != 0 } } /// Get the response type out of the raw bytes of an X11 error or event. fn response_type(raw_bytes: &[u8]) -> Result { raw_bytes.first() .map(|x| x & 0x7f) .ok_or(ParseError::InsufficientData) } /// Get the sequence number out of an X11 packet. fn sequence_number(raw_bytes: &[u8]) -> Result { raw_bytes.get(2..4) .map(|b| u16::from_ne_bytes(b.try_into().unwrap())) .ok_or(ParseError::InsufficientData) } x11rb-protocol-0.13.1/src/protocol/present.rs000064400000000000000000002113341046102023000171640ustar 00000000000000// This file contains generated code. Do not edit directly. // To regenerate this, run 'make'. //! Bindings to the `Present` X11 extension. #![allow(clippy::too_many_arguments)] // The code generator is simpler if it can always use conversions #![allow(clippy::useless_conversion)] #[allow(unused_imports)] use alloc::borrow::Cow; #[allow(unused_imports)] use core::convert::TryInto; use alloc::vec; use alloc::vec::Vec; use core::convert::TryFrom; use crate::errors::ParseError; #[allow(unused_imports)] use crate::x11_utils::TryIntoUSize; use crate::BufWithFds; #[allow(unused_imports)] use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; #[allow(unused_imports)] use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; #[allow(unused_imports)] use super::dri3; #[allow(unused_imports)] use super::randr; #[allow(unused_imports)] use super::sync; #[allow(unused_imports)] use super::xfixes; #[allow(unused_imports)] use super::xproto; /// The X11 name of the extension for QueryExtension pub const X11_EXTENSION_NAME: &str = "Present"; /// The version number of this extension that this client library supports. /// /// This constant contains the version number of this extension that is supported /// by this build of x11rb. For most things, it does not make sense to use this /// information. If you need to send a `QueryVersion`, it is recommended to instead /// send the maximum version of the extension that you need. pub const X11_XML_VERSION: (u32, u32) = (1, 4); #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct EventEnum(u8); impl EventEnum { pub const CONFIGURE_NOTIFY: Self = Self(0); pub const COMPLETE_NOTIFY: Self = Self(1); pub const IDLE_NOTIFY: Self = Self(2); pub const REDIRECT_NOTIFY: Self = Self(3); } impl From for u8 { #[inline] fn from(input: EventEnum) -> Self { input.0 } } impl From for core::option::Option { #[inline] fn from(input: EventEnum) -> Self { Some(input.0) } } impl From for u16 { #[inline] fn from(input: EventEnum) -> Self { u16::from(input.0) } } impl From for core::option::Option { #[inline] fn from(input: EventEnum) -> Self { Some(u16::from(input.0)) } } impl From for u32 { #[inline] fn from(input: EventEnum) -> Self { u32::from(input.0) } } impl From for core::option::Option { #[inline] fn from(input: EventEnum) -> Self { Some(u32::from(input.0)) } } impl From for EventEnum { #[inline] fn from(value: u8) -> Self { Self(value) } } impl core::fmt::Debug for EventEnum { fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let variants = [ (Self::CONFIGURE_NOTIFY.0.into(), "CONFIGURE_NOTIFY", "ConfigureNotify"), (Self::COMPLETE_NOTIFY.0.into(), "COMPLETE_NOTIFY", "CompleteNotify"), (Self::IDLE_NOTIFY.0.into(), "IDLE_NOTIFY", "IdleNotify"), (Self::REDIRECT_NOTIFY.0.into(), "REDIRECT_NOTIFY", "RedirectNotify"), ]; pretty_print_enum(fmt, self.0.into(), &variants) } } #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct EventMask(u32); impl EventMask { pub const NO_EVENT: Self = Self(0); pub const CONFIGURE_NOTIFY: Self = Self(1 << 0); pub const COMPLETE_NOTIFY: Self = Self(1 << 1); pub const IDLE_NOTIFY: Self = Self(1 << 2); pub const REDIRECT_NOTIFY: Self = Self(1 << 3); } impl From for u32 { #[inline] fn from(input: EventMask) -> Self { input.0 } } impl From for core::option::Option { #[inline] fn from(input: EventMask) -> Self { Some(input.0) } } impl From for EventMask { #[inline] fn from(value: u8) -> Self { Self(value.into()) } } impl From for EventMask { #[inline] fn from(value: u16) -> Self { Self(value.into()) } } impl From for EventMask { #[inline] fn from(value: u32) -> Self { Self(value) } } impl core::fmt::Debug for EventMask { fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { let variants = [ (Self::NO_EVENT.0, "NO_EVENT", "NoEvent"), (Self::CONFIGURE_NOTIFY.0, "CONFIGURE_NOTIFY", "ConfigureNotify"), (Self::COMPLETE_NOTIFY.0, "COMPLETE_NOTIFY", "CompleteNotify"), (Self::IDLE_NOTIFY.0, "IDLE_NOTIFY", "IdleNotify"), (Self::REDIRECT_NOTIFY.0, "REDIRECT_NOTIFY", "RedirectNotify"), ]; pretty_print_bitmask(fmt, self.0, &variants) } } bitmask_binop!(EventMask, u32); #[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Option(u8); impl Option { pub const NONE: Self = Self(0); pub const ASYNC: Self = Self(1 << 0); pub const COPY: Self = Self(1 << 1); pub const UST: Self = Self(1 << 2); pub const SUBOPTIMAL: Self = Self(1 << 3); pub const ASYNC_MAY_TEAR: Self = Self(1 << 4); } impl From