x11rb_async/protocol/
damage.rs

1// This file contains generated code. Do not edit directly.
2// To regenerate this, run 'make'.
3
4//! Bindings to the `Damage` 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::xfixes;
29#[allow(unused_imports)]
30use super::xproto;
31
32pub use x11rb_protocol::protocol::damage::*;
33
34/// Get the major opcode of this extension
35async fn major_opcode<Conn: RequestConnection + ?Sized>(conn: &Conn) -> Result<u8, ConnectionError> {
36    let info = conn.extension_information(X11_EXTENSION_NAME).await?;
37    let info = info.ok_or(ConnectionError::UnsupportedExtension)?;
38    Ok(info.major_opcode)
39}
40
41/// Negotiate the version of the DAMAGE extension.
42///
43/// This negotiates the version of the DAMAGE extension.  It must precede any other
44/// request using the DAMAGE extension.  Failure to do so will cause a BadRequest
45/// error for those requests.
46///
47/// # Fields
48///
49/// * `client_major_version` - The major version supported by the client.
50/// * `client_minor_version` - The minor version supported by the client.
51pub async fn query_version<Conn>(conn: &Conn, client_major_version: u32, client_minor_version: u32) -> Result<Cookie<'_, Conn, QueryVersionReply>, ConnectionError>
52where
53    Conn: RequestConnection + ?Sized,
54{
55    let request0 = QueryVersionRequest {
56        client_major_version,
57        client_minor_version,
58    };
59    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
60    let slices = [IoSlice::new(&bytes[0])];
61    assert_eq!(slices.len(), bytes.len());
62    conn.send_request_with_reply(&slices, fds).await
63}
64/// Creates a Damage object to monitor changes to a drawable..
65///
66/// This creates a Damage object to monitor changes to a drawable, and specifies
67/// the level of detail to be reported for changes.
68///
69/// We call changes made to pixel contents of windows and pixmaps 'damage'
70/// throughout this extension.
71///
72/// Damage accumulates as drawing occurs in the drawable.  Each drawing operation
73/// 'damages' one or more rectangular areas within the drawable.  The rectangles
74/// are guaranteed to include the set of pixels modified by each operation, but
75/// may include significantly more than just those pixels.  The desire is for
76/// the damage to strike a balance between the number of rectangles reported and
77/// the extraneous area included.  A reasonable goal is for each primitive
78/// object drawn (line, string, rectangle) to be represented as a single
79/// rectangle and for the damage area of the operation to be the union of these
80/// rectangles.
81///
82/// The DAMAGE extension allows applications to either receive the raw
83/// rectangles as a stream of events, or to have them partially processed within
84/// the X server to reduce the amount of data transmitted as well as reduce the
85/// processing latency once the repaint operation has started.
86///
87/// The Damage object holds any accumulated damage region and reflects the
88/// relationship between the drawable selected for damage notification and the
89/// drawable for which damage is tracked.
90///
91/// # Fields
92///
93/// * `damage` - The ID with which you will refer to the new Damage object, created by
94/// `xcb_generate_id`.
95/// * `drawable` - The ID of the drawable to be monitored.
96/// * `level` - The level of detail to be provided in Damage events.
97pub async fn create<Conn>(conn: &Conn, damage: Damage, drawable: xproto::Drawable, level: ReportLevel) -> Result<VoidCookie<'_, Conn>, ConnectionError>
98where
99    Conn: RequestConnection + ?Sized,
100{
101    let request0 = CreateRequest {
102        damage,
103        drawable,
104        level,
105    };
106    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
107    let slices = [IoSlice::new(&bytes[0])];
108    assert_eq!(slices.len(), bytes.len());
109    conn.send_request_without_reply(&slices, fds).await
110}
111/// Destroys a previously created Damage object..
112///
113/// This destroys a Damage object and requests the X server stop reporting
114/// the changes it was tracking.
115///
116/// # Fields
117///
118/// * `damage` - The ID you provided to `xcb_create_damage`.
119pub async fn destroy<Conn>(conn: &Conn, damage: Damage) -> Result<VoidCookie<'_, Conn>, ConnectionError>
120where
121    Conn: RequestConnection + ?Sized,
122{
123    let request0 = DestroyRequest {
124        damage,
125    };
126    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
127    let slices = [IoSlice::new(&bytes[0])];
128    assert_eq!(slices.len(), bytes.len());
129    conn.send_request_without_reply(&slices, fds).await
130}
131/// Remove regions from a previously created Damage object..
132///
133/// This updates the regions of damage recorded in a a Damage object.
134/// See <https://www.x.org/releases/current/doc/damageproto/damageproto.txt>
135/// for details.
136///
137/// # Fields
138///
139/// * `damage` - The ID you provided to `xcb_create_damage`.
140pub async fn subtract<Conn, A, B>(conn: &Conn, damage: Damage, repair: A, parts: B) -> Result<VoidCookie<'_, Conn>, ConnectionError>
141where
142    Conn: RequestConnection + ?Sized,
143    A: Into<xfixes::Region> + Send,
144    B: Into<xfixes::Region> + Send,
145{
146    let repair: xfixes::Region = repair.into();
147    let parts: xfixes::Region = parts.into();
148    let request0 = SubtractRequest {
149        damage,
150        repair,
151        parts,
152    };
153    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
154    let slices = [IoSlice::new(&bytes[0])];
155    assert_eq!(slices.len(), bytes.len());
156    conn.send_request_without_reply(&slices, fds).await
157}
158/// Add a region to a previously created Damage object..
159///
160/// This updates the regions of damage recorded in a a Damage object.
161/// See <https://www.x.org/releases/current/doc/damageproto/damageproto.txt>
162/// for details.
163///
164/// # Fields
165///
166/// * `damage` - The ID you provided to `xcb_create_damage`.
167pub async fn add<Conn>(conn: &Conn, drawable: xproto::Drawable, region: xfixes::Region) -> Result<VoidCookie<'_, Conn>, ConnectionError>
168where
169    Conn: RequestConnection + ?Sized,
170{
171    let request0 = AddRequest {
172        drawable,
173        region,
174    };
175    let (bytes, fds) = request0.serialize(major_opcode(conn).await?);
176    let slices = [IoSlice::new(&bytes[0])];
177    assert_eq!(slices.len(), bytes.len());
178    conn.send_request_without_reply(&slices, fds).await
179}
180/// Extension trait defining the requests of this extension.
181pub trait ConnectionExt: RequestConnection {
182    /// Negotiate the version of the DAMAGE extension.
183    ///
184    /// This negotiates the version of the DAMAGE extension.  It must precede any other
185    /// request using the DAMAGE extension.  Failure to do so will cause a BadRequest
186    /// error for those requests.
187    ///
188    /// # Fields
189    ///
190    /// * `client_major_version` - The major version supported by the client.
191    /// * `client_minor_version` - The minor version supported by the client.
192    fn damage_query_version(&self, client_major_version: u32, client_minor_version: u32) -> Pin<Box<dyn Future<Output = Result<Cookie<'_, Self, QueryVersionReply>, ConnectionError>> + Send + '_>>
193    {
194        Box::pin(query_version(self, client_major_version, client_minor_version))
195    }
196    /// Creates a Damage object to monitor changes to a drawable..
197    ///
198    /// This creates a Damage object to monitor changes to a drawable, and specifies
199    /// the level of detail to be reported for changes.
200    ///
201    /// We call changes made to pixel contents of windows and pixmaps 'damage'
202    /// throughout this extension.
203    ///
204    /// Damage accumulates as drawing occurs in the drawable.  Each drawing operation
205    /// 'damages' one or more rectangular areas within the drawable.  The rectangles
206    /// are guaranteed to include the set of pixels modified by each operation, but
207    /// may include significantly more than just those pixels.  The desire is for
208    /// the damage to strike a balance between the number of rectangles reported and
209    /// the extraneous area included.  A reasonable goal is for each primitive
210    /// object drawn (line, string, rectangle) to be represented as a single
211    /// rectangle and for the damage area of the operation to be the union of these
212    /// rectangles.
213    ///
214    /// The DAMAGE extension allows applications to either receive the raw
215    /// rectangles as a stream of events, or to have them partially processed within
216    /// the X server to reduce the amount of data transmitted as well as reduce the
217    /// processing latency once the repaint operation has started.
218    ///
219    /// The Damage object holds any accumulated damage region and reflects the
220    /// relationship between the drawable selected for damage notification and the
221    /// drawable for which damage is tracked.
222    ///
223    /// # Fields
224    ///
225    /// * `damage` - The ID with which you will refer to the new Damage object, created by
226    /// `xcb_generate_id`.
227    /// * `drawable` - The ID of the drawable to be monitored.
228    /// * `level` - The level of detail to be provided in Damage events.
229    fn damage_create(&self, damage: Damage, drawable: xproto::Drawable, level: ReportLevel) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
230    {
231        Box::pin(create(self, damage, drawable, level))
232    }
233    /// Destroys a previously created Damage object..
234    ///
235    /// This destroys a Damage object and requests the X server stop reporting
236    /// the changes it was tracking.
237    ///
238    /// # Fields
239    ///
240    /// * `damage` - The ID you provided to `xcb_create_damage`.
241    fn damage_destroy(&self, damage: Damage) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
242    {
243        Box::pin(destroy(self, damage))
244    }
245    /// Remove regions from a previously created Damage object..
246    ///
247    /// This updates the regions of damage recorded in a a Damage object.
248    /// See <https://www.x.org/releases/current/doc/damageproto/damageproto.txt>
249    /// for details.
250    ///
251    /// # Fields
252    ///
253    /// * `damage` - The ID you provided to `xcb_create_damage`.
254    fn damage_subtract<A, B>(&self, damage: Damage, repair: A, parts: B) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
255    where
256        A: Into<xfixes::Region> + Send + 'static,
257        B: Into<xfixes::Region> + Send + 'static,
258    {
259        Box::pin(subtract(self, damage, repair, parts))
260    }
261    /// Add a region to a previously created Damage object..
262    ///
263    /// This updates the regions of damage recorded in a a Damage object.
264    /// See <https://www.x.org/releases/current/doc/damageproto/damageproto.txt>
265    /// for details.
266    ///
267    /// # Fields
268    ///
269    /// * `damage` - The ID you provided to `xcb_create_damage`.
270    fn damage_add(&self, drawable: xproto::Drawable, region: xfixes::Region) -> Pin<Box<dyn Future<Output = Result<VoidCookie<'_, Self>, ConnectionError>> + Send + '_>>
271    {
272        Box::pin(add(self, drawable, region))
273    }
274}
275
276impl<C: RequestConnection + ?Sized> ConnectionExt for C {}