x11rb/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
8#[allow(unused_imports)]
9use std::borrow::Cow;
10#[allow(unused_imports)]
11use std::convert::TryInto;
12#[allow(unused_imports)]
13use crate::utils::RawFdContainer;
14#[allow(unused_imports)]
15use crate::x11_utils::{Request, RequestHeader, Serialize, TryParse, TryParseFd};
16use std::io::IoSlice;
17use crate::connection::RequestConnection;
18#[allow(unused_imports)]
19use crate::connection::Connection as X11Connection;
20#[allow(unused_imports)]
21use crate::cookie::{Cookie, CookieWithFds, VoidCookie};
22use crate::errors::ConnectionError;
23#[allow(unused_imports)]
24use crate::errors::ReplyOrIdError;
25#[allow(unused_imports)]
26use super::xfixes;
27#[allow(unused_imports)]
28use super::xproto;
29
30pub use x11rb_protocol::protocol::composite::*;
31
32/// Get the major opcode of this extension
33fn major_opcode<Conn: RequestConnection + ?Sized>(conn: &Conn) -> Result<u8, ConnectionError> {
34    let info = conn.extension_information(X11_EXTENSION_NAME)?;
35    let info = info.ok_or(ConnectionError::UnsupportedExtension)?;
36    Ok(info.major_opcode)
37}
38
39/// Negotiate the version of Composite.
40///
41/// This negotiates the version of the Composite extension.  It must be precede all
42/// other requests using Composite.  Failure to do so will cause a BadRequest error.
43///
44/// # Fields
45///
46/// * `client_major_version` - The major version supported by the client.
47/// * `client_minor_version` - The minor version supported by the client.
48pub fn query_version<Conn>(conn: &Conn, client_major_version: u32, client_minor_version: u32) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
49where
50    Conn: RequestConnection + ?Sized,
51{
52    let request0 = QueryVersionRequest {
53        client_major_version,
54        client_minor_version,
55    };
56    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
57    let slices = [IoSlice::new(&bytes[0])];
58    assert_eq!(slices.len(), bytes.len());
59    conn.send_request_with_reply(&slices, fds)
60}
61
62/// Redirect the hierarchy starting at "window" to off-screen storage..
63///
64/// The hierarchy starting at 'window' is directed to off-screen
65/// storage.  When all clients enabling redirection terminate,
66/// the redirection will automatically be disabled.
67///
68/// The root window may not be redirected. Doing so results in a Match
69/// error.
70///
71/// # Fields
72///
73/// * `window` - The root of the hierarchy to redirect to off-screen storage.
74/// * `update` - Whether contents are automatically mirrored to the parent window.  If one client
75/// already specifies an update type of Manual, any attempt by another to specify a
76/// mode of Manual so will result in an Access error.
77pub fn redirect_window<Conn>(conn: &Conn, window: xproto::Window, update: Redirect) -> Result<VoidCookie<'_, Conn>, ConnectionError>
78where
79    Conn: RequestConnection + ?Sized,
80{
81    let request0 = RedirectWindowRequest {
82        window,
83        update,
84    };
85    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
86    let slices = [IoSlice::new(&bytes[0])];
87    assert_eq!(slices.len(), bytes.len());
88    conn.send_request_without_reply(&slices, fds)
89}
90
91/// Redirect all current and future children of ‘window’.
92///
93/// Hierarchies starting at all current and future children of window
94/// will be redirected as in RedirectWindow. If update is Manual,
95/// then painting of the window background during window manipulation
96/// and ClearArea requests is inhibited.
97///
98/// # Fields
99///
100/// * `window` - The root of the hierarchy to redirect to off-screen storage.
101/// * `update` - Whether contents are automatically mirrored to the parent window.  If one client
102/// already specifies an update type of Manual, any attempt by another to specify a
103/// mode of Manual so will result in an Access error.
104pub fn redirect_subwindows<Conn>(conn: &Conn, window: xproto::Window, update: Redirect) -> Result<VoidCookie<'_, Conn>, ConnectionError>
105where
106    Conn: RequestConnection + ?Sized,
107{
108    let request0 = RedirectSubwindowsRequest {
109        window,
110        update,
111    };
112    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
113    let slices = [IoSlice::new(&bytes[0])];
114    assert_eq!(slices.len(), bytes.len());
115    conn.send_request_without_reply(&slices, fds)
116}
117
118/// Terminate redirection of the specified window..
119///
120/// Redirection of the specified window will be terminated.  This cannot be
121/// used if the window was redirected with RedirectSubwindows.
122///
123/// # Fields
124///
125/// * `window` - The window to terminate redirection of.  Must be redirected by the
126/// current client, or a Value error results.
127/// * `update` - The update type passed to RedirectWindows.  If this does not match the
128/// previously requested update type, a Value error results.
129pub fn unredirect_window<Conn>(conn: &Conn, window: xproto::Window, update: Redirect) -> Result<VoidCookie<'_, Conn>, ConnectionError>
130where
131    Conn: RequestConnection + ?Sized,
132{
133    let request0 = UnredirectWindowRequest {
134        window,
135        update,
136    };
137    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
138    let slices = [IoSlice::new(&bytes[0])];
139    assert_eq!(slices.len(), bytes.len());
140    conn.send_request_without_reply(&slices, fds)
141}
142
143/// Terminate redirection of the specified window’s children.
144///
145/// Redirection of all children of window will be terminated.
146///
147/// # Fields
148///
149/// * `window` - The window to terminate redirection of.  Must have previously been
150/// selected for sub-redirection by the current client, or a Value error
151/// results.
152/// * `update` - The update type passed to RedirectSubWindows.  If this does not match
153/// the previously requested update type, a Value error results.
154pub fn unredirect_subwindows<Conn>(conn: &Conn, window: xproto::Window, update: Redirect) -> Result<VoidCookie<'_, Conn>, ConnectionError>
155where
156    Conn: RequestConnection + ?Sized,
157{
158    let request0 = UnredirectSubwindowsRequest {
159        window,
160        update,
161    };
162    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
163    let slices = [IoSlice::new(&bytes[0])];
164    assert_eq!(slices.len(), bytes.len());
165    conn.send_request_without_reply(&slices, fds)
166}
167
168pub fn create_region_from_border_clip<Conn>(conn: &Conn, region: xfixes::Region, window: xproto::Window) -> Result<VoidCookie<'_, Conn>, ConnectionError>
169where
170    Conn: RequestConnection + ?Sized,
171{
172    let request0 = CreateRegionFromBorderClipRequest {
173        region,
174        window,
175    };
176    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
177    let slices = [IoSlice::new(&bytes[0])];
178    assert_eq!(slices.len(), bytes.len());
179    conn.send_request_without_reply(&slices, fds)
180}
181
182pub fn name_window_pixmap<Conn>(conn: &Conn, window: xproto::Window, pixmap: xproto::Pixmap) -> Result<VoidCookie<'_, Conn>, ConnectionError>
183where
184    Conn: RequestConnection + ?Sized,
185{
186    let request0 = NameWindowPixmapRequest {
187        window,
188        pixmap,
189    };
190    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
191    let slices = [IoSlice::new(&bytes[0])];
192    assert_eq!(slices.len(), bytes.len());
193    conn.send_request_without_reply(&slices, fds)
194}
195
196pub fn get_overlay_window<Conn>(conn: &Conn, window: xproto::Window) -> Result<Cookie<'_, Conn, GetOverlayWindowReply>, ConnectionError>
197where
198    Conn: RequestConnection + ?Sized,
199{
200    let request0 = GetOverlayWindowRequest {
201        window,
202    };
203    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
204    let slices = [IoSlice::new(&bytes[0])];
205    assert_eq!(slices.len(), bytes.len());
206    conn.send_request_with_reply(&slices, fds)
207}
208
209pub fn release_overlay_window<Conn>(conn: &Conn, window: xproto::Window) -> Result<VoidCookie<'_, Conn>, ConnectionError>
210where
211    Conn: RequestConnection + ?Sized,
212{
213    let request0 = ReleaseOverlayWindowRequest {
214        window,
215    };
216    let (bytes, fds) = request0.serialize(major_opcode(conn)?);
217    let slices = [IoSlice::new(&bytes[0])];
218    assert_eq!(slices.len(), bytes.len());
219    conn.send_request_without_reply(&slices, fds)
220}
221
222/// Extension trait defining the requests of this extension.
223pub trait ConnectionExt: RequestConnection {
224    /// Negotiate the version of Composite.
225    ///
226    /// This negotiates the version of the Composite extension.  It must be precede all
227    /// other requests using Composite.  Failure to do so will cause a BadRequest error.
228    ///
229    /// # Fields
230    ///
231    /// * `client_major_version` - The major version supported by the client.
232    /// * `client_minor_version` - The minor version supported by the client.
233    fn composite_query_version(&self, client_major_version: u32, client_minor_version: u32) -> Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>
234    {
235        query_version(self, client_major_version, client_minor_version)
236    }
237    /// Redirect the hierarchy starting at "window" to off-screen storage..
238    ///
239    /// The hierarchy starting at 'window' is directed to off-screen
240    /// storage.  When all clients enabling redirection terminate,
241    /// the redirection will automatically be disabled.
242    ///
243    /// The root window may not be redirected. Doing so results in a Match
244    /// error.
245    ///
246    /// # Fields
247    ///
248    /// * `window` - The root of the hierarchy to redirect to off-screen storage.
249    /// * `update` - Whether contents are automatically mirrored to the parent window.  If one client
250    /// already specifies an update type of Manual, any attempt by another to specify a
251    /// mode of Manual so will result in an Access error.
252    fn composite_redirect_window(&self, window: xproto::Window, update: Redirect) -> Result<VoidCookie<'_, Self>, ConnectionError>
253    {
254        redirect_window(self, window, update)
255    }
256    /// Redirect all current and future children of ‘window’.
257    ///
258    /// Hierarchies starting at all current and future children of window
259    /// will be redirected as in RedirectWindow. If update is Manual,
260    /// then painting of the window background during window manipulation
261    /// and ClearArea requests is inhibited.
262    ///
263    /// # Fields
264    ///
265    /// * `window` - The root of the hierarchy to redirect to off-screen storage.
266    /// * `update` - Whether contents are automatically mirrored to the parent window.  If one client
267    /// already specifies an update type of Manual, any attempt by another to specify a
268    /// mode of Manual so will result in an Access error.
269    fn composite_redirect_subwindows(&self, window: xproto::Window, update: Redirect) -> Result<VoidCookie<'_, Self>, ConnectionError>
270    {
271        redirect_subwindows(self, window, update)
272    }
273    /// Terminate redirection of the specified window..
274    ///
275    /// Redirection of the specified window will be terminated.  This cannot be
276    /// used if the window was redirected with RedirectSubwindows.
277    ///
278    /// # Fields
279    ///
280    /// * `window` - The window to terminate redirection of.  Must be redirected by the
281    /// current client, or a Value error results.
282    /// * `update` - The update type passed to RedirectWindows.  If this does not match the
283    /// previously requested update type, a Value error results.
284    fn composite_unredirect_window(&self, window: xproto::Window, update: Redirect) -> Result<VoidCookie<'_, Self>, ConnectionError>
285    {
286        unredirect_window(self, window, update)
287    }
288    /// Terminate redirection of the specified window’s children.
289    ///
290    /// Redirection of all children of window will be terminated.
291    ///
292    /// # Fields
293    ///
294    /// * `window` - The window to terminate redirection of.  Must have previously been
295    /// selected for sub-redirection by the current client, or a Value error
296    /// results.
297    /// * `update` - The update type passed to RedirectSubWindows.  If this does not match
298    /// the previously requested update type, a Value error results.
299    fn composite_unredirect_subwindows(&self, window: xproto::Window, update: Redirect) -> Result<VoidCookie<'_, Self>, ConnectionError>
300    {
301        unredirect_subwindows(self, window, update)
302    }
303    fn composite_create_region_from_border_clip(&self, region: xfixes::Region, window: xproto::Window) -> Result<VoidCookie<'_, Self>, ConnectionError>
304    {
305        create_region_from_border_clip(self, region, window)
306    }
307    fn composite_name_window_pixmap(&self, window: xproto::Window, pixmap: xproto::Pixmap) -> Result<VoidCookie<'_, Self>, ConnectionError>
308    {
309        name_window_pixmap(self, window, pixmap)
310    }
311    fn composite_get_overlay_window(&self, window: xproto::Window) -> Result<Cookie<'_, Self, GetOverlayWindowReply>, ConnectionError>
312    {
313        get_overlay_window(self, window)
314    }
315    fn composite_release_overlay_window(&self, window: xproto::Window) -> Result<VoidCookie<'_, Self>, ConnectionError>
316    {
317        release_overlay_window(self, window)
318    }
319}
320
321impl<C: RequestConnection + ?Sized> ConnectionExt for C {}