From 8aac79fbe0f06f9a576a0142707f3a49649cab36 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Wed, 16 Mar 2022 15:18:29 +0100 Subject: [PATCH 1/3] Split out a x11rb-protocol crate This commit splits the code into two crates: "x11rb-protocol" contains the protocol definitions and allows parsing and serialising things. It does not do any actual I/O. "x11rb" uses x11rb-protocol and implements an X11 client based on this. I tried to do as few changes as possible here. Code moves around, but the structure of the code is not supposed to change. There is one place where this did not work out: Previously, e.g. CreateWindowRequest had an associated function send(). This function send the request that it is called on via a given X11 connection. Since this does I/O, this functionality does not belong into the x11rb-protocol crate. Since it is an associated function, it cannot easily be provided by x11rb. For now, I worked around this problem by turning send() into a "free" function. The resulting name collision was dealt by renaming it to e.g. send_create_window(). The result of all this is a huge commit. This is still a mess and things should be cleaned up further in the future, but I didn't want to make this commit even larger. This is the first version that I managed to get to compile. Signed-off-by: Uli Schlachter --- Cargo.toml | 57 +- Makefile | 7 +- doc/making_a_release.md | 7 + generator/src/generator/mod.rs | 111 +- generator/src/generator/namespace/header.rs | 169 +- generator/src/generator/namespace/mod.rs | 66 +- generator/src/generator/namespace/request.rs | 79 +- generator/src/main.rs | 21 +- src/errors.rs | 68 +- src/image.rs | 34 +- src/lib.rs | 5 + src/protocol/bigreq.rs | 106 +- src/protocol/composite.rs | 812 +- src/protocol/damage.rs | 593 +- src/protocol/dpms.rs | 706 +- src/protocol/dri2.rs | 2023 +- src/protocol/dri3.rs | 1104 +- src/protocol/ge.rs | 122 +- src/protocol/glx.rs | 11851 +------ src/protocol/mod.rs | 9261 +----- src/protocol/present.rs | 1337 +- src/protocol/randr.rs | 6887 +---- src/protocol/record.rs | 1157 +- src/protocol/render.rs | 5500 +--- src/protocol/res.rs | 1031 +- src/protocol/screensaver.rs | 1207 +- src/protocol/shape.rs | 1158 +- src/protocol/shm.rs | 975 +- src/protocol/sync.rs | 2623 +- src/protocol/xc_misc.rs | 317 +- src/protocol/xevie.rs | 715 +- src/protocol/xf86dri.rs | 1278 +- src/protocol/xf86vidmode.rs | 3017 +- src/protocol/xfixes.rs | 3621 +-- src/protocol/xinerama.rs | 646 +- src/protocol/xinput.rs | 17925 +---------- src/protocol/xkb.rs | 12573 +------- src/protocol/xprint.rs | 2776 +- src/protocol/xproto.rs | 27465 ++--------------- src/protocol/xselinux.rs | 2377 +- src/protocol/xtest.rs | 484 +- src/protocol/xv.rs | 3511 +-- src/protocol/xvmc.rs | 1040 +- src/rust_connection/mod.rs | 2 +- src/utils.rs | 241 +- src/wrapper.rs | 42 - src/x11_utils.rs | 520 +- x11rb-protocol/Cargo.toml | 48 + x11rb-protocol/src/errors.rs | 67 + x11rb-protocol/src/lib.rs | 19 + x11rb-protocol/src/protocol/bigreq.rs | 101 + x11rb-protocol/src/protocol/composite.rs | 689 + x11rb-protocol/src/protocol/damage.rs | 530 + x11rb-protocol/src/protocol/dpms.rs | 596 + x11rb-protocol/src/protocol/dri2.rs | 1824 ++ x11rb-protocol/src/protocol/dri3.rs | 980 + x11rb-protocol/src/protocol/ge.rs | 117 + x11rb-protocol/src/protocol/glx.rs | 10329 +++++++ x11rb-protocol/src/protocol/mod.rs | 9326 ++++++ x11rb-protocol/src/protocol/present.rs | 1276 + x11rb-protocol/src/protocol/randr.rs | 6224 ++++ x11rb-protocol/src/protocol/record.rs | 1047 + x11rb-protocol/src/protocol/render.rs | 5022 +++ x11rb-protocol/src/protocol/res.rs | 952 + x11rb-protocol/src/protocol/screensaver.rs | 1128 + x11rb-protocol/src/protocol/shape.rs | 1034 + x11rb-protocol/src/protocol/shm.rs | 866 + x11rb-protocol/src/protocol/sync.rs | 2334 ++ x11rb-protocol/src/protocol/xc_misc.rs | 282 + x11rb-protocol/src/protocol/xevie.rs | 650 + x11rb-protocol/src/protocol/xf86dri.rs | 1108 + x11rb-protocol/src/protocol/xf86vidmode.rs | 2712 ++ x11rb-protocol/src/protocol/xfixes.rs | 3139 ++ x11rb-protocol/src/protocol/xinerama.rs | 567 + x11rb-protocol/src/protocol/xinput.rs | 16188 ++++++++++ x11rb-protocol/src/protocol/xkb.rs | 12190 ++++++++ x11rb-protocol/src/protocol/xprint.rs | 2412 ++ x11rb-protocol/src/protocol/xproto.rs | 22900 ++++++++++++++ x11rb-protocol/src/protocol/xselinux.rs | 2043 ++ x11rb-protocol/src/protocol/xtest.rs | 435 + x11rb-protocol/src/protocol/xv.rs | 3203 ++ x11rb-protocol/src/protocol/xvmc.rs | 916 + x11rb-protocol/src/utils.rs | 239 + x11rb-protocol/src/wrapper.rs | 44 + x11rb-protocol/src/x11_utils.rs | 515 + 85 files changed, 121688 insertions(+), 119991 deletions(-) create mode 100644 x11rb-protocol/Cargo.toml create mode 100644 x11rb-protocol/src/errors.rs create mode 100644 x11rb-protocol/src/lib.rs create mode 100644 x11rb-protocol/src/protocol/bigreq.rs create mode 100644 x11rb-protocol/src/protocol/composite.rs create mode 100644 x11rb-protocol/src/protocol/damage.rs create mode 100644 x11rb-protocol/src/protocol/dpms.rs create mode 100644 x11rb-protocol/src/protocol/dri2.rs create mode 100644 x11rb-protocol/src/protocol/dri3.rs create mode 100644 x11rb-protocol/src/protocol/ge.rs create mode 100644 x11rb-protocol/src/protocol/glx.rs create mode 100644 x11rb-protocol/src/protocol/mod.rs create mode 100644 x11rb-protocol/src/protocol/present.rs create mode 100644 x11rb-protocol/src/protocol/randr.rs create mode 100644 x11rb-protocol/src/protocol/record.rs create mode 100644 x11rb-protocol/src/protocol/render.rs create mode 100644 x11rb-protocol/src/protocol/res.rs create mode 100644 x11rb-protocol/src/protocol/screensaver.rs create mode 100644 x11rb-protocol/src/protocol/shape.rs create mode 100644 x11rb-protocol/src/protocol/shm.rs create mode 100644 x11rb-protocol/src/protocol/sync.rs create mode 100644 x11rb-protocol/src/protocol/xc_misc.rs create mode 100644 x11rb-protocol/src/protocol/xevie.rs create mode 100644 x11rb-protocol/src/protocol/xf86dri.rs create mode 100644 x11rb-protocol/src/protocol/xf86vidmode.rs create mode 100644 x11rb-protocol/src/protocol/xfixes.rs create mode 100644 x11rb-protocol/src/protocol/xinerama.rs create mode 100644 x11rb-protocol/src/protocol/xinput.rs create mode 100644 x11rb-protocol/src/protocol/xkb.rs create mode 100644 x11rb-protocol/src/protocol/xprint.rs create mode 100644 x11rb-protocol/src/protocol/xproto.rs create mode 100644 x11rb-protocol/src/protocol/xselinux.rs create mode 100644 x11rb-protocol/src/protocol/xtest.rs create mode 100644 x11rb-protocol/src/protocol/xv.rs create mode 100644 x11rb-protocol/src/protocol/xvmc.rs create mode 100644 x11rb-protocol/src/utils.rs create mode 100644 x11rb-protocol/src/wrapper.rs create mode 100644 x11rb-protocol/src/x11_utils.rs diff --git a/Cargo.toml b/Cargo.toml index e678a2b7..636e08f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,6 +19,7 @@ exclude = [ ] [dependencies] +x11rb-protocol = { version = "0.9.0", path = "x11rb-protocol" } libc = { version = "0.2", optional = true } libloading = { version = "0.7.0", optional = true } once_cell = { version = "1.8.0", optional = true } @@ -83,33 +84,33 @@ all-extensions = [ ] # Features to enable individual X11 extensions -composite = ["xfixes"] -damage = ["xfixes"] -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"] +composite = ["x11rb-protocol/composite", "xfixes"] +damage = ["x11rb-protocol/damage", "xfixes"] +dpms = ["x11rb-protocol/dpms"] +dri2 = ["x11rb-protocol/dri2"] +dri3 = ["x11rb-protocol/dri3"] +glx = ["x11rb-protocol/glx"] +present = ["x11rb-protocol/present", "randr", "xfixes", "sync"] +randr = ["x11rb-protocol/randr", "render"] +record = ["x11rb-protocol/record"] +render = ["x11rb-protocol/render"] +res = ["x11rb-protocol/res"] +screensaver = ["x11rb-protocol/screensaver"] +shape = ["x11rb-protocol/shape"] +shm = ["x11rb-protocol/shm"] +sync = ["x11rb-protocol/sync"] +xevie = ["x11rb-protocol/xevie"] +xf86dri = ["x11rb-protocol/xf86dri"] +xf86vidmode = ["x11rb-protocol/xf86vidmode"] +xfixes = ["x11rb-protocol/xfixes", "render", "shape"] +xinerama = ["x11rb-protocol/xinerama"] +xinput = ["x11rb-protocol/xinput", "xfixes"] +xkb = ["x11rb-protocol/xkb"] +xprint = ["x11rb-protocol/xprint"] +xselinux = ["x11rb-protocol/xselinux"] +xtest = ["x11rb-protocol/xtest"] +xv = ["x11rb-protocol/xv", "shm"] +xvmc = ["x11rb-protocol/xvmc", "xv"] [package.metadata.docs.rs] features = [ @@ -146,4 +147,4 @@ name = "record" required-features = ["record"] [workspace] -members = ["generator", "xcbgen-rs", "cairo-example", "xtrace-example"] +members = ["generator", "xcbgen-rs", "x11rb-protocol", "cairo-example", "xtrace-example"] diff --git a/Makefile b/Makefile index daecd457..7edec2fa 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,9 @@ PROTO=xcb-proto-1.14-1-g2b3559c -OUT=src/protocol +PROTO_OUT=x11rb-protocol/src/protocol +X11RB_OUT=src/protocol generate: - mkdir -p "$(OUT)" - cargo run -p x11rb-generator -- "$(PROTO)/src" "$(OUT)" + mkdir -p "$(PROTO_OUT)" "$(X11RB_OUT)" + cargo run -p x11rb-generator -- "$(PROTO)/src" "$(PROTO_OUT)" "$(X11RB_OUT)" .PHONY: generate diff --git a/doc/making_a_release.md b/doc/making_a_release.md index 950bc0bc..0d9a7ffa 100644 --- a/doc/making_a_release.md +++ b/doc/making_a_release.md @@ -8,3 +8,10 @@ git tag -a -m "Version 0.2.0" v0.2.0 cargo publish git push origin v0.2.0 ``` +TODO: Update the above for the split with the new x11rb-protocol crate. +Both crate versions should be kept close together. Still, if there are no +semver-incompatible changes in x11rb-protocol, only the micro version needs a +bump. + +Also: Beware! The version for the x11rb -> x11rb-protocol dependency needs to be +properly updated on version changes! diff --git a/generator/src/generator/mod.rs b/generator/src/generator/mod.rs index 14f1e003..a35d735d 100644 --- a/generator/src/generator/mod.rs +++ b/generator/src/generator/mod.rs @@ -12,71 +12,104 @@ mod special_cases; use output::Output; -pub(crate) fn generate(module: &xcbgen::defs::Module) -> HashMap { - let mut out_map = HashMap::new(); +pub(crate) struct Generated { + pub(crate) file_name: PathBuf, + pub(crate) proto: String, + pub(crate) x11rb: String, +} - let mut main_out = Output::new(); - write_code_header(&mut main_out); - outln!(main_out, "//! Bindings to the X11 protocol."); - outln!(main_out, "//!"); - outln!( - main_out, - "//! Each sub-module of this module corresponds to one X11 extension. It contains all the" - ); +pub(crate) fn generate(module: &xcbgen::defs::Module) -> Vec { + let mut out_map = Vec::new(); + + let mut main_proto_out = Output::new(); + let mut main_x11rb_out = Output::new(); + for out in [&mut main_proto_out, &mut main_x11rb_out] { + write_code_header(out); + outln!(out, "//! Bindings to the X11 protocol."); + outln!(out, "//!"); + outln!( + out, + "//! Each sub-module of this module corresponds to one X11 extension. It contains all the" + ); + outln!( + out, + "//! definitions from that extension. The core X11 protocol is in \ + [`xproto`](xproto/index.html).", + ); + outln!(out, ""); + outln!(out, "// Clippy does not like some names from the XML."); + outln!(out, "#![allow(clippy::upper_case_acronyms)]"); + outln!(out, "// This is not easy to fix, so ignore it."); + outln!( + out, + "#![allow(clippy::needless_borrow, clippy::needless_lifetimes)]" + ); + } + outln!(main_proto_out, ""); + outln!(main_proto_out, "use std::borrow::Cow;"); + outln!(main_proto_out, "use std::convert::TryInto;"); + outln!(main_proto_out, "use crate::errors::ParseError;"); + outln!(main_proto_out, "use crate::utils::RawFdContainer;"); outln!( - main_out, - "//! definitions from that extension. The core X11 protocol is in \ - [`xproto`](xproto/index.html).", + main_proto_out, + "use crate::x11_utils::{{TryParse, X11Error}};" ); - outln!(main_out, ""); - outln!(main_out, "// Clippy does not like some names from the XML."); - outln!(main_out, "#![allow(clippy::upper_case_acronyms)]"); - outln!(main_out, "// This is not easy to fix, so ignore it."); - outln!(main_out, "#![allow(clippy::needless_borrow)]"); - outln!(main_out, ""); - outln!(main_out, "use std::borrow::Cow;"); - outln!(main_out, "use std::convert::TryInto;"); - outln!(main_out, "use crate::errors::ParseError;"); - outln!(main_out, "use crate::utils::RawFdContainer;"); - outln!(main_out, "use crate::x11_utils::{{TryParse, X11Error}};"); outln!( - main_out, + main_proto_out, "use crate::x11_utils::{{ExtInfoProvider, ReplyParsingFunction, Request as RequestTrait, \ RequestHeader}};" ); - outln!(main_out, ""); + outln!(main_proto_out, ""); let caches = RefCell::new(namespace::helpers::Caches::default()); caches.borrow_mut().gather_enum_infos(module); let mut enum_cases = HashMap::new(); for ns in module.sorted_namespaces() { - let mut ns_out = Output::new(); + let mut ns_proto_out = Output::new(); + let mut ns_x11rb_out = Output::new(); let wrapper_info = resources::for_extension(&ns.header); namespace::generate( module, &ns, &caches, - &mut ns_out, + &mut ns_proto_out, + &mut ns_x11rb_out, &mut enum_cases, wrapper_info, ); - out_map.insert( - PathBuf::from(format!("{}.rs", ns.header)), - ns_out.into_data(), - ); + out_map.push(Generated { + file_name: PathBuf::from(format!("{}.rs", ns.header)), + proto: ns_proto_out.into_data(), + x11rb: ns_x11rb_out.into_data(), + }); - if ext_has_feature(&ns.header) { - outln!(main_out, "#[cfg(feature = \"{}\")]", ns.header); + for out in [&mut main_proto_out, &mut main_x11rb_out] { + if ext_has_feature(&ns.header) { + outln!(out, "#[cfg(feature = \"{}\")]", ns.header); + } + outln!(out, "pub mod {};", ns.header); } - outln!(main_out, "pub mod {};", ns.header); } - outln!(main_out, ""); + outln!(main_proto_out, ""); - requests_replies::generate(&mut main_out, module, enum_cases); - error_events::generate(&mut main_out, module); + requests_replies::generate(&mut main_proto_out, module, enum_cases); + error_events::generate(&mut main_proto_out, module); + + outln!(main_x11rb_out, ""); + outln!(main_x11rb_out, "pub use x11rb_protocol::protocol::Request;"); + outln!(main_x11rb_out, "pub use x11rb_protocol::protocol::Reply;"); + outln!( + main_x11rb_out, + "pub use x11rb_protocol::protocol::ErrorKind;" + ); + outln!(main_x11rb_out, "pub use x11rb_protocol::protocol::Event;"); - out_map.insert(PathBuf::from("mod.rs"), main_out.into_data()); + out_map.push(Generated { + file_name: PathBuf::from("mod.rs"), + proto: main_proto_out.into_data(), + x11rb: main_x11rb_out.into_data(), + }); out_map } diff --git a/generator/src/generator/namespace/header.rs b/generator/src/generator/namespace/header.rs index 114f9ef0..9e2ae8c3 100644 --- a/generator/src/generator/namespace/header.rs +++ b/generator/src/generator/namespace/header.rs @@ -2,7 +2,13 @@ use crate::generator::output::Output; use xcbgen::defs as xcbdefs; -pub(super) fn write_header(out: &mut Output, ns: &xcbdefs::Namespace) { +#[derive(Debug, PartialEq, Copy, Clone)] +pub(super) enum Mode { + Protocol, + X11rb, +} + +pub(super) fn write_header(out: &mut Output, ns: &xcbdefs::Namespace, mode: Mode) { if let Some(info) = &ns.ext_info { outln!(out, "//! Bindings to the `{}` X11 extension.", info.name); } else { @@ -27,41 +33,48 @@ pub(super) fn write_header(out: &mut Output, ns: &xcbdefs::Namespace) { outln!(out, ""); outln!(out, "#[allow(unused_imports)]"); outln!(out, "use std::borrow::Cow;"); - outln!(out, "use std::convert::TryFrom;"); outln!(out, "#[allow(unused_imports)]"); outln!(out, "use std::convert::TryInto;"); - outln!(out, "use std::io::IoSlice;"); - outln!(out, "#[allow(unused_imports)]"); - outln!( - out, - "use crate::utils::{{RawFdContainer, pretty_print_bitmask, pretty_print_enum}};" - ); - outln!(out, "#[allow(unused_imports)]"); - outln!( - out, - "use crate::x11_utils::{{Request, RequestHeader, Serialize, TryParse, TryParseFd, \ - TryIntoUSize}};" - ); - outln!( - out, - "use crate::connection::{{BufWithFds, PiecewiseBuf, RequestConnection}};" - ); + if mode == Mode::Protocol { + outln!(out, "use std::convert::TryFrom;"); + outln!(out, "use crate::errors::ParseError;"); + outln!(out, "#[allow(unused_imports)]"); + outln!(out, "use crate::x11_utils::TryIntoUSize;"); + outln!(out, "use crate::{{BufWithFds, PiecewiseBuf}};"); + } outln!(out, "#[allow(unused_imports)]"); - outln!(out, "use crate::connection::Connection as X11Connection;"); + match mode { + Mode::Protocol => outln!( + out, + "use crate::utils::{{RawFdContainer, pretty_print_bitmask, pretty_print_enum}};" + ), + Mode::X11rb => outln!(out, "use crate::utils::RawFdContainer;"), + } outln!(out, "#[allow(unused_imports)]"); outln!( out, - "use crate::cookie::{{Cookie, CookieWithFds, VoidCookie}};" + "use crate::x11_utils::{{Request, RequestHeader, Serialize, TryParse, TryParseFd}};" ); - if ns.header == "xproto" { - outln!(out, "use crate::cookie::ListFontsWithInfoCookie;"); - } - if ns.header == "record" { - outln!(out, "use crate::cookie::RecordEnableContextCookie;"); + if mode == Mode::X11rb { + outln!(out, "use std::io::IoSlice;"); + outln!(out, "use crate::connection::RequestConnection;"); + outln!(out, "#[allow(unused_imports)]"); + outln!(out, "use crate::connection::Connection as X11Connection;"); + outln!(out, "#[allow(unused_imports)]"); + outln!( + out, + "use crate::cookie::{{Cookie, CookieWithFds, VoidCookie}};" + ); + if ns.header == "xproto" { + outln!(out, "use crate::cookie::ListFontsWithInfoCookie;"); + } + if ns.header == "record" { + outln!(out, "use crate::cookie::RecordEnableContextCookie;"); + } + outln!(out, "use crate::errors::ConnectionError;"); + outln!(out, "#[allow(unused_imports)]"); + outln!(out, "use crate::errors::ReplyOrIdError;"); } - outln!(out, "use crate::errors::{{ConnectionError, ParseError}};"); - outln!(out, "#[allow(unused_imports)]"); - outln!(out, "use crate::errors::ReplyOrIdError;"); let mut imports = ns .imports @@ -71,62 +84,72 @@ pub(super) fn write_header(out: &mut Output, ns: &xcbdefs::Namespace) { .collect::>(); imports.sort(); for import in imports.iter() { + outln!(out, "#[allow(unused_imports)]"); outln!(out, "use super::{};", import); } - if let Some(ref ext_info) = ns.ext_info { - outln!(out, ""); - outln!(out, "/// The X11 name of the extension for QueryExtension"); - outln!( - out, - "pub const X11_EXTENSION_NAME: &str = \"{}\";", - ext_info.xname, - ); + if mode == Mode::X11rb { outln!(out, ""); - outln!( - out, - "/// The version number of this extension that this client library supports.", - ); - outln!(out, "///"); - outln!( - out, - "/// This constant contains the version number of this extension that is supported", - ); - outln!( - out, - "/// by this build of x11rb. For most things, it does not make sense to use this", - ); - outln!( - out, - "/// information. If you need to send a `QueryVersion`, it is recommended to \ - instead" - ); - outln!( - out, - "/// send the maximum version of the extension that you need.", - ); - outln!( - out, - "pub const X11_XML_VERSION: (u32, u32) = ({}, {});", - ext_info.major_version, - ext_info.minor_version, - ); + outln!(out, "pub use x11rb_protocol::protocol::{}::*;", ns.header); + } - outln!(out, ""); - outln!(out, "/// Get the major opcode of this extension"); - outln!(out, "fn major_opcode(conn: &Conn) -> Result {{"); - out.indented(|out| { + if let Some(ref ext_info) = ns.ext_info { + if mode == Mode::Protocol { + outln!(out, ""); + outln!(out, "/// The X11 name of the extension for QueryExtension"); + outln!( + out, + "pub const X11_EXTENSION_NAME: &str = \"{}\";", + ext_info.xname, + ); + outln!(out, ""); + outln!( + out, + "/// The version number of this extension that this client library supports.", + ); + outln!(out, "///"); + outln!( + out, + "/// This constant contains the version number of this extension that is supported", + ); outln!( out, - "let info = conn.extension_information(X11_EXTENSION_NAME)?;", + "/// by this build of x11rb. For most things, it does not make sense to use this", ); outln!( out, - "let info = info.ok_or(ConnectionError::UnsupportedExtension)?;", + "/// information. If you need to send a `QueryVersion`, it is recommended to \ + instead" + ); + outln!( + out, + "/// send the maximum version of the extension that you need.", ); - outln!(out, "Ok(info.major_opcode)"); - }); - outln!(out, "}}"); + outln!( + out, + "pub const X11_XML_VERSION: (u32, u32) = ({}, {});", + ext_info.major_version, + ext_info.minor_version, + ); + } + + if mode == Mode::X11rb { + outln!(out, ""); + outln!(out, "/// Get the major opcode of this extension"); + outln!(out, "fn major_opcode(conn: &Conn) -> Result {{"); + out.indented(|out| { + outln!( + out, + "let info = conn.extension_information(X11_EXTENSION_NAME)?;", + ); + outln!( + out, + "let info = info.ok_or(ConnectionError::UnsupportedExtension)?;", + ); + outln!(out, "Ok(info.major_opcode)"); + }); + outln!(out, "}}"); + } } outln!(out, ""); } diff --git a/generator/src/generator/namespace/mod.rs b/generator/src/generator/namespace/mod.rs index 61b4aada..0f93c3da 100644 --- a/generator/src/generator/namespace/mod.rs +++ b/generator/src/generator/namespace/mod.rs @@ -34,11 +34,17 @@ pub(super) fn generate( module: &xcbgen::defs::Module, ns: &xcbdefs::Namespace, caches: &RefCell, - out: &mut Output, + proto_out: &mut Output, + x11rb_out: &mut Output, enum_cases: &mut EnumCases, resource_info: &[super::ResourceInfo<'_>], ) { - NamespaceGenerator::new(module, ns, caches).generate(out, enum_cases, resource_info); + NamespaceGenerator::new(module, ns, caches).generate( + proto_out, + x11rb_out, + enum_cases, + resource_info, + ); } struct NamespaceGenerator<'ns, 'c> { @@ -72,12 +78,15 @@ impl<'ns, 'c> NamespaceGenerator<'ns, 'c> { fn generate( &self, - out: &mut Output, + proto_out: &mut Output, + x11rb_out: &mut Output, enum_cases: &mut EnumCases, resource_info: &[super::ResourceInfo<'_>], ) { - super::write_code_header(out); - header::write_header(out, self.ns); + super::write_code_header(proto_out); + super::write_code_header(x11rb_out); + header::write_header(proto_out, self.ns, header::Mode::Protocol); + header::write_header(x11rb_out, self.ns, header::Mode::X11rb); let mut trait_out = Output::new(); @@ -85,41 +94,50 @@ impl<'ns, 'c> NamespaceGenerator<'ns, 'c> { match def { xcbdefs::Def::Request(request_def) => { let cases_entry = enum_cases.entry(self.ns.header.clone()).or_default(); - request::generate_request(self, request_def, out, &mut trait_out, cases_entry) + request::generate_request( + self, + request_def, + proto_out, + x11rb_out, + &mut trait_out, + cases_entry, + ) } xcbdefs::Def::Event(event_def) => match event_def { xcbdefs::EventDef::Full(event_full_def) => { - self.generate_event_full_def(event_full_def, out); + self.generate_event_full_def(event_full_def, proto_out); } xcbdefs::EventDef::Copy(event_copy_def) => { - self.generate_event_copy_def(event_copy_def, out); + self.generate_event_copy_def(event_copy_def, proto_out); } }, xcbdefs::Def::Error(error_def) => match error_def { xcbdefs::ErrorDef::Full(error_full_def) => { - self.generate_error_full_def(error_full_def, out); + self.generate_error_full_def(error_full_def, proto_out); } xcbdefs::ErrorDef::Copy(error_copy_def) => { - self.generate_error_copy_def(error_copy_def, out); + self.generate_error_copy_def(error_copy_def, proto_out); } }, xcbdefs::Def::Type(type_def) => match type_def { xcbdefs::TypeDef::Struct(struct_def) => { - self.generate_struct_def(struct_def, out) + self.generate_struct_def(struct_def, proto_out) + } + xcbdefs::TypeDef::Union(union_def) => { + self.generate_union_def(union_def, proto_out) } - xcbdefs::TypeDef::Union(union_def) => self.generate_union_def(union_def, out), xcbdefs::TypeDef::EventStruct(event_struct_def) => { - self.generate_event_struct_def(event_struct_def, out); + self.generate_event_struct_def(event_struct_def, proto_out); } xcbdefs::TypeDef::Xid(xid_type_def) => { - self.generate_xid_type_def(xid_type_def, out) + self.generate_xid_type_def(xid_type_def, proto_out) } xcbdefs::TypeDef::XidUnion(xid_union_def) => { - self.generate_xid_union_def(xid_union_def, out) + self.generate_xid_union_def(xid_union_def, proto_out) } - xcbdefs::TypeDef::Enum(enum_def) => self.generate_enum_def(enum_def, out), + xcbdefs::TypeDef::Enum(enum_def) => self.generate_enum_def(enum_def, proto_out), xcbdefs::TypeDef::Alias(type_alias_def) => { - self.generate_type_alias_def(type_alias_def, out) + self.generate_type_alias_def(type_alias_def, proto_out) } }, } @@ -128,20 +146,20 @@ impl<'ns, 'c> NamespaceGenerator<'ns, 'c> { let trait_out = trait_out.into_data(); outln!( - out, + x11rb_out, "/// Extension trait defining the requests of this extension.", ); - outln!(out, "pub trait ConnectionExt: RequestConnection {{"); - out!(out.indent(), "{}", trait_out); - outln!(out, "}}"); - outln!(out, ""); + outln!(x11rb_out, "pub trait ConnectionExt: RequestConnection {{"); + out!(x11rb_out.indent(), "{}", trait_out); + outln!(x11rb_out, "}}"); + outln!(x11rb_out, ""); outln!( - out, + x11rb_out, "impl ConnectionExt for C {{}}", ); for info in resource_info { - resource_wrapper::generate(self, out, info); + resource_wrapper::generate(self, x11rb_out, info); } } diff --git a/generator/src/generator/namespace/request.rs b/generator/src/generator/namespace/request.rs index ed2148d7..9842ff0a 100644 --- a/generator/src/generator/namespace/request.rs +++ b/generator/src/generator/namespace/request.rs @@ -116,7 +116,8 @@ impl GatheredRequestFields { pub(super) fn generate_request( generator: &NamespaceGenerator<'_, '_>, request_def: &xcbdefs::RequestDef, - out: &mut Output, + proto_out: &mut Output, + x11rb_out: &mut Output, trait_out: &mut Output, enum_cases: &mut PerModuleEnumCases, ) { @@ -154,13 +155,13 @@ pub(super) fn generate_request( request_def, switch_fields[0], &function_name, - out, + proto_out, ); } - outln!(out, "/// Opcode for the {} request", name); + outln!(proto_out, "/// Opcode for the {} request", name); outln!( - out, + proto_out, "pub const {}_REQUEST: u8 = {};", super::super::camel_case_to_upper_snake(&name), request_def.opcode, @@ -174,7 +175,8 @@ pub(super) fn generate_request( &name, &deducible_fields, &gathered, - out, + proto_out, + x11rb_out, ); let ns_prefix = get_ns_name_prefix(generator.ns); let lifetime_block = if gathered.needs_lifetime { @@ -216,7 +218,7 @@ pub(super) fn generate_request( &name, &function_name, &gathered, - out, + x11rb_out, ); emit_request_trait_function( generator, @@ -227,9 +229,10 @@ pub(super) fn generate_request( trait_out, ); - super::special_cases::handle_request(request_def, out); + super::special_cases::handle_request(request_def, proto_out); - outln!(out, ""); + outln!(proto_out, ""); + outln!(x11rb_out, ""); if let Some(ref reply) = request_def.reply { let reply_struct_name = format!("{}Reply", name); @@ -271,10 +274,10 @@ pub(super) fn generate_request( false, false, reply.doc.as_ref(), - out, + proto_out, ); - outln!(out, ""); + outln!(proto_out, ""); } else { enum_cases.reply_parse_cases.push(format!( "Request::{ns_prefix}{name}(_) => None,", @@ -381,6 +384,7 @@ fn emit_request_struct( deducible_fields: &HashMap, gathered: &GatheredRequestFields, out: &mut Output, + x11rb_out: &mut Output, ) { let ns = request_def.namespace.upgrade().unwrap(); let is_xproto = ns.header == "xproto"; @@ -442,7 +446,7 @@ fn emit_request_struct( ); outln!( out, - "fn serialize_impl(self{opcode}) -> BufWithFds> {{", + "pub fn serialize(self{opcode}) -> BufWithFds> {{", opcode = if is_xproto { "" } else { ", major_opcode: u8" }, lifetime = serialize_lifetime_return, ); @@ -871,33 +875,36 @@ fn emit_request_struct( let ret_type = if is_list_fonts_with_info || is_record_enable_context { assert!(request_def.reply.is_some()); match (is_list_fonts_with_info, is_record_enable_context) { - (true, _) => "ListFontsWithInfoCookie<'_, Conn>".to_string(), - (_, true) => "RecordEnableContextCookie<'_, Conn>".to_string(), + (true, _) => "ListFontsWithInfoCookie<'c, Conn>".to_string(), + (_, true) => "RecordEnableContextCookie<'c, Conn>".to_string(), _ => unreachable!(), } } else { match (request_def.reply.is_some(), gathered.reply_has_fds) { - (false, _) => "VoidCookie<'_, Conn>".to_string(), - (true, false) => format!("Cookie<'_, Conn, {}Reply>", name), - (true, true) => format!("CookieWithFds<'_, Conn, {}Reply>", name), + (false, _) => "VoidCookie<'c, Conn>".to_string(), + (true, false) => format!("Cookie<'c, Conn, {}Reply>", name), + (true, true) => format!("CookieWithFds<'c, Conn, {}Reply>", name), } }; outln!( - out, - "pub fn send(self, conn: &Conn) -> Result<{}, ConnectionError>", - ret_type, + x11rb_out, + "fn send_{lower_name}<'c, Conn>(req: {name}Request{lifetime}, conn: &'c Conn) -> Result<{ret_type}, ConnectionError>", + ret_type=ret_type, + name=name, + lower_name=super::super::camel_case_to_lower_snake(name), + lifetime=if gathered.needs_lifetime { "<'_>" } else { "" }, ); - outln!(out, "where"); - outln!(out.indent(), "Conn: RequestConnection + ?Sized,"); - outln!(out, "{{"); - out.indented(|out| { + outln!(x11rb_out, "where"); + outln!(x11rb_out.indent(), "Conn: RequestConnection + ?Sized,"); + outln!(x11rb_out, "{{"); + x11rb_out.indented(|x11rb_out| { outln!( - out, - "let (bytes, fds) = self.serialize_impl({});", + x11rb_out, + "let (bytes, fds) = req.serialize({});", if is_xproto { "" } else { "major_opcode(conn)?" } ); outln!( - out, + x11rb_out, "let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>();" ); @@ -908,21 +915,21 @@ fn emit_request_struct( _ => unreachable!(), }; outln!( - out, + x11rb_out, "Ok({}::new(conn.send_request_with_reply(&slices, fds)?))", cookie, ) } else if request_def.reply.is_some() { if gathered.reply_has_fds { - outln!(out, "conn.send_request_with_reply_with_fds(&slices, fds)"); + outln!(x11rb_out, "conn.send_request_with_reply_with_fds(&slices, fds)"); } else { - outln!(out, "conn.send_request_with_reply(&slices, fds)",); + outln!(x11rb_out, "conn.send_request_with_reply(&slices, fds)",); } } else { - outln!(out, "conn.send_request_without_reply(&slices, fds)",); + outln!(x11rb_out, "conn.send_request_without_reply(&slices, fds)",); } }); - outln!(out, "}}"); + outln!(x11rb_out, "}}"); // Parsing implementation. outln!( @@ -1123,9 +1130,9 @@ fn emit_request_struct( ); out.indented(|out| { if is_xproto { - outln!(out, "let (bufs, fds) = self.serialize_impl();"); + outln!(out, "let (bufs, fds) = self.serialize();"); } else { - outln!(out, "let (bufs, fds) = self.serialize_impl(major_opcode);"); + outln!(out, "let (bufs, fds) = self.serialize(major_opcode);"); } outln!(out, "// Flatten the buffers into a single vector"); outln!( @@ -1251,7 +1258,11 @@ fn emit_request_function( outln!(out, "}};"); } - outln!(out, "request0.send(conn)") + outln!( + out, + "send_{}(request0, conn)", + super::super::camel_case_to_lower_snake(name) + ) }); outln!(out, "}}"); } diff --git a/generator/src/main.rs b/generator/src/main.rs index e292e1cd..992924c8 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -114,13 +114,17 @@ fn replace_file_if_different(file_path: &Path, data: &[u8]) -> Result<(), Error> fn main2() -> Result { let args: Vec<_> = std::env::args_os().collect(); - if args.len() != 3 { + if args.len() != 4 { eprintln!("USAGE:"); - eprintln!(" {} ", args[0].to_string_lossy()); + eprintln!( + " {} ", + args[0].to_string_lossy() + ); return Ok(1); } let input_dir_path = Path::new(&args[1]); - let output_dir_path = Path::new(&args[2]); + let proto_output_dir_path = Path::new(&args[2]); + let x11rb_output_dir_path = Path::new(&args[3]); let xml_files = list_xmls(input_dir_path)?; let module = xcbgen::defs::Module::new(); @@ -137,10 +141,13 @@ fn main2() -> Result { println!("Resolved successfully"); let generated = generator::generate(&module); - for (file_name, file_data) in generated.iter() { - let mut file_path = PathBuf::from(output_dir_path); - file_path.push(file_name); - replace_file_if_different(&file_path, file_data.as_bytes())?; + for generated in generated.iter() { + let mut proto_file_path = PathBuf::from(proto_output_dir_path); + let mut x11rb_file_path = PathBuf::from(x11rb_output_dir_path); + proto_file_path.push(&generated.file_name); + x11rb_file_path.push(&generated.file_name); + replace_file_if_different(&proto_file_path, generated.proto.as_bytes())?; + replace_file_if_different(&x11rb_file_path, generated.x11rb.as_bytes())?; } println!("Code generated successfully"); diff --git a/src/errors.rs b/src/errors.rs index de1fdde4..bbae5052 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -3,6 +3,8 @@ use crate::protocol::xproto::{SetupAuthenticate, SetupFailed}; use crate::x11_utils::X11Error; +pub use x11rb_protocol::errors::ParseError; + /// An error occurred while dynamically loading libxcb. #[cfg(feature = "dl-libxcb")] #[derive(Debug, Clone)] @@ -39,72 +41,6 @@ impl std::fmt::Display for LibxcbLoadError { #[cfg(feature = "dl-libxcb")] impl std::error::Error for LibxcbLoadError {} -/// 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, -} - -impl std::error::Error for ParseError {} - -impl std::fmt::Display for ParseError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::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 connecting to an X11 server #[derive(Debug)] #[non_exhaustive] diff --git a/src/image.rs b/src/image.rs index f921a6a9..08220e46 100644 --- a/src/image.rs +++ b/src/image.rs @@ -31,8 +31,8 @@ use crate::connection::Connection; use crate::cookie::VoidCookie; use crate::errors::{ConnectionError, ParseError, ReplyError}; use crate::protocol::xproto::{ - Drawable, Format, Gcontext, GetImageReply, GetImageRequest, ImageFormat, - ImageOrder as XprotoImageOrder, PutImageRequest, Setup, VisualClass, Visualtype, + get_image, put_image, Drawable, Format, Gcontext, GetImageReply, ImageFormat, + ImageOrder as XprotoImageOrder, Setup, VisualClass, Visualtype, }; /// The description of a single color component. @@ -691,16 +691,16 @@ impl<'a> Image<'a> { width: u16, height: u16, ) -> Result { - let reply = GetImageRequest { + let reply = get_image( + conn, + ImageFormat::Z_PIXMAP, drawable, x, y, width, height, - format: ImageFormat::Z_PIXMAP, - plane_mask: !0, - } - .send(conn)? + !0, + )? .reply()?; Ok(Self::get_from_reply(conn.setup(), width, height, reply)?) } @@ -760,19 +760,19 @@ impl<'a> Image<'a> { let next_lines = lines_per_request.min(self.height - y_offset); let next_byte_offset = byte_offset + usize::from(next_lines) * stride; let data = &self.data[byte_offset..next_byte_offset]; - let request = PutImageRequest { - format: ImageFormat::Z_PIXMAP, + result.push(put_image( + conn, + ImageFormat::Z_PIXMAP, drawable, gc, - width: self.width, - height: next_lines, + self.width, + next_lines, dst_x, - dst_y: dst_y + i16::try_from(y_offset).unwrap(), - left_pad: 0, // Must always be 0 for ZPixmap - depth: self.depth, - data: Cow::Borrowed(data), - }; - result.push(request.send(conn)?); + dst_y + i16::try_from(y_offset).unwrap(), + 0, // left_pad must always be 0 for ZPixmap + self.depth, + data, + )?); y_offset += next_lines; byte_offset = next_byte_offset; diff --git a/src/lib.rs b/src/lib.rs index 86fe6757..97c9810c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -141,6 +141,11 @@ // Only contains documentation, but no "actual rust" pub mod event_loop_integration; +/// Reexports of dependencies +pub mod reexports { + pub use x11rb_protocol; +} + pub mod utils; #[cfg(feature = "allow-unsafe-code")] pub mod xcb_ffi; diff --git a/src/protocol/bigreq.rs b/src/protocol/bigreq.rs index fcef643c..fc08a8e3 100644 --- a/src/protocol/bigreq.rs +++ b/src/protocol/bigreq.rs @@ -7,33 +7,23 @@ #[allow(unused_imports)] use std::borrow::Cow; -use std::convert::TryFrom; #[allow(unused_imports)] use std::convert::TryInto; -use std::io::IoSlice; #[allow(unused_imports)] -use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; +use crate::utils::RawFdContainer; #[allow(unused_imports)] -use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd, TryIntoUSize}; -use crate::connection::{BufWithFds, PiecewiseBuf, RequestConnection}; +use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; +use std::io::IoSlice; +use crate::connection::RequestConnection; #[allow(unused_imports)] use crate::connection::Connection as X11Connection; #[allow(unused_imports)] use crate::cookie::{Cookie, CookieWithFds, VoidCookie}; -use crate::errors::{ConnectionError, ParseError}; +use crate::errors::ConnectionError; #[allow(unused_imports)] use crate::errors::ReplyOrIdError; -/// 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); +pub use x11rb_protocol::protocol::bigreq::*; /// Get the major opcode of this extension fn major_opcode(conn: &Conn) -> Result { @@ -42,88 +32,20 @@ fn major_opcode(conn: &Conn) -> Result BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = EnableReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_enable<'c, Conn>(req: EnableRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for EnableRequest {} pub fn enable(conn: &Conn) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, { let request0 = EnableRequest; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct EnableReply { - pub sequence: u16, - pub length: u32, - pub maximum_request_length: u32, -} -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)) - } + send_enable(request0, conn) } /// Extension trait defining the requests of this extension. diff --git a/src/protocol/composite.rs b/src/protocol/composite.rs index 35dbc955..cac766c5 100644 --- a/src/protocol/composite.rs +++ b/src/protocol/composite.rs @@ -7,35 +7,27 @@ #[allow(unused_imports)] use std::borrow::Cow; -use std::convert::TryFrom; #[allow(unused_imports)] use std::convert::TryInto; -use std::io::IoSlice; #[allow(unused_imports)] -use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; +use crate::utils::RawFdContainer; #[allow(unused_imports)] -use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd, TryIntoUSize}; -use crate::connection::{BufWithFds, PiecewiseBuf, RequestConnection}; +use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; +use std::io::IoSlice; +use crate::connection::RequestConnection; #[allow(unused_imports)] use crate::connection::Connection as X11Connection; #[allow(unused_imports)] use crate::cookie::{Cookie, CookieWithFds, VoidCookie}; -use crate::errors::{ConnectionError, ParseError}; +use crate::errors::ConnectionError; #[allow(unused_imports)] use crate::errors::ReplyOrIdError; +#[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); +pub use x11rb_protocol::protocol::composite::*; /// Get the major opcode of this extension fn major_opcode(conn: &Conn) -> Result { @@ -44,132 +36,14 @@ fn major_opcode(conn: &Conn) -> Result 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 std::fmt::Debug for Redirect { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::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; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct QueryVersionRequest { - pub client_major_version: u32, - pub client_minor_version: u32, -} -impl QueryVersionRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = QueryVersionReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_query_version<'c, Conn>(req: QueryVersionRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for QueryVersionRequest {} pub fn query_version(conn: &Conn, client_major_version: u32, client_minor_version: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -178,107 +52,17 @@ where client_major_version, client_minor_version, }; - request0.send(conn) + send_query_version(request0, conn) } -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct QueryVersionReply { - pub sequence: u16, - pub length: u32, - pub major_version: u32, - pub minor_version: u32, -} -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)) - } -} - -/// Opcode for the RedirectWindow request -pub const REDIRECT_WINDOW_REQUEST: u8 = 1; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct RedirectWindowRequest { - pub window: xproto::Window, - pub update: Redirect, -} -impl RedirectWindowRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_redirect_window<'c, Conn>(req: RedirectWindowRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for RedirectWindowRequest {} pub fn redirect_window(conn: &Conn, window: xproto::Window, update: Redirect) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -287,79 +71,17 @@ where window, update, }; - request0.send(conn) + send_redirect_window(request0, conn) } -/// Opcode for the RedirectSubwindows request -pub const REDIRECT_SUBWINDOWS_REQUEST: u8 = 2; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct RedirectSubwindowsRequest { - pub window: xproto::Window, - pub update: Redirect, -} -impl RedirectSubwindowsRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_redirect_subwindows<'c, Conn>(req: RedirectSubwindowsRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for RedirectSubwindowsRequest {} pub fn redirect_subwindows(conn: &Conn, window: xproto::Window, update: Redirect) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -368,79 +90,17 @@ where window, update, }; - request0.send(conn) -} - -/// Opcode for the UnredirectWindow request -pub const UNREDIRECT_WINDOW_REQUEST: u8 = 3; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct UnredirectWindowRequest { - pub window: xproto::Window, - pub update: Redirect, -} -impl UnredirectWindowRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_redirect_subwindows(request0, conn) } -impl Request for UnredirectWindowRequest { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_unredirect_window<'c, Conn>(req: UnredirectWindowRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for UnredirectWindowRequest {} pub fn unredirect_window(conn: &Conn, window: xproto::Window, update: Redirect) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -449,79 +109,17 @@ where window, update, }; - request0.send(conn) -} - -/// Opcode for the UnredirectSubwindows request -pub const UNREDIRECT_SUBWINDOWS_REQUEST: u8 = 4; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct UnredirectSubwindowsRequest { - pub window: xproto::Window, - pub update: Redirect, -} -impl UnredirectSubwindowsRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_unredirect_window(request0, conn) } -impl Request for UnredirectSubwindowsRequest { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_unredirect_subwindows<'c, Conn>(req: UnredirectSubwindowsRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for UnredirectSubwindowsRequest {} pub fn unredirect_subwindows(conn: &Conn, window: xproto::Window, update: Redirect) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -530,77 +128,17 @@ where window, update, }; - request0.send(conn) + send_unredirect_subwindows(request0, conn) } -/// Opcode for the CreateRegionFromBorderClip request -pub const CREATE_REGION_FROM_BORDER_CLIP_REQUEST: u8 = 5; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct CreateRegionFromBorderClipRequest { - pub region: xfixes::Region, - pub window: xproto::Window, -} -impl CreateRegionFromBorderClipRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_create_region_from_border_clip<'c, Conn>(req: CreateRegionFromBorderClipRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for CreateRegionFromBorderClipRequest {} pub fn create_region_from_border_clip(conn: &Conn, region: xfixes::Region, window: xproto::Window) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -609,77 +147,17 @@ where region, window, }; - request0.send(conn) + send_create_region_from_border_clip(request0, conn) } -/// Opcode for the NameWindowPixmap request -pub const NAME_WINDOW_PIXMAP_REQUEST: u8 = 6; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct NameWindowPixmapRequest { - pub window: xproto::Window, - pub pixmap: xproto::Pixmap, -} -impl NameWindowPixmapRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_name_window_pixmap<'c, Conn>(req: NameWindowPixmapRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for NameWindowPixmapRequest {} pub fn name_window_pixmap(conn: &Conn, window: xproto::Window, pixmap: xproto::Pixmap) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -688,69 +166,17 @@ where window, pixmap, }; - request0.send(conn) + send_name_window_pixmap(request0, conn) } -/// Opcode for the GetOverlayWindow request -pub const GET_OVERLAY_WINDOW_REQUEST: u8 = 7; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetOverlayWindowRequest { - pub window: xproto::Window, -} -impl GetOverlayWindowRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetOverlayWindowReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_overlay_window<'c, Conn>(req: GetOverlayWindowRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetOverlayWindowRequest {} pub fn get_overlay_window(conn: &Conn, window: xproto::Window) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -758,95 +184,17 @@ where let request0 = GetOverlayWindowRequest { window, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetOverlayWindowReply { - pub sequence: u16, - pub length: u32, - pub overlay_win: xproto::Window, -} -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)) - } + send_get_overlay_window(request0, conn) } -/// Opcode for the ReleaseOverlayWindow request -pub const RELEASE_OVERLAY_WINDOW_REQUEST: u8 = 8; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct ReleaseOverlayWindowRequest { - pub window: xproto::Window, -} -impl ReleaseOverlayWindowRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_release_overlay_window<'c, Conn>(req: ReleaseOverlayWindowRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for ReleaseOverlayWindowRequest {} pub fn release_overlay_window(conn: &Conn, window: xproto::Window) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -854,7 +202,7 @@ where let request0 = ReleaseOverlayWindowRequest { window, }; - request0.send(conn) + send_release_overlay_window(request0, conn) } /// Extension trait defining the requests of this extension. diff --git a/src/protocol/damage.rs b/src/protocol/damage.rs index 286f4716..9785e9d5 100644 --- a/src/protocol/damage.rs +++ b/src/protocol/damage.rs @@ -7,35 +7,27 @@ #[allow(unused_imports)] use std::borrow::Cow; -use std::convert::TryFrom; #[allow(unused_imports)] use std::convert::TryInto; -use std::io::IoSlice; #[allow(unused_imports)] -use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; +use crate::utils::RawFdContainer; #[allow(unused_imports)] -use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd, TryIntoUSize}; -use crate::connection::{BufWithFds, PiecewiseBuf, RequestConnection}; +use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; +use std::io::IoSlice; +use crate::connection::RequestConnection; #[allow(unused_imports)] use crate::connection::Connection as X11Connection; #[allow(unused_imports)] use crate::cookie::{Cookie, CookieWithFds, VoidCookie}; -use crate::errors::{ConnectionError, ParseError}; +use crate::errors::ConnectionError; #[allow(unused_imports)] use crate::errors::ReplyOrIdError; +#[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 use x11rb_protocol::protocol::damage::*; /// Get the major opcode of this extension fn major_opcode(conn: &Conn) -> Result { @@ -44,141 +36,14 @@ fn major_opcode(conn: &Conn) -> Result 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 std::fmt::Debug for ReportLevel { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::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; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct QueryVersionRequest { - pub client_major_version: u32, - pub client_minor_version: u32, -} -impl QueryVersionRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = QueryVersionReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_query_version<'c, Conn>(req: QueryVersionRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for QueryVersionRequest {} pub fn query_version(conn: &Conn, client_major_version: u32, client_minor_version: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -187,115 +52,17 @@ where client_major_version, client_minor_version, }; - request0.send(conn) + send_query_version(request0, conn) } -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct QueryVersionReply { - pub sequence: u16, - pub length: u32, - pub major_version: u32, - pub minor_version: u32, -} -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)) - } -} - -/// Opcode for the Create request -pub const CREATE_REQUEST: u8 = 1; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct CreateRequest { - pub damage: Damage, - pub drawable: xproto::Drawable, - pub level: ReportLevel, -} -impl CreateRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_create<'c, Conn>(req: CreateRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for CreateRequest {} pub fn create(conn: &Conn, damage: Damage, drawable: xproto::Drawable, level: ReportLevel) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -305,69 +72,17 @@ where drawable, level, }; - request0.send(conn) + send_create(request0, conn) } -/// Opcode for the Destroy request -pub const DESTROY_REQUEST: u8 = 2; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct DestroyRequest { - pub damage: Damage, -} -impl DestroyRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_destroy<'c, Conn>(req: DestroyRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for DestroyRequest {} pub fn destroy(conn: &Conn, damage: Damage) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -375,85 +90,17 @@ where let request0 = DestroyRequest { damage, }; - request0.send(conn) + send_destroy(request0, conn) } -/// Opcode for the Subtract request -pub const SUBTRACT_REQUEST: u8 = 3; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct SubtractRequest { - pub damage: Damage, - pub repair: xfixes::Region, - pub parts: xfixes::Region, -} -impl SubtractRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_subtract<'c, Conn>(req: SubtractRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for SubtractRequest {} pub fn subtract(conn: &Conn, damage: Damage, repair: A, parts: B) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -467,77 +114,17 @@ where repair, parts, }; - request0.send(conn) + send_subtract(request0, conn) } -/// Opcode for the Add request -pub const ADD_REQUEST: u8 = 4; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct AddRequest { - pub drawable: xproto::Drawable, - pub region: xfixes::Region, -} -impl AddRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_add<'c, Conn>(req: AddRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for AddRequest {} pub fn add(conn: &Conn, drawable: xproto::Drawable, region: xfixes::Region) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -546,91 +133,7 @@ where drawable, region, }; - request0.send(conn) -} - -/// Opcode for the Notify event -pub const NOTIFY_EVENT: u8 = 0; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -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 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 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) - } + send_add(request0, conn) } /// Extension trait defining the requests of this extension. diff --git a/src/protocol/dpms.rs b/src/protocol/dpms.rs index 7b475082..638d3396 100644 --- a/src/protocol/dpms.rs +++ b/src/protocol/dpms.rs @@ -7,33 +7,23 @@ #[allow(unused_imports)] use std::borrow::Cow; -use std::convert::TryFrom; #[allow(unused_imports)] use std::convert::TryInto; -use std::io::IoSlice; #[allow(unused_imports)] -use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; +use crate::utils::RawFdContainer; #[allow(unused_imports)] -use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd, TryIntoUSize}; -use crate::connection::{BufWithFds, PiecewiseBuf, RequestConnection}; +use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; +use std::io::IoSlice; +use crate::connection::RequestConnection; #[allow(unused_imports)] use crate::connection::Connection as X11Connection; #[allow(unused_imports)] use crate::cookie::{Cookie, CookieWithFds, VoidCookie}; -use crate::errors::{ConnectionError, ParseError}; +use crate::errors::ConnectionError; #[allow(unused_imports)] use crate::errors::ReplyOrIdError; -/// 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) = (0, 0); +pub use x11rb_protocol::protocol::dpms::*; /// Get the major opcode of this extension fn major_opcode(conn: &Conn) -> Result { @@ -42,70 +32,14 @@ fn major_opcode(conn: &Conn) -> Result BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetVersionReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_version<'c, Conn>(req: GetVersionRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetVersionRequest {} pub fn get_version(conn: &Conn, client_major_version: u16, client_minor_version: u16) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -114,282 +48,49 @@ where client_major_version, client_minor_version, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetVersionReply { - pub sequence: u16, - pub length: u32, - pub server_major_version: u16, - pub server_minor_version: u16, -} -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)) - } -} - -/// Opcode for the Capable request -pub const CAPABLE_REQUEST: u8 = 1; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct CapableRequest; -impl CapableRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { - if header.minor_opcode != CAPABLE_REQUEST { - return Err(ParseError::InvalidValue); - } - let _ = value; - Ok(CapableRequest - ) - } + send_get_version(request0, conn) } -impl Request for CapableRequest { - type Reply = CapableReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_capable<'c, Conn>(req: CapableRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for CapableRequest {} pub fn capable(conn: &Conn) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, { let request0 = CapableRequest; - request0.send(conn) + send_capable(request0, conn) } -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct CapableReply { - pub sequence: u16, - pub length: u32, - pub capable: bool, -} -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)) - } -} - -/// Opcode for the GetTimeouts request -pub const GET_TIMEOUTS_REQUEST: u8 = 2; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetTimeoutsRequest; -impl GetTimeoutsRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetTimeoutsReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_timeouts<'c, Conn>(req: GetTimeoutsRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetTimeoutsRequest {} pub fn get_timeouts(conn: &Conn) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, { let request0 = GetTimeoutsRequest; - request0.send(conn) + send_get_timeouts(request0, conn) } -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetTimeoutsReply { - pub sequence: u16, - pub length: u32, - pub standby_timeout: u16, - pub suspend_timeout: u16, - pub off_timeout: u16, -} -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)) - } -} - -/// Opcode for the SetTimeouts request -pub const SET_TIMEOUTS_REQUEST: u8 = 3; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct SetTimeoutsRequest { - pub standby_timeout: u16, - pub suspend_timeout: u16, - pub off_timeout: u16, -} -impl SetTimeoutsRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_set_timeouts<'c, Conn>(req: SetTimeoutsRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for SetTimeoutsRequest {} pub fn set_timeouts(conn: &Conn, standby_timeout: u16, suspend_timeout: u16, off_timeout: u16) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -399,244 +100,49 @@ where suspend_timeout, off_timeout, }; - request0.send(conn) -} - -/// Opcode for the Enable request -pub const ENABLE_REQUEST: u8 = 4; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct EnableRequest; -impl EnableRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { - if header.minor_opcode != ENABLE_REQUEST { - return Err(ParseError::InvalidValue); - } - let _ = value; - Ok(EnableRequest - ) - } + send_set_timeouts(request0, conn) } -impl Request for EnableRequest { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_enable<'c, Conn>(req: EnableRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for EnableRequest {} pub fn enable(conn: &Conn) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, { let request0 = EnableRequest; - request0.send(conn) -} - -/// Opcode for the Disable request -pub const DISABLE_REQUEST: u8 = 5; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct DisableRequest; -impl DisableRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result { - if header.minor_opcode != DISABLE_REQUEST { - return Err(ParseError::InvalidValue); - } - let _ = value; - Ok(DisableRequest - ) - } + send_enable(request0, conn) } -impl Request for DisableRequest { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_disable<'c, Conn>(req: DisableRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for DisableRequest {} pub fn disable(conn: &Conn) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, { let request0 = DisableRequest; - request0.send(conn) + send_disable(request0, conn) } -#[derive(Clone, Copy, PartialEq, Eq)] -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 std::fmt::Debug for DPMSMode { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct ForceLevelRequest { - pub power_level: DPMSMode, -} -impl ForceLevelRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_force_level<'c, Conn>(req: ForceLevelRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for ForceLevelRequest {} pub fn force_level(conn: &Conn, power_level: DPMSMode) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -644,95 +150,23 @@ where let request0 = ForceLevelRequest { power_level, }; - request0.send(conn) + send_force_level(request0, conn) } -/// Opcode for the Info request -pub const INFO_REQUEST: u8 = 7; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct InfoRequest; -impl InfoRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = InfoReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_info<'c, Conn>(req: InfoRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for InfoRequest {} pub fn info(conn: &Conn) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, { let request0 = InfoRequest; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct InfoReply { - pub sequence: u16, - pub length: u32, - pub power_level: DPMSMode, - pub state: bool, -} -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)) - } + send_info(request0, conn) } /// Extension trait defining the requests of this extension. diff --git a/src/protocol/dri2.rs b/src/protocol/dri2.rs index 8b1d37d6..7b5be49a 100644 --- a/src/protocol/dri2.rs +++ b/src/protocol/dri2.rs @@ -7,34 +7,25 @@ #[allow(unused_imports)] use std::borrow::Cow; -use std::convert::TryFrom; #[allow(unused_imports)] use std::convert::TryInto; -use std::io::IoSlice; #[allow(unused_imports)] -use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; +use crate::utils::RawFdContainer; #[allow(unused_imports)] -use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd, TryIntoUSize}; -use crate::connection::{BufWithFds, PiecewiseBuf, RequestConnection}; +use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; +use std::io::IoSlice; +use crate::connection::RequestConnection; #[allow(unused_imports)] use crate::connection::Connection as X11Connection; #[allow(unused_imports)] use crate::cookie::{Cookie, CookieWithFds, VoidCookie}; -use crate::errors::{ConnectionError, ParseError}; +use crate::errors::ConnectionError; #[allow(unused_imports)] use crate::errors::ReplyOrIdError; +#[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); +pub use x11rb_protocol::protocol::dri2::*; /// Get the major opcode of this extension fn major_opcode(conn: &Conn) -> Result { @@ -43,336 +34,14 @@ fn major_opcode(conn: &Conn) -> Result 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 std::fmt::Debug for Attachment { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::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, PartialEq, Eq)] -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 std::fmt::Debug for DriverType { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let variants = [ - (Self::DRI.0, "DRI", "DRI"), - (Self::VDPAU.0, "VDPAU", "VDPAU"), - ]; - pretty_print_enum(fmt, self.0, &variants) - } -} - -#[derive(Clone, Copy, PartialEq, Eq)] -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 std::fmt::Debug for EventType { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct DRI2Buffer { - pub attachment: Attachment, - pub name: u32, - pub pitch: u32, - pub cpp: u32, - pub flags: u32, -} -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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct AttachFormat { - pub attachment: Attachment, - pub format: u32, -} -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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct QueryVersionRequest { - pub major_version: u32, - pub minor_version: u32, -} -impl QueryVersionRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = QueryVersionReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_query_version<'c, Conn>(req: QueryVersionRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for QueryVersionRequest {} pub fn query_version(conn: &Conn, major_version: u32, minor_version: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -381,105 +50,17 @@ where major_version, minor_version, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct QueryVersionReply { - pub sequence: u16, - pub length: u32, - pub major_version: u32, - pub minor_version: u32, -} -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)) - } -} - -/// Opcode for the Connect request -pub const CONNECT_REQUEST: u8 = 1; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct ConnectRequest { - pub window: xproto::Window, - pub driver_type: DriverType, -} -impl ConnectRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_query_version(request0, conn) } -impl Request for ConnectRequest { - type Reply = ConnectReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_connect<'c, Conn>(req: ConnectRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for ConnectRequest {} pub fn connect(conn: &Conn, window: xproto::Window, driver_type: DriverType) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -488,140 +69,17 @@ where window, driver_type, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct ConnectReply { - pub sequence: u16, - pub length: u32, - pub driver_name: Vec, - pub alignment_pad: Vec, - pub device_name: Vec, -} -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, (driver_name_length.checked_add(3u32).ok_or(ParseError::InvalidExpression)? & (!3u32)).checked_sub(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)) - } + send_connect(request0, conn) } -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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct AuthenticateRequest { - pub window: xproto::Window, - pub magic: u32, -} -impl AuthenticateRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = AuthenticateReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_authenticate<'c, Conn>(req: AuthenticateRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for AuthenticateRequest {} pub fn authenticate(conn: &Conn, window: xproto::Window, magic: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -630,94 +88,17 @@ where window, magic, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct AuthenticateReply { - pub sequence: u16, - pub length: u32, - pub authenticated: u32, -} -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)) - } + send_authenticate(request0, conn) } -/// Opcode for the CreateDrawable request -pub const CREATE_DRAWABLE_REQUEST: u8 = 3; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct CreateDrawableRequest { - pub drawable: xproto::Drawable, -} -impl CreateDrawableRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_create_drawable<'c, Conn>(req: CreateDrawableRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for CreateDrawableRequest {} pub fn create_drawable(conn: &Conn, drawable: xproto::Drawable) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -725,69 +106,17 @@ where let request0 = CreateDrawableRequest { drawable, }; - request0.send(conn) -} - -/// Opcode for the DestroyDrawable request -pub const DESTROY_DRAWABLE_REQUEST: u8 = 4; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct DestroyDrawableRequest { - pub drawable: xproto::Drawable, -} -impl DestroyDrawableRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_create_drawable(request0, conn) } -impl Request for DestroyDrawableRequest { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_destroy_drawable<'c, Conn>(req: DestroyDrawableRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for DestroyDrawableRequest {} pub fn destroy_drawable(conn: &Conn, drawable: xproto::Drawable) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -795,99 +124,17 @@ where let request0 = DestroyDrawableRequest { drawable, }; - request0.send(conn) -} - -/// Opcode for the GetBuffers request -pub const GET_BUFFERS_REQUEST: u8 = 5; -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetBuffersRequest<'input> { - pub drawable: xproto::Drawable, - pub count: u32, - pub attachments: Cow<'input, [u32]>, -} -impl<'input> GetBuffersRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into(), attachments_bytes.into(), padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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()), - } - } + send_destroy_drawable(request0, conn) } -impl<'input> Request for GetBuffersRequest<'input> { - type Reply = GetBuffersReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_buffers<'c, Conn>(req: GetBuffersRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl<'input> crate::x11_utils::ReplyRequest for GetBuffersRequest<'input> {} pub fn get_buffers<'c, 'input, Conn>(conn: &'c Conn, drawable: xproto::Drawable, count: u32, attachments: &'input [u32]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -897,139 +144,17 @@ where count, attachments: Cow::Borrowed(attachments), }; - request0.send(conn) + send_get_buffers(request0, conn) } -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetBuffersReply { - pub sequence: u16, - pub length: u32, - pub width: u32, - pub height: u32, - pub buffers: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct CopyRegionRequest { - pub drawable: xproto::Drawable, - pub region: u32, - pub dest: u32, - pub src: u32, -} -impl CopyRegionRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = CopyRegionReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_copy_region<'c, Conn>(req: CopyRegionRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for CopyRegionRequest {} pub fn copy_region(conn: &Conn, drawable: xproto::Drawable, region: u32, dest: u32, src: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1040,122 +165,17 @@ where dest, src, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct CopyRegionReply { - pub sequence: u16, - pub length: u32, -} -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)) - } + send_copy_region(request0, conn) } -/// Opcode for the GetBuffersWithFormat request -pub const GET_BUFFERS_WITH_FORMAT_REQUEST: u8 = 7; -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetBuffersWithFormatRequest<'input> { - pub drawable: xproto::Drawable, - pub count: u32, - pub attachments: Cow<'input, [AttachFormat]>, -} -impl<'input> GetBuffersWithFormatRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into(), attachments_bytes.into(), padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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> { - type Reply = GetBuffersWithFormatReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_buffers_with_format<'c, Conn>(req: GetBuffersWithFormatRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl<'input> crate::x11_utils::ReplyRequest for GetBuffersWithFormatRequest<'input> {} pub fn get_buffers_with_format<'c, 'input, Conn>(conn: &'c Conn, drawable: xproto::Drawable, count: u32, attachments: &'input [AttachFormat]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1165,163 +185,17 @@ where count, attachments: Cow::Borrowed(attachments), }; - request0.send(conn) + send_get_buffers_with_format(request0, conn) } -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetBuffersWithFormatReply { - pub sequence: u16, - pub length: u32, - pub width: u32, - pub height: u32, - pub buffers: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -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 SwapBuffersRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = SwapBuffersReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_swap_buffers<'c, Conn>(req: SwapBuffersRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for SwapBuffersRequest {} pub fn swap_buffers(conn: &Conn, drawable: xproto::Drawable, target_msc_hi: u32, target_msc_lo: u32, divisor_hi: u32, divisor_lo: u32, remainder_hi: u32, remainder_lo: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1335,96 +209,17 @@ where remainder_hi, remainder_lo, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct SwapBuffersReply { - pub sequence: u16, - pub length: u32, - pub swap_hi: u32, - pub swap_lo: u32, -} -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)) - } + send_swap_buffers(request0, conn) } -/// Opcode for the GetMSC request -pub const GET_MSC_REQUEST: u8 = 9; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetMSCRequest { - pub drawable: xproto::Drawable, -} -impl GetMSCRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetMSCReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_msc<'c, Conn>(req: GetMSCRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetMSCRequest {} pub fn get_msc(conn: &Conn, drawable: xproto::Drawable) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1432,152 +227,17 @@ where let request0 = GetMSCRequest { drawable, }; - request0.send(conn) + send_get_msc(request0, conn) } -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -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 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)) - } -} - -/// Opcode for the WaitMSC request -pub const WAIT_MSC_REQUEST: u8 = 10; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -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 WaitMSCRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = WaitMSCReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_wait_msc<'c, Conn>(req: WaitMSCRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for WaitMSCRequest {} pub fn wait_msc(conn: &Conn, drawable: xproto::Drawable, target_msc_hi: u32, target_msc_lo: u32, divisor_hi: u32, divisor_lo: u32, remainder_hi: u32, remainder_lo: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1591,120 +251,17 @@ where remainder_hi, remainder_lo, }; - request0.send(conn) + send_wait_msc(request0, conn) } -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -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 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)) - } -} - -/// Opcode for the WaitSBC request -pub const WAIT_SBC_REQUEST: u8 = 11; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct WaitSBCRequest { - pub drawable: xproto::Drawable, - pub target_sbc_hi: u32, - pub target_sbc_lo: u32, -} -impl WaitSBCRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = WaitSBCReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_wait_sbc<'c, Conn>(req: WaitSBCRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for WaitSBCRequest {} pub fn wait_sbc(conn: &Conn, drawable: xproto::Drawable, target_sbc_hi: u32, target_sbc_lo: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1714,112 +271,17 @@ where target_sbc_hi, target_sbc_lo, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -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 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)) - } -} - -/// Opcode for the SwapInterval request -pub const SWAP_INTERVAL_REQUEST: u8 = 12; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct SwapIntervalRequest { - pub drawable: xproto::Drawable, - pub interval: u32, -} -impl SwapIntervalRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_wait_sbc(request0, conn) } -impl Request for SwapIntervalRequest { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_swap_interval<'c, Conn>(req: SwapIntervalRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for SwapIntervalRequest {} pub fn swap_interval(conn: &Conn, drawable: xproto::Drawable, interval: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1828,77 +290,17 @@ where drawable, interval, }; - request0.send(conn) + send_swap_interval(request0, conn) } -/// Opcode for the GetParam request -pub const GET_PARAM_REQUEST: u8 = 13; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetParamRequest { - pub drawable: xproto::Drawable, - pub param: u32, -} -impl GetParamRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetParamReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_param<'c, Conn>(req: GetParamRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetParamRequest {} pub fn get_param(conn: &Conn, drawable: xproto::Drawable, param: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1907,194 +309,7 @@ where drawable, param, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetParamReply { - pub is_param_recognized: bool, - pub sequence: u16, - pub length: u32, - pub value_hi: u32, - pub value_lo: u32, -} -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)) - } -} - -/// Opcode for the BufferSwapComplete event -pub const BUFFER_SWAP_COMPLETE_EVENT: u8 = 0; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -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 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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct InvalidateBuffersEvent { - pub response_type: u8, - pub sequence: u16, - pub drawable: xproto::Drawable, -} -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 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) - } + send_get_param(request0, conn) } /// Extension trait defining the requests of this extension. diff --git a/src/protocol/dri3.rs b/src/protocol/dri3.rs index c8cbc31a..9d4a6bfc 100644 --- a/src/protocol/dri3.rs +++ b/src/protocol/dri3.rs @@ -7,34 +7,25 @@ #[allow(unused_imports)] use std::borrow::Cow; -use std::convert::TryFrom; #[allow(unused_imports)] use std::convert::TryInto; -use std::io::IoSlice; #[allow(unused_imports)] -use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; +use crate::utils::RawFdContainer; #[allow(unused_imports)] -use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd, TryIntoUSize}; -use crate::connection::{BufWithFds, PiecewiseBuf, RequestConnection}; +use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; +use std::io::IoSlice; +use crate::connection::RequestConnection; #[allow(unused_imports)] use crate::connection::Connection as X11Connection; #[allow(unused_imports)] use crate::cookie::{Cookie, CookieWithFds, VoidCookie}; -use crate::errors::{ConnectionError, ParseError}; +use crate::errors::ConnectionError; #[allow(unused_imports)] use crate::errors::ReplyOrIdError; +#[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, 2); +pub use x11rb_protocol::protocol::dri3::*; /// Get the major opcode of this extension fn major_opcode(conn: &Conn) -> Result { @@ -43,74 +34,14 @@ fn major_opcode(conn: &Conn) -> Result BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = QueryVersionReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_query_version<'c, Conn>(req: QueryVersionRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for QueryVersionRequest {} pub fn query_version(conn: &Conn, major_version: u32, minor_version: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -119,104 +50,17 @@ where major_version, minor_version, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct QueryVersionReply { - pub sequence: u16, - pub length: u32, - pub major_version: u32, - pub minor_version: u32, + send_query_version(request0, conn) } -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)) - } -} - -/// Opcode for the Open request -pub const OPEN_REQUEST: u8 = 1; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct OpenRequest { - pub drawable: xproto::Drawable, - pub provider: u32, -} -impl OpenRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply_with_fds(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = OpenReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_open<'c, Conn>(req: OpenRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply_with_fds(&slices, fds) } -impl crate::x11_utils::ReplyFDsRequest for OpenRequest {} pub fn open(conn: &Conn, drawable: xproto::Drawable, provider: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -225,145 +69,17 @@ where drawable, provider, }; - request0.send(conn) -} - -#[derive(Debug, PartialEq, Eq)] -pub struct OpenReply { - pub nfd: u8, - pub sequence: u16, - pub length: u32, - pub device_fd: RawFdContainer, -} -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)) - } + send_open(request0, conn) } -/// Opcode for the PixmapFromBuffer request -pub const PIXMAP_FROM_BUFFER_REQUEST: u8 = 2; -#[derive(Debug, PartialEq, Eq)] -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 PixmapFromBufferRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![self.pixmap_fd]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_pixmap_from_buffer<'c, Conn>(req: PixmapFromBufferRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for PixmapFromBufferRequest {} pub fn pixmap_from_buffer(conn: &Conn, pixmap: xproto::Pixmap, drawable: xproto::Drawable, size: u32, width: u16, height: u16, stride: u16, depth: u8, bpp: u8, pixmap_fd: A) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -381,69 +97,17 @@ where bpp, pixmap_fd, }; - request0.send(conn) + send_pixmap_from_buffer(request0, conn) } -/// Opcode for the BufferFromPixmap request -pub const BUFFER_FROM_PIXMAP_REQUEST: u8 = 3; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct BufferFromPixmapRequest { - pub pixmap: xproto::Pixmap, -} -impl BufferFromPixmapRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply_with_fds(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = BufferFromPixmapReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_buffer_from_pixmap<'c, Conn>(req: BufferFromPixmapRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply_with_fds(&slices, fds) } -impl crate::x11_utils::ReplyFDsRequest for BufferFromPixmapRequest {} pub fn buffer_from_pixmap(conn: &Conn, pixmap: xproto::Pixmap) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -451,130 +115,17 @@ where let request0 = BufferFromPixmapRequest { pixmap, }; - request0.send(conn) -} - -#[derive(Debug, PartialEq, Eq)] -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 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)) - } -} - -/// Opcode for the FenceFromFD request -pub const FENCE_FROM_FD_REQUEST: u8 = 4; -#[derive(Debug, PartialEq, Eq)] -pub struct FenceFromFDRequest { - pub drawable: xproto::Drawable, - pub fence: u32, - pub initially_triggered: bool, - pub fence_fd: RawFdContainer, -} -impl FenceFromFDRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![self.fence_fd]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_buffer_from_pixmap(request0, conn) } -impl Request for FenceFromFDRequest { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_fence_from_fd<'c, Conn>(req: FenceFromFDRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for FenceFromFDRequest {} pub fn fence_from_fd(conn: &Conn, drawable: xproto::Drawable, fence: u32, initially_triggered: bool, fence_fd: A) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -587,77 +138,17 @@ where initially_triggered, fence_fd, }; - request0.send(conn) + send_fence_from_fd(request0, conn) } -/// Opcode for the FDFromFence request -pub const FD_FROM_FENCE_REQUEST: u8 = 5; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct FDFromFenceRequest { - pub drawable: xproto::Drawable, - pub fence: u32, -} -impl FDFromFenceRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply_with_fds(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = FDFromFenceReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_fd_from_fence<'c, Conn>(req: FDFromFenceRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply_with_fds(&slices, fds) } -impl crate::x11_utils::ReplyFDsRequest for FDFromFenceRequest {} pub fn fd_from_fence(conn: &Conn, drawable: xproto::Drawable, fence: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -666,110 +157,17 @@ where drawable, fence, }; - request0.send(conn) + send_fd_from_fence(request0, conn) } -#[derive(Debug, PartialEq, Eq)] -pub struct FDFromFenceReply { - pub nfd: u8, - pub sequence: u16, - pub length: u32, - pub fence_fd: RawFdContainer, -} -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)) - } -} - -/// Opcode for the GetSupportedModifiers request -pub const GET_SUPPORTED_MODIFIERS_REQUEST: u8 = 6; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetSupportedModifiersRequest { - pub window: u32, - pub depth: u8, - pub bpp: u8, -} -impl GetSupportedModifiersRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetSupportedModifiersReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_supported_modifiers<'c, Conn>(req: GetSupportedModifiersRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetSupportedModifiersRequest {} pub fn get_supported_modifiers(conn: &Conn, window: u32, depth: u8, bpp: u8) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -779,250 +177,17 @@ where depth, bpp, }; - request0.send(conn) + send_get_supported_modifiers(request0, conn) } -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetSupportedModifiersReply { - pub sequence: u16, - pub length: u32, - pub window_modifiers: Vec, - pub screen_modifiers: Vec, -} -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 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; -#[derive(Debug, PartialEq, Eq)] -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 PixmapFromBuffersRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], self.buffers) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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); - std::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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_pixmap_from_buffers<'c, Conn>(req: PixmapFromBuffersRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for PixmapFromBuffersRequest {} pub fn pixmap_from_buffers(conn: &Conn, pixmap: xproto::Pixmap, window: xproto::Window, width: u16, height: u16, stride0: u32, offset0: u32, stride1: u32, offset1: u32, stride2: u32, offset2: u32, stride3: u32, offset3: u32, depth: u8, bpp: u8, modifier: u64, buffers: Vec) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1045,69 +210,17 @@ where modifier, buffers, }; - request0.send(conn) + send_pixmap_from_buffers(request0, conn) } -/// Opcode for the BuffersFromPixmap request -pub const BUFFERS_FROM_PIXMAP_REQUEST: u8 = 8; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct BuffersFromPixmapRequest { - pub pixmap: xproto::Pixmap, -} -impl BuffersFromPixmapRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply_with_fds(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = BuffersFromPixmapReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_buffers_from_pixmap<'c, Conn>(req: BuffersFromPixmapRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply_with_fds(&slices, fds) } -impl crate::x11_utils::ReplyFDsRequest for BuffersFromPixmapRequest {} pub fn buffers_from_pixmap(conn: &Conn, pixmap: xproto::Pixmap) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1115,66 +228,7 @@ where let request0 = BuffersFromPixmapRequest { pixmap, }; - request0.send(conn) -} - -#[derive(Debug, PartialEq, Eq)] -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 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); - std::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 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() - } + send_buffers_from_pixmap(request0, conn) } /// Extension trait defining the requests of this extension. diff --git a/src/protocol/ge.rs b/src/protocol/ge.rs index eacbcd6a..abdce7fc 100644 --- a/src/protocol/ge.rs +++ b/src/protocol/ge.rs @@ -7,33 +7,23 @@ #[allow(unused_imports)] use std::borrow::Cow; -use std::convert::TryFrom; #[allow(unused_imports)] use std::convert::TryInto; -use std::io::IoSlice; #[allow(unused_imports)] -use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; +use crate::utils::RawFdContainer; #[allow(unused_imports)] -use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd, TryIntoUSize}; -use crate::connection::{BufWithFds, PiecewiseBuf, RequestConnection}; +use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; +use std::io::IoSlice; +use crate::connection::RequestConnection; #[allow(unused_imports)] use crate::connection::Connection as X11Connection; #[allow(unused_imports)] use crate::cookie::{Cookie, CookieWithFds, VoidCookie}; -use crate::errors::{ConnectionError, ParseError}; +use crate::errors::ConnectionError; #[allow(unused_imports)] use crate::errors::ReplyOrIdError; -/// 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); +pub use x11rb_protocol::protocol::ge::*; /// Get the major opcode of this extension fn major_opcode(conn: &Conn) -> Result { @@ -42,70 +32,14 @@ fn major_opcode(conn: &Conn) -> Result BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = QueryVersionReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_query_version<'c, Conn>(req: QueryVersionRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for QueryVersionRequest {} pub fn query_version(conn: &Conn, client_major_version: u16, client_minor_version: u16) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -114,35 +48,7 @@ where client_major_version, client_minor_version, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct QueryVersionReply { - pub sequence: u16, - pub length: u32, - pub major_version: u16, - pub minor_version: u16, -} -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)) - } + send_query_version(request0, conn) } /// Extension trait defining the requests of this extension. diff --git a/src/protocol/glx.rs b/src/protocol/glx.rs index 0bc257f1..83f37108 100644 --- a/src/protocol/glx.rs +++ b/src/protocol/glx.rs @@ -7,34 +7,25 @@ #[allow(unused_imports)] use std::borrow::Cow; -use std::convert::TryFrom; #[allow(unused_imports)] use std::convert::TryInto; -use std::io::IoSlice; #[allow(unused_imports)] -use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; +use crate::utils::RawFdContainer; #[allow(unused_imports)] -use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd, TryIntoUSize}; -use crate::connection::{BufWithFds, PiecewiseBuf, RequestConnection}; +use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; +use std::io::IoSlice; +use crate::connection::RequestConnection; #[allow(unused_imports)] use crate::connection::Connection as X11Connection; #[allow(unused_imports)] use crate::cookie::{Cookie, CookieWithFds, VoidCookie}; -use crate::errors::{ConnectionError, ParseError}; +use crate::errors::ConnectionError; #[allow(unused_imports)] use crate::errors::ReplyOrIdError; +#[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 use x11rb_protocol::protocol::glx::*; /// Get the major opcode of this extension fn major_opcode(conn: &Conn) -> Result { @@ -43,431 +34,14 @@ fn major_opcode(conn: &Conn) -> Result 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 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(Debug, Clone, Copy, PartialEq, Eq)] -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 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 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, PartialEq, Eq)] -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 std::fmt::Debug for PBCET { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::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, PartialEq, Eq)] -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 std::fmt::Debug for PBCDT { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::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(Debug, Clone, PartialEq, Eq)] -pub struct RenderRequest<'input> { - pub context_tag: ContextTag, - pub data: Cow<'input, [u8]>, -} -impl<'input> RenderRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into(), self.data, padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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> { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_render<'c, Conn>(req: RenderRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl<'input> crate::x11_utils::VoidRequest for RenderRequest<'input> {} pub fn render<'c, 'input, Conn>(conn: &'c Conn, context_tag: ContextTag, data: &'input [u8]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -476,103 +50,17 @@ where context_tag, data: Cow::Borrowed(data), }; - request0.send(conn) -} - -/// Opcode for the RenderLarge request -pub const RENDER_LARGE_REQUEST: u8 = 2; -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct RenderLargeRequest<'input> { - pub context_tag: ContextTag, - pub request_num: u16, - pub request_total: u16, - pub data: Cow<'input, [u8]>, -} -impl<'input> RenderLargeRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into(), self.data, padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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()), - } - } + send_render(request0, conn) } -impl<'input> Request for RenderLargeRequest<'input> { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_render_large<'c, Conn>(req: RenderLargeRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl<'input> crate::x11_utils::VoidRequest for RenderLargeRequest<'input> {} pub fn render_large<'c, 'input, Conn>(conn: &'c Conn, context_tag: ContextTag, request_num: u16, request_total: u16, data: &'input [u8]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -583,102 +71,17 @@ where request_total, data: Cow::Borrowed(data), }; - request0.send(conn) -} - -/// Opcode for the CreateContext request -pub const CREATE_CONTEXT_REQUEST: u8 = 3; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct CreateContextRequest { - pub context: Context, - pub visual: xproto::Visualid, - pub screen: u32, - pub share_list: Context, - pub is_direct: bool, -} -impl CreateContextRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_render_large(request0, conn) } -impl Request for CreateContextRequest { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_create_context<'c, Conn>(req: CreateContextRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for CreateContextRequest {} pub fn create_context(conn: &Conn, context: Context, visual: xproto::Visualid, screen: u32, share_list: Context, is_direct: bool) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -690,69 +93,17 @@ where share_list, is_direct, }; - request0.send(conn) -} - -/// Opcode for the DestroyContext request -pub const DESTROY_CONTEXT_REQUEST: u8 = 4; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct DestroyContextRequest { - pub context: Context, -} -impl DestroyContextRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_create_context(request0, conn) } -impl Request for DestroyContextRequest { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_destroy_context<'c, Conn>(req: DestroyContextRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for DestroyContextRequest {} pub fn destroy_context(conn: &Conn, context: Context) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -760,85 +111,17 @@ where let request0 = DestroyContextRequest { context, }; - request0.send(conn) -} - -/// Opcode for the MakeCurrent request -pub const MAKE_CURRENT_REQUEST: u8 = 5; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct MakeCurrentRequest { - pub drawable: Drawable, - pub context: Context, - pub old_context_tag: ContextTag, -} -impl MakeCurrentRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_destroy_context(request0, conn) } -impl Request for MakeCurrentRequest { - type Reply = MakeCurrentReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_make_current<'c, Conn>(req: MakeCurrentRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for MakeCurrentRequest {} pub fn make_current(conn: &Conn, drawable: Drawable, context: Context, old_context_tag: ContextTag) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -848,95 +131,17 @@ where context, old_context_tag, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct MakeCurrentReply { - pub sequence: u16, - pub length: u32, - pub context_tag: ContextTag, -} -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)) - } -} - -/// Opcode for the IsDirect request -pub const IS_DIRECT_REQUEST: u8 = 6; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct IsDirectRequest { - pub context: Context, -} -impl IsDirectRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_make_current(request0, conn) } -impl Request for IsDirectRequest { - type Reply = IsDirectReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_is_direct<'c, Conn>(req: IsDirectRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for IsDirectRequest {} pub fn is_direct(conn: &Conn, context: Context) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -944,103 +149,17 @@ where let request0 = IsDirectRequest { context, }; - request0.send(conn) + send_is_direct(request0, conn) } -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct IsDirectReply { - pub sequence: u16, - pub length: u32, - pub is_direct: bool, -} -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)) - } -} - -/// Opcode for the QueryVersion request -pub const QUERY_VERSION_REQUEST: u8 = 7; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct QueryVersionRequest { - pub major_version: u32, - pub minor_version: u32, -} -impl QueryVersionRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = QueryVersionReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_query_version<'c, Conn>(req: QueryVersionRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for QueryVersionRequest {} pub fn query_version(conn: &Conn, major_version: u32, minor_version: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1049,97 +168,17 @@ where major_version, minor_version, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct QueryVersionReply { - pub sequence: u16, - pub length: u32, - pub major_version: u32, - pub minor_version: u32, -} -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)) - } -} - -/// Opcode for the WaitGL request -pub const WAIT_GL_REQUEST: u8 = 8; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct WaitGLRequest { - pub context_tag: ContextTag, -} -impl WaitGLRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_query_version(request0, conn) } -impl Request for WaitGLRequest { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_wait_gl<'c, Conn>(req: WaitGLRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for WaitGLRequest {} pub fn wait_gl(conn: &Conn, context_tag: ContextTag) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1147,69 +186,17 @@ where let request0 = WaitGLRequest { context_tag, }; - request0.send(conn) -} - -/// Opcode for the WaitX request -pub const WAIT_X_REQUEST: u8 = 9; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct WaitXRequest { - pub context_tag: ContextTag, -} -impl WaitXRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_wait_gl(request0, conn) } -impl Request for WaitXRequest { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_wait_x<'c, Conn>(req: WaitXRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for WaitXRequest {} pub fn wait_x(conn: &Conn, context_tag: ContextTag) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1217,93 +204,17 @@ where let request0 = WaitXRequest { context_tag, }; - request0.send(conn) -} - -/// Opcode for the CopyContext request -pub const COPY_CONTEXT_REQUEST: u8 = 10; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct CopyContextRequest { - pub src: Context, - pub dest: Context, - pub mask: u32, - pub src_context_tag: ContextTag, -} -impl CopyContextRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_wait_x(request0, conn) } -impl Request for CopyContextRequest { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_copy_context<'c, Conn>(req: CopyContextRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for CopyContextRequest {} pub fn copy_context(conn: &Conn, src: Context, dest: Context, mask: u32, src_context_tag: ContextTag) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1314,161 +225,17 @@ where mask, src_context_tag, }; - request0.send(conn) -} - -#[derive(Clone, Copy, PartialEq, Eq)] -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 std::fmt::Debug for GC { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct SwapBuffersRequest { - pub context_tag: ContextTag, - pub drawable: Drawable, -} -impl SwapBuffersRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_copy_context(request0, conn) } -impl Request for SwapBuffersRequest { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_swap_buffers<'c, Conn>(req: SwapBuffersRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for SwapBuffersRequest {} pub fn swap_buffers(conn: &Conn, context_tag: ContextTag, drawable: Drawable) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1477,101 +244,17 @@ where context_tag, drawable, }; - request0.send(conn) -} - -/// Opcode for the UseXFont request -pub const USE_X_FONT_REQUEST: u8 = 12; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct UseXFontRequest { - pub context_tag: ContextTag, - pub font: xproto::Font, - pub first: u32, - pub count: u32, - pub list_base: u32, -} -impl UseXFontRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_swap_buffers(request0, conn) } -impl Request for UseXFontRequest { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_use_x_font<'c, Conn>(req: UseXFontRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for UseXFontRequest {} pub fn use_x_font(conn: &Conn, context_tag: ContextTag, font: xproto::Font, first: u32, count: u32, list_base: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1583,93 +266,17 @@ where count, list_base, }; - request0.send(conn) -} - -/// Opcode for the CreateGLXPixmap request -pub const CREATE_GLX_PIXMAP_REQUEST: u8 = 13; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct CreateGLXPixmapRequest { - pub screen: u32, - pub visual: xproto::Visualid, - pub pixmap: xproto::Pixmap, - pub glx_pixmap: Pixmap, -} -impl CreateGLXPixmapRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_use_x_font(request0, conn) } -impl Request for CreateGLXPixmapRequest { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_create_glx_pixmap<'c, Conn>(req: CreateGLXPixmapRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for CreateGLXPixmapRequest {} pub fn create_glx_pixmap(conn: &Conn, screen: u32, visual: xproto::Visualid, pixmap: xproto::Pixmap, glx_pixmap: Pixmap) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1680,69 +287,17 @@ where pixmap, glx_pixmap, }; - request0.send(conn) + send_create_glx_pixmap(request0, conn) } -/// Opcode for the GetVisualConfigs request -pub const GET_VISUAL_CONFIGS_REQUEST: u8 = 14; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetVisualConfigsRequest { - pub screen: u32, -} -impl GetVisualConfigsRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetVisualConfigsReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_visual_configs<'c, Conn>(req: GetVisualConfigsRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetVisualConfigsRequest {} pub fn get_visual_configs(conn: &Conn, screen: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1750,113 +305,17 @@ where let request0 = GetVisualConfigsRequest { screen, }; - request0.send(conn) + send_get_visual_configs(request0, conn) } -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetVisualConfigsReply { - pub sequence: u16, - pub num_visuals: u32, - pub num_properties: u32, - pub property_list: Vec, -} -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)) - } +fn send_destroy_glx_pixmap<'c, Conn>(req: DestroyGLXPixmapRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct DestroyGLXPixmapRequest { - pub glx_pixmap: Pixmap, -} -impl DestroyGLXPixmapRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(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 {} pub fn destroy_glx_pixmap(conn: &Conn, glx_pixmap: Pixmap) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1864,91 +323,17 @@ where let request0 = DestroyGLXPixmapRequest { glx_pixmap, }; - request0.send(conn) -} - -/// Opcode for the VendorPrivate request -pub const VENDOR_PRIVATE_REQUEST: u8 = 16; -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct VendorPrivateRequest<'input> { - pub vendor_code: u32, - pub context_tag: ContextTag, - pub data: Cow<'input, [u8]>, -} -impl<'input> VendorPrivateRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into(), self.data, padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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()), - } - } + send_destroy_glx_pixmap(request0, conn) } -impl<'input> Request for VendorPrivateRequest<'input> { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_vendor_private<'c, Conn>(req: VendorPrivateRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl<'input> crate::x11_utils::VoidRequest for VendorPrivateRequest<'input> {} pub fn vendor_private<'c, 'input, Conn>(conn: &'c Conn, vendor_code: u32, context_tag: ContextTag, data: &'input [u8]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -1958,91 +343,17 @@ where context_tag, data: Cow::Borrowed(data), }; - request0.send(conn) -} - -/// Opcode for the VendorPrivateWithReply request -pub const VENDOR_PRIVATE_WITH_REPLY_REQUEST: u8 = 17; -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct VendorPrivateWithReplyRequest<'input> { - pub vendor_code: u32, - pub context_tag: ContextTag, - pub data: Cow<'input, [u8]>, -} -impl<'input> VendorPrivateWithReplyRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into(), self.data, padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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()), - } - } + send_vendor_private(request0, conn) } -impl<'input> Request for VendorPrivateWithReplyRequest<'input> { - type Reply = VendorPrivateWithReplyReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_vendor_private_with_reply<'c, Conn>(req: VendorPrivateWithReplyRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl<'input> crate::x11_utils::ReplyRequest for VendorPrivateWithReplyRequest<'input> {} pub fn vendor_private_with_reply<'c, 'input, Conn>(conn: &'c Conn, vendor_code: u32, context_tag: ContextTag, data: &'input [u8]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -2052,115 +363,17 @@ where context_tag, data: Cow::Borrowed(data), }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct VendorPrivateWithReplyReply { - pub sequence: u16, - pub retval: u32, - pub data1: [u8; 24], - pub data2: Vec, -} -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_list(remaining, 24)?; - let data1 = <[u8; 24]>::try_from(data1).unwrap(); - let (data2, remaining) = crate::x11_utils::parse_u8_list(remaining, 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 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() - } + send_vendor_private_with_reply(request0, conn) } -/// Opcode for the QueryExtensionsString request -pub const QUERY_EXTENSIONS_STRING_REQUEST: u8 = 18; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct QueryExtensionsStringRequest { - pub screen: u32, -} -impl QueryExtensionsStringRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = QueryExtensionsStringReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_query_extensions_string<'c, Conn>(req: QueryExtensionsStringRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for QueryExtensionsStringRequest {} pub fn query_extensions_string(conn: &Conn, screen: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -2168,104 +381,17 @@ where let request0 = QueryExtensionsStringRequest { screen, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct QueryExtensionsStringReply { - pub sequence: u16, - pub length: u32, - pub n: u32, -} -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)) - } -} - -/// Opcode for the QueryServerString request -pub const QUERY_SERVER_STRING_REQUEST: u8 = 19; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct QueryServerStringRequest { - pub screen: u32, - pub name: u32, -} -impl QueryServerStringRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_query_extensions_string(request0, conn) } -impl Request for QueryServerStringRequest { - type Reply = QueryServerStringReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_query_server_string<'c, Conn>(req: QueryServerStringRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for QueryServerStringRequest {} pub fn query_server_string(conn: &Conn, screen: u32, name: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -2274,142 +400,17 @@ where screen, name, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct QueryServerStringReply { - pub sequence: u16, - pub length: u32, - pub string: Vec, -} -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 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(Debug, Clone, PartialEq, Eq)] -pub struct ClientInfoRequest<'input> { - pub major_version: u32, - pub minor_version: u32, - pub string: Cow<'input, [u8]>, -} -impl<'input> ClientInfoRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into(), self.string, padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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()), - } - } + send_query_server_string(request0, conn) } -impl<'input> Request for ClientInfoRequest<'input> { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_client_info<'c, Conn>(req: ClientInfoRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl<'input> crate::x11_utils::VoidRequest for ClientInfoRequest<'input> {} pub fn client_info<'c, 'input, Conn>(conn: &'c Conn, major_version: u32, minor_version: u32, string: &'input [u8]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -2419,69 +420,17 @@ where minor_version, string: Cow::Borrowed(string), }; - request0.send(conn) -} - -/// Opcode for the GetFBConfigs request -pub const GET_FB_CONFIGS_REQUEST: u8 = 21; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetFBConfigsRequest { - pub screen: u32, -} -impl GetFBConfigsRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_client_info(request0, conn) } -impl Request for GetFBConfigsRequest { - type Reply = GetFBConfigsReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_fb_configs<'c, Conn>(req: GetFBConfigsRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetFBConfigsRequest {} pub fn get_fb_configs(conn: &Conn, screen: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -2489,162 +438,17 @@ where let request0 = GetFBConfigsRequest { screen, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetFBConfigsReply { - pub sequence: u16, - pub num_fb_configs: u32, - pub num_properties: u32, - pub property_list: Vec, -} -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)) - } + send_get_fb_configs(request0, conn) } -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(Debug, Clone, PartialEq, Eq)] -pub struct CreatePixmapRequest<'input> { - pub screen: u32, - pub fbconfig: Fbconfig, - pub pixmap: xproto::Pixmap, - pub glx_pixmap: Pixmap, - pub attribs: Cow<'input, [u32]>, -} -impl<'input> CreatePixmapRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into(), attribs_bytes.into(), padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, 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> { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_create_pixmap<'c, Conn>(req: CreatePixmapRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl<'input> crate::x11_utils::VoidRequest for CreatePixmapRequest<'input> {} pub fn create_pixmap<'c, 'input, Conn>(conn: &'c Conn, screen: u32, fbconfig: Fbconfig, pixmap: xproto::Pixmap, glx_pixmap: Pixmap, attribs: &'input [u32]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -2656,69 +460,17 @@ where glx_pixmap, attribs: Cow::Borrowed(attribs), }; - request0.send(conn) -} - -/// Opcode for the DestroyPixmap request -pub const DESTROY_PIXMAP_REQUEST: u8 = 23; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct DestroyPixmapRequest { - pub glx_pixmap: Pixmap, -} -impl DestroyPixmapRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_create_pixmap(request0, conn) } -impl Request for DestroyPixmapRequest { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_destroy_pixmap<'c, Conn>(req: DestroyPixmapRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for DestroyPixmapRequest {} pub fn destroy_pixmap(conn: &Conn, glx_pixmap: Pixmap) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -2726,110 +478,17 @@ where let request0 = DestroyPixmapRequest { glx_pixmap, }; - request0.send(conn) -} - -/// Opcode for the CreateNewContext request -pub const CREATE_NEW_CONTEXT_REQUEST: u8 = 24; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -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 CreateNewContextRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_destroy_pixmap(request0, conn) } -impl Request for CreateNewContextRequest { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_create_new_context<'c, Conn>(req: CreateNewContextRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for CreateNewContextRequest {} pub fn create_new_context(conn: &Conn, context: Context, fbconfig: Fbconfig, screen: u32, render_type: u32, share_list: Context, is_direct: bool) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -2842,69 +501,17 @@ where share_list, is_direct, }; - request0.send(conn) -} - -/// Opcode for the QueryContext request -pub const QUERY_CONTEXT_REQUEST: u8 = 25; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct QueryContextRequest { - pub context: Context, -} -impl QueryContextRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_create_new_context(request0, conn) } -impl Request for QueryContextRequest { - type Reply = QueryContextReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_query_context<'c, Conn>(req: QueryContextRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for QueryContextRequest {} pub fn query_context(conn: &Conn, context: Context) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -2912,136 +519,17 @@ where let request0 = QueryContextRequest { context, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct QueryContextReply { - pub sequence: u16, - pub length: u32, - pub attribs: Vec, -} -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, 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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct MakeContextCurrentRequest { - pub old_context_tag: ContextTag, - pub drawable: Drawable, - pub read_drawable: Drawable, - pub context: Context, -} -impl MakeContextCurrentRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_query_context(request0, conn) } -impl Request for MakeContextCurrentRequest { - type Reply = MakeContextCurrentReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_make_context_current<'c, Conn>(req: MakeContextCurrentRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for MakeContextCurrentRequest {} pub fn make_context_current(conn: &Conn, old_context_tag: ContextTag, drawable: Drawable, read_drawable: Drawable, context: Context) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -3052,135 +540,17 @@ where read_drawable, context, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct MakeContextCurrentReply { - pub sequence: u16, - pub length: u32, - pub context_tag: ContextTag, -} -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)) - } -} - -/// Opcode for the CreatePbuffer request -pub const CREATE_PBUFFER_REQUEST: u8 = 27; -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct CreatePbufferRequest<'input> { - pub screen: u32, - pub fbconfig: Fbconfig, - pub pbuffer: Pbuffer, - pub attribs: Cow<'input, [u32]>, -} -impl<'input> CreatePbufferRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into(), attribs_bytes.into(), padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, 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()), - } - } + send_make_context_current(request0, conn) } -impl<'input> Request for CreatePbufferRequest<'input> { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_create_pbuffer<'c, Conn>(req: CreatePbufferRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl<'input> crate::x11_utils::VoidRequest for CreatePbufferRequest<'input> {} pub fn create_pbuffer<'c, 'input, Conn>(conn: &'c Conn, screen: u32, fbconfig: Fbconfig, pbuffer: Pbuffer, attribs: &'input [u32]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -3191,69 +561,17 @@ where pbuffer, attribs: Cow::Borrowed(attribs), }; - request0.send(conn) -} - -/// Opcode for the DestroyPbuffer request -pub const DESTROY_PBUFFER_REQUEST: u8 = 28; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct DestroyPbufferRequest { - pub pbuffer: Pbuffer, -} -impl DestroyPbufferRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_create_pbuffer(request0, conn) } -impl Request for DestroyPbufferRequest { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_destroy_pbuffer<'c, Conn>(req: DestroyPbufferRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for DestroyPbufferRequest {} pub fn destroy_pbuffer(conn: &Conn, pbuffer: Pbuffer) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -3261,69 +579,17 @@ where let request0 = DestroyPbufferRequest { pbuffer, }; - request0.send(conn) -} - -/// Opcode for the GetDrawableAttributes request -pub const GET_DRAWABLE_ATTRIBUTES_REQUEST: u8 = 29; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetDrawableAttributesRequest { - pub drawable: Drawable, -} -impl GetDrawableAttributesRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_destroy_pbuffer(request0, conn) } -impl Request for GetDrawableAttributesRequest { - type Reply = GetDrawableAttributesReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_drawable_attributes<'c, Conn>(req: GetDrawableAttributesRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetDrawableAttributesRequest {} pub fn get_drawable_attributes(conn: &Conn, drawable: Drawable) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -3331,134 +597,17 @@ where let request0 = GetDrawableAttributesRequest { drawable, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetDrawableAttributesReply { - pub sequence: u16, - pub length: u32, - pub attribs: Vec, -} -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, 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 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(Debug, Clone, PartialEq, Eq)] -pub struct ChangeDrawableAttributesRequest<'input> { - pub drawable: Drawable, - pub attribs: Cow<'input, [u32]>, -} -impl<'input> ChangeDrawableAttributesRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into(), attribs_bytes.into(), padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, 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()), - } - } + send_get_drawable_attributes(request0, conn) } -impl<'input> Request for ChangeDrawableAttributesRequest<'input> { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_change_drawable_attributes<'c, Conn>(req: ChangeDrawableAttributesRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl<'input> crate::x11_utils::VoidRequest for ChangeDrawableAttributesRequest<'input> {} pub fn change_drawable_attributes<'c, 'input, Conn>(conn: &'c Conn, drawable: Drawable, attribs: &'input [u32]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -3467,118 +616,17 @@ where drawable, attribs: Cow::Borrowed(attribs), }; - request0.send(conn) -} - -/// Opcode for the CreateWindow request -pub const CREATE_WINDOW_REQUEST: u8 = 31; -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct CreateWindowRequest<'input> { - pub screen: u32, - pub fbconfig: Fbconfig, - pub window: xproto::Window, - pub glx_window: Window, - pub attribs: Cow<'input, [u32]>, -} -impl<'input> CreateWindowRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into(), attribs_bytes.into(), padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, 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()), - } - } + send_change_drawable_attributes(request0, conn) } -impl<'input> Request for CreateWindowRequest<'input> { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_create_window<'c, Conn>(req: CreateWindowRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl<'input> crate::x11_utils::VoidRequest for CreateWindowRequest<'input> {} pub fn create_window<'c, 'input, Conn>(conn: &'c Conn, screen: u32, fbconfig: Fbconfig, window: xproto::Window, glx_window: Window, attribs: &'input [u32]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -3590,69 +638,17 @@ where glx_window, attribs: Cow::Borrowed(attribs), }; - request0.send(conn) -} - -/// Opcode for the DeleteWindow request -pub const DELETE_WINDOW_REQUEST: u8 = 32; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct DeleteWindowRequest { - pub glxwindow: Window, -} -impl DeleteWindowRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_create_window(request0, conn) } -impl Request for DeleteWindowRequest { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_delete_window<'c, Conn>(req: DeleteWindowRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for DeleteWindowRequest {} pub fn delete_window(conn: &Conn, glxwindow: Window) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -3660,124 +656,17 @@ where let request0 = DeleteWindowRequest { glxwindow, }; - request0.send(conn) -} - -/// Opcode for the SetClientInfoARB request -pub const SET_CLIENT_INFO_ARB_REQUEST: u8 = 33; -#[derive(Debug, Clone, PartialEq, Eq)] -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<'input> SetClientInfoARBRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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 length_so_far = length_so_far + self.glx_extension_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()); - (vec![request0.into(), gl_versions_bytes.into(), self.gl_extension_string, self.glx_extension_string, padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, 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()?)?; - 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()), - } - } + send_delete_window(request0, conn) } -impl<'input> Request for SetClientInfoARBRequest<'input> { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_set_client_info_arb<'c, Conn>(req: SetClientInfoARBRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl<'input> crate::x11_utils::VoidRequest for SetClientInfoARBRequest<'input> {} pub fn set_client_info_arb<'c, 'input, Conn>(conn: &'c Conn, major_version: u32, minor_version: u32, gl_versions: &'input [u32], gl_extension_string: &'input [u8], glx_extension_string: &'input [u8]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -3789,128 +678,17 @@ where gl_extension_string: Cow::Borrowed(gl_extension_string), glx_extension_string: Cow::Borrowed(glx_extension_string), }; - request0.send(conn) + send_set_client_info_arb(request0, conn) } -/// Opcode for the CreateContextAttribsARB request -pub const CREATE_CONTEXT_ATTRIBS_ARB_REQUEST: u8 = 34; -#[derive(Debug, Clone, PartialEq, Eq)] -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<'input> CreateContextAttribsARBRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into(), attribs_bytes.into(), padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, 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()), - } - } +fn send_create_context_attribs_arb<'c, Conn>(req: CreateContextAttribsARBRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl<'input> Request for CreateContextAttribsARBRequest<'input> { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(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> {} pub fn create_context_attribs_arb<'c, 'input, Conn>(conn: &'c Conn, context: Context, fbconfig: Fbconfig, screen: u32, share_list: Context, is_direct: bool, attribs: &'input [u32]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -3923,124 +701,17 @@ where is_direct, attribs: Cow::Borrowed(attribs), }; - request0.send(conn) -} - -/// Opcode for the SetClientInfo2ARB request -pub const SET_CLIENT_INFO2_ARB_REQUEST: u8 = 35; -#[derive(Debug, Clone, PartialEq, Eq)] -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<'input> SetClientInfo2ARBRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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 length_so_far = length_so_far + self.glx_extension_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()); - (vec![request0.into(), gl_versions_bytes.into(), self.gl_extension_string, self.glx_extension_string, padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, 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()?)?; - 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()), - } - } + send_create_context_attribs_arb(request0, conn) } -impl<'input> Request for SetClientInfo2ARBRequest<'input> { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_set_client_info2_arb<'c, Conn>(req: SetClientInfo2ARBRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl<'input> crate::x11_utils::VoidRequest for SetClientInfo2ARBRequest<'input> {} pub fn set_client_info2_arb<'c, 'input, Conn>(conn: &'c Conn, major_version: u32, minor_version: u32, gl_versions: &'input [u32], gl_extension_string: &'input [u8], glx_extension_string: &'input [u8]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -4052,85 +723,17 @@ where gl_extension_string: Cow::Borrowed(gl_extension_string), glx_extension_string: Cow::Borrowed(glx_extension_string), }; - request0.send(conn) + send_set_client_info2_arb(request0, conn) } -/// Opcode for the NewList request -pub const NEW_LIST_REQUEST: u8 = 101; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct NewListRequest { - pub context_tag: ContextTag, - pub list: u32, - pub mode: u32, -} -impl NewListRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_new_list<'c, Conn>(req: NewListRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for NewListRequest {} pub fn new_list(conn: &Conn, context_tag: ContextTag, list: u32, mode: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -4140,69 +743,17 @@ where list, mode, }; - request0.send(conn) -} - -/// Opcode for the EndList request -pub const END_LIST_REQUEST: u8 = 102; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct EndListRequest { - pub context_tag: ContextTag, -} -impl EndListRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_new_list(request0, conn) } -impl Request for EndListRequest { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_end_list<'c, Conn>(req: EndListRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for EndListRequest {} pub fn end_list(conn: &Conn, context_tag: ContextTag) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -4210,85 +761,17 @@ where let request0 = EndListRequest { context_tag, }; - request0.send(conn) -} - -/// Opcode for the DeleteLists request -pub const DELETE_LISTS_REQUEST: u8 = 103; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct DeleteListsRequest { - pub context_tag: ContextTag, - pub list: u32, - pub range: i32, -} -impl DeleteListsRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_end_list(request0, conn) } -impl Request for DeleteListsRequest { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_delete_lists<'c, Conn>(req: DeleteListsRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for DeleteListsRequest {} pub fn delete_lists(conn: &Conn, context_tag: ContextTag, list: u32, range: i32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -4298,77 +781,17 @@ where list, range, }; - request0.send(conn) -} - -/// Opcode for the GenLists request -pub const GEN_LISTS_REQUEST: u8 = 104; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GenListsRequest { - pub context_tag: ContextTag, - pub range: i32, -} -impl GenListsRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_delete_lists(request0, conn) } -impl Request for GenListsRequest { - type Reply = GenListsReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_gen_lists<'c, Conn>(req: GenListsRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GenListsRequest {} pub fn gen_lists(conn: &Conn, context_tag: ContextTag, range: i32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -4377,110 +800,17 @@ where context_tag, range, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GenListsReply { - pub sequence: u16, - pub length: u32, - pub ret_val: u32, -} -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)) - } -} - -/// Opcode for the FeedbackBuffer request -pub const FEEDBACK_BUFFER_REQUEST: u8 = 105; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct FeedbackBufferRequest { - pub context_tag: ContextTag, - pub size: i32, - pub type_: i32, -} -impl FeedbackBufferRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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_, - }) - } + send_gen_lists(request0, conn) } -impl Request for FeedbackBufferRequest { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_feedback_buffer<'c, Conn>(req: FeedbackBufferRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for FeedbackBufferRequest {} pub fn feedback_buffer(conn: &Conn, context_tag: ContextTag, size: i32, type_: i32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -4490,77 +820,17 @@ where size, type_, }; - request0.send(conn) -} - -/// Opcode for the SelectBuffer request -pub const SELECT_BUFFER_REQUEST: u8 = 106; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct SelectBufferRequest { - pub context_tag: ContextTag, - pub size: i32, -} -impl SelectBufferRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_feedback_buffer(request0, conn) } -impl Request for SelectBufferRequest { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_select_buffer<'c, Conn>(req: SelectBufferRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for SelectBufferRequest {} pub fn select_buffer(conn: &Conn, context_tag: ContextTag, size: i32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -4569,77 +839,17 @@ where context_tag, size, }; - request0.send(conn) -} - -/// Opcode for the RenderMode request -pub const RENDER_MODE_REQUEST: u8 = 107; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct RenderModeRequest { - pub context_tag: ContextTag, - pub mode: u32, -} -impl RenderModeRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_select_buffer(request0, conn) } -impl Request for RenderModeRequest { - type Reply = RenderModeReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_render_mode<'c, Conn>(req: RenderModeRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for RenderModeRequest {} pub fn render_mode(conn: &Conn, context_tag: ContextTag, mode: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -4648,169 +858,17 @@ where context_tag, mode, }; - request0.send(conn) + send_render_mode(request0, conn) } -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct RenderModeReply { - pub sequence: u16, - pub length: u32, - pub ret_val: u32, - pub new_mode: u32, - pub data: Vec, -} -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 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, PartialEq, Eq)] -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 std::fmt::Debug for RM { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct FinishRequest { - pub context_tag: ContextTag, -} -impl FinishRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = FinishReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_finish<'c, Conn>(req: FinishRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for FinishRequest {} pub fn finish(conn: &Conn, context_tag: ContextTag) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -4818,108 +876,17 @@ where let request0 = FinishRequest { context_tag, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct FinishReply { - pub sequence: u16, - pub length: u32, -} -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)) - } -} - -/// Opcode for the PixelStoref request -pub const PIXEL_STOREF_REQUEST: u8 = 109; -#[derive(Debug, Clone, Copy, PartialEq)] -pub struct PixelStorefRequest { - pub context_tag: ContextTag, - pub pname: u32, - pub datum: Float32, -} -impl PixelStorefRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_finish(request0, conn) } -impl Request for PixelStorefRequest { - type Reply = (); - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_pixel_storef<'c, Conn>(req: PixelStorefRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for PixelStorefRequest {} pub fn pixel_storef(conn: &Conn, context_tag: ContextTag, pname: u32, datum: Float32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -4929,85 +896,17 @@ where pname, datum, }; - request0.send(conn) -} - -/// Opcode for the PixelStorei request -pub const PIXEL_STOREI_REQUEST: u8 = 110; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct PixelStoreiRequest { - pub context_tag: ContextTag, - pub pname: u32, - pub datum: i32, -} -impl PixelStoreiRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_pixel_storef(request0, conn) } -impl Request for PixelStoreiRequest { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_pixel_storei<'c, Conn>(req: PixelStoreiRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for PixelStoreiRequest {} pub fn pixel_storei(conn: &Conn, context_tag: ContextTag, pname: u32, datum: i32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -5017,129 +916,17 @@ where pname, datum, }; - request0.send(conn) + send_pixel_storei(request0, conn) } -/// Opcode for the ReadPixels request -pub const READ_PIXELS_REQUEST: u8 = 111; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -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 ReadPixelsRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = ReadPixelsReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_read_pixels<'c, Conn>(req: ReadPixelsRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for ReadPixelsRequest {} pub fn read_pixels(conn: &Conn, context_tag: ContextTag, x: i32, y: i32, width: i32, height: i32, format: u32, type_: u32, swap_bytes: bool, lsb_first: bool) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -5155,119 +942,17 @@ where swap_bytes, lsb_first, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct ReadPixelsReply { - pub sequence: u16, - pub data: Vec, -} -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, 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 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() - } + send_read_pixels(request0, conn) } -/// Opcode for the GetBooleanv request -pub const GET_BOOLEANV_REQUEST: u8 = 112; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetBooleanvRequest { - pub context_tag: ContextTag, - pub pname: i32, -} -impl GetBooleanvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetBooleanvReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_booleanv<'c, Conn>(req: GetBooleanvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetBooleanvRequest {} pub fn get_booleanv(conn: &Conn, context_tag: ContextTag, pname: i32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -5276,122 +961,17 @@ where context_tag, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetBooleanvReply { - pub sequence: u16, - pub length: u32, - pub datum: bool, - pub data: Vec, -} -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 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() - } + send_get_booleanv(request0, conn) } -/// Opcode for the GetClipPlane request -pub const GET_CLIP_PLANE_REQUEST: u8 = 113; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetClipPlaneRequest { - pub context_tag: ContextTag, - pub plane: i32, -} -impl GetClipPlaneRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetClipPlaneReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_clip_plane<'c, Conn>(req: GetClipPlaneRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetClipPlaneRequest {} pub fn get_clip_plane(conn: &Conn, context_tag: ContextTag, plane: i32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -5400,118 +980,17 @@ where context_tag, plane, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq)] -pub struct GetClipPlaneReply { - pub sequence: u16, - pub data: Vec, -} -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, 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 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() - } + send_get_clip_plane(request0, conn) } -/// Opcode for the GetDoublev request -pub const GET_DOUBLEV_REQUEST: u8 = 114; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetDoublevRequest { - pub context_tag: ContextTag, - pub pname: u32, -} -impl GetDoublevRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetDoublevReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_doublev<'c, Conn>(req: GetDoublevRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetDoublevRequest {} pub fn get_doublev(conn: &Conn, context_tag: ContextTag, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -5520,114 +999,17 @@ where context_tag, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq)] -pub struct GetDoublevReply { - pub sequence: u16, - pub length: u32, - pub datum: Float64, - pub data: Vec, -} -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 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() - } + send_get_doublev(request0, conn) } -/// Opcode for the GetError request -pub const GET_ERROR_REQUEST: u8 = 115; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetErrorRequest { - pub context_tag: ContextTag, -} -impl GetErrorRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetErrorReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_error<'c, Conn>(req: GetErrorRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetErrorRequest {} pub fn get_error(conn: &Conn, context_tag: ContextTag) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -5635,102 +1017,17 @@ where let request0 = GetErrorRequest { context_tag, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetErrorReply { - pub sequence: u16, - pub length: u32, - pub error: i32, -} -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)) - } -} - -/// Opcode for the GetFloatv request -pub const GET_FLOATV_REQUEST: u8 = 116; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetFloatvRequest { - pub context_tag: ContextTag, - pub pname: u32, -} -impl GetFloatvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_error(request0, conn) } -impl Request for GetFloatvRequest { - type Reply = GetFloatvReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_floatv<'c, Conn>(req: GetFloatvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetFloatvRequest {} pub fn get_floatv(conn: &Conn, context_tag: ContextTag, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -5739,123 +1036,18 @@ where context_tag, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq)] -pub struct GetFloatvReply { - pub sequence: u16, - pub length: u32, - pub datum: Float32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetIntegervRequest { - pub context_tag: ContextTag, - pub pname: u32, -} -impl GetIntegervRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_floatv(request0, conn) } -impl Request for GetIntegervRequest { - type Reply = GetIntegervReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(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 {} -pub fn get_integerv(conn: &Conn, context_tag: ContextTag, pname: u32) -> Result, ConnectionError> +fn send_get_integerv<'c, Conn>(req: GetIntegervRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) +} +pub fn get_integerv(conn: &Conn, context_tag: ContextTag, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, { @@ -5863,130 +1055,17 @@ where context_tag, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetIntegervReply { - pub sequence: u16, - pub length: u32, - pub datum: i32, - pub data: Vec, -} -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 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() - } + send_get_integerv(request0, conn) } -/// Opcode for the GetLightfv request -pub const GET_LIGHTFV_REQUEST: u8 = 118; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetLightfvRequest { - pub context_tag: ContextTag, - pub light: u32, - pub pname: u32, -} -impl GetLightfvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetLightfvReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_lightfv<'c, Conn>(req: GetLightfvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetLightfvRequest {} pub fn get_lightfv(conn: &Conn, context_tag: ContextTag, light: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -5996,130 +1075,17 @@ where light, pname, }; - request0.send(conn) + send_get_lightfv(request0, conn) } -#[derive(Debug, Clone, PartialEq)] -pub struct GetLightfvReply { - pub sequence: u16, - pub length: u32, - pub datum: Float32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetLightivRequest { - pub context_tag: ContextTag, - pub light: u32, - pub pname: u32, -} -impl GetLightivRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetLightivReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_lightiv<'c, Conn>(req: GetLightivRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetLightivRequest {} pub fn get_lightiv(conn: &Conn, context_tag: ContextTag, light: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -6129,130 +1095,17 @@ where light, pname, }; - request0.send(conn) + send_get_lightiv(request0, conn) } -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetLightivReply { - pub sequence: u16, - pub length: u32, - pub datum: i32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetMapdvRequest { - pub context_tag: ContextTag, - pub target: u32, - pub query: u32, -} -impl GetMapdvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetMapdvReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_mapdv<'c, Conn>(req: GetMapdvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetMapdvRequest {} pub fn get_mapdv(conn: &Conn, context_tag: ContextTag, target: u32, query: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -6262,130 +1115,17 @@ where target, query, }; - request0.send(conn) + send_get_mapdv(request0, conn) } -#[derive(Debug, Clone, PartialEq)] -pub struct GetMapdvReply { - pub sequence: u16, - pub length: u32, - pub datum: Float64, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetMapfvRequest { - pub context_tag: ContextTag, - pub target: u32, - pub query: u32, -} -impl GetMapfvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetMapfvReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_mapfv<'c, Conn>(req: GetMapfvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetMapfvRequest {} pub fn get_mapfv(conn: &Conn, context_tag: ContextTag, target: u32, query: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -6395,130 +1135,17 @@ where target, query, }; - request0.send(conn) + send_get_mapfv(request0, conn) } -#[derive(Debug, Clone, PartialEq)] -pub struct GetMapfvReply { - pub sequence: u16, - pub length: u32, - pub datum: Float32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetMapivRequest { - pub context_tag: ContextTag, - pub target: u32, - pub query: u32, -} -impl GetMapivRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetMapivReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_mapiv<'c, Conn>(req: GetMapivRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetMapivRequest {} pub fn get_mapiv(conn: &Conn, context_tag: ContextTag, target: u32, query: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -6528,130 +1155,17 @@ where target, query, }; - request0.send(conn) + send_get_mapiv(request0, conn) } -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetMapivReply { - pub sequence: u16, - pub length: u32, - pub datum: i32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetMaterialfvRequest { - pub context_tag: ContextTag, - pub face: u32, - pub pname: u32, -} -impl GetMaterialfvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetMaterialfvReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_materialfv<'c, Conn>(req: GetMaterialfvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetMaterialfvRequest {} pub fn get_materialfv(conn: &Conn, context_tag: ContextTag, face: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -6661,130 +1175,17 @@ where face, pname, }; - request0.send(conn) + send_get_materialfv(request0, conn) } -#[derive(Debug, Clone, PartialEq)] -pub struct GetMaterialfvReply { - pub sequence: u16, - pub length: u32, - pub datum: Float32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetMaterialivRequest { - pub context_tag: ContextTag, - pub face: u32, - pub pname: u32, -} -impl GetMaterialivRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetMaterialivReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_materialiv<'c, Conn>(req: GetMaterialivRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetMaterialivRequest {} pub fn get_materialiv(conn: &Conn, context_tag: ContextTag, face: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -6794,122 +1195,17 @@ where face, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetMaterialivReply { - pub sequence: u16, - pub length: u32, - pub datum: i32, - pub data: Vec, -} -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 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() - } + send_get_materialiv(request0, conn) } -/// Opcode for the GetPixelMapfv request -pub const GET_PIXEL_MAPFV_REQUEST: u8 = 125; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetPixelMapfvRequest { - pub context_tag: ContextTag, - pub map: u32, -} -impl GetPixelMapfvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetPixelMapfvReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_pixel_mapfv<'c, Conn>(req: GetPixelMapfvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetPixelMapfvRequest {} pub fn get_pixel_mapfv(conn: &Conn, context_tag: ContextTag, map: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -6918,122 +1214,17 @@ where context_tag, map, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq)] -pub struct GetPixelMapfvReply { - pub sequence: u16, - pub length: u32, - pub datum: Float32, - pub data: Vec, -} -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 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() - } + send_get_pixel_mapfv(request0, conn) } -/// Opcode for the GetPixelMapuiv request -pub const GET_PIXEL_MAPUIV_REQUEST: u8 = 126; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetPixelMapuivRequest { - pub context_tag: ContextTag, - pub map: u32, -} -impl GetPixelMapuivRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetPixelMapuivReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_pixel_mapuiv<'c, Conn>(req: GetPixelMapuivRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetPixelMapuivRequest {} pub fn get_pixel_mapuiv(conn: &Conn, context_tag: ContextTag, map: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -7042,122 +1233,17 @@ where context_tag, map, }; - request0.send(conn) + send_get_pixel_mapuiv(request0, conn) } -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetPixelMapuivReply { - pub sequence: u16, - pub length: u32, - pub datum: u32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetPixelMapusvRequest { - pub context_tag: ContextTag, - pub map: u32, -} -impl GetPixelMapusvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetPixelMapusvReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_pixel_mapusv<'c, Conn>(req: GetPixelMapusvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetPixelMapusvRequest {} pub fn get_pixel_mapusv(conn: &Conn, context_tag: ContextTag, map: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -7166,122 +1252,17 @@ where context_tag, map, }; - request0.send(conn) + send_get_pixel_mapusv(request0, conn) } -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetPixelMapusvReply { - pub sequence: u16, - pub length: u32, - pub datum: u16, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetPolygonStippleRequest { - pub context_tag: ContextTag, - pub lsb_first: bool, -} -impl GetPolygonStippleRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetPolygonStippleReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_polygon_stipple<'c, Conn>(req: GetPolygonStippleRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetPolygonStippleRequest {} pub fn get_polygon_stipple(conn: &Conn, context_tag: ContextTag, lsb_first: bool) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -7290,119 +1271,17 @@ where context_tag, lsb_first, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetPolygonStippleReply { - pub sequence: u16, - pub data: Vec, -} -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, 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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetStringRequest { - pub context_tag: ContextTag, - pub name: u32, -} -impl GetStringRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_polygon_stipple(request0, conn) } -impl Request for GetStringRequest { - type Reply = GetStringReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_string<'c, Conn>(req: GetStringRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetStringRequest {} pub fn get_string(conn: &Conn, context_tag: ContextTag, name: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -7411,129 +1290,17 @@ where context_tag, name, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetStringReply { - pub sequence: u16, - pub length: u32, - pub string: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetTexEnvfvRequest { - pub context_tag: ContextTag, - pub target: u32, - pub pname: u32, -} -impl GetTexEnvfvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_string(request0, conn) } -impl Request for GetTexEnvfvRequest { - type Reply = GetTexEnvfvReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_tex_envfv<'c, Conn>(req: GetTexEnvfvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetTexEnvfvRequest {} pub fn get_tex_envfv(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -7543,130 +1310,17 @@ where target, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq)] -pub struct GetTexEnvfvReply { - pub sequence: u16, - pub length: u32, - pub datum: Float32, - pub data: Vec, -} -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)) - } + send_get_tex_envfv(request0, conn) } -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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetTexEnvivRequest { - pub context_tag: ContextTag, - pub target: u32, - pub pname: u32, -} -impl GetTexEnvivRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetTexEnvivReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_tex_enviv<'c, Conn>(req: GetTexEnvivRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetTexEnvivRequest {} pub fn get_tex_enviv(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -7676,130 +1330,17 @@ where target, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetTexEnvivReply { - pub sequence: u16, - pub length: u32, - pub datum: i32, - pub data: Vec, -} -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 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() - } + send_get_tex_enviv(request0, conn) } -/// Opcode for the GetTexGendv request -pub const GET_TEX_GENDV_REQUEST: u8 = 132; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetTexGendvRequest { - pub context_tag: ContextTag, - pub coord: u32, - pub pname: u32, -} -impl GetTexGendvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetTexGendvReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_tex_gendv<'c, Conn>(req: GetTexGendvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetTexGendvRequest {} pub fn get_tex_gendv(conn: &Conn, context_tag: ContextTag, coord: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -7809,263 +1350,37 @@ where coord, pname, }; - request0.send(conn) + send_get_tex_gendv(request0, conn) } -#[derive(Debug, Clone, PartialEq)] -pub struct GetTexGendvReply { - pub sequence: u16, - pub length: u32, - pub datum: Float64, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetTexGenfvRequest { - pub context_tag: ContextTag, - pub coord: u32, - pub pname: u32, -} -impl GetTexGenfvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetTexGenfvReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(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 {} -pub fn get_tex_genfv(conn: &Conn, context_tag: ContextTag, coord: u32, pname: u32) -> Result, ConnectionError> +fn send_get_tex_genfv<'c, Conn>(req: GetTexGenfvRequest, conn: &'c Conn) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, { - let request0 = GetTexGenfvRequest { - context_tag, - coord, - pname, - }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq)] -pub struct GetTexGenfvReply { - pub sequence: u16, - pub length: u32, - pub datum: Float32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetTexGenivRequest { - pub context_tag: ContextTag, - pub coord: u32, - pub pname: u32, -} -impl GetTexGenivRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) +} +pub fn get_tex_genfv(conn: &Conn, context_tag: ContextTag, coord: u32, pname: u32) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let request0 = GetTexGenfvRequest { + context_tag, + coord, + pname, + }; + send_get_tex_genfv(request0, conn) } -impl Request for GetTexGenivRequest { - type Reply = GetTexGenivReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_tex_geniv<'c, Conn>(req: GetTexGenivRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetTexGenivRequest {} pub fn get_tex_geniv(conn: &Conn, context_tag: ContextTag, coord: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -8075,154 +1390,17 @@ where coord, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetTexGenivReply { - pub sequence: u16, - pub length: u32, - pub datum: i32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetTexImageRequest { - pub context_tag: ContextTag, - pub target: u32, - pub level: i32, - pub format: u32, - pub type_: u32, - pub swap_bytes: bool, -} -impl GetTexImageRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_tex_geniv(request0, conn) } -impl Request for GetTexImageRequest { - type Reply = GetTexImageReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_tex_image<'c, Conn>(req: GetTexImageRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetTexImageRequest {} pub fn get_tex_image(conn: &Conn, context_tag: ContextTag, target: u32, level: i32, format: u32, type_: u32, swap_bytes: bool) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -8235,134 +1413,17 @@ where type_, swap_bytes, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetTexImageReply { - pub sequence: u16, - pub width: i32, - pub height: i32, - pub depth: i32, - pub data: Vec, -} -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, 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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetTexParameterfvRequest { - pub context_tag: ContextTag, - pub target: u32, - pub pname: u32, -} -impl GetTexParameterfvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_tex_image(request0, conn) } -impl Request for GetTexParameterfvRequest { - type Reply = GetTexParameterfvReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_tex_parameterfv<'c, Conn>(req: GetTexParameterfvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetTexParameterfvRequest {} pub fn get_tex_parameterfv(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -8372,130 +1433,17 @@ where target, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq)] -pub struct GetTexParameterfvReply { - pub sequence: u16, - pub length: u32, - pub datum: Float32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetTexParameterivRequest { - pub context_tag: ContextTag, - pub target: u32, - pub pname: u32, -} -impl GetTexParameterivRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_tex_parameterfv(request0, conn) } -impl Request for GetTexParameterivRequest { - type Reply = GetTexParameterivReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_tex_parameteriv<'c, Conn>(req: GetTexParameterivRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetTexParameterivRequest {} pub fn get_tex_parameteriv(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -8505,138 +1453,17 @@ where target, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetTexParameterivReply { - pub sequence: u16, - pub length: u32, - pub datum: i32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetTexLevelParameterfvRequest { - pub context_tag: ContextTag, - pub target: u32, - pub level: i32, - pub pname: u32, -} -impl GetTexLevelParameterfvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_tex_parameteriv(request0, conn) } -impl Request for GetTexLevelParameterfvRequest { - type Reply = GetTexLevelParameterfvReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_tex_level_parameterfv<'c, Conn>(req: GetTexLevelParameterfvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetTexLevelParameterfvRequest {} pub fn get_tex_level_parameterfv(conn: &Conn, context_tag: ContextTag, target: u32, level: i32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -8647,138 +1474,17 @@ where level, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq)] -pub struct GetTexLevelParameterfvReply { - pub sequence: u16, - pub length: u32, - pub datum: Float32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetTexLevelParameterivRequest { - pub context_tag: ContextTag, - pub target: u32, - pub level: i32, - pub pname: u32, -} -impl GetTexLevelParameterivRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_tex_level_parameterfv(request0, conn) } -impl Request for GetTexLevelParameterivRequest { - type Reply = GetTexLevelParameterivReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_tex_level_parameteriv<'c, Conn>(req: GetTexLevelParameterivRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetTexLevelParameterivRequest {} pub fn get_tex_level_parameteriv(conn: &Conn, context_tag: ContextTag, target: u32, level: i32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -8789,122 +1495,17 @@ where level, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetTexLevelParameterivReply { - pub sequence: u16, - pub length: u32, - pub datum: i32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct IsEnabledRequest { - pub context_tag: ContextTag, - pub capability: u32, -} -impl IsEnabledRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_tex_level_parameteriv(request0, conn) } -impl Request for IsEnabledRequest { - type Reply = IsEnabledReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_is_enabled<'c, Conn>(req: IsEnabledRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for IsEnabledRequest {} pub fn is_enabled(conn: &Conn, context_tag: ContextTag, capability: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -8913,102 +1514,17 @@ where context_tag, capability, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct IsEnabledReply { - pub sequence: u16, - pub length: u32, - pub ret_val: Bool32, -} -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)) - } -} - -/// Opcode for the IsList request -pub const IS_LIST_REQUEST: u8 = 141; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct IsListRequest { - pub context_tag: ContextTag, - pub list: u32, -} -impl IsListRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_is_enabled(request0, conn) } -impl Request for IsListRequest { - type Reply = IsListReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_is_list<'c, Conn>(req: IsListRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for IsListRequest {} pub fn is_list(conn: &Conn, context_tag: ContextTag, list: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -9017,94 +1533,17 @@ where context_tag, list, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct IsListReply { - pub sequence: u16, - pub length: u32, - pub ret_val: Bool32, -} -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)) - } + send_is_list(request0, conn) } -/// Opcode for the Flush request -pub const FLUSH_REQUEST: u8 = 142; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct FlushRequest { - pub context_tag: ContextTag, -} -impl FlushRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_flush<'c, Conn>(req: FlushRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl crate::x11_utils::VoidRequest for FlushRequest {} pub fn flush(conn: &Conn, context_tag: ContextTag) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -9112,90 +1551,17 @@ where let request0 = FlushRequest { context_tag, }; - request0.send(conn) -} - -/// Opcode for the AreTexturesResident request -pub const ARE_TEXTURES_RESIDENT_REQUEST: u8 = 143; -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct AreTexturesResidentRequest<'input> { - pub context_tag: ContextTag, - pub textures: Cow<'input, [u32]>, -} -impl<'input> AreTexturesResidentRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into(), textures_bytes.into(), padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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()), - } - } + send_flush(request0, conn) } -impl<'input> Request for AreTexturesResidentRequest<'input> { - type Reply = AreTexturesResidentReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_are_textures_resident<'c, Conn>(req: AreTexturesResidentRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl<'input> crate::x11_utils::ReplyRequest for AreTexturesResidentRequest<'input> {} pub fn are_textures_resident<'c, 'input, Conn>(conn: &'c Conn, context_tag: ContextTag, textures: &'input [u32]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -9204,133 +1570,17 @@ where context_tag, textures: Cow::Borrowed(textures), }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct AreTexturesResidentReply { - pub sequence: u16, - pub ret_val: Bool32, - pub data: Vec, -} -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, 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 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(Debug, Clone, PartialEq, Eq)] -pub struct DeleteTexturesRequest<'input> { - pub context_tag: ContextTag, - pub textures: Cow<'input, [u32]>, -} -impl<'input> DeleteTexturesRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into(), textures_bytes.into(), padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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()), - } - } + send_are_textures_resident(request0, conn) } -impl<'input> Request for DeleteTexturesRequest<'input> { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_delete_textures<'c, Conn>(req: DeleteTexturesRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl<'input> crate::x11_utils::VoidRequest for DeleteTexturesRequest<'input> {} pub fn delete_textures<'c, 'input, Conn>(conn: &'c Conn, context_tag: ContextTag, textures: &'input [u32]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -9339,77 +1589,17 @@ where context_tag, textures: Cow::Borrowed(textures), }; - request0.send(conn) + send_delete_textures(request0, conn) } -/// Opcode for the GenTextures request -pub const GEN_TEXTURES_REQUEST: u8 = 145; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GenTexturesRequest { - pub context_tag: ContextTag, - pub n: i32, -} -impl GenTexturesRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GenTexturesReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_gen_textures<'c, Conn>(req: GenTexturesRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GenTexturesRequest {} pub fn gen_textures(conn: &Conn, context_tag: ContextTag, n: i32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -9418,117 +1608,17 @@ where context_tag, n, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GenTexturesReply { - pub sequence: u16, - pub data: Vec, -} -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 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() - } + send_gen_textures(request0, conn) } -/// Opcode for the IsTexture request -pub const IS_TEXTURE_REQUEST: u8 = 146; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct IsTextureRequest { - pub context_tag: ContextTag, - pub texture: u32, -} -impl IsTextureRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = IsTextureReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_is_texture<'c, Conn>(req: IsTextureRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for IsTextureRequest {} pub fn is_texture(conn: &Conn, context_tag: ContextTag, texture: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -9537,126 +1627,17 @@ where context_tag, texture, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct IsTextureReply { - pub sequence: u16, - pub length: u32, - pub ret_val: Bool32, -} -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)) - } -} - -/// Opcode for the GetColorTable request -pub const GET_COLOR_TABLE_REQUEST: u8 = 147; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetColorTableRequest { - pub context_tag: ContextTag, - pub target: u32, - pub format: u32, - pub type_: u32, - pub swap_bytes: bool, -} -impl GetColorTableRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_is_texture(request0, conn) } -impl Request for GetColorTableRequest { - type Reply = GetColorTableReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_color_table<'c, Conn>(req: GetColorTableRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetColorTableRequest {} pub fn get_color_table(conn: &Conn, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -9668,130 +1649,17 @@ where type_, swap_bytes, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetColorTableReply { - pub sequence: u16, - pub width: i32, - pub data: Vec, -} -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, 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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetColorTableParameterfvRequest { - pub context_tag: ContextTag, - pub target: u32, - pub pname: u32, -} -impl GetColorTableParameterfvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_color_table(request0, conn) } -impl Request for GetColorTableParameterfvRequest { - type Reply = GetColorTableParameterfvReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_color_table_parameterfv<'c, Conn>(req: GetColorTableParameterfvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetColorTableParameterfvRequest {} pub fn get_color_table_parameterfv(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -9801,130 +1669,17 @@ where target, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq)] -pub struct GetColorTableParameterfvReply { - pub sequence: u16, - pub length: u32, - pub datum: Float32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetColorTableParameterivRequest { - pub context_tag: ContextTag, - pub target: u32, - pub pname: u32, -} -impl GetColorTableParameterivRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_color_table_parameterfv(request0, conn) } -impl Request for GetColorTableParameterivRequest { - type Reply = GetColorTableParameterivReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_color_table_parameteriv<'c, Conn>(req: GetColorTableParameterivRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetColorTableParameterivRequest {} pub fn get_color_table_parameteriv(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -9934,146 +1689,17 @@ where target, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetColorTableParameterivReply { - pub sequence: u16, - pub length: u32, - pub datum: i32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetConvolutionFilterRequest { - pub context_tag: ContextTag, - pub target: u32, - pub format: u32, - pub type_: u32, - pub swap_bytes: bool, -} -impl GetConvolutionFilterRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_color_table_parameteriv(request0, conn) } -impl Request for GetConvolutionFilterRequest { - type Reply = GetConvolutionFilterReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_convolution_filter<'c, Conn>(req: GetConvolutionFilterRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetConvolutionFilterRequest {} pub fn get_convolution_filter(conn: &Conn, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -10085,132 +1711,17 @@ where type_, swap_bytes, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetConvolutionFilterReply { - pub sequence: u16, - pub width: i32, - pub height: i32, - pub data: Vec, -} -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, 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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetConvolutionParameterfvRequest { - pub context_tag: ContextTag, - pub target: u32, - pub pname: u32, -} -impl GetConvolutionParameterfvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_convolution_filter(request0, conn) } -impl Request for GetConvolutionParameterfvRequest { - type Reply = GetConvolutionParameterfvReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_convolution_parameterfv<'c, Conn>(req: GetConvolutionParameterfvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetConvolutionParameterfvRequest {} pub fn get_convolution_parameterfv(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -10220,130 +1731,17 @@ where target, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq)] -pub struct GetConvolutionParameterfvReply { - pub sequence: u16, - pub length: u32, - pub datum: Float32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetConvolutionParameterivRequest { - pub context_tag: ContextTag, - pub target: u32, - pub pname: u32, -} -impl GetConvolutionParameterivRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_convolution_parameterfv(request0, conn) } -impl Request for GetConvolutionParameterivRequest { - type Reply = GetConvolutionParameterivReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_convolution_parameteriv<'c, Conn>(req: GetConvolutionParameterivRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetConvolutionParameterivRequest {} pub fn get_convolution_parameteriv(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -10353,146 +1751,17 @@ where target, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetConvolutionParameterivReply { - pub sequence: u16, - pub length: u32, - pub datum: i32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetSeparableFilterRequest { - pub context_tag: ContextTag, - pub target: u32, - pub format: u32, - pub type_: u32, - pub swap_bytes: bool, -} -impl GetSeparableFilterRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_convolution_parameteriv(request0, conn) } -impl Request for GetSeparableFilterRequest { - type Reply = GetSeparableFilterReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_separable_filter<'c, Conn>(req: GetSeparableFilterRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetSeparableFilterRequest {} pub fn get_separable_filter(conn: &Conn, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -10504,152 +1773,17 @@ where type_, swap_bytes, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetSeparableFilterReply { - pub sequence: u16, - pub row_w: i32, - pub col_h: i32, - pub rows_and_cols: Vec, -} -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, 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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetHistogramRequest { - pub context_tag: ContextTag, - pub target: u32, - pub format: u32, - pub type_: u32, - pub swap_bytes: bool, - pub reset: bool, -} -impl GetHistogramRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_separable_filter(request0, conn) } -impl Request for GetHistogramRequest { - type Reply = GetHistogramReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_histogram<'c, Conn>(req: GetHistogramRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetHistogramRequest {} pub fn get_histogram(conn: &Conn, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool, reset: bool) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -10662,130 +1796,17 @@ where swap_bytes, reset, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetHistogramReply { - pub sequence: u16, - pub width: i32, - pub data: Vec, -} -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, 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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetHistogramParameterfvRequest { - pub context_tag: ContextTag, - pub target: u32, - pub pname: u32, -} -impl GetHistogramParameterfvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_histogram(request0, conn) } -impl Request for GetHistogramParameterfvRequest { - type Reply = GetHistogramParameterfvReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_histogram_parameterfv<'c, Conn>(req: GetHistogramParameterfvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetHistogramParameterfvRequest {} pub fn get_histogram_parameterfv(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -10795,130 +1816,17 @@ where target, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq)] -pub struct GetHistogramParameterfvReply { - pub sequence: u16, - pub length: u32, - pub datum: Float32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetHistogramParameterivRequest { - pub context_tag: ContextTag, - pub target: u32, - pub pname: u32, -} -impl GetHistogramParameterivRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_histogram_parameterfv(request0, conn) } -impl Request for GetHistogramParameterivRequest { - type Reply = GetHistogramParameterivReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_histogram_parameteriv<'c, Conn>(req: GetHistogramParameterivRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetHistogramParameterivRequest {} pub fn get_histogram_parameteriv(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -10928,150 +1836,17 @@ where target, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetHistogramParameterivReply { - pub sequence: u16, - pub length: u32, - pub datum: i32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetMinmaxRequest { - pub context_tag: ContextTag, - pub target: u32, - pub format: u32, - pub type_: u32, - pub swap_bytes: bool, - pub reset: bool, -} -impl GetMinmaxRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_histogram_parameteriv(request0, conn) } -impl Request for GetMinmaxRequest { - type Reply = GetMinmaxReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_minmax<'c, Conn>(req: GetMinmaxRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetMinmaxRequest {} pub fn get_minmax(conn: &Conn, context_tag: ContextTag, target: u32, format: u32, type_: u32, swap_bytes: bool, reset: bool) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -11084,127 +1859,17 @@ where swap_bytes, reset, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetMinmaxReply { - pub sequence: u16, - pub data: Vec, -} -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, 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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetMinmaxParameterfvRequest { - pub context_tag: ContextTag, - pub target: u32, - pub pname: u32, -} -impl GetMinmaxParameterfvRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_minmax(request0, conn) } -impl Request for GetMinmaxParameterfvRequest { - type Reply = GetMinmaxParameterfvReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_minmax_parameterfv<'c, Conn>(req: GetMinmaxParameterfvRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetMinmaxParameterfvRequest {} pub fn get_minmax_parameterfv(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -11214,130 +1879,17 @@ where target, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq)] -pub struct GetMinmaxParameterfvReply { - pub sequence: u16, - pub length: u32, - pub datum: Float32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetMinmaxParameterivRequest { - pub context_tag: ContextTag, - pub target: u32, - pub pname: u32, -} -impl GetMinmaxParameterivRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_minmax_parameterfv(request0, conn) } -impl Request for GetMinmaxParameterivRequest { - type Reply = GetMinmaxParameterivReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_minmax_parameteriv<'c, Conn>(req: GetMinmaxParameterivRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetMinmaxParameterivRequest {} pub fn get_minmax_parameteriv(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -11347,130 +1899,17 @@ where target, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetMinmaxParameterivReply { - pub sequence: u16, - pub length: u32, - pub datum: i32, - pub data: Vec, -} -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 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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetCompressedTexImageARBRequest { - pub context_tag: ContextTag, - pub target: u32, - pub level: i32, -} -impl GetCompressedTexImageARBRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_get_minmax_parameteriv(request0, conn) } -impl Request for GetCompressedTexImageARBRequest { - type Reply = GetCompressedTexImageARBReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_compressed_tex_image_arb<'c, Conn>(req: GetCompressedTexImageARBRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetCompressedTexImageARBRequest {} pub fn get_compressed_tex_image_arb(conn: &Conn, context_tag: ContextTag, target: u32, level: i32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -11480,135 +1919,17 @@ where target, level, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetCompressedTexImageARBReply { - pub sequence: u16, - pub size: i32, - pub data: Vec, -} -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, 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 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(Debug, Clone, PartialEq, Eq)] -pub struct DeleteQueriesARBRequest<'input> { - pub context_tag: ContextTag, - pub ids: Cow<'input, [u32]>, -} -impl<'input> DeleteQueriesARBRequest<'input> { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into(), ids_bytes.into(), padding0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_without_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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()), - } - } + send_get_compressed_tex_image_arb(request0, conn) } -impl<'input> Request for DeleteQueriesARBRequest<'input> { - type Reply = (); - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_delete_queries_arb<'c, Conn>(req: DeleteQueriesARBRequest<'_>, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_without_reply(&slices, fds) } -impl<'input> crate::x11_utils::VoidRequest for DeleteQueriesARBRequest<'input> {} pub fn delete_queries_arb<'c, 'input, Conn>(conn: &'c Conn, context_tag: ContextTag, ids: &'input [u32]) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -11617,77 +1938,17 @@ where context_tag, ids: Cow::Borrowed(ids), }; - request0.send(conn) -} - -/// Opcode for the GenQueriesARB request -pub const GEN_QUERIES_ARB_REQUEST: u8 = 162; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GenQueriesARBRequest { - pub context_tag: ContextTag, - pub n: i32, -} -impl GenQueriesARBRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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, - }) - } + send_delete_queries_arb(request0, conn) } -impl Request for GenQueriesARBRequest { - type Reply = GenQueriesARBReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_gen_queries_arb<'c, Conn>(req: GenQueriesARBRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GenQueriesARBRequest {} pub fn gen_queries_arb(conn: &Conn, context_tag: ContextTag, n: i32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -11696,117 +1957,17 @@ where context_tag, n, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GenQueriesARBReply { - pub sequence: u16, - pub data: Vec, -} -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)) - } + send_gen_queries_arb(request0, conn) } -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(Debug, Clone, Copy, PartialEq, Eq)] -pub struct IsQueryARBRequest { - pub context_tag: ContextTag, - pub id: u32, -} -impl IsQueryARBRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = IsQueryARBReply; - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_is_query_arb<'c, Conn>(req: IsQueryARBRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for IsQueryARBRequest {} pub fn is_query_arb(conn: &Conn, context_tag: ContextTag, id: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -11815,110 +1976,17 @@ where context_tag, id, }; - request0.send(conn) -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct IsQueryARBReply { - pub sequence: u16, - pub length: u32, - pub ret_val: Bool32, -} -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)) - } + send_is_query_arb(request0, conn) } -/// Opcode for the GetQueryivARB request -pub const GET_QUERYIV_ARB_REQUEST: u8 = 164; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetQueryivARBRequest { - pub context_tag: ContextTag, - pub target: u32, - pub pname: u32, -} -impl GetQueryivARBRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetQueryivARBReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_queryiv_arb<'c, Conn>(req: GetQueryivARBRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetQueryivARBRequest {} pub fn get_queryiv_arb(conn: &Conn, context_tag: ContextTag, target: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -11928,130 +1996,17 @@ where target, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetQueryivARBReply { - pub sequence: u16, - pub length: u32, - pub datum: i32, - pub data: Vec, -} -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 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() - } + send_get_queryiv_arb(request0, conn) } -/// Opcode for the GetQueryObjectivARB request -pub const GET_QUERY_OBJECTIV_ARB_REQUEST: u8 = 165; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetQueryObjectivARBRequest { - pub context_tag: ContextTag, - pub id: u32, - pub pname: u32, -} -impl GetQueryObjectivARBRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetQueryObjectivARBReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_query_objectiv_arb<'c, Conn>(req: GetQueryObjectivARBRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetQueryObjectivARBRequest {} pub fn get_query_objectiv_arb(conn: &Conn, context_tag: ContextTag, id: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -12061,130 +2016,17 @@ where id, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetQueryObjectivARBReply { - pub sequence: u16, - pub length: u32, - pub datum: i32, - pub data: Vec, -} -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 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() - } + send_get_query_objectiv_arb(request0, conn) } -/// Opcode for the GetQueryObjectuivARB request -pub const GET_QUERY_OBJECTUIV_ARB_REQUEST: u8 = 166; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct GetQueryObjectuivARBRequest { - pub context_tag: ContextTag, - pub id: u32, - pub pname: u32, -} -impl GetQueryObjectuivARBRequest { - /// Serialize this request into bytes for the provided connection - fn serialize_impl(self, major_opcode: u8) -> BufWithFds> { - 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()); - (vec![request0.into()], vec![]) - } - pub fn send(self, conn: &Conn) -> Result, ConnectionError> - where - Conn: RequestConnection + ?Sized, - { - let (bytes, fds) = self.serialize_impl(major_opcode(conn)?); - let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); - conn.send_request_with_reply(&slices, fds) - } - /// Parse this request given its header, its body, and any fds that go along with it - 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 { - type Reply = GetQueryObjectuivARBReply; - - const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME); - - fn serialize(self, major_opcode: u8) -> BufWithFds> { - let (bufs, fds) = self.serialize_impl(major_opcode); - // Flatten the buffers into a single vector - let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect(); - (buf, fds) - } +fn send_get_query_objectuiv_arb<'c, Conn>(req: GetQueryObjectuivARBRequest, conn: &'c Conn) -> Result, ConnectionError> +where + Conn: RequestConnection + ?Sized, +{ + let (bytes, fds) = req.serialize(major_opcode(conn)?); + let slices = bytes.iter().map(|b| IoSlice::new(&*b)).collect::>(); + conn.send_request_with_reply(&slices, fds) } -impl crate::x11_utils::ReplyRequest for GetQueryObjectuivARBRequest {} pub fn get_query_objectuiv_arb(conn: &Conn, context_tag: ContextTag, id: u32, pname: u32) -> Result, ConnectionError> where Conn: RequestConnection + ?Sized, @@ -12194,52 +2036,7 @@ where id, pname, }; - request0.send(conn) -} - -#[derive(Debug, Clone, PartialEq, Eq)] -pub struct GetQueryObjectuivARBReply { - pub sequence: u16, - pub length: u32, - pub datum: u32, - pub data: Vec, -} -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 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() - } + send_get_query_objectuiv_arb(request0, conn) } /// Extension trait defining the requests of this extension. diff --git a/src/protocol/mod.rs b/src/protocol/mod.rs index d8ad312f..b0640599 100644 --- a/src/protocol/mod.rs +++ b/src/protocol/mod.rs @@ -9,15 +9,7 @@ // 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)] - -use std::borrow::Cow; -use std::convert::TryInto; -use crate::errors::ParseError; -use crate::utils::RawFdContainer; -use crate::x11_utils::{TryParse, X11Error}; -use crate::x11_utils::{ExtInfoProvider, ReplyParsingFunction, Request as RequestTrait, RequestHeader}; - +#![allow(clippy::needless_borrow, clippy::needless_lifetimes)] pub mod xproto; pub mod bigreq; #[cfg(feature = "composite")] @@ -77,9250 +69,7 @@ pub mod xv; #[cfg(feature = "xvmc")] pub mod xvmc; -/// 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 = "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 = "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), - 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 = "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 = "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)] - 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 = "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)?)), - _ => (), - } - } - #[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)?)), - _ => (), - } - } - 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)?)), - _ => (), - } - } - #[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)?)), - _ => (), - } - } - #[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(xproto::GetWindowAttributesRequest::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(xproto::GetGeometryRequest::parse_reply), - Request::QueryTree(_) => Some(xproto::QueryTreeRequest::parse_reply), - Request::InternAtom(_) => Some(xproto::InternAtomRequest::parse_reply), - Request::GetAtomName(_) => Some(xproto::GetAtomNameRequest::parse_reply), - Request::ChangeProperty(_) => None, - Request::DeleteProperty(_) => None, - Request::GetProperty(_) => Some(xproto::GetPropertyRequest::parse_reply), - Request::ListProperties(_) => Some(xproto::ListPropertiesRequest::parse_reply), - Request::SetSelectionOwner(_) => None, - Request::GetSelectionOwner(_) => Some(xproto::GetSelectionOwnerRequest::parse_reply), - Request::ConvertSelection(_) => None, - Request::SendEvent(_) => None, - Request::GrabPointer(_) => Some(xproto::GrabPointerRequest::parse_reply), - Request::UngrabPointer(_) => None, - Request::GrabButton(_) => None, - Request::UngrabButton(_) => None, - Request::ChangeActivePointerGrab(_) => None, - Request::GrabKeyboard(_) => Some(xproto::GrabKeyboardRequest::parse_reply), - Request::UngrabKeyboard(_) => None, - Request::GrabKey(_) => None, - Request::UngrabKey(_) => None, - Request::AllowEvents(_) => None, - Request::GrabServer(_) => None, - Request::UngrabServer(_) => None, - Request::QueryPointer(_) => Some(xproto::QueryPointerRequest::parse_reply), - Request::GetMotionEvents(_) => Some(xproto::GetMotionEventsRequest::parse_reply), - Request::TranslateCoordinates(_) => Some(xproto::TranslateCoordinatesRequest::parse_reply), - Request::WarpPointer(_) => None, - Request::SetInputFocus(_) => None, - Request::GetInputFocus(_) => Some(xproto::GetInputFocusRequest::parse_reply), - Request::QueryKeymap(_) => Some(xproto::QueryKeymapRequest::parse_reply), - Request::OpenFont(_) => None, - Request::CloseFont(_) => None, - Request::QueryFont(_) => Some(xproto::QueryFontRequest::parse_reply), - Request::QueryTextExtents(_) => Some(xproto::QueryTextExtentsRequest::parse_reply), - Request::ListFonts(_) => Some(xproto::ListFontsRequest::parse_reply), - Request::ListFontsWithInfo(_) => Some(xproto::ListFontsWithInfoRequest::parse_reply), - Request::SetFontPath(_) => None, - Request::GetFontPath(_) => Some(xproto::GetFontPathRequest::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(xproto::GetImageRequest::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(xproto::ListInstalledColormapsRequest::parse_reply), - Request::AllocColor(_) => Some(xproto::AllocColorRequest::parse_reply), - Request::AllocNamedColor(_) => Some(xproto::AllocNamedColorRequest::parse_reply), - Request::AllocColorCells(_) => Some(xproto::AllocColorCellsRequest::parse_reply), - Request::AllocColorPlanes(_) => Some(xproto::AllocColorPlanesRequest::parse_reply), - Request::FreeColors(_) => None, - Request::StoreColors(_) => None, - Request::StoreNamedColor(_) => None, - Request::QueryColors(_) => Some(xproto::QueryColorsRequest::parse_reply), - Request::LookupColor(_) => Some(xproto::LookupColorRequest::parse_reply), - Request::CreateCursor(_) => None, - Request::CreateGlyphCursor(_) => None, - Request::FreeCursor(_) => None, - Request::RecolorCursor(_) => None, - Request::QueryBestSize(_) => Some(xproto::QueryBestSizeRequest::parse_reply), - Request::QueryExtension(_) => Some(xproto::QueryExtensionRequest::parse_reply), - Request::ListExtensions(_) => Some(xproto::ListExtensionsRequest::parse_reply), - Request::ChangeKeyboardMapping(_) => None, - Request::GetKeyboardMapping(_) => Some(xproto::GetKeyboardMappingRequest::parse_reply), - Request::ChangeKeyboardControl(_) => None, - Request::GetKeyboardControl(_) => Some(xproto::GetKeyboardControlRequest::parse_reply), - Request::Bell(_) => None, - Request::ChangePointerControl(_) => None, - Request::GetPointerControl(_) => Some(xproto::GetPointerControlRequest::parse_reply), - Request::SetScreenSaver(_) => None, - Request::GetScreenSaver(_) => Some(xproto::GetScreenSaverRequest::parse_reply), - Request::ChangeHosts(_) => None, - Request::ListHosts(_) => Some(xproto::ListHostsRequest::parse_reply), - Request::SetAccessControl(_) => None, - Request::SetCloseDownMode(_) => None, - Request::KillClient(_) => None, - Request::RotateProperties(_) => None, - Request::ForceScreenSaver(_) => None, - Request::SetPointerMapping(_) => Some(xproto::SetPointerMappingRequest::parse_reply), - Request::GetPointerMapping(_) => Some(xproto::GetPointerMappingRequest::parse_reply), - Request::SetModifierMapping(_) => Some(xproto::SetModifierMappingRequest::parse_reply), - Request::GetModifierMapping(_) => Some(xproto::GetModifierMappingRequest::parse_reply), - Request::NoOperation(_) => None, - Request::BigreqEnable(_) => Some(bigreq::EnableRequest::parse_reply), - #[cfg(feature = "composite")] - Request::CompositeQueryVersion(_) => Some(composite::QueryVersionRequest::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(composite::GetOverlayWindowRequest::parse_reply), - #[cfg(feature = "composite")] - Request::CompositeReleaseOverlayWindow(_) => None, - #[cfg(feature = "damage")] - Request::DamageQueryVersion(_) => Some(damage::QueryVersionRequest::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 = "dpms")] - Request::DpmsGetVersion(_) => Some(dpms::GetVersionRequest::parse_reply), - #[cfg(feature = "dpms")] - Request::DpmsCapable(_) => Some(dpms::CapableRequest::parse_reply), - #[cfg(feature = "dpms")] - Request::DpmsGetTimeouts(_) => Some(dpms::GetTimeoutsRequest::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(dpms::InfoRequest::parse_reply), - #[cfg(feature = "dri2")] - Request::Dri2QueryVersion(_) => Some(dri2::QueryVersionRequest::parse_reply), - #[cfg(feature = "dri2")] - Request::Dri2Connect(_) => Some(dri2::ConnectRequest::parse_reply), - #[cfg(feature = "dri2")] - Request::Dri2Authenticate(_) => Some(dri2::AuthenticateRequest::parse_reply), - #[cfg(feature = "dri2")] - Request::Dri2CreateDrawable(_) => None, - #[cfg(feature = "dri2")] - Request::Dri2DestroyDrawable(_) => None, - #[cfg(feature = "dri2")] - Request::Dri2GetBuffers(_) => Some(dri2::GetBuffersRequest::parse_reply), - #[cfg(feature = "dri2")] - Request::Dri2CopyRegion(_) => Some(dri2::CopyRegionRequest::parse_reply), - #[cfg(feature = "dri2")] - Request::Dri2GetBuffersWithFormat(_) => Some(dri2::GetBuffersWithFormatRequest::parse_reply), - #[cfg(feature = "dri2")] - Request::Dri2SwapBuffers(_) => Some(dri2::SwapBuffersRequest::parse_reply), - #[cfg(feature = "dri2")] - Request::Dri2GetMSC(_) => Some(dri2::GetMSCRequest::parse_reply), - #[cfg(feature = "dri2")] - Request::Dri2WaitMSC(_) => Some(dri2::WaitMSCRequest::parse_reply), - #[cfg(feature = "dri2")] - Request::Dri2WaitSBC(_) => Some(dri2::WaitSBCRequest::parse_reply), - #[cfg(feature = "dri2")] - Request::Dri2SwapInterval(_) => None, - #[cfg(feature = "dri2")] - Request::Dri2GetParam(_) => Some(dri2::GetParamRequest::parse_reply), - #[cfg(feature = "dri3")] - Request::Dri3QueryVersion(_) => Some(dri3::QueryVersionRequest::parse_reply), - #[cfg(feature = "dri3")] - Request::Dri3Open(_) => Some(dri3::OpenRequest::parse_reply), - #[cfg(feature = "dri3")] - Request::Dri3PixmapFromBuffer(_) => None, - #[cfg(feature = "dri3")] - Request::Dri3BufferFromPixmap(_) => Some(dri3::BufferFromPixmapRequest::parse_reply), - #[cfg(feature = "dri3")] - Request::Dri3FenceFromFD(_) => None, - #[cfg(feature = "dri3")] - Request::Dri3FDFromFence(_) => Some(dri3::FDFromFenceRequest::parse_reply), - #[cfg(feature = "dri3")] - Request::Dri3GetSupportedModifiers(_) => Some(dri3::GetSupportedModifiersRequest::parse_reply), - #[cfg(feature = "dri3")] - Request::Dri3PixmapFromBuffers(_) => None, - #[cfg(feature = "dri3")] - Request::Dri3BuffersFromPixmap(_) => Some(dri3::BuffersFromPixmapRequest::parse_reply), - Request::GeQueryVersion(_) => Some(ge::QueryVersionRequest::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(glx::MakeCurrentRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxIsDirect(_) => Some(glx::IsDirectRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxQueryVersion(_) => Some(glx::QueryVersionRequest::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(glx::GetVisualConfigsRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxDestroyGLXPixmap(_) => None, - #[cfg(feature = "glx")] - Request::GlxVendorPrivate(_) => None, - #[cfg(feature = "glx")] - Request::GlxVendorPrivateWithReply(_) => Some(glx::VendorPrivateWithReplyRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxQueryExtensionsString(_) => Some(glx::QueryExtensionsStringRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxQueryServerString(_) => Some(glx::QueryServerStringRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxClientInfo(_) => None, - #[cfg(feature = "glx")] - Request::GlxGetFBConfigs(_) => Some(glx::GetFBConfigsRequest::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(glx::QueryContextRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxMakeContextCurrent(_) => Some(glx::MakeContextCurrentRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxCreatePbuffer(_) => None, - #[cfg(feature = "glx")] - Request::GlxDestroyPbuffer(_) => None, - #[cfg(feature = "glx")] - Request::GlxGetDrawableAttributes(_) => Some(glx::GetDrawableAttributesRequest::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(glx::GenListsRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxFeedbackBuffer(_) => None, - #[cfg(feature = "glx")] - Request::GlxSelectBuffer(_) => None, - #[cfg(feature = "glx")] - Request::GlxRenderMode(_) => Some(glx::RenderModeRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxFinish(_) => Some(glx::FinishRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxPixelStoref(_) => None, - #[cfg(feature = "glx")] - Request::GlxPixelStorei(_) => None, - #[cfg(feature = "glx")] - Request::GlxReadPixels(_) => Some(glx::ReadPixelsRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetBooleanv(_) => Some(glx::GetBooleanvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetClipPlane(_) => Some(glx::GetClipPlaneRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetDoublev(_) => Some(glx::GetDoublevRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetError(_) => Some(glx::GetErrorRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetFloatv(_) => Some(glx::GetFloatvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetIntegerv(_) => Some(glx::GetIntegervRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetLightfv(_) => Some(glx::GetLightfvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetLightiv(_) => Some(glx::GetLightivRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetMapdv(_) => Some(glx::GetMapdvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetMapfv(_) => Some(glx::GetMapfvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetMapiv(_) => Some(glx::GetMapivRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetMaterialfv(_) => Some(glx::GetMaterialfvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetMaterialiv(_) => Some(glx::GetMaterialivRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetPixelMapfv(_) => Some(glx::GetPixelMapfvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetPixelMapuiv(_) => Some(glx::GetPixelMapuivRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetPixelMapusv(_) => Some(glx::GetPixelMapusvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetPolygonStipple(_) => Some(glx::GetPolygonStippleRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetString(_) => Some(glx::GetStringRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetTexEnvfv(_) => Some(glx::GetTexEnvfvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetTexEnviv(_) => Some(glx::GetTexEnvivRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetTexGendv(_) => Some(glx::GetTexGendvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetTexGenfv(_) => Some(glx::GetTexGenfvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetTexGeniv(_) => Some(glx::GetTexGenivRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetTexImage(_) => Some(glx::GetTexImageRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetTexParameterfv(_) => Some(glx::GetTexParameterfvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetTexParameteriv(_) => Some(glx::GetTexParameterivRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetTexLevelParameterfv(_) => Some(glx::GetTexLevelParameterfvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetTexLevelParameteriv(_) => Some(glx::GetTexLevelParameterivRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxIsEnabled(_) => Some(glx::IsEnabledRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxIsList(_) => Some(glx::IsListRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxFlush(_) => None, - #[cfg(feature = "glx")] - Request::GlxAreTexturesResident(_) => Some(glx::AreTexturesResidentRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxDeleteTextures(_) => None, - #[cfg(feature = "glx")] - Request::GlxGenTextures(_) => Some(glx::GenTexturesRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxIsTexture(_) => Some(glx::IsTextureRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetColorTable(_) => Some(glx::GetColorTableRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetColorTableParameterfv(_) => Some(glx::GetColorTableParameterfvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetColorTableParameteriv(_) => Some(glx::GetColorTableParameterivRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetConvolutionFilter(_) => Some(glx::GetConvolutionFilterRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetConvolutionParameterfv(_) => Some(glx::GetConvolutionParameterfvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetConvolutionParameteriv(_) => Some(glx::GetConvolutionParameterivRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetSeparableFilter(_) => Some(glx::GetSeparableFilterRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetHistogram(_) => Some(glx::GetHistogramRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetHistogramParameterfv(_) => Some(glx::GetHistogramParameterfvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetHistogramParameteriv(_) => Some(glx::GetHistogramParameterivRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetMinmax(_) => Some(glx::GetMinmaxRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetMinmaxParameterfv(_) => Some(glx::GetMinmaxParameterfvRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetMinmaxParameteriv(_) => Some(glx::GetMinmaxParameterivRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetCompressedTexImageARB(_) => Some(glx::GetCompressedTexImageARBRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxDeleteQueriesARB(_) => None, - #[cfg(feature = "glx")] - Request::GlxGenQueriesARB(_) => Some(glx::GenQueriesARBRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxIsQueryARB(_) => Some(glx::IsQueryARBRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetQueryivARB(_) => Some(glx::GetQueryivARBRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetQueryObjectivARB(_) => Some(glx::GetQueryObjectivARBRequest::parse_reply), - #[cfg(feature = "glx")] - Request::GlxGetQueryObjectuivARB(_) => Some(glx::GetQueryObjectuivARBRequest::parse_reply), - #[cfg(feature = "present")] - Request::PresentQueryVersion(_) => Some(present::QueryVersionRequest::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(present::QueryCapabilitiesRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrQueryVersion(_) => Some(randr::QueryVersionRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrSetScreenConfig(_) => Some(randr::SetScreenConfigRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrSelectInput(_) => None, - #[cfg(feature = "randr")] - Request::RandrGetScreenInfo(_) => Some(randr::GetScreenInfoRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrGetScreenSizeRange(_) => Some(randr::GetScreenSizeRangeRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrSetScreenSize(_) => None, - #[cfg(feature = "randr")] - Request::RandrGetScreenResources(_) => Some(randr::GetScreenResourcesRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrGetOutputInfo(_) => Some(randr::GetOutputInfoRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrListOutputProperties(_) => Some(randr::ListOutputPropertiesRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrQueryOutputProperty(_) => Some(randr::QueryOutputPropertyRequest::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(randr::GetOutputPropertyRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrCreateMode(_) => Some(randr::CreateModeRequest::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(randr::GetCrtcInfoRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrSetCrtcConfig(_) => Some(randr::SetCrtcConfigRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrGetCrtcGammaSize(_) => Some(randr::GetCrtcGammaSizeRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrGetCrtcGamma(_) => Some(randr::GetCrtcGammaRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrSetCrtcGamma(_) => None, - #[cfg(feature = "randr")] - Request::RandrGetScreenResourcesCurrent(_) => Some(randr::GetScreenResourcesCurrentRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrSetCrtcTransform(_) => None, - #[cfg(feature = "randr")] - Request::RandrGetCrtcTransform(_) => Some(randr::GetCrtcTransformRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrGetPanning(_) => Some(randr::GetPanningRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrSetPanning(_) => Some(randr::SetPanningRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrSetOutputPrimary(_) => None, - #[cfg(feature = "randr")] - Request::RandrGetOutputPrimary(_) => Some(randr::GetOutputPrimaryRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrGetProviders(_) => Some(randr::GetProvidersRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrGetProviderInfo(_) => Some(randr::GetProviderInfoRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrSetProviderOffloadSink(_) => None, - #[cfg(feature = "randr")] - Request::RandrSetProviderOutputSource(_) => None, - #[cfg(feature = "randr")] - Request::RandrListProviderProperties(_) => Some(randr::ListProviderPropertiesRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrQueryProviderProperty(_) => Some(randr::QueryProviderPropertyRequest::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(randr::GetProviderPropertyRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrGetMonitors(_) => Some(randr::GetMonitorsRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrSetMonitor(_) => None, - #[cfg(feature = "randr")] - Request::RandrDeleteMonitor(_) => None, - #[cfg(feature = "randr")] - Request::RandrCreateLease(_) => Some(randr::CreateLeaseRequest::parse_reply), - #[cfg(feature = "randr")] - Request::RandrFreeLease(_) => None, - #[cfg(feature = "record")] - Request::RecordQueryVersion(_) => Some(record::QueryVersionRequest::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(record::GetContextRequest::parse_reply), - #[cfg(feature = "record")] - Request::RecordEnableContext(_) => Some(record::EnableContextRequest::parse_reply), - #[cfg(feature = "record")] - Request::RecordDisableContext(_) => None, - #[cfg(feature = "record")] - Request::RecordFreeContext(_) => None, - #[cfg(feature = "render")] - Request::RenderQueryVersion(_) => Some(render::QueryVersionRequest::parse_reply), - #[cfg(feature = "render")] - Request::RenderQueryPictFormats(_) => Some(render::QueryPictFormatsRequest::parse_reply), - #[cfg(feature = "render")] - Request::RenderQueryPictIndexValues(_) => Some(render::QueryPictIndexValuesRequest::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(render::QueryFiltersRequest::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(res::QueryVersionRequest::parse_reply), - #[cfg(feature = "res")] - Request::ResQueryClients(_) => Some(res::QueryClientsRequest::parse_reply), - #[cfg(feature = "res")] - Request::ResQueryClientResources(_) => Some(res::QueryClientResourcesRequest::parse_reply), - #[cfg(feature = "res")] - Request::ResQueryClientPixmapBytes(_) => Some(res::QueryClientPixmapBytesRequest::parse_reply), - #[cfg(feature = "res")] - Request::ResQueryClientIds(_) => Some(res::QueryClientIdsRequest::parse_reply), - #[cfg(feature = "res")] - Request::ResQueryResourceBytes(_) => Some(res::QueryResourceBytesRequest::parse_reply), - #[cfg(feature = "screensaver")] - Request::ScreensaverQueryVersion(_) => Some(screensaver::QueryVersionRequest::parse_reply), - #[cfg(feature = "screensaver")] - Request::ScreensaverQueryInfo(_) => Some(screensaver::QueryInfoRequest::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(shape::QueryVersionRequest::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(shape::QueryExtentsRequest::parse_reply), - #[cfg(feature = "shape")] - Request::ShapeSelectInput(_) => None, - #[cfg(feature = "shape")] - Request::ShapeInputSelected(_) => Some(shape::InputSelectedRequest::parse_reply), - #[cfg(feature = "shape")] - Request::ShapeGetRectangles(_) => Some(shape::GetRectanglesRequest::parse_reply), - #[cfg(feature = "shm")] - Request::ShmQueryVersion(_) => Some(shm::QueryVersionRequest::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(shm::GetImageRequest::parse_reply), - #[cfg(feature = "shm")] - Request::ShmCreatePixmap(_) => None, - #[cfg(feature = "shm")] - Request::ShmAttachFd(_) => None, - #[cfg(feature = "shm")] - Request::ShmCreateSegment(_) => Some(shm::CreateSegmentRequest::parse_reply), - #[cfg(feature = "sync")] - Request::SyncInitialize(_) => Some(sync::InitializeRequest::parse_reply), - #[cfg(feature = "sync")] - Request::SyncListSystemCounters(_) => Some(sync::ListSystemCountersRequest::parse_reply), - #[cfg(feature = "sync")] - Request::SyncCreateCounter(_) => None, - #[cfg(feature = "sync")] - Request::SyncDestroyCounter(_) => None, - #[cfg(feature = "sync")] - Request::SyncQueryCounter(_) => Some(sync::QueryCounterRequest::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(sync::QueryAlarmRequest::parse_reply), - #[cfg(feature = "sync")] - Request::SyncSetPriority(_) => None, - #[cfg(feature = "sync")] - Request::SyncGetPriority(_) => Some(sync::GetPriorityRequest::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(sync::QueryFenceRequest::parse_reply), - #[cfg(feature = "sync")] - Request::SyncAwaitFence(_) => None, - Request::XcMiscGetVersion(_) => Some(xc_misc::GetVersionRequest::parse_reply), - Request::XcMiscGetXIDRange(_) => Some(xc_misc::GetXIDRangeRequest::parse_reply), - Request::XcMiscGetXIDList(_) => Some(xc_misc::GetXIDListRequest::parse_reply), - #[cfg(feature = "xevie")] - Request::XevieQueryVersion(_) => Some(xevie::QueryVersionRequest::parse_reply), - #[cfg(feature = "xevie")] - Request::XevieStart(_) => Some(xevie::StartRequest::parse_reply), - #[cfg(feature = "xevie")] - Request::XevieEnd(_) => Some(xevie::EndRequest::parse_reply), - #[cfg(feature = "xevie")] - Request::XevieSend(_) => Some(xevie::SendRequest::parse_reply), - #[cfg(feature = "xevie")] - Request::XevieSelectInput(_) => Some(xevie::SelectInputRequest::parse_reply), - #[cfg(feature = "xf86dri")] - Request::Xf86driQueryVersion(_) => Some(xf86dri::QueryVersionRequest::parse_reply), - #[cfg(feature = "xf86dri")] - Request::Xf86driQueryDirectRenderingCapable(_) => Some(xf86dri::QueryDirectRenderingCapableRequest::parse_reply), - #[cfg(feature = "xf86dri")] - Request::Xf86driOpenConnection(_) => Some(xf86dri::OpenConnectionRequest::parse_reply), - #[cfg(feature = "xf86dri")] - Request::Xf86driCloseConnection(_) => None, - #[cfg(feature = "xf86dri")] - Request::Xf86driGetClientDriverName(_) => Some(xf86dri::GetClientDriverNameRequest::parse_reply), - #[cfg(feature = "xf86dri")] - Request::Xf86driCreateContext(_) => Some(xf86dri::CreateContextRequest::parse_reply), - #[cfg(feature = "xf86dri")] - Request::Xf86driDestroyContext(_) => None, - #[cfg(feature = "xf86dri")] - Request::Xf86driCreateDrawable(_) => Some(xf86dri::CreateDrawableRequest::parse_reply), - #[cfg(feature = "xf86dri")] - Request::Xf86driDestroyDrawable(_) => None, - #[cfg(feature = "xf86dri")] - Request::Xf86driGetDrawableInfo(_) => Some(xf86dri::GetDrawableInfoRequest::parse_reply), - #[cfg(feature = "xf86dri")] - Request::Xf86driGetDeviceInfo(_) => Some(xf86dri::GetDeviceInfoRequest::parse_reply), - #[cfg(feature = "xf86dri")] - Request::Xf86driAuthConnection(_) => Some(xf86dri::AuthConnectionRequest::parse_reply), - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeQueryVersion(_) => Some(xf86vidmode::QueryVersionRequest::parse_reply), - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeGetModeLine(_) => Some(xf86vidmode::GetModeLineRequest::parse_reply), - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeModModeLine(_) => None, - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeSwitchMode(_) => None, - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeGetMonitor(_) => Some(xf86vidmode::GetMonitorRequest::parse_reply), - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeLockModeSwitch(_) => None, - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeGetAllModeLines(_) => Some(xf86vidmode::GetAllModeLinesRequest::parse_reply), - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeAddModeLine(_) => None, - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeDeleteModeLine(_) => None, - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeValidateModeLine(_) => Some(xf86vidmode::ValidateModeLineRequest::parse_reply), - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeSwitchToMode(_) => None, - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeGetViewPort(_) => Some(xf86vidmode::GetViewPortRequest::parse_reply), - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeSetViewPort(_) => None, - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeGetDotClocks(_) => Some(xf86vidmode::GetDotClocksRequest::parse_reply), - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeSetClientVersion(_) => None, - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeSetGamma(_) => None, - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeGetGamma(_) => Some(xf86vidmode::GetGammaRequest::parse_reply), - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeGetGammaRamp(_) => Some(xf86vidmode::GetGammaRampRequest::parse_reply), - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeSetGammaRamp(_) => None, - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeGetGammaRampSize(_) => Some(xf86vidmode::GetGammaRampSizeRequest::parse_reply), - #[cfg(feature = "xf86vidmode")] - Request::Xf86vidmodeGetPermissions(_) => Some(xf86vidmode::GetPermissionsRequest::parse_reply), - #[cfg(feature = "xfixes")] - Request::XfixesQueryVersion(_) => Some(xfixes::QueryVersionRequest::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(xfixes::GetCursorImageRequest::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(xfixes::FetchRegionRequest::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(xfixes::GetCursorNameRequest::parse_reply), - #[cfg(feature = "xfixes")] - Request::XfixesGetCursorImageAndName(_) => Some(xfixes::GetCursorImageAndNameRequest::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 = "xinerama")] - Request::XineramaQueryVersion(_) => Some(xinerama::QueryVersionRequest::parse_reply), - #[cfg(feature = "xinerama")] - Request::XineramaGetState(_) => Some(xinerama::GetStateRequest::parse_reply), - #[cfg(feature = "xinerama")] - Request::XineramaGetScreenCount(_) => Some(xinerama::GetScreenCountRequest::parse_reply), - #[cfg(feature = "xinerama")] - Request::XineramaGetScreenSize(_) => Some(xinerama::GetScreenSizeRequest::parse_reply), - #[cfg(feature = "xinerama")] - Request::XineramaIsActive(_) => Some(xinerama::IsActiveRequest::parse_reply), - #[cfg(feature = "xinerama")] - Request::XineramaQueryScreens(_) => Some(xinerama::QueryScreensRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputGetExtensionVersion(_) => Some(xinput::GetExtensionVersionRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputListInputDevices(_) => Some(xinput::ListInputDevicesRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputOpenDevice(_) => Some(xinput::OpenDeviceRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputCloseDevice(_) => None, - #[cfg(feature = "xinput")] - Request::XinputSetDeviceMode(_) => Some(xinput::SetDeviceModeRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputSelectExtensionEvent(_) => None, - #[cfg(feature = "xinput")] - Request::XinputGetSelectedExtensionEvents(_) => Some(xinput::GetSelectedExtensionEventsRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputChangeDeviceDontPropagateList(_) => None, - #[cfg(feature = "xinput")] - Request::XinputGetDeviceDontPropagateList(_) => Some(xinput::GetDeviceDontPropagateListRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputGetDeviceMotionEvents(_) => Some(xinput::GetDeviceMotionEventsRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputChangeKeyboardDevice(_) => Some(xinput::ChangeKeyboardDeviceRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputChangePointerDevice(_) => Some(xinput::ChangePointerDeviceRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputGrabDevice(_) => Some(xinput::GrabDeviceRequest::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(xinput::GetDeviceFocusRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputSetDeviceFocus(_) => None, - #[cfg(feature = "xinput")] - Request::XinputGetFeedbackControl(_) => Some(xinput::GetFeedbackControlRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputChangeFeedbackControl(_) => None, - #[cfg(feature = "xinput")] - Request::XinputGetDeviceKeyMapping(_) => Some(xinput::GetDeviceKeyMappingRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputChangeDeviceKeyMapping(_) => None, - #[cfg(feature = "xinput")] - Request::XinputGetDeviceModifierMapping(_) => Some(xinput::GetDeviceModifierMappingRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputSetDeviceModifierMapping(_) => Some(xinput::SetDeviceModifierMappingRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputGetDeviceButtonMapping(_) => Some(xinput::GetDeviceButtonMappingRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputSetDeviceButtonMapping(_) => Some(xinput::SetDeviceButtonMappingRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputQueryDeviceState(_) => Some(xinput::QueryDeviceStateRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputDeviceBell(_) => None, - #[cfg(feature = "xinput")] - Request::XinputSetDeviceValuators(_) => Some(xinput::SetDeviceValuatorsRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputGetDeviceControl(_) => Some(xinput::GetDeviceControlRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputChangeDeviceControl(_) => Some(xinput::ChangeDeviceControlRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputListDeviceProperties(_) => Some(xinput::ListDevicePropertiesRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputChangeDeviceProperty(_) => None, - #[cfg(feature = "xinput")] - Request::XinputDeleteDeviceProperty(_) => None, - #[cfg(feature = "xinput")] - Request::XinputGetDeviceProperty(_) => Some(xinput::GetDevicePropertyRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputXIQueryPointer(_) => Some(xinput::XIQueryPointerRequest::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(xinput::XIGetClientPointerRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputXISelectEvents(_) => None, - #[cfg(feature = "xinput")] - Request::XinputXIQueryVersion(_) => Some(xinput::XIQueryVersionRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputXIQueryDevice(_) => Some(xinput::XIQueryDeviceRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputXISetFocus(_) => None, - #[cfg(feature = "xinput")] - Request::XinputXIGetFocus(_) => Some(xinput::XIGetFocusRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputXIGrabDevice(_) => Some(xinput::XIGrabDeviceRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputXIUngrabDevice(_) => None, - #[cfg(feature = "xinput")] - Request::XinputXIAllowEvents(_) => None, - #[cfg(feature = "xinput")] - Request::XinputXIPassiveGrabDevice(_) => Some(xinput::XIPassiveGrabDeviceRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputXIPassiveUngrabDevice(_) => None, - #[cfg(feature = "xinput")] - Request::XinputXIListProperties(_) => Some(xinput::XIListPropertiesRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputXIChangeProperty(_) => None, - #[cfg(feature = "xinput")] - Request::XinputXIDeleteProperty(_) => None, - #[cfg(feature = "xinput")] - Request::XinputXIGetProperty(_) => Some(xinput::XIGetPropertyRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputXIGetSelectedEvents(_) => Some(xinput::XIGetSelectedEventsRequest::parse_reply), - #[cfg(feature = "xinput")] - Request::XinputXIBarrierReleasePointer(_) => None, - #[cfg(feature = "xinput")] - Request::XinputSendExtensionEvent(_) => None, - #[cfg(feature = "xkb")] - Request::XkbUseExtension(_) => Some(xkb::UseExtensionRequest::parse_reply), - #[cfg(feature = "xkb")] - Request::XkbSelectEvents(_) => None, - #[cfg(feature = "xkb")] - Request::XkbBell(_) => None, - #[cfg(feature = "xkb")] - Request::XkbGetState(_) => Some(xkb::GetStateRequest::parse_reply), - #[cfg(feature = "xkb")] - Request::XkbLatchLockState(_) => None, - #[cfg(feature = "xkb")] - Request::XkbGetControls(_) => Some(xkb::GetControlsRequest::parse_reply), - #[cfg(feature = "xkb")] - Request::XkbSetControls(_) => None, - #[cfg(feature = "xkb")] - Request::XkbGetMap(_) => Some(xkb::GetMapRequest::parse_reply), - #[cfg(feature = "xkb")] - Request::XkbSetMap(_) => None, - #[cfg(feature = "xkb")] - Request::XkbGetCompatMap(_) => Some(xkb::GetCompatMapRequest::parse_reply), - #[cfg(feature = "xkb")] - Request::XkbSetCompatMap(_) => None, - #[cfg(feature = "xkb")] - Request::XkbGetIndicatorState(_) => Some(xkb::GetIndicatorStateRequest::parse_reply), - #[cfg(feature = "xkb")] - Request::XkbGetIndicatorMap(_) => Some(xkb::GetIndicatorMapRequest::parse_reply), - #[cfg(feature = "xkb")] - Request::XkbSetIndicatorMap(_) => None, - #[cfg(feature = "xkb")] - Request::XkbGetNamedIndicator(_) => Some(xkb::GetNamedIndicatorRequest::parse_reply), - #[cfg(feature = "xkb")] - Request::XkbSetNamedIndicator(_) => None, - #[cfg(feature = "xkb")] - Request::XkbGetNames(_) => Some(xkb::GetNamesRequest::parse_reply), - #[cfg(feature = "xkb")] - Request::XkbSetNames(_) => None, - #[cfg(feature = "xkb")] - Request::XkbPerClientFlags(_) => Some(xkb::PerClientFlagsRequest::parse_reply), - #[cfg(feature = "xkb")] - Request::XkbListComponents(_) => Some(xkb::ListComponentsRequest::parse_reply), - #[cfg(feature = "xkb")] - Request::XkbGetKbdByName(_) => Some(xkb::GetKbdByNameRequest::parse_reply), - #[cfg(feature = "xkb")] - Request::XkbGetDeviceInfo(_) => Some(xkb::GetDeviceInfoRequest::parse_reply), - #[cfg(feature = "xkb")] - Request::XkbSetDeviceInfo(_) => None, - #[cfg(feature = "xkb")] - Request::XkbSetDebuggingFlags(_) => Some(xkb::SetDebuggingFlagsRequest::parse_reply), - #[cfg(feature = "xprint")] - Request::XprintPrintQueryVersion(_) => Some(xprint::PrintQueryVersionRequest::parse_reply), - #[cfg(feature = "xprint")] - Request::XprintPrintGetPrinterList(_) => Some(xprint::PrintGetPrinterListRequest::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(xprint::PrintGetContextRequest::parse_reply), - #[cfg(feature = "xprint")] - Request::XprintPrintDestroyContext(_) => None, - #[cfg(feature = "xprint")] - Request::XprintPrintGetScreenOfContext(_) => Some(xprint::PrintGetScreenOfContextRequest::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(xprint::PrintGetDocumentDataRequest::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(xprint::PrintInputSelectedRequest::parse_reply), - #[cfg(feature = "xprint")] - Request::XprintPrintGetAttributes(_) => Some(xprint::PrintGetAttributesRequest::parse_reply), - #[cfg(feature = "xprint")] - Request::XprintPrintGetOneAttributes(_) => Some(xprint::PrintGetOneAttributesRequest::parse_reply), - #[cfg(feature = "xprint")] - Request::XprintPrintSetAttributes(_) => None, - #[cfg(feature = "xprint")] - Request::XprintPrintGetPageDimensions(_) => Some(xprint::PrintGetPageDimensionsRequest::parse_reply), - #[cfg(feature = "xprint")] - Request::XprintPrintQueryScreens(_) => Some(xprint::PrintQueryScreensRequest::parse_reply), - #[cfg(feature = "xprint")] - Request::XprintPrintSetImageResolution(_) => Some(xprint::PrintSetImageResolutionRequest::parse_reply), - #[cfg(feature = "xprint")] - Request::XprintPrintGetImageResolution(_) => Some(xprint::PrintGetImageResolutionRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxQueryVersion(_) => Some(xselinux::QueryVersionRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxSetDeviceCreateContext(_) => None, - #[cfg(feature = "xselinux")] - Request::XselinuxGetDeviceCreateContext(_) => Some(xselinux::GetDeviceCreateContextRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxSetDeviceContext(_) => None, - #[cfg(feature = "xselinux")] - Request::XselinuxGetDeviceContext(_) => Some(xselinux::GetDeviceContextRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxSetWindowCreateContext(_) => None, - #[cfg(feature = "xselinux")] - Request::XselinuxGetWindowCreateContext(_) => Some(xselinux::GetWindowCreateContextRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxGetWindowContext(_) => Some(xselinux::GetWindowContextRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxSetPropertyCreateContext(_) => None, - #[cfg(feature = "xselinux")] - Request::XselinuxGetPropertyCreateContext(_) => Some(xselinux::GetPropertyCreateContextRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxSetPropertyUseContext(_) => None, - #[cfg(feature = "xselinux")] - Request::XselinuxGetPropertyUseContext(_) => Some(xselinux::GetPropertyUseContextRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxGetPropertyContext(_) => Some(xselinux::GetPropertyContextRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxGetPropertyDataContext(_) => Some(xselinux::GetPropertyDataContextRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxListProperties(_) => Some(xselinux::ListPropertiesRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxSetSelectionCreateContext(_) => None, - #[cfg(feature = "xselinux")] - Request::XselinuxGetSelectionCreateContext(_) => Some(xselinux::GetSelectionCreateContextRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxSetSelectionUseContext(_) => None, - #[cfg(feature = "xselinux")] - Request::XselinuxGetSelectionUseContext(_) => Some(xselinux::GetSelectionUseContextRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxGetSelectionContext(_) => Some(xselinux::GetSelectionContextRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxGetSelectionDataContext(_) => Some(xselinux::GetSelectionDataContextRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxListSelections(_) => Some(xselinux::ListSelectionsRequest::parse_reply), - #[cfg(feature = "xselinux")] - Request::XselinuxGetClientContext(_) => Some(xselinux::GetClientContextRequest::parse_reply), - #[cfg(feature = "xtest")] - Request::XtestGetVersion(_) => Some(xtest::GetVersionRequest::parse_reply), - #[cfg(feature = "xtest")] - Request::XtestCompareCursor(_) => Some(xtest::CompareCursorRequest::parse_reply), - #[cfg(feature = "xtest")] - Request::XtestFakeInput(_) => None, - #[cfg(feature = "xtest")] - Request::XtestGrabControl(_) => None, - #[cfg(feature = "xv")] - Request::XvQueryExtension(_) => Some(xv::QueryExtensionRequest::parse_reply), - #[cfg(feature = "xv")] - Request::XvQueryAdaptors(_) => Some(xv::QueryAdaptorsRequest::parse_reply), - #[cfg(feature = "xv")] - Request::XvQueryEncodings(_) => Some(xv::QueryEncodingsRequest::parse_reply), - #[cfg(feature = "xv")] - Request::XvGrabPort(_) => Some(xv::GrabPortRequest::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(xv::QueryBestSizeRequest::parse_reply), - #[cfg(feature = "xv")] - Request::XvSetPortAttribute(_) => None, - #[cfg(feature = "xv")] - Request::XvGetPortAttribute(_) => Some(xv::GetPortAttributeRequest::parse_reply), - #[cfg(feature = "xv")] - Request::XvQueryPortAttributes(_) => Some(xv::QueryPortAttributesRequest::parse_reply), - #[cfg(feature = "xv")] - Request::XvListImageFormats(_) => Some(xv::ListImageFormatsRequest::parse_reply), - #[cfg(feature = "xv")] - Request::XvQueryImageAttributes(_) => Some(xv::QueryImageAttributesRequest::parse_reply), - #[cfg(feature = "xv")] - Request::XvPutImage(_) => None, - #[cfg(feature = "xv")] - Request::XvShmPutImage(_) => None, - #[cfg(feature = "xvmc")] - Request::XvmcQueryVersion(_) => Some(xvmc::QueryVersionRequest::parse_reply), - #[cfg(feature = "xvmc")] - Request::XvmcListSurfaceTypes(_) => Some(xvmc::ListSurfaceTypesRequest::parse_reply), - #[cfg(feature = "xvmc")] - Request::XvmcCreateContext(_) => Some(xvmc::CreateContextRequest::parse_reply), - #[cfg(feature = "xvmc")] - Request::XvmcDestroyContext(_) => None, - #[cfg(feature = "xvmc")] - Request::XvmcCreateSurface(_) => Some(xvmc::CreateSurfaceRequest::parse_reply), - #[cfg(feature = "xvmc")] - Request::XvmcDestroySurface(_) => None, - #[cfg(feature = "xvmc")] - Request::XvmcCreateSubpicture(_) => Some(xvmc::CreateSubpictureRequest::parse_reply), - #[cfg(feature = "xvmc")] - Request::XvmcDestroySubpicture(_) => None, - #[cfg(feature = "xvmc")] - Request::XvmcListSubpictureTypes(_) => Some(xvmc::ListSubpictureTypesRequest::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 = "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 = "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), - 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 = "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 = "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 = "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 = "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 = "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 = "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. -pub(crate) fn request_name(extension: Option<&str>, major_opcode: u8, minor_opcode: u16) -> Option<&'static str> { - // Check if this is a core protocol request. - match major_opcode { - 1 => return Some("CreateWindow"), - 2 => return Some("ChangeWindowAttributes"), - 3 => return Some("GetWindowAttributes"), - 4 => return Some("DestroyWindow"), - 5 => return Some("DestroySubwindows"), - 6 => return Some("ChangeSaveSet"), - 7 => return Some("ReparentWindow"), - 8 => return Some("MapWindow"), - 9 => return Some("MapSubwindows"), - 10 => return Some("UnmapWindow"), - 11 => return Some("UnmapSubwindows"), - 12 => return Some("ConfigureWindow"), - 13 => return Some("CirculateWindow"), - 14 => return Some("GetGeometry"), - 15 => return Some("QueryTree"), - 16 => return Some("InternAtom"), - 17 => return Some("GetAtomName"), - 18 => return Some("ChangeProperty"), - 19 => return Some("DeleteProperty"), - 20 => return Some("GetProperty"), - 21 => return Some("ListProperties"), - 22 => return Some("SetSelectionOwner"), - 23 => return Some("GetSelectionOwner"), - 24 => return Some("ConvertSelection"), - 25 => return Some("SendEvent"), - 26 => return Some("GrabPointer"), - 27 => return Some("UngrabPointer"), - 28 => return Some("GrabButton"), - 29 => return Some("UngrabButton"), - 30 => return Some("ChangeActivePointerGrab"), - 31 => return Some("GrabKeyboard"), - 32 => return Some("UngrabKeyboard"), - 33 => return Some("GrabKey"), - 34 => return Some("UngrabKey"), - 35 => return Some("AllowEvents"), - 36 => return Some("GrabServer"), - 37 => return Some("UngrabServer"), - 38 => return Some("QueryPointer"), - 39 => return Some("GetMotionEvents"), - 40 => return Some("TranslateCoordinates"), - 41 => return Some("WarpPointer"), - 42 => return Some("SetInputFocus"), - 43 => return Some("GetInputFocus"), - 44 => return Some("QueryKeymap"), - 45 => return Some("OpenFont"), - 46 => return Some("CloseFont"), - 47 => return Some("QueryFont"), - 48 => return Some("QueryTextExtents"), - 49 => return Some("ListFonts"), - 50 => return Some("ListFontsWithInfo"), - 51 => return Some("SetFontPath"), - 52 => return Some("GetFontPath"), - 53 => return Some("CreatePixmap"), - 54 => return Some("FreePixmap"), - 55 => return Some("CreateGC"), - 56 => return Some("ChangeGC"), - 57 => return Some("CopyGC"), - 58 => return Some("SetDashes"), - 59 => return Some("SetClipRectangles"), - 60 => return Some("FreeGC"), - 61 => return Some("ClearArea"), - 62 => return Some("CopyArea"), - 63 => return Some("CopyPlane"), - 64 => return Some("PolyPoint"), - 65 => return Some("PolyLine"), - 66 => return Some("PolySegment"), - 67 => return Some("PolyRectangle"), - 68 => return Some("PolyArc"), - 69 => return Some("FillPoly"), - 70 => return Some("PolyFillRectangle"), - 71 => return Some("PolyFillArc"), - 72 => return Some("PutImage"), - 73 => return Some("GetImage"), - 74 => return Some("PolyText8"), - 75 => return Some("PolyText16"), - 76 => return Some("ImageText8"), - 77 => return Some("ImageText16"), - 78 => return Some("CreateColormap"), - 79 => return Some("FreeColormap"), - 80 => return Some("CopyColormapAndFree"), - 81 => return Some("InstallColormap"), - 82 => return Some("UninstallColormap"), - 83 => return Some("ListInstalledColormaps"), - 84 => return Some("AllocColor"), - 85 => return Some("AllocNamedColor"), - 86 => return Some("AllocColorCells"), - 87 => return Some("AllocColorPlanes"), - 88 => return Some("FreeColors"), - 89 => return Some("StoreColors"), - 90 => return Some("StoreNamedColor"), - 91 => return Some("QueryColors"), - 92 => return Some("LookupColor"), - 93 => return Some("CreateCursor"), - 94 => return Some("CreateGlyphCursor"), - 95 => return Some("FreeCursor"), - 96 => return Some("RecolorCursor"), - 97 => return Some("QueryBestSize"), - 98 => return Some("QueryExtension"), - 99 => return Some("ListExtensions"), - 100 => return Some("ChangeKeyboardMapping"), - 101 => return Some("GetKeyboardMapping"), - 102 => return Some("ChangeKeyboardControl"), - 103 => return Some("GetKeyboardControl"), - 104 => return Some("Bell"), - 105 => return Some("ChangePointerControl"), - 106 => return Some("GetPointerControl"), - 107 => return Some("SetScreenSaver"), - 108 => return Some("GetScreenSaver"), - 109 => return Some("ChangeHosts"), - 110 => return Some("ListHosts"), - 111 => return Some("SetAccessControl"), - 112 => return Some("SetCloseDownMode"), - 113 => return Some("KillClient"), - 114 => return Some("RotateProperties"), - 115 => return Some("ForceScreenSaver"), - 116 => return Some("SetPointerMapping"), - 117 => return Some("GetPointerMapping"), - 118 => return Some("SetModifierMapping"), - 119 => return Some("GetModifierMapping"), - 127 => return Some("NoOperation"), - _ => (), - } - // Check the extension - match (extension, minor_opcode) { - (Some(bigreq::X11_EXTENSION_NAME), 0) => Some("Enable"), - #[cfg(feature = "composite")] - (Some(composite::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "composite")] - (Some(composite::X11_EXTENSION_NAME), 1) => Some("RedirectWindow"), - #[cfg(feature = "composite")] - (Some(composite::X11_EXTENSION_NAME), 2) => Some("RedirectSubwindows"), - #[cfg(feature = "composite")] - (Some(composite::X11_EXTENSION_NAME), 3) => Some("UnredirectWindow"), - #[cfg(feature = "composite")] - (Some(composite::X11_EXTENSION_NAME), 4) => Some("UnredirectSubwindows"), - #[cfg(feature = "composite")] - (Some(composite::X11_EXTENSION_NAME), 5) => Some("CreateRegionFromBorderClip"), - #[cfg(feature = "composite")] - (Some(composite::X11_EXTENSION_NAME), 6) => Some("NameWindowPixmap"), - #[cfg(feature = "composite")] - (Some(composite::X11_EXTENSION_NAME), 7) => Some("GetOverlayWindow"), - #[cfg(feature = "composite")] - (Some(composite::X11_EXTENSION_NAME), 8) => Some("ReleaseOverlayWindow"), - #[cfg(feature = "damage")] - (Some(damage::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "damage")] - (Some(damage::X11_EXTENSION_NAME), 1) => Some("Create"), - #[cfg(feature = "damage")] - (Some(damage::X11_EXTENSION_NAME), 2) => Some("Destroy"), - #[cfg(feature = "damage")] - (Some(damage::X11_EXTENSION_NAME), 3) => Some("Subtract"), - #[cfg(feature = "damage")] - (Some(damage::X11_EXTENSION_NAME), 4) => Some("Add"), - #[cfg(feature = "dpms")] - (Some(dpms::X11_EXTENSION_NAME), 0) => Some("GetVersion"), - #[cfg(feature = "dpms")] - (Some(dpms::X11_EXTENSION_NAME), 1) => Some("Capable"), - #[cfg(feature = "dpms")] - (Some(dpms::X11_EXTENSION_NAME), 2) => Some("GetTimeouts"), - #[cfg(feature = "dpms")] - (Some(dpms::X11_EXTENSION_NAME), 3) => Some("SetTimeouts"), - #[cfg(feature = "dpms")] - (Some(dpms::X11_EXTENSION_NAME), 4) => Some("Enable"), - #[cfg(feature = "dpms")] - (Some(dpms::X11_EXTENSION_NAME), 5) => Some("Disable"), - #[cfg(feature = "dpms")] - (Some(dpms::X11_EXTENSION_NAME), 6) => Some("ForceLevel"), - #[cfg(feature = "dpms")] - (Some(dpms::X11_EXTENSION_NAME), 7) => Some("Info"), - #[cfg(feature = "dri2")] - (Some(dri2::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "dri2")] - (Some(dri2::X11_EXTENSION_NAME), 1) => Some("Connect"), - #[cfg(feature = "dri2")] - (Some(dri2::X11_EXTENSION_NAME), 2) => Some("Authenticate"), - #[cfg(feature = "dri2")] - (Some(dri2::X11_EXTENSION_NAME), 3) => Some("CreateDrawable"), - #[cfg(feature = "dri2")] - (Some(dri2::X11_EXTENSION_NAME), 4) => Some("DestroyDrawable"), - #[cfg(feature = "dri2")] - (Some(dri2::X11_EXTENSION_NAME), 5) => Some("GetBuffers"), - #[cfg(feature = "dri2")] - (Some(dri2::X11_EXTENSION_NAME), 6) => Some("CopyRegion"), - #[cfg(feature = "dri2")] - (Some(dri2::X11_EXTENSION_NAME), 7) => Some("GetBuffersWithFormat"), - #[cfg(feature = "dri2")] - (Some(dri2::X11_EXTENSION_NAME), 8) => Some("SwapBuffers"), - #[cfg(feature = "dri2")] - (Some(dri2::X11_EXTENSION_NAME), 9) => Some("GetMSC"), - #[cfg(feature = "dri2")] - (Some(dri2::X11_EXTENSION_NAME), 10) => Some("WaitMSC"), - #[cfg(feature = "dri2")] - (Some(dri2::X11_EXTENSION_NAME), 11) => Some("WaitSBC"), - #[cfg(feature = "dri2")] - (Some(dri2::X11_EXTENSION_NAME), 12) => Some("SwapInterval"), - #[cfg(feature = "dri2")] - (Some(dri2::X11_EXTENSION_NAME), 13) => Some("GetParam"), - #[cfg(feature = "dri3")] - (Some(dri3::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "dri3")] - (Some(dri3::X11_EXTENSION_NAME), 1) => Some("Open"), - #[cfg(feature = "dri3")] - (Some(dri3::X11_EXTENSION_NAME), 2) => Some("PixmapFromBuffer"), - #[cfg(feature = "dri3")] - (Some(dri3::X11_EXTENSION_NAME), 3) => Some("BufferFromPixmap"), - #[cfg(feature = "dri3")] - (Some(dri3::X11_EXTENSION_NAME), 4) => Some("FenceFromFD"), - #[cfg(feature = "dri3")] - (Some(dri3::X11_EXTENSION_NAME), 5) => Some("FDFromFence"), - #[cfg(feature = "dri3")] - (Some(dri3::X11_EXTENSION_NAME), 6) => Some("GetSupportedModifiers"), - #[cfg(feature = "dri3")] - (Some(dri3::X11_EXTENSION_NAME), 7) => Some("PixmapFromBuffers"), - #[cfg(feature = "dri3")] - (Some(dri3::X11_EXTENSION_NAME), 8) => Some("BuffersFromPixmap"), - (Some(ge::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 1) => Some("Render"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 2) => Some("RenderLarge"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 3) => Some("CreateContext"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 4) => Some("DestroyContext"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 5) => Some("MakeCurrent"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 6) => Some("IsDirect"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 7) => Some("QueryVersion"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 8) => Some("WaitGL"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 9) => Some("WaitX"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 10) => Some("CopyContext"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 11) => Some("SwapBuffers"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 12) => Some("UseXFont"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 13) => Some("CreateGLXPixmap"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 14) => Some("GetVisualConfigs"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 15) => Some("DestroyGLXPixmap"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 16) => Some("VendorPrivate"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 17) => Some("VendorPrivateWithReply"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 18) => Some("QueryExtensionsString"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 19) => Some("QueryServerString"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 20) => Some("ClientInfo"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 21) => Some("GetFBConfigs"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 22) => Some("CreatePixmap"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 23) => Some("DestroyPixmap"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 24) => Some("CreateNewContext"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 25) => Some("QueryContext"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 26) => Some("MakeContextCurrent"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 27) => Some("CreatePbuffer"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 28) => Some("DestroyPbuffer"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 29) => Some("GetDrawableAttributes"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 30) => Some("ChangeDrawableAttributes"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 31) => Some("CreateWindow"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 32) => Some("DeleteWindow"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 33) => Some("SetClientInfoARB"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 34) => Some("CreateContextAttribsARB"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 35) => Some("SetClientInfo2ARB"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 101) => Some("NewList"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 102) => Some("EndList"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 103) => Some("DeleteLists"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 104) => Some("GenLists"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 105) => Some("FeedbackBuffer"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 106) => Some("SelectBuffer"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 107) => Some("RenderMode"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 108) => Some("Finish"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 109) => Some("PixelStoref"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 110) => Some("PixelStorei"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 111) => Some("ReadPixels"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 112) => Some("GetBooleanv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 113) => Some("GetClipPlane"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 114) => Some("GetDoublev"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 115) => Some("GetError"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 116) => Some("GetFloatv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 117) => Some("GetIntegerv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 118) => Some("GetLightfv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 119) => Some("GetLightiv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 120) => Some("GetMapdv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 121) => Some("GetMapfv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 122) => Some("GetMapiv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 123) => Some("GetMaterialfv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 124) => Some("GetMaterialiv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 125) => Some("GetPixelMapfv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 126) => Some("GetPixelMapuiv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 127) => Some("GetPixelMapusv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 128) => Some("GetPolygonStipple"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 129) => Some("GetString"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 130) => Some("GetTexEnvfv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 131) => Some("GetTexEnviv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 132) => Some("GetTexGendv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 133) => Some("GetTexGenfv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 134) => Some("GetTexGeniv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 135) => Some("GetTexImage"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 136) => Some("GetTexParameterfv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 137) => Some("GetTexParameteriv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 138) => Some("GetTexLevelParameterfv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 139) => Some("GetTexLevelParameteriv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 140) => Some("IsEnabled"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 141) => Some("IsList"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 142) => Some("Flush"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 143) => Some("AreTexturesResident"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 144) => Some("DeleteTextures"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 145) => Some("GenTextures"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 146) => Some("IsTexture"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 147) => Some("GetColorTable"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 148) => Some("GetColorTableParameterfv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 149) => Some("GetColorTableParameteriv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 150) => Some("GetConvolutionFilter"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 151) => Some("GetConvolutionParameterfv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 152) => Some("GetConvolutionParameteriv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 153) => Some("GetSeparableFilter"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 154) => Some("GetHistogram"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 155) => Some("GetHistogramParameterfv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 156) => Some("GetHistogramParameteriv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 157) => Some("GetMinmax"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 158) => Some("GetMinmaxParameterfv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 159) => Some("GetMinmaxParameteriv"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 160) => Some("GetCompressedTexImageARB"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 161) => Some("DeleteQueriesARB"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 162) => Some("GenQueriesARB"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 163) => Some("IsQueryARB"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 164) => Some("GetQueryivARB"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 165) => Some("GetQueryObjectivARB"), - #[cfg(feature = "glx")] - (Some(glx::X11_EXTENSION_NAME), 166) => Some("GetQueryObjectuivARB"), - #[cfg(feature = "present")] - (Some(present::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "present")] - (Some(present::X11_EXTENSION_NAME), 1) => Some("Pixmap"), - #[cfg(feature = "present")] - (Some(present::X11_EXTENSION_NAME), 2) => Some("NotifyMSC"), - #[cfg(feature = "present")] - (Some(present::X11_EXTENSION_NAME), 3) => Some("SelectInput"), - #[cfg(feature = "present")] - (Some(present::X11_EXTENSION_NAME), 4) => Some("QueryCapabilities"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 2) => Some("SetScreenConfig"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 4) => Some("SelectInput"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 5) => Some("GetScreenInfo"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 6) => Some("GetScreenSizeRange"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 7) => Some("SetScreenSize"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 8) => Some("GetScreenResources"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 9) => Some("GetOutputInfo"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 10) => Some("ListOutputProperties"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 11) => Some("QueryOutputProperty"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 12) => Some("ConfigureOutputProperty"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 13) => Some("ChangeOutputProperty"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 14) => Some("DeleteOutputProperty"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 15) => Some("GetOutputProperty"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 16) => Some("CreateMode"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 17) => Some("DestroyMode"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 18) => Some("AddOutputMode"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 19) => Some("DeleteOutputMode"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 20) => Some("GetCrtcInfo"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 21) => Some("SetCrtcConfig"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 22) => Some("GetCrtcGammaSize"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 23) => Some("GetCrtcGamma"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 24) => Some("SetCrtcGamma"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 25) => Some("GetScreenResourcesCurrent"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 26) => Some("SetCrtcTransform"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 27) => Some("GetCrtcTransform"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 28) => Some("GetPanning"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 29) => Some("SetPanning"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 30) => Some("SetOutputPrimary"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 31) => Some("GetOutputPrimary"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 32) => Some("GetProviders"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 33) => Some("GetProviderInfo"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 34) => Some("SetProviderOffloadSink"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 35) => Some("SetProviderOutputSource"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 36) => Some("ListProviderProperties"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 37) => Some("QueryProviderProperty"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 38) => Some("ConfigureProviderProperty"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 39) => Some("ChangeProviderProperty"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 40) => Some("DeleteProviderProperty"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 41) => Some("GetProviderProperty"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 42) => Some("GetMonitors"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 43) => Some("SetMonitor"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 44) => Some("DeleteMonitor"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 45) => Some("CreateLease"), - #[cfg(feature = "randr")] - (Some(randr::X11_EXTENSION_NAME), 46) => Some("FreeLease"), - #[cfg(feature = "record")] - (Some(record::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "record")] - (Some(record::X11_EXTENSION_NAME), 1) => Some("CreateContext"), - #[cfg(feature = "record")] - (Some(record::X11_EXTENSION_NAME), 2) => Some("RegisterClients"), - #[cfg(feature = "record")] - (Some(record::X11_EXTENSION_NAME), 3) => Some("UnregisterClients"), - #[cfg(feature = "record")] - (Some(record::X11_EXTENSION_NAME), 4) => Some("GetContext"), - #[cfg(feature = "record")] - (Some(record::X11_EXTENSION_NAME), 5) => Some("EnableContext"), - #[cfg(feature = "record")] - (Some(record::X11_EXTENSION_NAME), 6) => Some("DisableContext"), - #[cfg(feature = "record")] - (Some(record::X11_EXTENSION_NAME), 7) => Some("FreeContext"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 1) => Some("QueryPictFormats"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 2) => Some("QueryPictIndexValues"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 4) => Some("CreatePicture"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 5) => Some("ChangePicture"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 6) => Some("SetPictureClipRectangles"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 7) => Some("FreePicture"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 8) => Some("Composite"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 10) => Some("Trapezoids"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 11) => Some("Triangles"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 12) => Some("TriStrip"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 13) => Some("TriFan"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 17) => Some("CreateGlyphSet"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 18) => Some("ReferenceGlyphSet"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 19) => Some("FreeGlyphSet"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 20) => Some("AddGlyphs"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 22) => Some("FreeGlyphs"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 23) => Some("CompositeGlyphs8"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 24) => Some("CompositeGlyphs16"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 25) => Some("CompositeGlyphs32"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 26) => Some("FillRectangles"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 27) => Some("CreateCursor"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 28) => Some("SetPictureTransform"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 29) => Some("QueryFilters"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 30) => Some("SetPictureFilter"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 31) => Some("CreateAnimCursor"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 32) => Some("AddTraps"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 33) => Some("CreateSolidFill"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 34) => Some("CreateLinearGradient"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 35) => Some("CreateRadialGradient"), - #[cfg(feature = "render")] - (Some(render::X11_EXTENSION_NAME), 36) => Some("CreateConicalGradient"), - #[cfg(feature = "res")] - (Some(res::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "res")] - (Some(res::X11_EXTENSION_NAME), 1) => Some("QueryClients"), - #[cfg(feature = "res")] - (Some(res::X11_EXTENSION_NAME), 2) => Some("QueryClientResources"), - #[cfg(feature = "res")] - (Some(res::X11_EXTENSION_NAME), 3) => Some("QueryClientPixmapBytes"), - #[cfg(feature = "res")] - (Some(res::X11_EXTENSION_NAME), 4) => Some("QueryClientIds"), - #[cfg(feature = "res")] - (Some(res::X11_EXTENSION_NAME), 5) => Some("QueryResourceBytes"), - #[cfg(feature = "screensaver")] - (Some(screensaver::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "screensaver")] - (Some(screensaver::X11_EXTENSION_NAME), 1) => Some("QueryInfo"), - #[cfg(feature = "screensaver")] - (Some(screensaver::X11_EXTENSION_NAME), 2) => Some("SelectInput"), - #[cfg(feature = "screensaver")] - (Some(screensaver::X11_EXTENSION_NAME), 3) => Some("SetAttributes"), - #[cfg(feature = "screensaver")] - (Some(screensaver::X11_EXTENSION_NAME), 4) => Some("UnsetAttributes"), - #[cfg(feature = "screensaver")] - (Some(screensaver::X11_EXTENSION_NAME), 5) => Some("Suspend"), - #[cfg(feature = "shape")] - (Some(shape::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "shape")] - (Some(shape::X11_EXTENSION_NAME), 1) => Some("Rectangles"), - #[cfg(feature = "shape")] - (Some(shape::X11_EXTENSION_NAME), 2) => Some("Mask"), - #[cfg(feature = "shape")] - (Some(shape::X11_EXTENSION_NAME), 3) => Some("Combine"), - #[cfg(feature = "shape")] - (Some(shape::X11_EXTENSION_NAME), 4) => Some("Offset"), - #[cfg(feature = "shape")] - (Some(shape::X11_EXTENSION_NAME), 5) => Some("QueryExtents"), - #[cfg(feature = "shape")] - (Some(shape::X11_EXTENSION_NAME), 6) => Some("SelectInput"), - #[cfg(feature = "shape")] - (Some(shape::X11_EXTENSION_NAME), 7) => Some("InputSelected"), - #[cfg(feature = "shape")] - (Some(shape::X11_EXTENSION_NAME), 8) => Some("GetRectangles"), - #[cfg(feature = "shm")] - (Some(shm::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "shm")] - (Some(shm::X11_EXTENSION_NAME), 1) => Some("Attach"), - #[cfg(feature = "shm")] - (Some(shm::X11_EXTENSION_NAME), 2) => Some("Detach"), - #[cfg(feature = "shm")] - (Some(shm::X11_EXTENSION_NAME), 3) => Some("PutImage"), - #[cfg(feature = "shm")] - (Some(shm::X11_EXTENSION_NAME), 4) => Some("GetImage"), - #[cfg(feature = "shm")] - (Some(shm::X11_EXTENSION_NAME), 5) => Some("CreatePixmap"), - #[cfg(feature = "shm")] - (Some(shm::X11_EXTENSION_NAME), 6) => Some("AttachFd"), - #[cfg(feature = "shm")] - (Some(shm::X11_EXTENSION_NAME), 7) => Some("CreateSegment"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 0) => Some("Initialize"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 1) => Some("ListSystemCounters"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 2) => Some("CreateCounter"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 3) => Some("SetCounter"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 4) => Some("ChangeCounter"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 5) => Some("QueryCounter"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 6) => Some("DestroyCounter"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 7) => Some("Await"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 8) => Some("CreateAlarm"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 9) => Some("ChangeAlarm"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 10) => Some("QueryAlarm"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 11) => Some("DestroyAlarm"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 12) => Some("SetPriority"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 13) => Some("GetPriority"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 14) => Some("CreateFence"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 15) => Some("TriggerFence"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 16) => Some("ResetFence"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 17) => Some("DestroyFence"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 18) => Some("QueryFence"), - #[cfg(feature = "sync")] - (Some(sync::X11_EXTENSION_NAME), 19) => Some("AwaitFence"), - (Some(xc_misc::X11_EXTENSION_NAME), 0) => Some("GetVersion"), - (Some(xc_misc::X11_EXTENSION_NAME), 1) => Some("GetXIDRange"), - (Some(xc_misc::X11_EXTENSION_NAME), 2) => Some("GetXIDList"), - #[cfg(feature = "xevie")] - (Some(xevie::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "xevie")] - (Some(xevie::X11_EXTENSION_NAME), 1) => Some("Start"), - #[cfg(feature = "xevie")] - (Some(xevie::X11_EXTENSION_NAME), 2) => Some("End"), - #[cfg(feature = "xevie")] - (Some(xevie::X11_EXTENSION_NAME), 3) => Some("Send"), - #[cfg(feature = "xevie")] - (Some(xevie::X11_EXTENSION_NAME), 4) => Some("SelectInput"), - #[cfg(feature = "xf86dri")] - (Some(xf86dri::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "xf86dri")] - (Some(xf86dri::X11_EXTENSION_NAME), 1) => Some("QueryDirectRenderingCapable"), - #[cfg(feature = "xf86dri")] - (Some(xf86dri::X11_EXTENSION_NAME), 2) => Some("OpenConnection"), - #[cfg(feature = "xf86dri")] - (Some(xf86dri::X11_EXTENSION_NAME), 3) => Some("CloseConnection"), - #[cfg(feature = "xf86dri")] - (Some(xf86dri::X11_EXTENSION_NAME), 4) => Some("GetClientDriverName"), - #[cfg(feature = "xf86dri")] - (Some(xf86dri::X11_EXTENSION_NAME), 5) => Some("CreateContext"), - #[cfg(feature = "xf86dri")] - (Some(xf86dri::X11_EXTENSION_NAME), 6) => Some("DestroyContext"), - #[cfg(feature = "xf86dri")] - (Some(xf86dri::X11_EXTENSION_NAME), 7) => Some("CreateDrawable"), - #[cfg(feature = "xf86dri")] - (Some(xf86dri::X11_EXTENSION_NAME), 8) => Some("DestroyDrawable"), - #[cfg(feature = "xf86dri")] - (Some(xf86dri::X11_EXTENSION_NAME), 9) => Some("GetDrawableInfo"), - #[cfg(feature = "xf86dri")] - (Some(xf86dri::X11_EXTENSION_NAME), 10) => Some("GetDeviceInfo"), - #[cfg(feature = "xf86dri")] - (Some(xf86dri::X11_EXTENSION_NAME), 11) => Some("AuthConnection"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 1) => Some("GetModeLine"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 2) => Some("ModModeLine"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 3) => Some("SwitchMode"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 4) => Some("GetMonitor"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 5) => Some("LockModeSwitch"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 6) => Some("GetAllModeLines"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 7) => Some("AddModeLine"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 8) => Some("DeleteModeLine"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 9) => Some("ValidateModeLine"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 10) => Some("SwitchToMode"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 11) => Some("GetViewPort"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 12) => Some("SetViewPort"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 13) => Some("GetDotClocks"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 14) => Some("SetClientVersion"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 15) => Some("SetGamma"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 16) => Some("GetGamma"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 17) => Some("GetGammaRamp"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 18) => Some("SetGammaRamp"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 19) => Some("GetGammaRampSize"), - #[cfg(feature = "xf86vidmode")] - (Some(xf86vidmode::X11_EXTENSION_NAME), 20) => Some("GetPermissions"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 1) => Some("ChangeSaveSet"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 2) => Some("SelectSelectionInput"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 3) => Some("SelectCursorInput"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 4) => Some("GetCursorImage"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 5) => Some("CreateRegion"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 6) => Some("CreateRegionFromBitmap"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 7) => Some("CreateRegionFromWindow"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 8) => Some("CreateRegionFromGC"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 9) => Some("CreateRegionFromPicture"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 10) => Some("DestroyRegion"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 11) => Some("SetRegion"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 12) => Some("CopyRegion"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 13) => Some("UnionRegion"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 14) => Some("IntersectRegion"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 15) => Some("SubtractRegion"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 16) => Some("InvertRegion"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 17) => Some("TranslateRegion"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 18) => Some("RegionExtents"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 19) => Some("FetchRegion"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 20) => Some("SetGCClipRegion"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 21) => Some("SetWindowShapeRegion"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 22) => Some("SetPictureClipRegion"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 23) => Some("SetCursorName"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 24) => Some("GetCursorName"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 25) => Some("GetCursorImageAndName"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 26) => Some("ChangeCursor"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 27) => Some("ChangeCursorByName"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 28) => Some("ExpandRegion"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 29) => Some("HideCursor"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 30) => Some("ShowCursor"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 31) => Some("CreatePointerBarrier"), - #[cfg(feature = "xfixes")] - (Some(xfixes::X11_EXTENSION_NAME), 32) => Some("DeletePointerBarrier"), - #[cfg(feature = "xinerama")] - (Some(xinerama::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "xinerama")] - (Some(xinerama::X11_EXTENSION_NAME), 1) => Some("GetState"), - #[cfg(feature = "xinerama")] - (Some(xinerama::X11_EXTENSION_NAME), 2) => Some("GetScreenCount"), - #[cfg(feature = "xinerama")] - (Some(xinerama::X11_EXTENSION_NAME), 3) => Some("GetScreenSize"), - #[cfg(feature = "xinerama")] - (Some(xinerama::X11_EXTENSION_NAME), 4) => Some("IsActive"), - #[cfg(feature = "xinerama")] - (Some(xinerama::X11_EXTENSION_NAME), 5) => Some("QueryScreens"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 1) => Some("GetExtensionVersion"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 2) => Some("ListInputDevices"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 3) => Some("OpenDevice"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 4) => Some("CloseDevice"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 5) => Some("SetDeviceMode"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 6) => Some("SelectExtensionEvent"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 7) => Some("GetSelectedExtensionEvents"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 8) => Some("ChangeDeviceDontPropagateList"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 9) => Some("GetDeviceDontPropagateList"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 10) => Some("GetDeviceMotionEvents"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 11) => Some("ChangeKeyboardDevice"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 12) => Some("ChangePointerDevice"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 13) => Some("GrabDevice"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 14) => Some("UngrabDevice"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 15) => Some("GrabDeviceKey"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 16) => Some("UngrabDeviceKey"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 17) => Some("GrabDeviceButton"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 18) => Some("UngrabDeviceButton"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 19) => Some("AllowDeviceEvents"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 20) => Some("GetDeviceFocus"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 21) => Some("SetDeviceFocus"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 22) => Some("GetFeedbackControl"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 23) => Some("ChangeFeedbackControl"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 24) => Some("GetDeviceKeyMapping"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 25) => Some("ChangeDeviceKeyMapping"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 26) => Some("GetDeviceModifierMapping"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 27) => Some("SetDeviceModifierMapping"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 28) => Some("GetDeviceButtonMapping"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 29) => Some("SetDeviceButtonMapping"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 30) => Some("QueryDeviceState"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 31) => Some("SendExtensionEvent"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 32) => Some("DeviceBell"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 33) => Some("SetDeviceValuators"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 34) => Some("GetDeviceControl"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 35) => Some("ChangeDeviceControl"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 36) => Some("ListDeviceProperties"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 37) => Some("ChangeDeviceProperty"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 38) => Some("DeleteDeviceProperty"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 39) => Some("GetDeviceProperty"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 40) => Some("XIQueryPointer"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 41) => Some("XIWarpPointer"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 42) => Some("XIChangeCursor"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 43) => Some("XIChangeHierarchy"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 44) => Some("XISetClientPointer"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 45) => Some("XIGetClientPointer"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 46) => Some("XISelectEvents"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 47) => Some("XIQueryVersion"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 48) => Some("XIQueryDevice"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 49) => Some("XISetFocus"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 50) => Some("XIGetFocus"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 51) => Some("XIGrabDevice"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 52) => Some("XIUngrabDevice"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 53) => Some("XIAllowEvents"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 54) => Some("XIPassiveGrabDevice"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 55) => Some("XIPassiveUngrabDevice"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 56) => Some("XIListProperties"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 57) => Some("XIChangeProperty"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 58) => Some("XIDeleteProperty"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 59) => Some("XIGetProperty"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 60) => Some("XIGetSelectedEvents"), - #[cfg(feature = "xinput")] - (Some(xinput::X11_EXTENSION_NAME), 61) => Some("XIBarrierReleasePointer"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 0) => Some("UseExtension"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 1) => Some("SelectEvents"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 3) => Some("Bell"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 4) => Some("GetState"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 5) => Some("LatchLockState"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 6) => Some("GetControls"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 7) => Some("SetControls"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 8) => Some("GetMap"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 9) => Some("SetMap"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 10) => Some("GetCompatMap"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 11) => Some("SetCompatMap"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 12) => Some("GetIndicatorState"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 13) => Some("GetIndicatorMap"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 14) => Some("SetIndicatorMap"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 15) => Some("GetNamedIndicator"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 16) => Some("SetNamedIndicator"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 17) => Some("GetNames"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 18) => Some("SetNames"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 21) => Some("PerClientFlags"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 22) => Some("ListComponents"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 23) => Some("GetKbdByName"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 24) => Some("GetDeviceInfo"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 25) => Some("SetDeviceInfo"), - #[cfg(feature = "xkb")] - (Some(xkb::X11_EXTENSION_NAME), 101) => Some("SetDebuggingFlags"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 0) => Some("PrintQueryVersion"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 1) => Some("PrintGetPrinterList"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 2) => Some("CreateContext"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 3) => Some("PrintSetContext"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 4) => Some("PrintGetContext"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 5) => Some("PrintDestroyContext"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 6) => Some("PrintGetScreenOfContext"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 7) => Some("PrintStartJob"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 8) => Some("PrintEndJob"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 9) => Some("PrintStartDoc"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 10) => Some("PrintEndDoc"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 11) => Some("PrintPutDocumentData"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 12) => Some("PrintGetDocumentData"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 13) => Some("PrintStartPage"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 14) => Some("PrintEndPage"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 15) => Some("PrintSelectInput"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 16) => Some("PrintInputSelected"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 17) => Some("PrintGetAttributes"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 18) => Some("PrintSetAttributes"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 19) => Some("PrintGetOneAttributes"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 20) => Some("PrintRehashPrinterList"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 21) => Some("PrintGetPageDimensions"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 22) => Some("PrintQueryScreens"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 23) => Some("PrintSetImageResolution"), - #[cfg(feature = "xprint")] - (Some(xprint::X11_EXTENSION_NAME), 24) => Some("PrintGetImageResolution"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 1) => Some("SetDeviceCreateContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 2) => Some("GetDeviceCreateContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 3) => Some("SetDeviceContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 4) => Some("GetDeviceContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 5) => Some("SetWindowCreateContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 6) => Some("GetWindowCreateContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 7) => Some("GetWindowContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 8) => Some("SetPropertyCreateContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 9) => Some("GetPropertyCreateContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 10) => Some("SetPropertyUseContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 11) => Some("GetPropertyUseContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 12) => Some("GetPropertyContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 13) => Some("GetPropertyDataContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 14) => Some("ListProperties"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 15) => Some("SetSelectionCreateContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 16) => Some("GetSelectionCreateContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 17) => Some("SetSelectionUseContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 18) => Some("GetSelectionUseContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 19) => Some("GetSelectionContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 20) => Some("GetSelectionDataContext"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 21) => Some("ListSelections"), - #[cfg(feature = "xselinux")] - (Some(xselinux::X11_EXTENSION_NAME), 22) => Some("GetClientContext"), - #[cfg(feature = "xtest")] - (Some(xtest::X11_EXTENSION_NAME), 0) => Some("GetVersion"), - #[cfg(feature = "xtest")] - (Some(xtest::X11_EXTENSION_NAME), 1) => Some("CompareCursor"), - #[cfg(feature = "xtest")] - (Some(xtest::X11_EXTENSION_NAME), 2) => Some("FakeInput"), - #[cfg(feature = "xtest")] - (Some(xtest::X11_EXTENSION_NAME), 3) => Some("GrabControl"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 0) => Some("QueryExtension"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 1) => Some("QueryAdaptors"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 2) => Some("QueryEncodings"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 3) => Some("GrabPort"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 4) => Some("UngrabPort"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 5) => Some("PutVideo"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 6) => Some("PutStill"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 7) => Some("GetVideo"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 8) => Some("GetStill"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 9) => Some("StopVideo"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 10) => Some("SelectVideoNotify"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 11) => Some("SelectPortNotify"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 12) => Some("QueryBestSize"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 13) => Some("SetPortAttribute"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 14) => Some("GetPortAttribute"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 15) => Some("QueryPortAttributes"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 16) => Some("ListImageFormats"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 17) => Some("QueryImageAttributes"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 18) => Some("PutImage"), - #[cfg(feature = "xv")] - (Some(xv::X11_EXTENSION_NAME), 19) => Some("ShmPutImage"), - #[cfg(feature = "xvmc")] - (Some(xvmc::X11_EXTENSION_NAME), 0) => Some("QueryVersion"), - #[cfg(feature = "xvmc")] - (Some(xvmc::X11_EXTENSION_NAME), 1) => Some("ListSurfaceTypes"), - #[cfg(feature = "xvmc")] - (Some(xvmc::X11_EXTENSION_NAME), 2) => Some("CreateContext"), - #[cfg(feature = "xvmc")] - (Some(xvmc::X11_EXTENSION_NAME), 3) => Some("DestroyContext"), - #[cfg(feature = "xvmc")] - (Some(xvmc::X11_EXTENSION_NAME), 4) => Some("CreateSurface"), - #[cfg(feature = "xvmc")] - (Some(xvmc::X11_EXTENSION_NAME), 5) => Some("DestroySurface"), - #[cfg(feature = "xvmc")] - (Some(xvmc::X11_EXTENSION_NAME), 6) => Some("CreateSubpicture"), - #[cfg(feature = "xvmc")] - (Some(xvmc::X11_EXTENSION_NAME), 7) => Some("DestroySubpicture"), - #[cfg(feature = "xvmc")] - (Some(xvmc::X11_EXTENSION_NAME), 8) => Some("ListSubpictureTypes"), - _ => None, - } -} - -/// Enumeration of all possible X11 error kinds. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -#[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 = "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 = "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 = "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")] - 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 = "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::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 = "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::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 = "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::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.get(0) - .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) -} +pub use x11rb_protocol::protocol::Request; +pub use x11rb_protocol::protocol::Reply; +pub use x11rb_protocol::protocol::ErrorKind; +pub use x11rb_protocol::protocol::Event; diff --git a/src/protocol/present.rs b/src/protocol/present.rs index ebb956b2..280a3e41 100644 --- a/src/protocol/present.rs +++ b/src/protocol/present.rs @@ -7,37 +7,31 @@ #[allow(unused_imports)] use std::borrow::Cow; -use std::convert::TryFrom; #[allow(unused_imports)] use std::convert::TryInto; -use std::io::IoSlice; #[allow(unused_imports)] -use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum}; +use crate::utils::RawFdContainer; #[allow(unused_imports)] -use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd, TryIntoUSize}; -use crate::connection::{BufWithFds, PiecewiseBuf, RequestConnection}; +use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd}; +use std::io::IoSlice; +use crate::connection::RequestConnection; #[allow(unused_imports)] use crate::connection::Connection as X11Connection; #[allow(unused_imports)] use crate::cookie::{Cookie, CookieWithFds, VoidCookie}; -use crate::errors::{ConnectionError, ParseError}; +use crate::errors::ConnectionError; #[allow(unused_imports)] use crate::errors::ReplyOrIdError; +#[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, 2); +pub use x11rb_protocol::protocol::present::*; /// Get the major opcode of this extension fn major_opcode(conn: &Conn) -> Result { @@ -46,485 +40,14 @@ fn major_opcode(conn: &Conn) -> Result for u8 { - #[inline] - fn from(input: EventEnum) -> Self { - input.0 - } -} -impl From for std::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 std::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 std::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 std::fmt::Debug for EventEnum { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::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, PartialEq, Eq)] -pub struct EventMask(u8); -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 u8 { - #[inline] - fn from(input: EventMask) -> Self { - input.0 - } -} -impl From for std::option::Option { - #[inline] - fn from(input: EventMask) -> Self { - Some(input.0) - } -} -impl From for u16 { - #[inline] - fn from(input: EventMask) -> Self { - u16::from(input.0) - } -} -impl From for std::option::Option { - #[inline] - fn from(input: EventMask) -> Self { - Some(u16::from(input.0)) - } -} -impl From for u32 { - #[inline] - fn from(input: EventMask) -> Self { - u32::from(input.0) - } -} -impl From for std::option::Option { - #[inline] - fn from(input: EventMask) -> Self { - Some(u32::from(input.0)) - } -} -impl From for EventMask { - #[inline] - fn from(value: u8) -> Self { - Self(value) - } -} -impl std::fmt::Debug for EventMask { - fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let variants = [ - (Self::NO_EVENT.0.into(), "NO_EVENT", "NoEvent"), - (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_bitmask(fmt, self.0.into(), &variants) - } -} -bitmask_binop!(EventMask, u8); - -#[derive(Clone, Copy, PartialEq, Eq)] -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); -} -impl From