x11rb_async/protocol/
dbe.rs

1// This file contains generated code. Do not edit directly.
2// To regenerate this, run 'make'.
3
4//! Bindings to the `Dbe` 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;
25use std::future::Future;
26use std::pin::Pin;
27#[allow(unused_imports)]
28use super::xproto;
29
30pub use x11rb_protocol::protocol::dbe::*;
31
32/// Get the major opcode of this extension
33async fn major_opcode<Conn: RequestConnection + ?Sized>(conn: &Conn) -> Result<u8, ConnectionError> {
34    let info = conn.extension_information(X11_EXTENSION_NAME).await?;
35    let info = info.ok_or(ConnectionError::UnsupportedExtension)?;
36    Ok(info.major_opcode)
37}
38
39/// Queries the version of this extension.
40///
41/// Queries the version of this extension. You must do this before using any functionality it provides.
42///
43/// # Fields
44///
45/// * `major_version` - The major version of the extension. Check that it is compatible with the XCB_DBE_MAJOR_VERSION that your code is compiled with.
46/// * `minor_version` - The minor version of the extension. Check that it is compatible with the XCB_DBE_MINOR_VERSION that your code is compiled with.
47pub async fn query_version<Conn>(conn: &Conn, major_version: u8, minor_version: u8) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
48where
49    Conn: RequestConnection + ?Sized,
50{
51    let request0 = QueryVersionRequest {
52        major_version,
53        minor_version,
54    };
55    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
56    let slices = [IoSlice::new(&bytes[0])];
57    assert_eq!(slices.len(), bytes.len());
58    conn.send_request_with_reply(&slices, fds).await
59}
60/// Allocates a back buffer.
61///
62/// Associates `buffer` with the back buffer of `window`. Multiple ids may be associated with the back buffer, which is created by the first allocate call and destroyed by the last deallocate.
63///
64/// # Fields
65///
66/// * `window` - The window to which to add the back buffer.
67/// * `buffer` - The buffer id to associate with the back buffer.
68/// * `swap_action` - The swap action most likely to be used to present this back buffer. This is only a hint, and does not preclude the use of other swap actions.
69pub async fn allocate_back_buffer<Conn>(conn: &Conn, window: xproto::Window, buffer: BackBuffer, swap_action: u8) -> Result<VoidCookie<'_, Conn>, ConnectionError>
70where
71    Conn: RequestConnection + ?Sized,
72{
73    let request0 = AllocateBackBufferRequest {
74        window,
75        buffer,
76        swap_action,
77    };
78    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
79    let slices = [IoSlice::new(&bytes[0])];
80    assert_eq!(slices.len(), bytes.len());
81    conn.send_request_without_reply(&slices, fds).await
82}
83/// Deallocates a back buffer.
84///
85/// Deallocates the given `buffer`. If `buffer` is an invalid id, a `BadBuffer` error is returned. Because a window may have allocated multiple back buffer ids, the back buffer itself is not deleted until all these ids are deallocated by this call.
86///
87/// # Fields
88///
89/// * `buffer` - The back buffer to deallocate.
90pub async fn deallocate_back_buffer<Conn>(conn: &Conn, buffer: BackBuffer) -> Result<VoidCookie<'_, Conn>, ConnectionError>
91where
92    Conn: RequestConnection + ?Sized,
93{
94    let request0 = DeallocateBackBufferRequest {
95        buffer,
96    };
97    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
98    let slices = [IoSlice::new(&bytes[0])];
99    assert_eq!(slices.len(), bytes.len());
100    conn.send_request_without_reply(&slices, fds).await
101}
102/// Swaps front and back buffers.
103///
104/// Swaps the front and back buffers on the specified windows. The front and back buffers retain their ids, so that the window id continues to refer to the front buffer, while the back buffer id created by this extension continues to refer to the back buffer. Back buffer contents is moved to the front buffer. Back buffer contents after the operation depends on the given swap action. The optimal swap action depends on how each frame is rendered. For example, if the buffer is cleared and fully overwritten on every frame, the "untouched" action, which throws away the buffer contents, would provide the best performance. To eliminate visual artifacts, the swap will occure during the monitor VSync, if the X server supports detecting it.
105///
106/// # Fields
107///
108/// * `n_actions` - Number of swap actions in `actions`.
109/// * `actions` - List of windows on which to swap buffers.
110pub async fn swap_buffers<'c, 'input, Conn>(conn: &'c Conn, actions: &'input [SwapInfo]) -> Result<VoidCookie<'c, Conn>, ConnectionError>
111where
112    Conn: RequestConnection + ?Sized,
113{
114    let request0 = SwapBuffersRequest {
115        actions: Cow::Borrowed(actions),
116    };
117    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
118    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
119    assert_eq!(slices.len(), bytes.len());
120    conn.send_request_without_reply(&slices, fds).await
121}
122/// Begins a logical swap block.
123///
124/// Creates a block of operations intended to occur together. This may be needed if window presentation requires changing buffers unknown to this extension, such as depth or stencil buffers.
125pub async fn begin_idiom<Conn>(conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
126where
127    Conn: RequestConnection + ?Sized,
128{
129    let request0 = BeginIdiomRequest;
130    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
131    let slices = [IoSlice::new(&bytes[0])];
132    assert_eq!(slices.len(), bytes.len());
133    conn.send_request_without_reply(&slices, fds).await
134}
135/// Ends a logical swap block.
136pub async fn end_idiom<Conn>(conn: &Conn) -> Result<VoidCookie<'_, Conn>, ConnectionError>
137where
138    Conn: RequestConnection + ?Sized,
139{
140    let request0 = EndIdiomRequest;
141    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
142    let slices = [IoSlice::new(&bytes[0])];
143    assert_eq!(slices.len(), bytes.len());
144    conn.send_request_without_reply(&slices, fds).await
145}
146/// Requests visuals that support double buffering.
147pub async fn get_visual_info<'c, 'input, Conn>(conn: &'c Conn, drawables: &'input [xproto::Drawable]) -> Result<Cookie<'c, Conn, GetVisualInfoReply>, ConnectionError>
148where
149    Conn: RequestConnection + ?Sized,
150{
151    let request0 = GetVisualInfoRequest {
152        drawables: Cow::Borrowed(drawables),
153    };
154    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
155    let slices = [IoSlice::new(&bytes[0]), IoSlice::new(&bytes[1]), IoSlice::new(&bytes[2])];
156    assert_eq!(slices.len(), bytes.len());
157    conn.send_request_with_reply(&slices, fds).await
158}
159/// Gets back buffer attributes.
160///
161/// Returns the attributes of the specified `buffer`.
162///
163/// # Fields
164///
165/// * `buffer` - The back buffer to query.
166/// * `attributes` - The attributes of `buffer`.
167pub async fn get_back_buffer_attributes<Conn>(conn: &Conn, buffer: BackBuffer) -> Result<Cookie<'_, Conn, GetBackBufferAttributesReply>, ConnectionError>
168where
169    Conn: RequestConnection + ?Sized,
170{
171    let request0 = GetBackBufferAttributesRequest {
172        buffer,
173    };
174    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
175    let slices = [IoSlice::new(&bytes[0])];
176    assert_eq!(slices.len(), bytes.len());
177    conn.send_request_with_reply(&slices, fds).await
178}
179/// Extension trait defining the requests of this extension.
180pub trait ConnectionExt: RequestConnection {
181    /// Queries the version of this extension.
182    ///
183    /// Queries the version of this extension. You must do this before using any functionality it provides.
184    ///
185    /// # Fields
186    ///
187    /// * `major_version` - The major version of the extension. Check that it is compatible with the XCB_DBE_MAJOR_VERSION that your code is compiled with.
188    /// * `minor_version` - The minor version of the extension. Check that it is compatible with the XCB_DBE_MINOR_VERSION that your code is compiled with.
189    fn dbe_query_version(&self, major_version: u8, minor_version: u8) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>> + Send + '_>>
190    {
191        Box::pin(query_version(self, major_version, minor_version))
192    }
193    /// Allocates a back buffer.
194    ///
195    /// Associates `buffer` with the back buffer of `window`. Multiple ids may be associated with the back buffer, which is created by the first allocate call and destroyed by the last deallocate.
196    ///
197    /// # Fields
198    ///
199    /// * `window` - The window to which to add the back buffer.
200    /// * `buffer` - The buffer id to associate with the back buffer.
201    /// * `swap_action` - The swap action most likely to be used to present this back buffer. This is only a hint, and does not preclude the use of other swap actions.
202    fn dbe_allocate_back_buffer(&self, window: xproto::Window, buffer: BackBuffer, swap_action: u8) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
203    {
204        Box::pin(allocate_back_buffer(self, window, buffer, swap_action))
205    }
206    /// Deallocates a back buffer.
207    ///
208    /// Deallocates the given `buffer`. If `buffer` is an invalid id, a `BadBuffer` error is returned. Because a window may have allocated multiple back buffer ids, the back buffer itself is not deleted until all these ids are deallocated by this call.
209    ///
210    /// # Fields
211    ///
212    /// * `buffer` - The back buffer to deallocate.
213    fn dbe_deallocate_back_buffer(&self, buffer: BackBuffer) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
214    {
215        Box::pin(deallocate_back_buffer(self, buffer))
216    }
217    /// Swaps front and back buffers.
218    ///
219    /// Swaps the front and back buffers on the specified windows. The front and back buffers retain their ids, so that the window id continues to refer to the front buffer, while the back buffer id created by this extension continues to refer to the back buffer. Back buffer contents is moved to the front buffer. Back buffer contents after the operation depends on the given swap action. The optimal swap action depends on how each frame is rendered. For example, if the buffer is cleared and fully overwritten on every frame, the "untouched" action, which throws away the buffer contents, would provide the best performance. To eliminate visual artifacts, the swap will occure during the monitor VSync, if the X server supports detecting it.
220    ///
221    /// # Fields
222    ///
223    /// * `n_actions` - Number of swap actions in `actions`.
224    /// * `actions` - List of windows on which to swap buffers.
225    fn dbe_swap_buffers<'c, 'input, 'future>(&'c self, actions: &'input [SwapInfo]) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'c, Self>, ConnectionError>> + Send + 'future>>
226    where
227        'c: 'future,
228        'input: 'future,
229    {
230        Box::pin(swap_buffers(self, actions))
231    }
232    /// Begins a logical swap block.
233    ///
234    /// Creates a block of operations intended to occur together. This may be needed if window presentation requires changing buffers unknown to this extension, such as depth or stencil buffers.
235    fn dbe_begin_idiom(&self) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
236    {
237        Box::pin(begin_idiom(self))
238    }
239    /// Ends a logical swap block.
240    fn dbe_end_idiom(&self) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
241    {
242        Box::pin(end_idiom(self))
243    }
244    /// Requests visuals that support double buffering.
245    fn dbe_get_visual_info<'c, 'input, 'future>(&'c self, drawables: &'input [xproto::Drawable]) -> Pin<Box<dyn Future<Output = Result<Cookie<'c, Self, GetVisualInfoReply>, ConnectionError>> + Send + 'future>>
246    where
247        'c: 'future,
248        'input: 'future,
249    {
250        Box::pin(get_visual_info(self, drawables))
251    }
252    /// Gets back buffer attributes.
253    ///
254    /// Returns the attributes of the specified `buffer`.
255    ///
256    /// # Fields
257    ///
258    /// * `buffer` - The back buffer to query.
259    /// * `attributes` - The attributes of `buffer`.
260    fn dbe_get_back_buffer_attributes(&self, buffer: BackBuffer) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, GetBackBufferAttributesReply>, ConnectionError>> + Send + '_>>
261    {
262        Box::pin(get_back_buffer_attributes(self, buffer))
263    }
264}
265
266impl<C: RequestConnection + ?Sized> ConnectionExt for C {}