x11rb_protocol/protocol/
composite.rs

1// This file contains generated code. Do not edit directly.
2// To regenerate this, run 'make'.
3
4//! Bindings to the `Composite` X11 extension.
5
6#![allow(clippy::too_many_arguments)]
7// The code generator is simpler if it can always use conversions
8#![allow(clippy::useless_conversion)]
9
10#[allow(unused_imports)]
11use alloc::borrow::Cow;
12#[allow(unused_imports)]
13use core::convert::TryInto;
14use alloc::vec;
15use alloc::vec::Vec;
16use core::convert::TryFrom;
17use crate::errors::ParseError;
18#[allow(unused_imports)]
19use crate::x11_utils::TryIntoUSize;
20use crate::BufWithFds;
21#[allow(unused_imports)]
22use crate::utils::{RawFdContainer, pretty_print_bitmask, pretty_print_enum};
23#[allow(unused_imports)]
24use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd};
25#[allow(unused_imports)]
26use super::xfixes;
27#[allow(unused_imports)]
28use super::xproto;
29
30/// The X11 name of the extension for QueryExtension
31pub const X11_EXTENSION_NAME: &str = "Composite";
32
33/// The version number of this extension that this client library supports.
34///
35/// This constant contains the version number of this extension that is supported
36/// by this build of x11rb. For most things, it does not make sense to use this
37/// information. If you need to send a `QueryVersion`, it is recommended to instead
38/// send the maximum version of the extension that you need.
39pub const X11_XML_VERSION: (u32, u32) = (0, 4);
40
41#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
42#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
43pub struct Redirect(u8);
44impl Redirect {
45    pub const AUTOMATIC: Self = Self(0);
46    pub const MANUAL: Self = Self(1);
47}
48impl From<Redirect> for u8 {
49    #[inline]
50    fn from(input: Redirect) -> Self {
51        input.0
52    }
53}
54impl From<Redirect> for Option<u8> {
55    #[inline]
56    fn from(input: Redirect) -> Self {
57        Some(input.0)
58    }
59}
60impl From<Redirect> for u16 {
61    #[inline]
62    fn from(input: Redirect) -> Self {
63        u16::from(input.0)
64    }
65}
66impl From<Redirect> for Option<u16> {
67    #[inline]
68    fn from(input: Redirect) -> Self {
69        Some(u16::from(input.0))
70    }
71}
72impl From<Redirect> for u32 {
73    #[inline]
74    fn from(input: Redirect) -> Self {
75        u32::from(input.0)
76    }
77}
78impl From<Redirect> for Option<u32> {
79    #[inline]
80    fn from(input: Redirect) -> Self {
81        Some(u32::from(input.0))
82    }
83}
84impl From<u8> for Redirect {
85    #[inline]
86    fn from(value: u8) -> Self {
87        Self(value)
88    }
89}
90impl core::fmt::Debug for Redirect  {
91    fn fmt(&self, fmt: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
92        let variants = [
93            (Self::AUTOMATIC.0.into(), "AUTOMATIC", "Automatic"),
94            (Self::MANUAL.0.into(), "MANUAL", "Manual"),
95        ];
96        pretty_print_enum(fmt, self.0.into(), &variants)
97    }
98}
99
100/// Opcode for the QueryVersion request
101pub const QUERY_VERSION_REQUEST: u8 = 0;
102/// Negotiate the version of Composite.
103///
104/// This negotiates the version of the Composite extension.  It must be precede all
105/// other requests using Composite.  Failure to do so will cause a BadRequest error.
106///
107/// # Fields
108///
109/// * `client_major_version` - The major version supported by the client.
110/// * `client_minor_version` - The minor version supported by the client.
111#[derive(Clone, Copy, Default)]
112#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
113#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
114pub struct QueryVersionRequest {
115    pub client_major_version: u32,
116    pub client_minor_version: u32,
117}
118impl_debug_if_no_extra_traits!(QueryVersionRequest, "QueryVersionRequest");
119impl QueryVersionRequest {
120    /// Serialize this request into bytes for the provided connection
121    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
122        let length_so_far = 0;
123        let client_major_version_bytes = self.client_major_version.serialize();
124        let client_minor_version_bytes = self.client_minor_version.serialize();
125        let mut request0 = vec![
126            major_opcode,
127            QUERY_VERSION_REQUEST,
128            0,
129            0,
130            client_major_version_bytes[0],
131            client_major_version_bytes[1],
132            client_major_version_bytes[2],
133            client_major_version_bytes[3],
134            client_minor_version_bytes[0],
135            client_minor_version_bytes[1],
136            client_minor_version_bytes[2],
137            client_minor_version_bytes[3],
138        ];
139        let length_so_far = length_so_far + request0.len();
140        assert_eq!(length_so_far % 4, 0);
141        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
142        request0[2..4].copy_from_slice(&length.to_ne_bytes());
143        ([request0.into()], vec![])
144    }
145    /// Parse this request given its header, its body, and any fds that go along with it
146    #[cfg(feature = "request-parsing")]
147    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
148        if header.minor_opcode != QUERY_VERSION_REQUEST {
149            return Err(ParseError::InvalidValue);
150        }
151        let (client_major_version, remaining) = u32::try_parse(value)?;
152        let (client_minor_version, remaining) = u32::try_parse(remaining)?;
153        let _ = remaining;
154        Ok(QueryVersionRequest {
155            client_major_version,
156            client_minor_version,
157        })
158    }
159}
160impl Request for QueryVersionRequest {
161    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
162
163    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
164        let (bufs, fds) = self.serialize(major_opcode);
165        // Flatten the buffers into a single vector
166        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
167        (buf, fds)
168    }
169}
170impl crate::x11_utils::ReplyRequest for QueryVersionRequest {
171    type Reply = QueryVersionReply;
172}
173
174/// The negotiated version of Composite.
175///
176/// This indicates the version of Composite chosen by the server.  It will always be
177/// less than or equal to the version offered by the client.
178///
179/// # Fields
180///
181/// * `major_version` - The major version chosen by the server.
182/// * `minor_version` - The minor version chosen by the server.
183#[derive(Clone, Copy, Default)]
184#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
185#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
186pub struct QueryVersionReply {
187    pub sequence: u16,
188    pub length: u32,
189    pub major_version: u32,
190    pub minor_version: u32,
191}
192impl_debug_if_no_extra_traits!(QueryVersionReply, "QueryVersionReply");
193impl TryParse for QueryVersionReply {
194    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
195        let remaining = initial_value;
196        let (response_type, remaining) = u8::try_parse(remaining)?;
197        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
198        let (sequence, remaining) = u16::try_parse(remaining)?;
199        let (length, remaining) = u32::try_parse(remaining)?;
200        let (major_version, remaining) = u32::try_parse(remaining)?;
201        let (minor_version, remaining) = u32::try_parse(remaining)?;
202        let remaining = remaining.get(16..).ok_or(ParseError::InsufficientData)?;
203        if response_type != 1 {
204            return Err(ParseError::InvalidValue);
205        }
206        let result = QueryVersionReply { sequence, length, major_version, minor_version };
207        let _ = remaining;
208        let remaining = initial_value.get(32 + length as usize * 4..)
209            .ok_or(ParseError::InsufficientData)?;
210        Ok((result, remaining))
211    }
212}
213impl Serialize for QueryVersionReply {
214    type Bytes = [u8; 32];
215    fn serialize(&self) -> [u8; 32] {
216        let response_type_bytes = &[1];
217        let sequence_bytes = self.sequence.serialize();
218        let length_bytes = self.length.serialize();
219        let major_version_bytes = self.major_version.serialize();
220        let minor_version_bytes = self.minor_version.serialize();
221        [
222            response_type_bytes[0],
223            0,
224            sequence_bytes[0],
225            sequence_bytes[1],
226            length_bytes[0],
227            length_bytes[1],
228            length_bytes[2],
229            length_bytes[3],
230            major_version_bytes[0],
231            major_version_bytes[1],
232            major_version_bytes[2],
233            major_version_bytes[3],
234            minor_version_bytes[0],
235            minor_version_bytes[1],
236            minor_version_bytes[2],
237            minor_version_bytes[3],
238            0,
239            0,
240            0,
241            0,
242            0,
243            0,
244            0,
245            0,
246            0,
247            0,
248            0,
249            0,
250            0,
251            0,
252            0,
253            0,
254        ]
255    }
256    fn serialize_into(&self, bytes: &mut Vec<u8>) {
257        bytes.reserve(32);
258        let response_type_bytes = &[1];
259        bytes.push(response_type_bytes[0]);
260        bytes.extend_from_slice(&[0; 1]);
261        self.sequence.serialize_into(bytes);
262        self.length.serialize_into(bytes);
263        self.major_version.serialize_into(bytes);
264        self.minor_version.serialize_into(bytes);
265        bytes.extend_from_slice(&[0; 16]);
266    }
267}
268
269/// Opcode for the RedirectWindow request
270pub const REDIRECT_WINDOW_REQUEST: u8 = 1;
271/// Redirect the hierarchy starting at "window" to off-screen storage..
272///
273/// The hierarchy starting at 'window' is directed to off-screen
274/// storage.  When all clients enabling redirection terminate,
275/// the redirection will automatically be disabled.
276///
277/// The root window may not be redirected. Doing so results in a Match
278/// error.
279///
280/// # Fields
281///
282/// * `window` - The root of the hierarchy to redirect to off-screen storage.
283/// * `update` - Whether contents are automatically mirrored to the parent window.  If one client
284/// already specifies an update type of Manual, any attempt by another to specify a
285/// mode of Manual so will result in an Access error.
286#[derive(Clone, Copy, Default)]
287#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
288#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
289pub struct RedirectWindowRequest {
290    pub window: xproto::Window,
291    pub update: Redirect,
292}
293impl_debug_if_no_extra_traits!(RedirectWindowRequest, "RedirectWindowRequest");
294impl RedirectWindowRequest {
295    /// Serialize this request into bytes for the provided connection
296    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
297        let length_so_far = 0;
298        let window_bytes = self.window.serialize();
299        let update_bytes = u8::from(self.update).serialize();
300        let mut request0 = vec![
301            major_opcode,
302            REDIRECT_WINDOW_REQUEST,
303            0,
304            0,
305            window_bytes[0],
306            window_bytes[1],
307            window_bytes[2],
308            window_bytes[3],
309            update_bytes[0],
310            0,
311            0,
312            0,
313        ];
314        let length_so_far = length_so_far + request0.len();
315        assert_eq!(length_so_far % 4, 0);
316        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
317        request0[2..4].copy_from_slice(&length.to_ne_bytes());
318        ([request0.into()], vec![])
319    }
320    /// Parse this request given its header, its body, and any fds that go along with it
321    #[cfg(feature = "request-parsing")]
322    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
323        if header.minor_opcode != REDIRECT_WINDOW_REQUEST {
324            return Err(ParseError::InvalidValue);
325        }
326        let (window, remaining) = xproto::Window::try_parse(value)?;
327        let (update, remaining) = u8::try_parse(remaining)?;
328        let update = update.into();
329        let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
330        let _ = remaining;
331        Ok(RedirectWindowRequest {
332            window,
333            update,
334        })
335    }
336}
337impl Request for RedirectWindowRequest {
338    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
339
340    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
341        let (bufs, fds) = self.serialize(major_opcode);
342        // Flatten the buffers into a single vector
343        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
344        (buf, fds)
345    }
346}
347impl crate::x11_utils::VoidRequest for RedirectWindowRequest {
348}
349
350/// Opcode for the RedirectSubwindows request
351pub const REDIRECT_SUBWINDOWS_REQUEST: u8 = 2;
352/// Redirect all current and future children of ‘window’.
353///
354/// Hierarchies starting at all current and future children of window
355/// will be redirected as in RedirectWindow. If update is Manual,
356/// then painting of the window background during window manipulation
357/// and ClearArea requests is inhibited.
358///
359/// # Fields
360///
361/// * `window` - The root of the hierarchy to redirect to off-screen storage.
362/// * `update` - Whether contents are automatically mirrored to the parent window.  If one client
363/// already specifies an update type of Manual, any attempt by another to specify a
364/// mode of Manual so will result in an Access error.
365#[derive(Clone, Copy, Default)]
366#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
367#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
368pub struct RedirectSubwindowsRequest {
369    pub window: xproto::Window,
370    pub update: Redirect,
371}
372impl_debug_if_no_extra_traits!(RedirectSubwindowsRequest, "RedirectSubwindowsRequest");
373impl RedirectSubwindowsRequest {
374    /// Serialize this request into bytes for the provided connection
375    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
376        let length_so_far = 0;
377        let window_bytes = self.window.serialize();
378        let update_bytes = u8::from(self.update).serialize();
379        let mut request0 = vec![
380            major_opcode,
381            REDIRECT_SUBWINDOWS_REQUEST,
382            0,
383            0,
384            window_bytes[0],
385            window_bytes[1],
386            window_bytes[2],
387            window_bytes[3],
388            update_bytes[0],
389            0,
390            0,
391            0,
392        ];
393        let length_so_far = length_so_far + request0.len();
394        assert_eq!(length_so_far % 4, 0);
395        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
396        request0[2..4].copy_from_slice(&length.to_ne_bytes());
397        ([request0.into()], vec![])
398    }
399    /// Parse this request given its header, its body, and any fds that go along with it
400    #[cfg(feature = "request-parsing")]
401    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
402        if header.minor_opcode != REDIRECT_SUBWINDOWS_REQUEST {
403            return Err(ParseError::InvalidValue);
404        }
405        let (window, remaining) = xproto::Window::try_parse(value)?;
406        let (update, remaining) = u8::try_parse(remaining)?;
407        let update = update.into();
408        let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
409        let _ = remaining;
410        Ok(RedirectSubwindowsRequest {
411            window,
412            update,
413        })
414    }
415}
416impl Request for RedirectSubwindowsRequest {
417    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
418
419    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
420        let (bufs, fds) = self.serialize(major_opcode);
421        // Flatten the buffers into a single vector
422        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
423        (buf, fds)
424    }
425}
426impl crate::x11_utils::VoidRequest for RedirectSubwindowsRequest {
427}
428
429/// Opcode for the UnredirectWindow request
430pub const UNREDIRECT_WINDOW_REQUEST: u8 = 3;
431/// Terminate redirection of the specified window..
432///
433/// Redirection of the specified window will be terminated.  This cannot be
434/// used if the window was redirected with RedirectSubwindows.
435///
436/// # Fields
437///
438/// * `window` - The window to terminate redirection of.  Must be redirected by the
439/// current client, or a Value error results.
440/// * `update` - The update type passed to RedirectWindows.  If this does not match the
441/// previously requested update type, a Value error results.
442#[derive(Clone, Copy, Default)]
443#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
444#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
445pub struct UnredirectWindowRequest {
446    pub window: xproto::Window,
447    pub update: Redirect,
448}
449impl_debug_if_no_extra_traits!(UnredirectWindowRequest, "UnredirectWindowRequest");
450impl UnredirectWindowRequest {
451    /// Serialize this request into bytes for the provided connection
452    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
453        let length_so_far = 0;
454        let window_bytes = self.window.serialize();
455        let update_bytes = u8::from(self.update).serialize();
456        let mut request0 = vec![
457            major_opcode,
458            UNREDIRECT_WINDOW_REQUEST,
459            0,
460            0,
461            window_bytes[0],
462            window_bytes[1],
463            window_bytes[2],
464            window_bytes[3],
465            update_bytes[0],
466            0,
467            0,
468            0,
469        ];
470        let length_so_far = length_so_far + request0.len();
471        assert_eq!(length_so_far % 4, 0);
472        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
473        request0[2..4].copy_from_slice(&length.to_ne_bytes());
474        ([request0.into()], vec![])
475    }
476    /// Parse this request given its header, its body, and any fds that go along with it
477    #[cfg(feature = "request-parsing")]
478    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
479        if header.minor_opcode != UNREDIRECT_WINDOW_REQUEST {
480            return Err(ParseError::InvalidValue);
481        }
482        let (window, remaining) = xproto::Window::try_parse(value)?;
483        let (update, remaining) = u8::try_parse(remaining)?;
484        let update = update.into();
485        let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
486        let _ = remaining;
487        Ok(UnredirectWindowRequest {
488            window,
489            update,
490        })
491    }
492}
493impl Request for UnredirectWindowRequest {
494    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
495
496    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
497        let (bufs, fds) = self.serialize(major_opcode);
498        // Flatten the buffers into a single vector
499        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
500        (buf, fds)
501    }
502}
503impl crate::x11_utils::VoidRequest for UnredirectWindowRequest {
504}
505
506/// Opcode for the UnredirectSubwindows request
507pub const UNREDIRECT_SUBWINDOWS_REQUEST: u8 = 4;
508/// Terminate redirection of the specified window’s children.
509///
510/// Redirection of all children of window will be terminated.
511///
512/// # Fields
513///
514/// * `window` - The window to terminate redirection of.  Must have previously been
515/// selected for sub-redirection by the current client, or a Value error
516/// results.
517/// * `update` - The update type passed to RedirectSubWindows.  If this does not match
518/// the previously requested update type, a Value error results.
519#[derive(Clone, Copy, Default)]
520#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
521#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
522pub struct UnredirectSubwindowsRequest {
523    pub window: xproto::Window,
524    pub update: Redirect,
525}
526impl_debug_if_no_extra_traits!(UnredirectSubwindowsRequest, "UnredirectSubwindowsRequest");
527impl UnredirectSubwindowsRequest {
528    /// Serialize this request into bytes for the provided connection
529    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
530        let length_so_far = 0;
531        let window_bytes = self.window.serialize();
532        let update_bytes = u8::from(self.update).serialize();
533        let mut request0 = vec![
534            major_opcode,
535            UNREDIRECT_SUBWINDOWS_REQUEST,
536            0,
537            0,
538            window_bytes[0],
539            window_bytes[1],
540            window_bytes[2],
541            window_bytes[3],
542            update_bytes[0],
543            0,
544            0,
545            0,
546        ];
547        let length_so_far = length_so_far + request0.len();
548        assert_eq!(length_so_far % 4, 0);
549        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
550        request0[2..4].copy_from_slice(&length.to_ne_bytes());
551        ([request0.into()], vec![])
552    }
553    /// Parse this request given its header, its body, and any fds that go along with it
554    #[cfg(feature = "request-parsing")]
555    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
556        if header.minor_opcode != UNREDIRECT_SUBWINDOWS_REQUEST {
557            return Err(ParseError::InvalidValue);
558        }
559        let (window, remaining) = xproto::Window::try_parse(value)?;
560        let (update, remaining) = u8::try_parse(remaining)?;
561        let update = update.into();
562        let remaining = remaining.get(3..).ok_or(ParseError::InsufficientData)?;
563        let _ = remaining;
564        Ok(UnredirectSubwindowsRequest {
565            window,
566            update,
567        })
568    }
569}
570impl Request for UnredirectSubwindowsRequest {
571    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
572
573    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
574        let (bufs, fds) = self.serialize(major_opcode);
575        // Flatten the buffers into a single vector
576        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
577        (buf, fds)
578    }
579}
580impl crate::x11_utils::VoidRequest for UnredirectSubwindowsRequest {
581}
582
583/// Opcode for the CreateRegionFromBorderClip request
584pub const CREATE_REGION_FROM_BORDER_CLIP_REQUEST: u8 = 5;
585#[derive(Clone, Copy, Default)]
586#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
587#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
588pub struct CreateRegionFromBorderClipRequest {
589    pub region: xfixes::Region,
590    pub window: xproto::Window,
591}
592impl_debug_if_no_extra_traits!(CreateRegionFromBorderClipRequest, "CreateRegionFromBorderClipRequest");
593impl CreateRegionFromBorderClipRequest {
594    /// Serialize this request into bytes for the provided connection
595    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
596        let length_so_far = 0;
597        let region_bytes = self.region.serialize();
598        let window_bytes = self.window.serialize();
599        let mut request0 = vec![
600            major_opcode,
601            CREATE_REGION_FROM_BORDER_CLIP_REQUEST,
602            0,
603            0,
604            region_bytes[0],
605            region_bytes[1],
606            region_bytes[2],
607            region_bytes[3],
608            window_bytes[0],
609            window_bytes[1],
610            window_bytes[2],
611            window_bytes[3],
612        ];
613        let length_so_far = length_so_far + request0.len();
614        assert_eq!(length_so_far % 4, 0);
615        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
616        request0[2..4].copy_from_slice(&length.to_ne_bytes());
617        ([request0.into()], vec![])
618    }
619    /// Parse this request given its header, its body, and any fds that go along with it
620    #[cfg(feature = "request-parsing")]
621    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
622        if header.minor_opcode != CREATE_REGION_FROM_BORDER_CLIP_REQUEST {
623            return Err(ParseError::InvalidValue);
624        }
625        let (region, remaining) = xfixes::Region::try_parse(value)?;
626        let (window, remaining) = xproto::Window::try_parse(remaining)?;
627        let _ = remaining;
628        Ok(CreateRegionFromBorderClipRequest {
629            region,
630            window,
631        })
632    }
633}
634impl Request for CreateRegionFromBorderClipRequest {
635    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
636
637    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
638        let (bufs, fds) = self.serialize(major_opcode);
639        // Flatten the buffers into a single vector
640        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
641        (buf, fds)
642    }
643}
644impl crate::x11_utils::VoidRequest for CreateRegionFromBorderClipRequest {
645}
646
647/// Opcode for the NameWindowPixmap request
648pub const NAME_WINDOW_PIXMAP_REQUEST: u8 = 6;
649#[derive(Clone, Copy, Default)]
650#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
651#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
652pub struct NameWindowPixmapRequest {
653    pub window: xproto::Window,
654    pub pixmap: xproto::Pixmap,
655}
656impl_debug_if_no_extra_traits!(NameWindowPixmapRequest, "NameWindowPixmapRequest");
657impl NameWindowPixmapRequest {
658    /// Serialize this request into bytes for the provided connection
659    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
660        let length_so_far = 0;
661        let window_bytes = self.window.serialize();
662        let pixmap_bytes = self.pixmap.serialize();
663        let mut request0 = vec![
664            major_opcode,
665            NAME_WINDOW_PIXMAP_REQUEST,
666            0,
667            0,
668            window_bytes[0],
669            window_bytes[1],
670            window_bytes[2],
671            window_bytes[3],
672            pixmap_bytes[0],
673            pixmap_bytes[1],
674            pixmap_bytes[2],
675            pixmap_bytes[3],
676        ];
677        let length_so_far = length_so_far + request0.len();
678        assert_eq!(length_so_far % 4, 0);
679        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
680        request0[2..4].copy_from_slice(&length.to_ne_bytes());
681        ([request0.into()], vec![])
682    }
683    /// Parse this request given its header, its body, and any fds that go along with it
684    #[cfg(feature = "request-parsing")]
685    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
686        if header.minor_opcode != NAME_WINDOW_PIXMAP_REQUEST {
687            return Err(ParseError::InvalidValue);
688        }
689        let (window, remaining) = xproto::Window::try_parse(value)?;
690        let (pixmap, remaining) = xproto::Pixmap::try_parse(remaining)?;
691        let _ = remaining;
692        Ok(NameWindowPixmapRequest {
693            window,
694            pixmap,
695        })
696    }
697}
698impl Request for NameWindowPixmapRequest {
699    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
700
701    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
702        let (bufs, fds) = self.serialize(major_opcode);
703        // Flatten the buffers into a single vector
704        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
705        (buf, fds)
706    }
707}
708impl crate::x11_utils::VoidRequest for NameWindowPixmapRequest {
709}
710
711/// Opcode for the GetOverlayWindow request
712pub const GET_OVERLAY_WINDOW_REQUEST: u8 = 7;
713#[derive(Clone, Copy, Default)]
714#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
715#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
716pub struct GetOverlayWindowRequest {
717    pub window: xproto::Window,
718}
719impl_debug_if_no_extra_traits!(GetOverlayWindowRequest, "GetOverlayWindowRequest");
720impl GetOverlayWindowRequest {
721    /// Serialize this request into bytes for the provided connection
722    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
723        let length_so_far = 0;
724        let window_bytes = self.window.serialize();
725        let mut request0 = vec![
726            major_opcode,
727            GET_OVERLAY_WINDOW_REQUEST,
728            0,
729            0,
730            window_bytes[0],
731            window_bytes[1],
732            window_bytes[2],
733            window_bytes[3],
734        ];
735        let length_so_far = length_so_far + request0.len();
736        assert_eq!(length_so_far % 4, 0);
737        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
738        request0[2..4].copy_from_slice(&length.to_ne_bytes());
739        ([request0.into()], vec![])
740    }
741    /// Parse this request given its header, its body, and any fds that go along with it
742    #[cfg(feature = "request-parsing")]
743    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
744        if header.minor_opcode != GET_OVERLAY_WINDOW_REQUEST {
745            return Err(ParseError::InvalidValue);
746        }
747        let (window, remaining) = xproto::Window::try_parse(value)?;
748        let _ = remaining;
749        Ok(GetOverlayWindowRequest {
750            window,
751        })
752    }
753}
754impl Request for GetOverlayWindowRequest {
755    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
756
757    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
758        let (bufs, fds) = self.serialize(major_opcode);
759        // Flatten the buffers into a single vector
760        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
761        (buf, fds)
762    }
763}
764impl crate::x11_utils::ReplyRequest for GetOverlayWindowRequest {
765    type Reply = GetOverlayWindowReply;
766}
767
768#[derive(Clone, Copy, Default)]
769#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
770#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
771pub struct GetOverlayWindowReply {
772    pub sequence: u16,
773    pub length: u32,
774    pub overlay_win: xproto::Window,
775}
776impl_debug_if_no_extra_traits!(GetOverlayWindowReply, "GetOverlayWindowReply");
777impl TryParse for GetOverlayWindowReply {
778    fn try_parse(initial_value: &[u8]) -> Result<(Self, &[u8]), ParseError> {
779        let remaining = initial_value;
780        let (response_type, remaining) = u8::try_parse(remaining)?;
781        let remaining = remaining.get(1..).ok_or(ParseError::InsufficientData)?;
782        let (sequence, remaining) = u16::try_parse(remaining)?;
783        let (length, remaining) = u32::try_parse(remaining)?;
784        let (overlay_win, remaining) = xproto::Window::try_parse(remaining)?;
785        let remaining = remaining.get(20..).ok_or(ParseError::InsufficientData)?;
786        if response_type != 1 {
787            return Err(ParseError::InvalidValue);
788        }
789        let result = GetOverlayWindowReply { sequence, length, overlay_win };
790        let _ = remaining;
791        let remaining = initial_value.get(32 + length as usize * 4..)
792            .ok_or(ParseError::InsufficientData)?;
793        Ok((result, remaining))
794    }
795}
796impl Serialize for GetOverlayWindowReply {
797    type Bytes = [u8; 32];
798    fn serialize(&self) -> [u8; 32] {
799        let response_type_bytes = &[1];
800        let sequence_bytes = self.sequence.serialize();
801        let length_bytes = self.length.serialize();
802        let overlay_win_bytes = self.overlay_win.serialize();
803        [
804            response_type_bytes[0],
805            0,
806            sequence_bytes[0],
807            sequence_bytes[1],
808            length_bytes[0],
809            length_bytes[1],
810            length_bytes[2],
811            length_bytes[3],
812            overlay_win_bytes[0],
813            overlay_win_bytes[1],
814            overlay_win_bytes[2],
815            overlay_win_bytes[3],
816            0,
817            0,
818            0,
819            0,
820            0,
821            0,
822            0,
823            0,
824            0,
825            0,
826            0,
827            0,
828            0,
829            0,
830            0,
831            0,
832            0,
833            0,
834            0,
835            0,
836        ]
837    }
838    fn serialize_into(&self, bytes: &mut Vec<u8>) {
839        bytes.reserve(32);
840        let response_type_bytes = &[1];
841        bytes.push(response_type_bytes[0]);
842        bytes.extend_from_slice(&[0; 1]);
843        self.sequence.serialize_into(bytes);
844        self.length.serialize_into(bytes);
845        self.overlay_win.serialize_into(bytes);
846        bytes.extend_from_slice(&[0; 20]);
847    }
848}
849
850/// Opcode for the ReleaseOverlayWindow request
851pub const RELEASE_OVERLAY_WINDOW_REQUEST: u8 = 8;
852#[derive(Clone, Copy, Default)]
853#[cfg_attr(feature = "extra-traits", derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash))]
854#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
855pub struct ReleaseOverlayWindowRequest {
856    pub window: xproto::Window,
857}
858impl_debug_if_no_extra_traits!(ReleaseOverlayWindowRequest, "ReleaseOverlayWindowRequest");
859impl ReleaseOverlayWindowRequest {
860    /// Serialize this request into bytes for the provided connection
861    pub fn serialize(self, major_opcode: u8) -> BufWithFds<[Cow<'static, [u8]>; 1]> {
862        let length_so_far = 0;
863        let window_bytes = self.window.serialize();
864        let mut request0 = vec![
865            major_opcode,
866            RELEASE_OVERLAY_WINDOW_REQUEST,
867            0,
868            0,
869            window_bytes[0],
870            window_bytes[1],
871            window_bytes[2],
872            window_bytes[3],
873        ];
874        let length_so_far = length_so_far + request0.len();
875        assert_eq!(length_so_far % 4, 0);
876        let length = u16::try_from(length_so_far / 4).unwrap_or(0);
877        request0[2..4].copy_from_slice(&length.to_ne_bytes());
878        ([request0.into()], vec![])
879    }
880    /// Parse this request given its header, its body, and any fds that go along with it
881    #[cfg(feature = "request-parsing")]
882    pub fn try_parse_request(header: RequestHeader, value: &[u8]) -> Result<Self, ParseError> {
883        if header.minor_opcode != RELEASE_OVERLAY_WINDOW_REQUEST {
884            return Err(ParseError::InvalidValue);
885        }
886        let (window, remaining) = xproto::Window::try_parse(value)?;
887        let _ = remaining;
888        Ok(ReleaseOverlayWindowRequest {
889            window,
890        })
891    }
892}
893impl Request for ReleaseOverlayWindowRequest {
894    const EXTENSION_NAME: Option<&'static str> = Some(X11_EXTENSION_NAME);
895
896    fn serialize(self, major_opcode: u8) -> BufWithFds<Vec<u8>> {
897        let (bufs, fds) = self.serialize(major_opcode);
898        // Flatten the buffers into a single vector
899        let buf = bufs.iter().flat_map(|buf| buf.iter().copied()).collect();
900        (buf, fds)
901    }
902}
903impl crate::x11_utils::VoidRequest for ReleaseOverlayWindowRequest {
904}
905